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

Structure to read input data for performing simulation output. More...

#include <outputDeck.h>

Collaboration diagram for inp::OutputDeck:

Public Member Functions

 OutputDeck (const json &j=json({}))
 Constructor.
 
 OutputDeck (std::string outFormat, std::string path="./", std::vector< std::string > outTags={"Displacement"}, size_t outputInterval=1, size_t debug=2, bool performFEOut=true, std::string compressType="zlib", bool performOut=true, size_t dtTestOut=1, std::string tagPPFile="", bool pvdCollection=false)
 Constructor.
 
void readFromJson (const json &j)
 Reads from 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 json getExampleJson (const std::string &)=delete
 Returns example JSON object for ModelDeck configuration.
 
static json getExampleJson (const char *)=delete
 Returns example JSON object for ModelDeck configuration.
 
static const std::vector< Field< OutputDeck > > & fields ()
 The fields of this deck, declared once.
 
static json getExampleJson (const json &given=json::object())
 Returns the block with the given fields set.
 

Data Fields

std::string d_outFormat
 Output format. Allowed values are vtu, msh, legacy_vtk.
 
std::string d_path
 Output Path where the files will be written.
 
std::vector< std::string > d_outTags
 List of tags of data to be dumped.
 
size_t d_dtOut
 Size of time steps (or frequency) for output operation.
 
size_t d_dtOutOld
 Size of time steps (or frequency) for output operation.
 
size_t d_debug
 Level below which a message is logged.
 
bool d_performFEOut
 Flag specifying if element-node connectivity should not be dumped.
 
std::string d_compressType
 Compressor type for .vtu files.
 
std::string d_outCriteria
 Specify output criteria to change output frequency.
 
size_t d_dtOutCriteria
 Specify output frequency if output criteria is met.
 
std::vector< double > d_outCriteriaParams
 List of parameters required in checking output criteria.
 
bool d_performOut
 Perform vtu output.
 
size_t d_dtTestOut
 Size of time steps (or frequency) for output operation.
 
std::string d_tagPPFile
 Tag for postprocessing file.
 
bool d_pvdCollection
 If true, write a ParaView .pvd collection alongside VTU files so one file can be opened to animate all timesteps (references the per-step .vtu files).
 

Detailed Description

Structure to read input data for performing simulation output.

Definition at line 29 of file outputDeck.h.

Constructor & Destructor Documentation

◆ OutputDeck() [1/2]

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

Constructor.

Definition at line 110 of file outputDeck.h.

110 {}))
111 : d_outFormat("vtu"), d_path("./"), d_dtOut(0), d_dtOutOld(0), d_debug(0),
113 d_dtTestOut(0), d_tagPPFile(""), d_pvdCollection(false) {
114
115 readFromJson(j);
116 };
size_t d_dtTestOut
Size of time steps (or frequency) for output operation.
Definition outputDeck.h:96
size_t d_dtOutCriteria
Specify output frequency if output criteria is met.
Definition outputDeck.h:87
void readFromJson(const json &j)
Reads from json object.
Definition outputDeck.h:208
size_t d_dtOut
Size of time steps (or frequency) for output operation.
Definition outputDeck.h:46
bool d_performFEOut
Flag specifying if element-node connectivity should not be dumped.
Definition outputDeck.h:66
std::string d_outFormat
Output format. Allowed values are vtu, msh, legacy_vtk.
Definition outputDeck.h:34
std::string d_path
Output Path where the files will be written.
Definition outputDeck.h:40
std::string d_tagPPFile
Tag for postprocessing file.
Definition outputDeck.h:99
size_t d_debug
Level below which a message is logged.
Definition outputDeck.h:58
bool d_performOut
Perform vtu output.
Definition outputDeck.h:93
size_t d_dtOutOld
Size of time steps (or frequency) for output operation.
Definition outputDeck.h:49
bool d_pvdCollection
If true, write a ParaView .pvd collection alongside VTU files so one file can be opened to animate al...
Definition outputDeck.h:105

◆ OutputDeck() [2/2]

inp::OutputDeck::OutputDeck ( std::string  outFormat,
std::string  path = "./",
std::vector< std::string >  outTags = {"Displacement"},
size_t  outputInterval = 1,
size_t  debug = 2,
bool  performFEOut = true,
std::string  compressType = "zlib",
bool  performOut = true,
size_t  dtTestOut = 1,
std::string  tagPPFile = "",
bool  pvdCollection = false 
)
inline

Constructor.

Definition at line 122 of file outputDeck.h.

124 {"Displacement"},
125 size_t outputInterval = 1,
126 size_t debug = 2,
127 bool performFEOut = true,
128 std::string compressType = "zlib",
129 bool performOut = true,
130 size_t dtTestOut = 1,
131 std::string tagPPFile = "",
132 bool pvdCollection = false)
133 : d_outFormat(outFormat), d_path(path),
134 d_dtOut(outputInterval), d_dtOutOld(outputInterval), d_dtOutCriteria(outputInterval),
135 d_debug(debug),
136 d_performFEOut(performFEOut), d_compressType(compressType),
137 d_performOut(performOut), d_dtTestOut(dtTestOut), d_tagPPFile(tagPPFile),
138 d_pvdCollection(pvdCollection), d_outTags(outTags){};
std::vector< std::string > d_outTags
List of tags of data to be dumped.
Definition outputDeck.h:43
std::string d_compressType
Compressor type for .vtu files.
Definition outputDeck.h:69

Member Function Documentation

◆ fields()

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

The fields of this deck, declared once.

Reading, writing, printing and the schema are generated from this table. The output criteria are a block of their own and are read in readDerived.

Returns
fields The field table

Definition at line 164 of file outputDeck.h.

164 {
165 static const std::vector<Field<OutputDeck>> f = {
166 field(&OutputDeck::d_path, "Path", std::string("./"),
167 "Directory the output is written to"),
168 field(&OutputDeck::d_performOut, "Perform_Out", true,
169 "Write output at all"),
170 field(&OutputDeck::d_outTags, "Tags", std::vector<std::string>(),
171 "Fields written at each output step"),
172 field(&OutputDeck::d_dtOut, "Output_Interval", size_t(1),
173 "Steps between outputs", {{}, size_t(1), {}}),
174 field(&OutputDeck::d_debug, "Debug", size_t(2),
175 "How much is written to the log"),
176 field(&OutputDeck::d_performFEOut, "Perform_FE_Out", true,
177 "Write the finite element mesh as well as the nodes"),
178 field(&OutputDeck::d_compressType, "Compress_Type",
179 std::string("zlib"), "Compression used in the output files"),
180 field(&OutputDeck::d_outFormat, "File_Format", std::string("vtu"),
181 "Output file format"),
182 field(&OutputDeck::d_dtTestOut, "Test_Output_Interval", size_t(1),
183 "Steps between post-processing outputs"),
184 field(&OutputDeck::d_tagPPFile, "Tag_PP", std::string(),
185 "Suffix of the post-processing file"),
186 // Absent unless a collection is asked for, which is how the decks
187 // in the repository were written.
188 field<OutputDeck, bool>(&OutputDeck::d_pvdCollection,
189 "PVD_Collection", false,
190 "Write a PVD file indexing the time steps",
191 {}, [](const bool &v) { return v; }),
192 };
193 return f;
194 }
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_compressType, d_debug, d_dtOut, d_dtTestOut, d_outFormat, d_outTags, d_path, d_performFEOut, d_performOut, d_pvdCollection, d_tagPPFile, and inp::field().

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

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

◆ getExampleJson() [1/3]

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

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

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

A format or path 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::OutputDeck::getExampleJson ( const json &  given = json::object())
inlinestatic

Returns the block with the given fields set.

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

Definition at line 201 of file outputDeck.h.

201 {
202 return applyGiven(given, fields(), {"Output_Criteria"});
203 }
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< OutputDeck > > & fields()
The fields of this deck, declared once.
Definition outputDeck.h:164

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

Here is the call graph for this function:

◆ getExampleJson() [3/3]

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

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

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

A format or path 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.

Referenced by anonymous_namespace{main.cpp}::buildBhatInputJson(), anonymous_namespace{main.cpp}::buildImpactInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildTraskInputJson(), getInputJson(), anonymous_namespace{main.cpp}::makeDeck(), and anonymous_namespace{testDeckRoundTrip.cpp}::testOutputDeck().

Here is the caller graph for this function:

◆ print()

void inp::OutputDeck::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 262 of file outputDeck.h.

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

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::OutputDeck::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 239 of file outputDeck.h.

239 {
240 auto tabS = util::io::getTabS(nt);
241 std::ostringstream oss;
242 oss << tabS << "------- OutputDeck --------" << std::endl << std::endl;
243 printFields(*this, oss, fields(), tabS);
244 oss << tabS << "Output_Interval before the criteria = " << d_dtOutOld
245 << std::endl;
246 oss << tabS << "Output_Criteria.Type = " << d_outCriteria << std::endl;
247 oss << tabS << "Output_Criteria.New_Interval = " << d_dtOutCriteria
248 << std::endl;
249 oss << tabS << "Output_Criteria.Parameters = "
250 << util::io::printStr<double>(d_outCriteriaParams, 0) << std::endl;
251 oss << tabS << std::endl;
252
253 return oss.str();
254 }
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
std::string d_outCriteria
Specify output criteria to change output frequency.
Definition outputDeck.h:81
std::vector< double > d_outCriteriaParams
List of parameters required in checking output criteria.
Definition outputDeck.h:90

References d_dtOutCriteria, d_dtOutOld, d_outCriteria, d_outCriteriaParams, 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::OutputDeck::readFromJson ( const json &  j)
inline

Reads from json object.

Definition at line 208 of file outputDeck.h.

208 {
209 if (j.empty())
210 return ;
211
212 readFields(*this, j, fields());
213
214 // An empty path names the working directory.
215 if (d_path.empty())
216 d_path = "./";
217
218 // Both follow the output interval until the criteria block changes one.
221
222 if (j.contains("Output_Criteria")) {
223 d_outCriteria = j.at("Output_Criteria").value("Type", std::string(""));
224 d_dtOutCriteria = j.at("Output_Criteria").value("New_Interval", size_t(1));
225 d_outCriteriaParams = j.at("Output_Criteria").value("Parameters", std::vector<double>());
226 if (d_dtOutCriteria < 1)
227 throw std::runtime_error(
228 "Output_Criteria.New_Interval must be >= 1 (use 1 to write every step).");
229 }
230 }
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 d_dtOut, d_dtOutCriteria, d_dtOutOld, d_outCriteria, d_outCriteriaParams, d_path, fields(), and inp::readFields().

Referenced by anonymous_namespace{testDeckRoundTrip.cpp}::testOutputDeck().

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

Field Documentation

◆ d_compressType

std::string inp::OutputDeck::d_compressType

Compressor type for .vtu files.

Definition at line 69 of file outputDeck.h.

Referenced by fields().

◆ d_debug

size_t inp::OutputDeck::d_debug

Level below which a message is logged.

util::io::log(priority, ...) writes when this value is greater than priority, so a level of n writes the messages of priority 0 to n-1. Priorities 0 to 3 are in use, so 0 writes nothing and 4 writes all.

Definition at line 58 of file outputDeck.h.

Referenced by fields().

◆ d_dtOut

size_t inp::OutputDeck::d_dtOut

Size of time steps (or frequency) for output operation.

Definition at line 46 of file outputDeck.h.

Referenced by fields(), and readFromJson().

◆ d_dtOutCriteria

size_t inp::OutputDeck::d_dtOutCriteria

Specify output frequency if output criteria is met.

If criteria is met, then this number if used as output frequency.

Definition at line 87 of file outputDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_dtOutOld

size_t inp::OutputDeck::d_dtOutOld

Size of time steps (or frequency) for output operation.

Definition at line 49 of file outputDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_dtTestOut

size_t inp::OutputDeck::d_dtTestOut

Size of time steps (or frequency) for output operation.

Definition at line 96 of file outputDeck.h.

Referenced by fields().

◆ d_outCriteria

std::string inp::OutputDeck::d_outCriteria

Specify output criteria to change output frequency.

Choices are:

  • '' (none/null)
  • max_Z
  • max_Z_stop

Specify the method used in changing the output frequency. If not specified then we do not change the output frequency from d_dtOut.

Definition at line 81 of file outputDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_outCriteriaParams

std::vector<double> inp::OutputDeck::d_outCriteriaParams

List of parameters required in checking output criteria.

Definition at line 90 of file outputDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_outFormat

std::string inp::OutputDeck::d_outFormat

Output format. Allowed values are vtu, msh, legacy_vtk.

Default is vtu format.

Definition at line 34 of file outputDeck.h.

Referenced by fields().

◆ d_outTags

std::vector<std::string> inp::OutputDeck::d_outTags

List of tags of data to be dumped.

Definition at line 43 of file outputDeck.h.

Referenced by fields().

◆ d_path

std::string inp::OutputDeck::d_path

Output Path where the files will be written.

Default is current working directory

Definition at line 40 of file outputDeck.h.

Referenced by fields(), and readFromJson().

◆ d_performFEOut

bool inp::OutputDeck::d_performFEOut

Flag specifying if element-node connectivity should not be dumped.

For large mesh, vtk writer crashes when writing element-node connectivity.

Definition at line 66 of file outputDeck.h.

Referenced by fields().

◆ d_performOut

bool inp::OutputDeck::d_performOut

Perform vtu output.

Definition at line 93 of file outputDeck.h.

Referenced by fields().

◆ d_pvdCollection

bool inp::OutputDeck::d_pvdCollection

If true, write a ParaView .pvd collection alongside VTU files so one file can be opened to animate all timesteps (references the per-step .vtu files).

Definition at line 105 of file outputDeck.h.

Referenced by fields().

◆ d_tagPPFile

std::string inp::OutputDeck::d_tagPPFile

Tag for postprocessing file.

Definition at line 99 of file outputDeck.h.

Referenced by fields().


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