MoReFEM
|
This class is used to create and retrieve Domain objects. More...
#include <DomainManager.hpp>
Public Types | |
using | indexed_section_tag = ::MoReFEM::Internal::InputDataNS::DomainNS::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 | 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) |
Create a NumberingSubset object from InputData and ModelSettings information. | |
const Domain & | GetDomain (DomainNS::unique_id unique_id, const std::source_location location=std::source_location::current()) const |
Fetch the domain object associated with unique_id unique identifier. | |
Domain & | GetNonCstDomain (DomainNS::unique_id unique_id, const std::source_location location=std::source_location::current()) |
Fetch the domain object associated with unique_id unique identifier. | |
const storage_type & | GetStorage () const noexcept |
Constant accessor to the domain list. | |
Static Public Member Functions | |
static const std::string & | ClassName () |
Returns the name of the class (required for some Singleton-related errors). | |
static DomainManager & | CreateOrGetInstance (const std::source_location location=std::source_location::current(), Args &&... args) |
Call instance of the singleton. | |
static DomainManager & | 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 Types | |
using | storage_type = std::unordered_map<DomainNS::unique_id, Domain::const_unique_ptr> |
Convenient alias to avoid repeating the type. | |
Private Member Functions | |
void | Create (DomainNS::unique_id unique_id, const std::vector< MeshNS::unique_id > &mesh_index_list, const std::vector< std::size_t > &dimension_list, const std::vector< std::size_t > &mesh_label_list, const std::vector< Advanced::GeomEltNS::GenericName > &geometric_type_list) |
Create a brand new Domain. | |
void | CreateLightweightDomain (DomainNS::unique_id unique_id, MeshNS::unique_id mesh_index, const std::vector< std::size_t > &mesh_label_list) |
Create a brand new lightweight Domain. | |
void | Clear () |
Clear the storage content. | |
storage_type & | GetNonCstStorage () noexcept |
Non constant accessor to the domain list. | |
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 domain objects by their unique identifier. | |
Static Private Attributes | |
static DomainManager * | 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 | |
struct | TestHelper |
Friendship for tests purposes. | |
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! | |
class | Advanced::LightweightDomainList |
Friendship to a class that needs access to CreateLightweightDomain method. | |
This class is used to create and retrieve Domain objects.
Domain 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 Domain 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::DomainManager::Create | ( | const IndexedSectionDescriptionT & | indexed_section_description, |
const ModelSettingsT & | model_settings, | ||
const InputDataT & | input_data ) |
Create a NumberingSubset 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. |
const Domain & MoReFEM::DomainManager::GetDomain | ( | DomainNS::unique_id | unique_id, |
const std::source_location | location = std::source_location::current() ) const |
Fetch the domain object associated with unique_id unique identifier.
If the unique_id is invalid, an exception is thrown.
[in] | unique_id | Unique identifier of the sought Domain (as returned by Domain::GetUniqueId()). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
Domain & MoReFEM::DomainManager::GetNonCstDomain | ( | DomainNS::unique_id | unique_id, |
const std::source_location | location = std::source_location::current() ) |
Fetch the domain object associated with unique_id unique identifier.
If the unique_id is invalid, an exception is thrown.
[in] | unique_id | Unique identifier of the sought Domain (as returned by Domain::GetUniqueId()). |
[in] | location | STL object with relevant information about the calling site (usually to help when an exception is thrown. |
|
private |
Create a brand new Domain.
[in] | unique_id | Identifier of the domain, that must be unique. It is in the input data file the figure that is in the block name, e.g. 1 for Domain1 = { .... }. |
[in] | mesh_index_list | There might be here one index, that indicates in which mesh the domain is defined. If the domain is not limited to one mesh, leave it empty. |
[in] | dimension_list | List of dimensions to consider. If empty, no restriction on dimension. |
[in] | mesh_label_list | List of mesh labels to consider. If empty, no restriction on it. This argument must mandatorily be empty if mesh_index is empty: a mesh label is closely related to one given mesh. |
[in] | geometric_type_list | List of geometric element types to consider in the domain. List of elements available is given by Advanced::GeometricEltFactory::GetNameList(); most if not all of them should been displayed in the comment in the input data file. |
|
private |
Create a brand new lightweight Domain.
Such a Domain, more restricted than a full-fledged one, should be created only by a LightweightDomainList object.
[in] | unique_id | Identifier of the domain, that must be unique. |
[in] | mesh_index | Index of the mesh onto which Domain must be created. |
[in] | mesh_label_list | List of mesh labels to consider. |
|
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 for tests purposes.
In tests, we might want to create objects without a full-fledged model:
for instance creates directly a domain labelled 0 for the mesh 1 with geometric elements of dimension 2.
|
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.