MoReFEM
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends
MoReFEM::GodOfDofManager Class Reference

This class is used to create and retrieve GodOfDof objects. More...

#include <GodOfDofManager.hpp>

Inheritance diagram for MoReFEM::GodOfDofManager:
Collaboration diagram for MoReFEM::GodOfDofManager:

Public Types

using indexed_section_tag = ::MoReFEM::Internal::InputDataNS::MeshNS::Tag
 Convenient alias to the (internal) tag used to identify IndexedSection of a specific type (e.g. all the sections related to a Mesh).
 
using storage_type = std::unordered_map<MeshNS::unique_id, GodOfDof::shared_ptr>
 Convenient alias.
 
using self
 Convenient alias.
 

Public Member Functions

template<class IndexedSectionDescriptionT , ::MoReFEM::Concept::ModelSettingsType ModelSettingsT, ::MoReFEM::Concept::InputDataType InputDataT>
void Create (const IndexedSectionDescriptionT &indexed_section_description, const ModelSettingsT &model_settings, const InputDataT &input_data, const Wrappers::Mpi &mpi)
 Create a GodOfDof object from InputData and ModelSettings information.
 
void Create (const Wrappers::Mpi &mpi, Mesh &mesh)
 Create a new GodOfDof object from a Mesh.
 
const GodOfDofGetGodOfDof (MeshNS::unique_id unique_id) const
 
GodOfDofGetNonCstGodOfDof (MeshNS::unique_id unique_id)
 
GodOfDof::shared_ptr GetGodOfDofPtr (MeshNS::unique_id unique_id) const
 
const GodOfDofGetGodOfDof (const Mesh &mesh) const
 
const storage_typeGetStorage () const noexcept
 Access to the storage.
 

Static Public Member Functions

static const std::string & ClassName ()
 Returns the name of the class (required for some Singleton-related errors).
 
static GodOfDofManagerCreateOrGetInstance (const std::source_location location=std::source_location::current(), Args &&... args)
 Call instance of the singleton.
 
static GodOfDofManagerGetInstance (const std::source_location location=std::source_location::current())
 Call an instance of the singleton that must already have been created.
 
static void Destroy ()
 Destroy the singleton.
 

Private Member Functions

storage_typeGetNonCstStorage () noexcept
 Non constant access to the storage.
 
void Clear ()
 Clear the storage content.
 

Static Private Member Functions

static void OnDeadReference (const std::source_location location=std::source_location::current())
 Gets called if dead reference detected.
 
static std::mutex & GetNonCstSingletonMutex ()
 Get reference to the singleton mutex.
 

Private Attributes

storage_type storage_
 Store the god of dof objects by their unique identifier.
 

Static Private Attributes

static GodOfDofManagerinstance_
 Internal pointer to the actual instance.
 
static bool destroyed_
 Used for protection against dead reference problem (invocation while the instance has been destroyed).
 
static std::mutex singleton_mutex_
 Mutex object.
 

Friends

template<TIME_MANAGER_TEMPLATE_KEYWORD TimeManagerTT>
struct MoReFEM::TestNS::ClearSingletons
 Friendship to a function in tests that is allowed to call Clear(). This function should be used only for tests!
 

Singleton requirements.

class Utilities::Singleton< GodOfDofManager >
 Friendship declaration to Singleton template class (to enable call to constructor).
 
 GodOfDofManager ()
 Constructor.
 
virtual ~GodOfDofManager () override
 Destructor.
 

Detailed Description

This class is used to create and retrieve GodOfDof objects.

GodOfDof objects get private constructor and can only be created through this class. In addition to their creation, this class keeps their address, so it's possible from instance to retrieve a GodOfDof object given its unique id (which is the one that appears in the input data file).

Member Typedef Documentation

◆ indexed_section_tag

Convenient alias to the (internal) tag used to identify IndexedSection of a specific type (e.g. all the sections related to a Mesh).

Tag used to identify IndexedSection of a given type (e.g. all Mesh sections in the input data or model settings)

Member Function Documentation

◆ ClassName()

static const std::string & MoReFEM::GodOfDofManager::ClassName ( )
static

Returns the name of the class (required for some Singleton-related errors).

Returns
Name of the class.

◆ Create() [1/2]

template<class IndexedSectionDescriptionT , ::MoReFEM::Concept::ModelSettingsType ModelSettingsT, ::MoReFEM::Concept::InputDataType InputDataT>
void MoReFEM::GodOfDofManager::Create ( const IndexedSectionDescriptionT & indexed_section_description,
const ModelSettingsT & model_settings,
const InputDataT & input_data,
const Wrappers::Mpi & mpi )

Create a GodOfDof object from InputData and ModelSettings information.

Parameters
[in]indexed_section_descriptionInstantiation of a IndexedSectionDescription object that is a placeholder to tell a given IndexedSection exists for the Model. Most of the time the instantiation itself is not used and the relevant information is in fact its type (from which type of the IndexedSection may be inferred).
Parameters
[in]model_settingsObject 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.
Parameters
[in]input_dataObject which hold the values of all the input data that were defined in the Lua file (and that is thus modifiable by the end user). Example (in most of the models): the shape function to use for an Unknown in a FEltSpace.
[in]mpiMpi object which knows the rank of the processor, the total number of processors, etc...

◆ Create() [2/2]

void MoReFEM::GodOfDofManager::Create ( const Wrappers::Mpi & mpi,
Mesh & mesh )

Create a new GodOfDof object from a Mesh.

Mesh is not a typo here: there is one god of dof per mesh and so GodOfDofs are created by tracking mesh sections in the input data.

This method should NOT be used directly: it is introduced for the sake of tests. Ue instead the template namesake method.

Parameters
[in,out]meshMesh to which the GodOfDof to be created is related.
[in]mpiMpi object which knows the rank of the processor, the total number of processors, etc...

◆ GetGodOfDof() [1/2]

const GodOfDof & MoReFEM::GodOfDofManager::GetGodOfDof ( MeshNS::unique_id unique_id) const

Fetch the god of dof object associated with unique_id unique identifier.

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

◆ GetNonCstGodOfDof()

GodOfDof & MoReFEM::GodOfDofManager::GetNonCstGodOfDof ( MeshNS::unique_id unique_id)

Fetch the god of dof object associated with unique_id unique identifier.

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

◆ GetGodOfDofPtr()

GodOfDof::shared_ptr MoReFEM::GodOfDofManager::GetGodOfDofPtr ( MeshNS::unique_id unique_id) const

Fetch the god of dof object associated with unique_id unique identifier.

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

◆ GetGodOfDof() [2/2]

const GodOfDof & MoReFEM::GodOfDofManager::GetGodOfDof ( const Mesh & mesh) const

Fetch the god of dof object associated with Mesh.

Parameters
[in]meshMesh associated to the GodOfDof (by construct both share the same unique id).

◆ Clear()

void MoReFEM::GodOfDofManager::Clear ( )
private

Clear the storage content.

This is a functionality only to be used in tests, after the call to TestNS::ClearSingletons::Do()...

◆ CreateOrGetInstance()

static GodOfDofManager & MoReFEM::Utilities::Singleton< GodOfDofManager >::CreateOrGetInstance ( const std::source_location location = std::source_location::current(),
Args &&... args )
staticinherited

Call instance of the singleton.

If not already existing it will be created on the fly, otherwise the existing one will be used. This method should be called in two cases:

  • If we do not know whether the instance already exists or not. The most typical example is when a value is registered within the singleton in an anonymous namespace.
  • If we know for sure it is the first call to the singleton. For instance the initialization of TimeKeep sinfgleton class that sets the initial time.

In all other cases, call instead GetInstance().

Template Parameters
ArgsVariadic template arguments.
Parameters
[in]argsArguments passed to the constructor if the object is to be built.
Parameters
[in]locationSTL object with relevant information about the calling site (usually to help when an exception is thrown.
Returns
Instance of the singleton.

◆ GetInstance()

static GodOfDofManager & MoReFEM::Utilities::Singleton< GodOfDofManager >::GetInstance ( const std::source_location location = std::source_location::current())
staticinherited

Call an instance of the singleton that must already have been created.

This must be called instead of CreateOrGetInstance(location) if T doesn't get a default constructor.

Parameters
[in]locationSTL object with relevant information about the calling site (usually to help when an exception is thrown.
Returns
Instance of the singleton.

◆ OnDeadReference()

static void MoReFEM::Utilities::Singleton< GodOfDofManager >::OnDeadReference ( const std::source_location location = std::source_location::current())
staticprivateinherited

Gets called if dead reference detected.

Parameters
[in]locationSTL object with relevant information about the calling site (usually to help when an exception is thrown.

Friends And Related Symbol Documentation

◆ MoReFEM::TestNS::ClearSingletons

template<TIME_MANAGER_TEMPLATE_KEYWORD TimeManagerTT>
friend struct MoReFEM::TestNS::ClearSingletons
friend

Friendship to a function in tests that is allowed to call Clear(). This function should be used only for tests!

Field Documentation

◆ destroyed_

bool MoReFEM::Utilities::Singleton< GodOfDofManager >::destroyed_
staticprivateinherited

Used for protection against dead reference problem (invocation while the instance has been destroyed).

Should not occur in our case, but it is much safer to put the protection there anyway.

◆ singleton_mutex_

std::mutex MoReFEM::Utilities::Singleton< GodOfDofManager >::singleton_mutex_
staticprivateinherited

Mutex object.

This follows item 16 of Scott Meyers's "Effective Modern C++", which advises to make const member functions thread safe.


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