MoReFEM
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
MoReFEM::ModelSettings< TupleT > Class Template Referenceabstract

Class which purpose is to store model-related data that are intended to be set exclusively by the author of the model. More...

#include <ModelSettings.hpp>

Inheritance diagram for MoReFEM::ModelSettings< TupleT >:
Collaboration diagram for MoReFEM::ModelSettings< TupleT >:

Public Types

using self = ModelSettings
 Self.
 
using parent = Internal::InputDataNS::AbstractClass<TupleT>
 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

 ModelSettings ()
 Special members.
 
 ModelSettings (const ModelSettings &rhs)=delete
 The copy constructor.
 
 ModelSettings (ModelSettings &&rhs)=default
 The move constructor.
 
ModelSettingsoperator= (const ModelSettings &rhs)=delete
 The (copy) operator=.
 
ModelSettingsoperator= (ModelSettings &&rhs)=default
 The (move) operator=.
 
virtual ~ModelSettings () override
 Destructor.
 
template<Advanced::Concept::InputDataNS::LeafType LeafT>
void Add (typename LeafT::return_type &&value)
 Fill the value related to the leaf LeafT.
 
template<Advanced::Concept::InputDataNS::IndexedSectionType SectionT>
void SetDescription (std::string &&description)
 Specify the description for a given IndexedSection.
 
void CheckTupleCompletelyFilled () const
 Check all the values in the tuple have been properly filled.
 
virtual void Init ()=0
 
std::unordered_set< std::string > ExtractIndexedSectionNames () const
 Extract from the tuple the names of the indexed sections.
 
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_typeGetTuple () 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 ConceptIsModelSettings = true
 Helper variable to define the ModelSettingsType concept.
 

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_typeGetNonCstTuple ()
 

Private Types

using tuple_iteration = Internal::InputDataNS::TupleIteration<underlying_tuple_type, 0ul>
 Helper object to iterate upon the tuple (including the in-depth sections).
 

Private Member Functions

const std::vector< std::string > & GetListIdentifiersProperlySet () const
 
std::vector< std::string > & GetNonCstListIdentifiersProperlySet ()
 
void CheckNoDuplicateKeysInTuple () const
 Throw an exception if there is a duplicate in the keys.
 

Private Attributes

std::vector< std::string > list_identifiers_properly_set_
 
underlying_tuple_type tuple_
 The tuple that actually stores all the relevant quantities for the problem.
 

Detailed Description

template<Concept::Tuple TupleT>
class MoReFEM::ModelSettings< TupleT >

Class which purpose is to store model-related data that are intended to be set exclusively by the author of the model.

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:

Constructor & Destructor Documentation

◆ ModelSettings() [1/3]

template<Concept::Tuple TupleT>
MoReFEM::ModelSettings< TupleT >::ModelSettings ( )
explicit

Special members.

Constructor.

◆ ModelSettings() [2/3]

template<Concept::Tuple TupleT>
MoReFEM::ModelSettings< TupleT >::ModelSettings ( const ModelSettings< TupleT > & rhs)
delete

The copy constructor.

Parameters
[in]rhsThe object from which the construction occurs.

◆ ModelSettings() [3/3]

template<Concept::Tuple TupleT>
MoReFEM::ModelSettings< TupleT >::ModelSettings ( ModelSettings< TupleT > && rhs)
default

The move constructor.

Parameters
[in]rhsThe object from which the construction occurs.

Member Function Documentation

◆ operator=() [1/2]

template<Concept::Tuple TupleT>
ModelSettings & MoReFEM::ModelSettings< TupleT >::operator= ( const ModelSettings< TupleT > & rhs)
delete

The (copy) operator=.

Parameters
[in]rhsThe object from which the affectation occurs.
Returns
Reference to the object (to enable chained affectation).

◆ operator=() [2/2]

template<Concept::Tuple TupleT>
ModelSettings & MoReFEM::ModelSettings< TupleT >::operator= ( ModelSettings< TupleT > && rhs)
default

The (move) operator=.

Parameters
[in]rhsThe object from which the affectation occurs.
Returns
Reference to the object (to enable chained affectation).

◆ Add()

template<Concept::Tuple TupleT>
template<Advanced::Concept::InputDataNS::LeafType LeafT>
void MoReFEM::ModelSettings< TupleT >::Add ( typename LeafT::return_type && value)

Fill the value related to the leaf LeafT.

Template Parameters
LeafTLeaf for which the value is set. An exception is thrown if LeafT is not in TupleT.
Parameters
[in]valueValue to be put in the tuple. Its type is defined in LeafT.

◆ SetDescription()

template<Concept::Tuple TupleT>
template<Advanced::Concept::InputDataNS::IndexedSectionType SectionT>
void MoReFEM::ModelSettings< TupleT >::SetDescription ( std::string && description)

Specify the description for a given IndexedSection.

The description will appear above the section in the input data file (if some leaves are still handled there and thus modifiable by the end-user).

Current function is essentially syntactic sugar over Add() method concerning the IndexedSectionDescription special leaf of the IndexedSection.

Parameters
[in]descriptionDescription of the specific instance of SectionT, which will appear as such before the section within the Lua file (if it is automatically generated or updated through the specific UpdateLuaFile executable for your model).

◆ CheckTupleCompletelyFilled()

template<Concept::Tuple TupleT>
void MoReFEM::ModelSettings< TupleT >::CheckTupleCompletelyFilled ( ) const

Check all the values in the tuple have been properly filled.

This method must be add explicitly - I'm not proud of it but baring introducing an Init() method which is not much better I have not better way to do so.

◆ Init()

template<Concept::Tuple TupleT>
virtual void MoReFEM::ModelSettings< TupleT >::Init ( )
pure virtual

Virtual method to be overriden in child classes. In this method the content of the values of the tuple must be filled.

Implemented in MoReFEM::ElasticityNS::ModelSettings, MoReFEM::HeatNS::ModelSettings, MoReFEM::MidpointHyperelasticityNS::ModelSettings, MoReFEM::LaplacianNS::ModelSettings, MoReFEM::MidpointNonLinearShellNS::ModelSettings, MoReFEM::RivlinCubeNS::ModelSettings, MoReFEM::StokesNS::ModelSettings, MoReFEM::TestNS::InputDataSolidNS::ModelSettings, MoReFEM::TestNS::InputDataSolidNS::ModelSettings, MoReFEM::TestNS::WriteLuaFileNS::ModelSettings, MoReFEM::TestNS::BoundaryConditionNS::InvalidCompNS::ModelSettings, MoReFEM::TestNS::BoundaryConditionNS::TwoMeshesNS::ModelSettings, MoReFEM::TestNS::LoadPrepartitionedGodOfDofNS::ModelSettings, MoReFEM::TestNS::MovemeshNS::ModelSettings, MoReFEM::TestNS::MovemeshNS::ModelSettingsForScalarUnknownTest, MoReFEM::TestNS::MovemeshNS::ModelSettingsForSeveralUnknownTest, MoReFEM::TestNS::ColoringNS::ModelSettings, MoReFEM::TestNS::CoordsInParallelNS::ModelSettings, MoReFEM::TestNS::CoordsMatchingNS::ModelSettings, MoReFEM::TestNS::DomainListInCoordsNS::ModelSettings, MoReFEM::TestNS::LightweightDomainListNS::ModelSettings, MoReFEM::TestNS::LoadPrepartitionedMeshNS::ModelSettings, MoReFEM::TestNS::NcoordInDomainNS::ModelSettings, MoReFEM::TestNS::HyperelasticLawNS::ModelSettings, MoReFEM::TestNS::FromCoordsMatchingNS::ModelSettings, MoReFEM::TestNS::P1_to_P_HigherOrder_NS::ModelSettings, MoReFEM::TestNS::GlobalCoordsQuadPt::ModelSettings, MoReFEM::TestNS::UpdateCauchyGreenTensorNS::ModelSettings, MoReFEM::TestNS::ConformProjectorNS::ModelSettings, MoReFEM::TestNS::AnalyticalInternalVariable::ModelSettings, MoReFEM::TestNS::GradGrad::ModelSettings, MoReFEM::TestNS::HyperelasticOperatorNS::ModelSettings, MoReFEM::TestNS::Mass::ModelSettings, MoReFEM::TestNS::Microsphere::ModelSettings, MoReFEM::TestNS::NonLinearMembraneOperatorNS::ModelSettings, MoReFEM::TestNS::NonlinearShell::ModelSettings, MoReFEM::TestNS::MITCNS::ModelSettings, MoReFEM::TestNS::QuasiIncompressiblePk2::ModelSettings, MoReFEM::TestNS::FibersAtQuadPt::ModelSettings, MoReFEM::TestNS::FromInputDataNS::ModelSettings, MoReFEM::TestNS::FromInputDataNS::ModelSettings, MoReFEM::TestNS::FromInputDataNS::ModelSettings, MoReFEM::TestNS::FromInputDataNS::ModelSettings, MoReFEM::TestNS::FromInputDataAndModelSettingsNS::ModelSettings, MoReFEM::TestNS::HardcodedConstructionNS::ModelSettings, MoReFEM::TestNS::ParameterNS::TimeDependencyNS::ModelSettings, MoReFEM::TestNS::PetscNS::MatrixNS::ModelSettings, MoReFEM::TestNS::PetscNS::MatrixOperationsNS::ModelSettings, MoReFEM::TestNS::PetscNS::VectorIONS::ModelSettings, MoReFEM::TestNS::SlepcNS::ModelSettings, MoReFEM::TestNS::EmptyModelSettings, and MoReFEM::TestNS::ReadInputDataNS::ModelSettings.

◆ ExtractIndexedSectionNames()

template<Concept::Tuple TupleT>
std::unordered_set< std::string > MoReFEM::ModelSettings< TupleT >::ExtractIndexedSectionNames ( ) const

Extract from the tuple the names of the indexed sections.

Returns
List of the full names (i.e. with enclosing section name present as well) with '.' as separator) of indexed sections.

The way to tag these is to use the special leaves than inherits from IndexedSectionDescription CRTP. If not they won't be found properly - but there are safeties in the code to pinpoint this to the developer of a model (see Model::CheckNoMissingIndexedSectionDescriptions()).

Current method is public but isn't intended to be used publicly - in other words if you're not a developer of the main library you shouldn't bother.

◆ GetListIdentifiersProperlySet()

template<Concept::Tuple TupleT>
const std::vector< std::string > & MoReFEM::ModelSettings< TupleT >::GetListIdentifiersProperlySet ( ) const
private

Accessor to the list of identifiers that have been filled with Add() method. This is a purely internal data attribute that shouldn't be exposed publicly.

◆ GetNonCstListIdentifiersProperlySet()

template<Concept::Tuple TupleT>
std::vector< std::string > & MoReFEM::ModelSettings< TupleT >::GetNonCstListIdentifiersProperlySet ( )
private

Non constant accessor to the list of identifiers that have been filled with Add() method. This is a purely internal data attribute that shouldn't be exposed publicly.

◆ Nleaves()

template<::MoReFEM::Concept::Tuple TupleT>
static constexpr std::size_t MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::Nleaves ( )
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.

Returns
Number of leaves found.

◆ PrintUnusedLeafs()

template<::MoReFEM::Concept::Tuple TupleT>
void MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::PrintUnusedLeafs ( std::ostream & stream,
const ::MoReFEM::Wrappers::Mpi & mpi ) const
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.

Parameters
[in,out]streamStream upon which object information are written. If nothing added then all input data were used.
[in]mpiMpi 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.

◆ PrintKeys()

template<::MoReFEM::Concept::Tuple TupleT>
void MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::PrintKeys ( std::ostream & stream) const
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"

Parameters
[in,out]streamStream upon which object information are written.

◆ ExtractKeys()

template<::MoReFEM::Concept::Tuple TupleT>
std::vector< std::string > MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::ExtractKeys ( ) const
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"

Returns
The list of all extracted items from the tuple.

◆ Find()

template<::MoReFEM::Concept::Tuple TupleT>
template<class ItemT >
static constexpr bool MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::Find ( )
staticconstexprinherited

Whether ItemT is present in the tuple or not.

Template Parameters
ItemTField sought in the tuple.
Returns
True if present.

◆ ComputeUnusedLeafList()

template<::MoReFEM::Concept::Tuple TupleT>
std::vector< std::string > MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::ComputeUnusedLeafList ( const ::MoReFEM::Wrappers::Mpi & mpi) const
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.

Attention
In parallel, list is computed only on root processor. A leaf is there in this case only if it is counted as unused in all of the ranks.
Parameters
[in]mpiMpi object which knows the rank of the processor, the total number of processors, etc...
Returns
All the leafs not counted as used, sort in alphabetical order.

◆ ExtractLeaf()

template<::MoReFEM::Concept::Tuple TupleT>
template<::MoReFEM::Advanced::Concept::InputDataNS::LeafType LeafT, ::MoReFEM::InputDataNS::CountAsUsed CountAsUsedT = ::MoReFEM::InputDataNS::CountAsUsed::yes>
auto MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::ExtractLeaf ( ) const -> typename Utilities::ConstRefOrValue< typename LeafT::return_type >::type
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!).

Template Parameters
AbstractClassTAbstractClass class used to store the wanted input data.
CountAsUsedTWhether 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.
Returns
The requested element in the tuple. It is either copied by value or a const reference.

◆ ExtractSection()

template<::MoReFEM::Concept::Tuple TupleT>
template<Advanced::Concept::InputDataNS::SectionType SectionT>
auto & MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::ExtractSection ( ) const
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.

Template Parameters
SectionTThe section object we which to extract.

◆ CheckNoDuplicateKeysInTuple()

template<::MoReFEM::Concept::Tuple TupleT>
void MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::CheckNoDuplicateKeysInTuple ( ) const
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.

◆ GetTuple()

template<::MoReFEM::Concept::Tuple TupleT>
const underlying_tuple_type & MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::GetTuple ( ) const
noexceptinherited

Accessor to the underlying tuple.

Returns
Underlying tuple.

◆ GetNonCstTuple()

template<::MoReFEM::Concept::Tuple TupleT>
underlying_tuple_type & MoReFEM::Internal::InputDataNS::AbstractClass< TupleT >::GetNonCstTuple ( )
protectedinherited

Non constant accessor to the underlying tuple.

Returns
Underlying tuple.

Field Documentation

◆ list_identifiers_properly_set_

template<Concept::Tuple TupleT>
std::vector<std::string> MoReFEM::ModelSettings< TupleT >::list_identifiers_properly_set_
private

List of identifiers that have been filled with Add() method. This is a purely internal data attribute that shouldn't be exposed publicly.


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