MoReFEM
|
This class is used to create and retrieve GodOfDof objects. More...
#include <GodOfDofManager.hpp>
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 GodOfDof & | GetGodOfDof (MeshNS::unique_id unique_id) const |
GodOfDof & | GetNonCstGodOfDof (MeshNS::unique_id unique_id) |
GodOfDof::shared_ptr | GetGodOfDofPtr (MeshNS::unique_id unique_id) const |
const GodOfDof & | GetGodOfDof (const Mesh &mesh) const |
const storage_type & | GetStorage () 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 GodOfDofManager & | CreateOrGetInstance (const std::source_location location=std::source_location::current(), Args &&... args) |
Call instance of the singleton. | |
static GodOfDofManager & | GetInstance (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_type & | GetNonCstStorage () 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 GodOfDofManager * | instance_ |
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! | |
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).
|
static |
Returns the name of the class (required for some Singleton-related errors).
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.
[in] | indexed_section_description | Instantiation 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). |
[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. |
[in] | input_data | Object 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] | mpi | Mpi object which knows the rank of the processor, the total number of processors, etc... |
void MoReFEM::GodOfDofManager::Create | ( | const Wrappers::Mpi & | mpi, |
Mesh & | mesh ) |
const GodOfDof & MoReFEM::GodOfDofManager::GetGodOfDof | ( | MeshNS::unique_id | unique_id | ) | const |
Fetch the god of dof object associated with unique_id unique identifier.
[in] | unique_id | Unique identifier of the sought GodOfDof (as returned by GodOfDof::GetUniqueId()). |
GodOfDof & MoReFEM::GodOfDofManager::GetNonCstGodOfDof | ( | MeshNS::unique_id | unique_id | ) |
Fetch the god of dof object associated with unique_id unique identifier.
[in] | unique_id | Unique identifier of the sought GodOfDof (as returned by GodOfDof::GetUniqueId()). |
GodOfDof::shared_ptr MoReFEM::GodOfDofManager::GetGodOfDofPtr | ( | MeshNS::unique_id | unique_id | ) | const |
Fetch the god of dof object associated with unique_id unique identifier.
[in] | unique_id | Unique identifier of the sought GodOfDof (as returned by GodOfDof::GetUniqueId()). |
|
private |
Clear the storage content.
This is a functionality only to be used in tests, after the call to TestNS::ClearSingletons::Do()...
|
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:
In all other cases, call instead GetInstance().
Args | Variadic template arguments. |
[in] | args | Arguments passed to the constructor if the object is to be built. |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
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.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
staticprivateinherited |
Gets called if dead reference detected.
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
friend |
Friendship to a function in tests that is allowed to call Clear(). This function should be used only for tests!
|
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.
|
staticprivateinherited |
Mutex object.
This follows item 16 of Scott Meyers's "Effective Modern C++", which advises to make const member functions thread safe.