![]() |
PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
|
Collection of methods and database related to input. More...
Data Structures | |
| struct | Accepts |
| What a field accepts. More... | |
| struct | BCBaseDeck |
| User-input data for particle neighbor search. More... | |
| struct | BCDeck |
| Structure to read and store test-related input data. More... | |
| struct | ContactDeck |
| Structure to read and store particle-particle contact related input data. More... | |
| struct | ContactPairDeck |
| Structure to read and store particle-particle contact related input data. More... | |
| struct | Field |
| One field of a deck, declared once. More... | |
| class | Input |
| A class to read input file. More... | |
| struct | MatData |
| Structure for elastic properties and fracture properties. More... | |
| struct | MaterialDeck |
| Structure to read and store material related data. More... | |
| struct | MeshDeck |
| Structure to read and store mesh related input data. More... | |
| struct | ModelDeck |
| Structure to read and store model related input data. More... | |
| struct | OneOf |
| A quantity that can be given in more than one way. More... | |
| struct | OutputDeck |
| Structure to read input data for performing simulation output. More... | |
| struct | ParticleDeck |
| Structure to read and store particle related input data. More... | |
| struct | PGenDeck |
| Structure to read and store particle generation data, such as particle locations and group file. More... | |
| struct | PNeighborDeck |
| User-input data for particle neighbor search. More... | |
| struct | RestartDeck |
| Structure to read and store restart related data input. More... | |
| struct | TestDeck |
| Structure to read and store test-related input data. More... | |
Functions | |
| template<class T > | |
| std::string | typeName () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< bool > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< int > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< std::size_t > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< double > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< std::string > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< std::vector< double > > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< std::vector< std::string > > () |
| Name of the type of a field, reported by the schema. | |
| template<> | |
| std::string | typeName< std::vector< std::size_t > > () |
| Name of the type of a field, reported by the schema. | |
| template<class T > | |
| void | printValue (std::ostringstream &oss, const T &v) |
| Appends a value to a stream. | |
| template<class T > | |
| void | printValue (std::ostringstream &oss, const std::vector< T > &v) |
| Appends the entries of a vector, separated by commas. | |
| template<class Deck , class T > | |
| 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. | |
| template<class Deck , class T > | |
| Field< Deck > | requiredField (T Deck::*m, std::string key, std::string doc, Accepts< T > accepts={}) |
| Declares a field that has no default and must be present. | |
| template<class Deck > | |
| void | readFields (Deck &d, const json &j, const std::vector< Field< Deck > > &fs) |
| Reads every field of the table from the block. | |
| template<class Deck > | |
| void | writeFields (const Deck &d, json &j, const std::vector< Field< Deck > > &fs) |
| Writes every field of the table into the block. | |
| template<class Deck > | |
| 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. | |
| template<class Deck > | |
| json | defaultsJson (const std::vector< Field< Deck > > &fs) |
| The block with every field at its default. | |
| template<class Deck > | |
| json | schemaJson (const std::vector< Field< Deck > > &fs) |
| Key, type, default and description of every field. | |
| void | checkGroups (const json &block, const std::vector< OneOf > &groups) |
| Checks that each group has exactly one of its keys. | |
| std::size_t | editDistance (const std::string &a, const std::string &b) |
| Number of single character edits between two strings. | |
| void | checkNames (const json &given, const std::vector< std::string > &names) |
| Rejects a key that is not among those named. | |
| template<class Deck > | |
| void | checkKeys (const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={}) |
| Rejects a key that no field declares. | |
| template<class Deck > | |
| 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. | |
Collection of methods and database related to input.
This namespace provides methods and data members specific to reading input data. We partition the input data into number of small collection of input data referred to as decks, e.g. inp::FractureDeck, inp::MeshDeck, etc. We use structs to define the deck.
The namespace consists of Input and Policy member classes. Input class is the main class responsible of reading input data into the decks.
| json inp::applyGiven | ( | const json & | given, |
| const std::vector< Field< Deck > > & | fs, | ||
| const std::vector< std::string > & | extra = {} |
||
| ) |
The default block with the given keys replaced.
The name of every key and the value of every field are checked here, so that a deck is rejected where it is built rather than where it is read.
| given | Keys and values to replace, checked against the table |
| fs | Field table of the deck |
| extra | Keys the deck reads outside the table |
Definition at line 443 of file deckField.h.
Referenced by inp::ContactDeck::getExampleJson(), inp::ContactPairDeck::getExampleJson(), inp::MaterialDeck::getExampleJson(), inp::MeshDeck::getExampleJson(), inp::ModelDeck::getExampleJson(), inp::OutputDeck::getExampleJson(), inp::PGenDeck::getExampleJson(), inp::PNeighborDeck::getExampleJson(), inp::RestartDeck::getExampleJson(), inp::TestDeck::getExampleJson(), inp::BCBaseDeck::getExampleJson(), anonymous_namespace{testDeckField.cpp}::testKeysAreNamed(), anonymous_namespace{testDeckField.cpp}::testReadAndWrite(), and anonymous_namespace{testDeckField.cpp}::testValuesCheckedWhenBuilt().
Checks that each group has exactly one of its keys.
| block | The block to check |
| groups | Groups of the deck |
Definition at line 317 of file deckField.h.
Referenced by inp::ContactPairDeck::getExampleJson(), inp::MaterialDeck::getExampleJson(), inp::ContactPairDeck::readFromJson(), inp::MaterialDeck::readFromJson(), and anonymous_namespace{testDeckField.cpp}::testGroups().
| void inp::checkKeys | ( | const json & | given, |
| const std::vector< Field< Deck > > & | fs, | ||
| const std::vector< std::string > & | extra = {} |
||
| ) |
Rejects a key that no field declares.
| given | Keys the caller supplied |
| fs | Field table of the deck |
| extra | Keys the deck reads outside the table |
Definition at line 421 of file deckField.h.
Referenced by inp::ContactPairDeck::getExampleJson(), and inp::BCBaseDeck::getExampleJson().
|
inline |
Rejects a key that is not among those named.
A deck is built by naming keys. A key that is not declared would otherwise be dropped without a message, and the run would proceed with the default in place of the value the caller asked for. A key within an edit distance of three of a declared one is reported together with that name.
| given | Keys the caller supplied |
| names | Every key the deck accepts |
Definition at line 379 of file deckField.h.
References editDistance().
Referenced by inp::BCDeck::getExampleJson(), and inp::MeshDeck::getExampleJson().
The block with every field at its default.
Definition at line 260 of file deckField.h.
Referenced by schemaJson(), and anonymous_namespace{testDeckField.cpp}::testDefaultsAndSchema().
|
inline |
Number of single character edits between two strings.
Used to name the closest key when a caller supplies one that is not declared.
| a | First string |
| b | Second string |
Definition at line 354 of file deckField.h.
Referenced by checkNames(), and anonymous_namespace{testDeckField.cpp}::testEditDistance().
| Field< Deck > inp::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.
| m | Pointer to the member |
| key | Key in the JSON block |
| def | Value used when the key is absent |
| doc | One line describing the field |
| accepts | What the field accepts |
| emitIf | Written only when this is true of the value. Use it for a key the deck omits rather than writes at its default, such as Horizon, which is absent when the horizon is set by Horizon_Mesh_Ratio instead |
Definition at line 144 of file deckField.h.
Referenced by inp::MeshDeck::createMeshFields(), inp::BCBaseDeck::fields(), inp::ContactDeck::fields(), inp::ContactPairDeck::fields(), inp::MatData::fields(), inp::MaterialDeck::fields(), inp::MeshDeck::fields(), inp::ModelDeck::fields(), inp::OutputDeck::fields(), inp::PGenDeck::fields(), inp::PNeighborDeck::fields(), inp::RestartDeck::fields(), inp::TestDeck::fields(), anonymous_namespace{testDeckField.cpp}::SampleDeck::fields(), inp::MaterialDeck::influenceFields(), inp::BCBaseDeck::spatialFunctionFields(), and inp::BCBaseDeck::timeFunctionFields().
| void inp::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.
| d | The deck |
| oss | Stream to append to |
| fs | Field table of the deck |
| tab | Prefix written before each field |
Definition at line 251 of file deckField.h.
Referenced by inp::ContactDeck::printStr(), inp::MeshDeck::printStr(), inp::ModelDeck::printStr(), inp::OutputDeck::printStr(), inp::PGenDeck::printStr(), inp::PNeighborDeck::printStr(), inp::RestartDeck::printStr(), inp::TestDeck::printStr(), and anonymous_namespace{testDeckField.cpp}::testPrint().
| void inp::printValue | ( | std::ostringstream & | oss, |
| const std::vector< T > & | v | ||
| ) |
Appends the entries of a vector, separated by commas.
Definition at line 107 of file deckField.h.
| void inp::printValue | ( | std::ostringstream & | oss, |
| const T & | v | ||
| ) |
| void inp::readFields | ( | Deck & | d, |
| const json & | j, | ||
| const std::vector< Field< Deck > > & | fs | ||
| ) |
Reads every field of the table from the block.
Definition at line 230 of file deckField.h.
Referenced by inp::ContactDeck::readFromJson(), inp::ContactPairDeck::readFromJson(), inp::MatData::readFromJson(), inp::MaterialDeck::readFromJson(), inp::MeshDeck::readFromJson(), inp::ModelDeck::readFromJson(), inp::OutputDeck::readFromJson(), inp::PGenDeck::readFromJson(), inp::PNeighborDeck::readFromJson(), inp::RestartDeck::readFromJson(), inp::TestDeck::readFromJson(), inp::BCBaseDeck::readFromJson(), anonymous_namespace{testDeckField.cpp}::testAccepted(), and anonymous_namespace{testDeckField.cpp}::testReadAndWrite().
| Field< Deck > inp::requiredField | ( | T Deck::* | m, |
| std::string | key, | ||
| std::string | doc, | ||
| Accepts< T > | accepts = {} |
||
| ) |
Declares a field that has no default and must be present.
| m | Pointer to the member |
| key | Key in the JSON block |
| doc | One line describing the field |
| accepts | What the field accepts |
Definition at line 215 of file deckField.h.
Key, type, default and description of every field.
The Python interface builds its arguments from this, so that a field added to the table needs no change on the Python side.
| fs | Field table of the deck |
Definition at line 276 of file deckField.h.
References defaultsJson().
Referenced by anonymous_namespace{testDeckField.cpp}::testDefaultsAndSchema().
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 75 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 77 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 83 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 79 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 81 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 85 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 87 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 95 of file deckField.h.
|
inline |
Name of the type of a field, reported by the schema.
Definition at line 91 of file deckField.h.
| void inp::writeFields | ( | const Deck & | d, |
| json & | j, | ||
| const std::vector< Field< Deck > > & | fs | ||
| ) |
Writes every field of the table into the block.
Definition at line 237 of file deckField.h.
Referenced by anonymous_namespace{testDeckField.cpp}::testReadAndWrite(), inp::PGenDeck::writeToJson(), inp::PNeighborDeck::writeToJson(), and inp::RestartDeck::writeToJson().