PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
inp::RestartDeck Struct Reference

Structure to read and store restart related data input. More...

#include <restartDeck.h>

Collaboration diagram for inp::RestartDeck:

Public Member Functions

 RestartDeck (std::string file, size_t step=0, bool changeRefFreeDofs=false)
 Constructor.
 
 RestartDeck (const json &j=json({}))
 Constructor.
 
void readFromJson (const json &j)
 Reads from json object.
 
json writeToJson () const
 Returns this deck as a JSON object.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 

Static Public Member Functions

static const std::vector< Field< RestartDeck > > & fields ()
 Returns example JSON object for ModelDeck configuration.
 
static json getExampleJson (const json &given=json::object())
 Returns the block with the given fields set.
 
static json getExampleJson (const std::string &)=delete
 Rejects a value given where a set of named values is expected.
 
static json getExampleJson (const char *)=delete
 Rejects a value given where a set of named values is expected.
 

Data Fields

std::string d_file
 restart filename
 
size_t d_step
 Restart time step.
 
bool d_changeRefFreeDofs
 Change only those particles/walls which have any one of its nodes dof free.
 

Detailed Description

Structure to read and store restart related data input.

Definition at line 26 of file restartDeck.h.

Constructor & Destructor Documentation

◆ RestartDeck() [1/2]

inp::RestartDeck::RestartDeck ( std::string  file,
size_t  step = 0,
bool  changeRefFreeDofs = false 
)
inline

Constructor.

Definition at line 41 of file restartDeck.h.

42 : d_file(file), d_step(step), d_changeRefFreeDofs(changeRefFreeDofs) {};
std::string d_file
restart filename
Definition restartDeck.h:29
size_t d_step
Restart time step.
Definition restartDeck.h:32
bool d_changeRefFreeDofs
Change only those particles/walls which have any one of its nodes dof free.
Definition restartDeck.h:36

◆ RestartDeck() [2/2]

inp::RestartDeck::RestartDeck ( const json &  j = json({}))
inline

Constructor.

Definition at line 47 of file restartDeck.h.

47 {}))
48 : d_file(""), d_step(0), d_changeRefFreeDofs(false) {
49 readFromJson(j);
50 };
void readFromJson(const json &j)
Reads from json object.

Member Function Documentation

◆ fields()

static const std::vector< Field< RestartDeck > > & inp::RestartDeck::fields ( )
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 57 of file restartDeck.h.

57 {
58 static const std::vector<Field<RestartDeck>> f = {
59 field(&RestartDeck::d_file, "File", std::string(),
60 "File the state is read from"),
61 field(&RestartDeck::d_step, "Step", size_t(0),
62 "Step the state was written at"),
64 "Change_Reference_Free_Dofs", false,
65 "Move only the bodies that have a free degree of freedom"),
66 };
67 return f;
68 }
Field< Deck > field(T Deck::*m, std::string key, T def, std::string doc, Accepts< T > accepts={}, std::function< bool(const T &)> emitIf=[](const T &) { return true;})
Declares a field that maps one key to one member.
Definition deckField.h:144

References d_changeRefFreeDofs, d_file, d_step, and inp::field().

Referenced by getExampleJson(), printStr(), readFromJson(), and writeToJson().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getExampleJson() [1/3]

static json inp::RestartDeck::getExampleJson ( const char *  )
staticdelete

Rejects a value given where a set of named values is expected.

A file name passed on its own would convert to a JSON string and be read as a block with no keys, so such a call is rejected when compiling.

◆ getExampleJson() [2/3]

static json inp::RestartDeck::getExampleJson ( const json &  given = json::object())
inlinestatic

Returns the block with the given fields set.

A restart is requested by naming a file. Without one the block is empty, and the model starts from the initial condition.

Parameters
givenField names and values to set, checked against the table
Returns
JSON object for this deck

Definition at line 79 of file restartDeck.h.

79 {
80 json j = applyGiven(given, fields());
81 if (j.at("File").get<std::string>().empty())
82 return json({});
83 return j;
84 }
nlohmann::ordered_json json
json applyGiven(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
The default block with the given keys replaced.
Definition deckField.h:443
static const std::vector< Field< RestartDeck > > & fields()
Returns example JSON object for ModelDeck configuration.
Definition restartDeck.h:57

References inp::applyGiven(), and fields().

Here is the call graph for this function:

◆ getExampleJson() [3/3]

static json inp::RestartDeck::getExampleJson ( const std::string &  )
staticdelete

Rejects a value given where a set of named values is expected.

A file name passed on its own would convert to a JSON string and be read as a block with no keys, so such a call is rejected when compiling.

◆ print()

void inp::RestartDeck::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 140 of file restartDeck.h.

140{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::RestartDeck::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 124 of file restartDeck.h.

124 {
125 auto tabS = util::io::getTabS(nt);
126 std::ostringstream oss;
127 oss << tabS << "------- RestartDeck --------" << std::endl << std::endl;
128 printFields(*this, oss, fields(), tabS);
129 oss << tabS << std::endl;
130
131 return oss.str();
132 }
void printFields(const Deck &d, std::ostringstream &oss, const std::vector< Field< Deck > > &fs, const std::string &tab="")
Appends every field of the table to a stream.
Definition deckField.h:251
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82

References fields(), util::io::getTabS(), and inp::printFields().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFromJson()

void inp::RestartDeck::readFromJson ( const json &  j)
inline

Reads from json object.

Parameters
jJSON object

Definition at line 101 of file restartDeck.h.

101 {
102 if (j.empty())
103 return;
104 readFields(*this, j, fields());
105 }
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
Definition deckField.h:230

References fields(), and inp::readFields().

Here is the call graph for this function:

◆ writeToJson()

json inp::RestartDeck::writeToJson ( ) const
inline

Returns this deck as a JSON object.

Returns
JSON object for this deck

Definition at line 111 of file restartDeck.h.

111 {
112 json j = json::object();
113 writeFields(*this, j, fields());
114 return j;
115 }
void writeFields(const Deck &d, json &j, const std::vector< Field< Deck > > &fs)
Writes every field of the table into the block.
Definition deckField.h:237

References fields(), and inp::writeFields().

Here is the call graph for this function:

Field Documentation

◆ d_changeRefFreeDofs

bool inp::RestartDeck::d_changeRefFreeDofs

Change only those particles/walls which have any one of its nodes dof free.

Definition at line 36 of file restartDeck.h.

Referenced by fields().

◆ d_file

std::string inp::RestartDeck::d_file

restart filename

Definition at line 29 of file restartDeck.h.

Referenced by fields().

◆ d_step

size_t inp::RestartDeck::d_step

Restart time step.

Definition at line 32 of file restartDeck.h.

Referenced by fields().


The documentation for this struct was generated from the following file: