MoReFEM
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT > Class Template Reference

Class that drives the finite element resolution. More...

#include <Model.hpp>

Inheritance diagram for MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >:
Collaboration diagram for MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >:

Public Types

using self = Model<DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT>
 Alias to the type of the class.
 
using morefem_data_type = MoReFEMDataT
 Alias to MoReFEMDataT.
 
using time_manager_type = typename morefem_data_type::time_manager_type
 Alias to the object in charge of time management.
 

Public Member Functions

bool HasFinished ()
 Whether the model has finished all its dynamic iterations.
 
void Initialize ()
 Initialize the model.
 
void InitializeStep ()
 Initialize the dynamic step.
 
void FinalizeStep ()
 Finalize the dynamic step.
 
void Finalize ()
 Finalize the model once the time loop is done.
 
void Run ()
 A convenient wrapper over the usual way a Model is used.
 
const time_manager_typeGetTimeManager () const noexcept
 Access to the object in charge of transient data.
 
const FilesystemNS::DirectoryGetOutputDirectory () const noexcept
 Access to output directory.
 
void SetDoPrintNewTimeIterationBanner (bool do_print) noexcept
 
void SetClearGodOfDofTemporaryDataToFalse ()
 Set do_clear_god_of_dof_temporary_data_after_initialize_ to false.
 
const GodOfDofGetGodOfDof (::MoReFEM::MeshNS::unique_id unique_id) const
 
const morefem_data_typeGetMoReFEMData () const noexcept
 Accessor to the underlying MoReFEMData object.
 
const MeshGetMesh (::MoReFEM::MeshNS::unique_id unique_id) const
 Non constant accessor to Mesh which unique identifier is unique_id

.
 
bool DoWriteRestartData () const noexcept
 
const Wrappers::MpiGetMpi () const noexcept
 
Special members.
 Model (morefem_data_type &morefem_data, create_domain_list_for_coords a_create_domain_list_for_coords=create_domain_list_for_coords::no, print_banner do_print_banner=print_banner::yes)
 Constructor.
 
 ~Model ()
 Destructor.
 
 Model (const Model &rhs)=delete
 The copy constructor.
 
 Model (Model &&rhs)=delete
 The move constructor. - deactivated.
 
Modeloperator= (const Model &rhs)=delete
 The (copy) operator=.
 
Modeloperator= (Model &&rhs)=delete
 The (move) operator=.
 

Protected Member Functions

MeshGetNonCstMesh (::MoReFEM::MeshNS::unique_id unique_id) const
 Constant accessor to Mesh which unique identifier is unique_id

.
 
std::size_t GetDisplayValue () const
 Files will be written every GetDisplayValue() time iterations.
 
time_manager_typeGetNonCstTimeManager () noexcept
 Non constant access to the object in charge of transient data.
 
morefem_data_typeGetNonCstMoReFEMData () noexcept
 Accessor to the underlying MoReFEMData object.
 

Private Member Functions

void UpdateTime ()
 Go the the next iteration step.
 
void PrintNewTimeIterationBanner () const
 Print a banner with text, the time and the iteration number.
 
create_domain_list_for_coords GetCreateDomainListForCoords () const noexcept
 Constant accessor to create_domain_list_for_coords_.
 
void CreateDomainListForCoords ()
 Coords will get the information of which domain they are in.
 
bool DoPrintBanner () const noexcept
 Whether banners should be printed or not.
 

Private Attributes

morefem_data_typemorefem_data_
 Reference to the MoReFEMData object.
 
std::optional< std::size_t > display_value_ { std::nullopt }
 Files will be written every display_value_ time iteration. Choose 1 to write all of them.
 
bool do_clear_god_of_dof_temporary_data_after_initialize_ = true
 Enables to postpone the ClearGodOfDofTemporaryData to be able to create operators after the initialize.
 
bool do_print_new_time_iteration_banner_ = true
 If false, the banner for each new time iteration won't be printed.
 
print_banner do_print_banner_ = print_banner::yes
 If false, no banner at all will be printed. False is useful for test framework.
 
bool was_initialize_already_called_ { false }
 
bool do_write_restart_data_ { false }
 
const Wrappers::Mpimpi_
 Mpi object.
 

Detailed Description

template<class DerivedT, ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
class MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >

Class that drives the finite element resolution.

A main can consist only on the instantiation of a Model and a call to its Run() method.

Template Parameters
DerivedTModel is used as a CRTP class.
DoConsiderProcessorWiseLocal2GlobalTWhether the local-2-global for processor-wise data might be required by at least one of the operator. In some models processor-wise is never considered (most linear models); in that case it's irrelevant to use up loads of memory to store them so 'no'should be given.
TimeManagerPolicyTThe time manager policy to use. Currently three options are open:

DerivedT is expected to define the following methods (otherwise the compilation will fail):

In the case TimeManagerNS::Policy::None policy is chosen, only SupplInitialize() and SupplFinalize() are mandatory.

Member Typedef Documentation

◆ self

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
using MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::self = Model<DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT>

Alias to the type of the class.

Constructor & Destructor Documentation

◆ Model() [1/3]

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::Model ( morefem_data_type & morefem_data,
create_domain_list_for_coords a_create_domain_list_for_coords = create_domain_list_for_coords::no,
print_banner do_print_banner = print_banner::yes )
explicit

Constructor.

Model drives most of MoReFEM; so its constructor is responsible for a lot the initialisation steps (for instance VariationalFormulation or dof numbering are fully built there).

Parameters
[in,out]morefem_dataThe object which encapsulates some stuff that acts as global data, such as:
  • The content of the input data.
  • Mpi related information.
  • The directory into which output is to be written.
  • Management of time iterations

The argument is noted as input and output, but most of the content is actually constant; the only part that may be modified here is the time iteration related stuff.

Parameters
[in]a_create_domain_list_for_coordsWhether the model will compute the list of domains a coord is in or not.
[in]do_print_bannerIf True, print text at the beginning and the end of the program. False has been introduced only for the integration tests.

◆ Model() [2/3]

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::Model ( const Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT > & rhs)
delete

The copy constructor.

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

◆ Model() [3/3]

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::Model ( Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT > && rhs)
delete

The move constructor. - deactivated.

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

Member Function Documentation

◆ operator=() [1/2]

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
Model & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::operator= ( const Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT > & 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<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
Model & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::operator= ( Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT > && rhs)
delete

The (move) operator=.

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

◆ HasFinished()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::HasFinished ( )

Whether the model has finished all its dynamic iterations.

[internal] Part of its implementation is the responsibility of DerivedT: the base class just checks whether maximum time has been hit, but it is possible for some model to add additional criteria through SupplHasFinishedConditions().

Returns
True if all time iterations are done.

◆ Initialize()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
void MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::Initialize ( )

Initialize the model.

Base class only creates the GodOfDof and finite element spaces; additional functionalities must be implemented in DerivedT::SupplInitialize() (this method must be defined even in cases its content is null).

◆ InitializeStep()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
void MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::InitializeStep ( )

Initialize the dynamic step.

Base class only print information about time; additional functionalities must be implemented in DerivedT::SupplInitializeStep() (this method must be defined even in cases its content is null).

◆ FinalizeStep()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
void MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::FinalizeStep ( )

Finalize the dynamic step.

Base class only asks the TimeManager object to update the time; additional functionalities must be implemented in DerivedT::SupplFinalizeStep() (this method must be defined even in cases its content is null).

◆ Run()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
void MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::Run ( )

A convenient wrapper over the usual way a Model is used.

A main could be just the instantiation of a Model and subsequently the call to this method.

This method is equivalent to what is usually in a main for Verdandi:

model.Initialize();
while (!HasFinished())
{
model.InitializeStep();
model.Forward();
model.SupplFinalizeStep();
}
model.Finalize();
bool HasFinished()
Whether the model has finished all its dynamic iterations.

◆ SetDoPrintNewTimeIterationBanner()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
void MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::SetDoPrintNewTimeIterationBanner ( bool do_print)
noexcept

Setter on do_print_new_time_iteration_banner_.

Parameters
[in]do_printTrue if you want to print the banner.

◆ GetGodOfDof()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
const GodOfDof & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::GetGodOfDof ( ::MoReFEM::MeshNS::unique_id unique_id) const

Access a GodOfDof object using its unique id.

Parameters
[in]unique_idUnique identifier of the sought GodOfDof (as returned by GodOfDof::GetUniqueId()).

◆ GetMoReFEMData()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
const morefem_data_type & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::GetMoReFEMData ( ) const
noexcept

Accessor to the underlying MoReFEMData object.

Returns
Constant reference to the MoReFEMData object.

◆ GetMesh()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
const Mesh & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::GetMesh ( ::MoReFEM::MeshNS::unique_id unique_id) const

Non constant accessor to Mesh which unique identifier is unique_id

.

Returns
Reference to Mesh which unique identifier is unique_id
Parameters
[in]unique_idUnique identifier of the sought Mesh (as returned by Mesh::GetUniqueId())..

◆ DoWriteRestartData()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::DoWriteRestartData ( ) const
noexcept

Please notice this field does little more than store what was indicated in the input data file in the InputDataNS::Restart::DoWriteRestartData field; it is in each model that support restarts that you may provide the logic to write or not the data, e.g. with something like (in which MyModel derives from current class):

void MyModel::WriteRestartData() const
{
decltype(auto) time_manager = parent::GetTimeManager();
decltype(auto) god_of_dof = parent::GetGodOfDof();
{
Advanced::RestartNS::WriteDataForRestart(time_manager, god_of_dof, "velocity", GetVectorCurrentVelocity());
Advanced::RestartNS::WriteDataForRestart(time_manager, god_of_dof, "displacement", GetVectorCurrentDisplacement());
}
}
bool DoWriteRestartData() const noexcept
void WriteDataForRestart(const TimeManagerT &time_manager, const GodOfDof &god_of_dof, std::string_view tag, const GlobalVector &vector)
Write content of vector into a dedicated directory that might be used in a later restart run.
Returns
True if such restart data should be written.

This is for an Advanced user; you may have a look at Elastic model in the example to see how it is used.

◆ GetNonCstMesh()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
Mesh & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::GetNonCstMesh ( ::MoReFEM::MeshNS::unique_id unique_id) const
protected

Constant accessor to Mesh which unique identifier is unique_id

.

Returns
Mesh which unique identifier is unique_id
Parameters
[in]unique_idUnique identifier of the sought Mesh (as returned by Mesh::GetUniqueId())..

◆ GetNonCstMoReFEMData()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
morefem_data_type & MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::GetNonCstMoReFEMData ( )
protectednoexcept

Accessor to the underlying MoReFEMData object.

Returns
Constant reference to the MoReFEMData object.

◆ DoPrintBanner()

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::DoPrintBanner ( ) const
privatenoexcept

Whether banners should be printed or not.

Returns
Boolean...

◆ GetMpi()

const Wrappers::Mpi & MoReFEM::Crtp::CrtpMpi< DerivedT >::GetMpi ( ) const
noexceptinherited

Read-only access to underlying Mpi object.

Returns
Constant accessor to underlying Mpi object.

Field Documentation

◆ display_value_

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
std::optional<std::size_t> MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::display_value_ { std::nullopt }
private

Files will be written every display_value_ time iteration. Choose 1 to write all of them.

May be std::nullopt for 'models' related to some of the tests.

◆ do_clear_god_of_dof_temporary_data_after_initialize_

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::do_clear_god_of_dof_temporary_data_after_initialize_ = true
private

Enables to postpone the ClearGodOfDofTemporaryData to be able to create operators after the initialize.

Attention
If set to false you will need to call ClearGodOfDofTemporaryData manually once you have initialize all your operators. When writing a simple MoReFEM model one should not set this attribute to false it is designed to be used when interfacong with another code.

◆ do_print_new_time_iteration_banner_

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::do_print_new_time_iteration_banner_ = true
private

If false, the banner for each new time iteration won't be printed.

Even if true it is second to do_print_banner_.

◆ was_initialize_already_called_

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::was_initialize_already_called_ { false }
private

In debug mode, data attribute to check Initialize is not called more than one for a given Model object.

◆ do_write_restart_data_

template<class DerivedT , ::MoReFEM::Advanced::Concept::MoReFEMDataType MoReFEMDataT, DoConsiderProcessorWiseLocal2Global DoConsiderProcessorWiseLocal2GlobalT>
bool MoReFEM::Model< DerivedT, MoReFEMDataT, DoConsiderProcessorWiseLocal2GlobalT >::do_write_restart_data_ { false }
private

Please notice this field does little more than store what was indicated in the input data file in the InputDataNS::Restart::DoWriteRestartData field; it is in each model that support restarts that you may provide the logic to write or not the data, e.g. with something like (in which MyModel derives from current class):

void MyModel::WriteRestartData() const
{
decltype(auto) time_manager = parent::GetTimeManager();
decltype(auto) god_of_dof = parent::GetGodOfDof();
{
Advanced::RestartNS::WriteDataForRestart(time_manager, god_of_dof, "velocity", GetVectorCurrentVelocity());
Advanced::RestartNS::WriteDataForRestart(time_manager, god_of_dof, "displacement", GetVectorCurrentDisplacement());
}
}

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