Feel++ 0.111.0-preview.14
Finite Element Embedded Library in C++
Feel::FunctionSpaceManager Class Reference

Own and reuse canonical whole-mesh function spaces within a process. More...

+ Collaboration diagram for Feel::FunctionSpaceManager:

Classes

struct  Impl
 Private synchronized storage and policy implementation. More...
 

Public Types

using erased_factory_type = std::function< erased_space_ptrtype()>
 Callable that constructs a type-erased function space on a miss.
 
using erased_space_ptrtype = std::shared_ptr< FunctionSpaceBase >
 Type-erased function-space pointer retained by the manager.
 
using mesh_change_slot_type = std::function< void(MESH_CHANGES)>
 Slot invoked when the associated mesh reports a change.
 
using mesh_connector_type = std::function< boost::signals2::connection(mesh_change_slot_type)>
 Callable that connects a mesh-change slot and returns its connection.
 

Public Member Functions

void clear ()
 Release all entries retained by the manager. More...
 
template<typename MeshType >
void clear (std::shared_ptr< MeshType > const &mesh)
 Release entries retained for one mesh. More...
 
FunctionSpaceManagerConfig config () const
 Return the effective manager configuration. More...
 
void configure (FunctionSpaceManagerConfig config)
 Replace the manager configuration and enforce its capacity limits. More...
 
erased_space_ptrtype getOrCreate (std::weak_ptr< void > const &meshOwner, uint64_type structuralRevision, std::type_index spaceType, FunctionSpaceManagerOptions const &options, FunctionSpaceReusePolicy policy, WorldComm const &worldComm, erased_factory_type factory, mesh_connector_type connector)
 Return a compatible retained space or construct one according to a policy. More...
 
FunctionSpaceManagerStats stats () const
 Return aggregate statistics for all managed meshes. More...
 
template<typename MeshType >
FunctionSpaceManagerStats stats (std::shared_ptr< MeshType > const &mesh) const
 Return counters and retained-state measurements for one mesh. More...
 

Static Public Member Functions

static FunctionSpaceManager & instance ()
 Access the process-wide function-space manager. More...
 

Detailed Description

Own and reuse canonical whole-mesh function spaces within a process.

Entries are keyed by mesh ownership identity, structural mesh revision, concrete function-space type, and normalized construction options. The manager holds strong references in bounded global and per-mesh LRU caches. Coordinate-only mesh changes refresh live function spaces without replacing their DOF topology.

Calls for a distributed mesh are collective on its communicator: all ranks must issue compatible requests in the same order. A cache hit is returned only when every rank reports a local hit.

Member Function Documentation

◆ clear() [1/2]

void Feel::FunctionSpaceManager::clear ( )

Release all entries retained by the manager.

Spaces that are still owned by callers remain valid.

◆ clear() [2/2]

template<typename MeshType >
void Feel::FunctionSpaceManager::clear ( std::shared_ptr< MeshType > const &  mesh)

Release entries retained for one mesh.

Spaces that are still owned by callers remain valid.

Template Parameters
MeshTypeconcrete mesh type
Parameters
meshmesh whose retained entries are released

◆ config()

FunctionSpaceManagerConfig Feel::FunctionSpaceManager::config ( ) const

Return the effective manager configuration.

Returns
the effective process-local manager configuration

◆ configure()

void Feel::FunctionSpaceManager::configure ( FunctionSpaceManagerConfig  config)

Replace the manager configuration and enforce its capacity limits.

Parameters
confignew process-local configuration

◆ getOrCreate()

FunctionSpaceManager::erased_space_ptrtype Feel::FunctionSpaceManager::getOrCreate ( std::weak_ptr< void > const &  meshOwner,
uint64_type  structuralRevision,
std::type_index  spaceType,
FunctionSpaceManagerOptions const &  options,
FunctionSpaceReusePolicy  policy,
WorldComm const &  worldComm,
erased_factory_type  factory,
mesh_connector_type  connector 
)

Return a compatible retained space or construct one according to a policy.

This type-erased entry point is intended for function-space factory helpers. Prefer getOrCreateFunctionSpace from typed code.

Parameters
meshOwnerweak ownership identity of the mesh
structuralRevisioncurrent function-space structural mesh revision
spaceTypeconcrete requested function-space type
optionsnormalized construction options included in the key
policyrequested reuse policy
worldCommcommunicator on which request consistency is checked
factoryconstruction callable used when a new space is required
connectoroptional mesh-change signal connector
Returns
the retained or newly constructed type-erased function space
Exceptions
std::runtime_errorif request signatures differ across MPI ranks

◆ instance()

FunctionSpaceManager & Feel::FunctionSpaceManager::instance ( )
static

Access the process-wide function-space manager.

Returns
the process-wide function-space manager instance

◆ stats() [1/2]

FunctionSpaceManagerStats Feel::FunctionSpaceManager::stats ( ) const

Return aggregate statistics for all managed meshes.

Returns
aggregate process-local manager statistics

◆ stats() [2/2]

template<typename MeshType >
FunctionSpaceManagerStats Feel::FunctionSpaceManager::stats ( std::shared_ptr< MeshType > const &  mesh) const

Return counters and retained-state measurements for one mesh.

Template Parameters
MeshTypeconcrete mesh type
Parameters
meshmesh for which statistics are requested
Returns
process-local statistics for mesh