MoReFEM
|
This class read the input data file and then is in charge of holding the values read. More...
#include <InputData.hpp>
Public Types | |
using | self = InputData<TupleT, DoUpdateLuaFileT> |
Self. | |
using | parent = Internal::InputDataNS::AbstractClass<TupleT> |
Abstract parent. | |
using | const_unique_ptr = std::unique_ptr<const self> |
Alias to smart pointers storing objects. | |
using | underlying_tuple_type = TupleT |
The underlying tuple type. | |
Public Member Functions | |
template<::MoReFEM::Concept::ModelSettingsType ModelSettingsT> | |
InputData (const ModelSettingsT &model_settings, const FilesystemNS::File &filename, InputDataNS::DoTrackUnusedFields do_track_unused_fields=InputDataNS::DoTrackUnusedFields::yes) | |
Special members. | |
InputData (const InputData &rhs)=delete | |
The copy constructor. | |
InputData (InputData &&rhs)=delete | |
The move constructor. | |
InputData & | operator= (const InputData &rhs)=delete |
The (copy) operator=. | |
InputData & | operator= (InputData &&rhs)=delete |
The (move) operator=. | |
virtual | ~InputData () override |
Destructor. | |
const FilesystemNS::File & | GetInputFile () const |
void | PrintUnusedLeafs (std::ostream &stream, const ::MoReFEM::Wrappers::Mpi &mpi) const |
Print the list of input data that weren't used in the program. | |
void | PrintKeys (std::ostream &stream) const |
Print the complete identifiers of all the expected leaves expected in an input data tuple. | |
std::vector< std::string > | ExtractKeys () const |
Extract the complete identifiers of all the expected leaves expected in an input data tuple. | |
std::vector< std::string > | ComputeUnusedLeafList (const ::MoReFEM::Wrappers::Mpi &mpi) const |
Compute the list of all leaves that are in fact not used. | |
const underlying_tuple_type & | GetTuple () const noexcept |
Static Public Member Functions | |
static constexpr std::size_t | Size () |
Size of the tuple. | |
static constexpr std::size_t | Nleaves () |
Returns the number of leaves in the tuple. | |
template<class ItemT > | |
static constexpr bool | Find () |
Whether ItemT is present in the tuple or not. | |
Static Public Attributes | |
static constexpr bool | ConceptIsInputData = true |
Helper variable to define the InputDataType concept. | |
Protected Types | |
using | tuple_iteration = Internal::InputDataNS::TupleIteration<underlying_tuple_type, 0ul> |
Helper object to iterate upon the tuple (including the in-depth sections). | |
Protected Member Functions | |
template<::MoReFEM::Advanced::Concept::InputDataNS::LeafType LeafT, ::MoReFEM::InputDataNS::CountAsUsed CountAsUsedT = ::MoReFEM::InputDataNS::CountAsUsed::yes> | |
auto | ExtractLeaf () const -> typename Utilities::ConstRefOrValue< typename LeafT::return_type >::type |
Helper function used to extract value of a leaf. | |
template<Advanced::Concept::InputDataNS::SectionType SectionT> | |
auto & | ExtractSection () const |
Helper function used to extract a section. | |
underlying_tuple_type & | GetNonCstTuple () |
Private Member Functions | |
template<::MoReFEM::Advanced::Concept::InputDataNS::LeafType LeafT> | |
std::filesystem::path | ExtractLeafAsPath () const |
Helper function used to handle a path: it is basically handled as a mere string, except that environment variables are replaced on the fly if they respect the format ${...}. | |
void | CheckUnboundInputData (const FilesystemNS::File &filename, ::MoReFEM::Wrappers::Lua::OptionFile &lua_option_file, InputDataNS::DoTrackUnusedFields do_track_unused_fields) const |
Check no input data present in the Lua file is actually not known by the input data file tuple. | |
void | CheckNoDuplicateKeysInTuple () const |
Throw an exception if there is a duplicate in the keys. | |
Private Attributes | |
FilesystemNS::File | input_data_file_ |
Path of the input data file. | |
underlying_tuple_type | tuple_ |
The tuple that actually stores all the relevant quantities for the problem. | |
This class read the input data file and then is in charge of holding the values read.
It hold the charge of checking that mandatory parameters are correctly filled in the data file as soon as possible: we want for instance to avoid a program failure at the end because a path for an output file is invalid.
DoUpdateLuaFileT | In the case we want to update a Lua file, we need some wiggle room (for instance we may need to load an invalid Lua file if a field no longer exists, which is forbidden in a normal run). Do not choose 'yes' except if ProgramType of your MoReFEMData class is program_type::update_lua_file. |
TupleT | A tuple which should include a class for each input data to consider in the file. The class for each input datum should derive from InputData::Crtp::InputData and defines several static methods such as Description(), NameInFile() or Section(). Compiler won't let you not define one of those anyway; to see an example of such a class see in Core/InputData or in MoReFEM documentation. |
When a model is written, there is need to specify some data that are really specific to this model: how many meshes or finite elements spaces are involved, which unknowns are involved, what are the characteristics of a Solid involved, and so forth...
Up to v23.11.2, all these data were stored in a template class named InputData
which parameter is a tuple telling which data is expected in the input file. Doing this enable a rather tight control: we could check that all the data mentioned in said input file are accounted for and are really expected, and there are also no "hidden" value that the end user may not know (said otherwise, if you tackle volumic mass of a solid the field MUST be in the input data file; there is no risk that a value is silently used).
There was however a default doing so: when defining for instance a finite element space, there is (at the time of this writing) 5 leaves to be defined in the input data file:
The problem is that the only ones that are truly expected to be modified by an end user is the shape function list (or numbering subset list in the very specific case of the Stokes model).
So to circumvent this, a new structure named ModelSettings
has been introduced. Its goal is to provide a way for a model user to set the values the end user should not modify without breaking completely the infrastructure that has already been implemented for InputData
.
So tu put in a nutshell, now model-related data may be stored:
InputData
class, in which case the data will be modifiable by the end-user.ModelSettings
class, in which case the data is not intended to be modified by the end-user (but it should nonetheless be visible - ordering of unknowns for instance must be known to provide in the Lua file the shape functions).
|
explicit |
Special members.
Constructor.
[in] | filename | Name of the Lua input data list to be read. |
[in] | do_track_unused_fields | Whether a field found in the file but not referenced in the tuple yields an exception or not. Should be 'yes' most of the time; I have introduced the 'no' option for cases in which we need only a handful of parameters shared by all models for post-processing purposes (namely mesh-related ones). |
[in] | model_settings | Object which hold the values of all the input data that should not be modifiable by the end user. Example (in most of the models): NumberingSubset in which an Unknown should be allotted in a FEltSpace. |
|
delete |
The copy constructor.
[in] | rhs | The object from which the construction occurs. |
|
delete |
The move constructor.
[in] | rhs | The object from which the construction occurs. |
|
delete |
The (copy) operator=.
[in] | rhs | The object from which the affectation occurs. |
|
delete |
The (move) operator=.
[in] | rhs | The object from which the affectation occurs. |
const FilesystemNS::File & MoReFEM::InputData< TupleT, DoUpdateLuaFileT >::GetInputFile | ( | ) | const |
Get the path to the input data file.
|
private |
Helper function used to handle a path: it is basically handled as a mere string, except that environment variables are replaced on the fly if they respect the format ${...}.
For instance "${HOME}/Codes/MoReFEM" will be resolved on a Mac in /Users/ username /Codes/MoReFEM.
|
private |
Check no input data present in the Lua file is actually not known by the input data file tuple.
[in] | filename | Path to the input file. |
[in] | lua_option_file | The object that helps interpreting the content of the Lua file. |
[in] | do_track_unused_fields | See constructor. |
|
staticconstexprinherited |
Returns the number of leaves in the tuple.
It is not the same as size: this method explorates the sections to count how many leaves they include.
|
inherited |
Print the list of input data that weren't used in the program.
This method is dedicated to be called at destruction, but when using OpenMPI it is rather uneasy to make it called in the destructor due to racing conditions (error if MPI_Finalize() has already been called.
So this method should be called at the very end of your program if you want the information it gives.
[in,out] | stream | Stream upon which object information are written. If nothing added then all input data were used. |
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
[internal]
This method collects the data from all mpi processors; the list is therefore ensured to be exhaustive.
|
inherited |
Print the complete identifiers of all the expected leaves expected in an input data tuple.
An identifier being here the chaining of sections and subsections followed by the leaf name, with '.' acting as a separator.
For instance "Section1.SubsectionInSection1.LeafInSubSection1"
[in,out] | stream | Stream upon which object information are written. |
|
inherited |
Extract the complete identifiers of all the expected leaves expected in an input data tuple.
An identifier being here the chaining of sections and subsections followed by the leaf name, with '.' acting as a separator.
For instance "Section1.SubsectionInSection1.LeafInSubSection1"
|
staticconstexprinherited |
Whether ItemT is present in the tuple or not.
ItemT | Field sought in the tuple. |
|
inherited |
Compute the list of all leaves that are in fact not used.
This is a rather crude indicator: a leaf is considered 'used' if Extract facility is called upon it. Leaf that are present indirectly because their enclosing section is given in the input data tuple are correctly counted.
[in] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
|
protectedinherited |
Helper function used to extract value of a leaf.
This should not be used directly by a user; ExtractLeaf class deals with it with a more user-friendly interface (no pesky template keyword to add!).
AbstractClassT | AbstractClass class used to store the wanted input data. |
CountAsUsedT | Whether the call to the methods counts as an effective use of the input parameter in the program. See CountAsUsed for more details; default value is fine in almost all cases. |
|
protectedinherited |
Helper function used to extract a section.
Currently it is not of much use and you shouldn't have to call it; however it might be handy in the future if we need to extend the class.
SectionT | The section object we which to extract. |
|
privateinherited |
Throw an exception if there is a duplicate in the keys.
The key for an AbstractClass A class is given by free function AbstractClassKey<A>().
As these keys are what is used by OptionFile to read the value, it is important not to use the same for two parameters.
An additional bonus is that a same AbstractClass class put twice in the tuple will also trigger this exception.
|
noexceptinherited |
Accessor to the underlying tuple.
|
protectedinherited |
Non constant accessor to the underlying tuple.