12#ifndef ARCANE_MATERIALS_INTERNAL_MESHMATERIALMNG_H
13#define ARCANE_MATERIALS_INTERNAL_MESHMATERIALMNG_H
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/Mutex.h"
21#include "arcane/core/MeshHandle.h"
23#include "arcane/core/materials/IMeshMaterialMng.h"
25#include "arcane/core/materials/internal/IMeshMaterialMngInternal.h"
27#include "arcane/accelerator/core/Runner.h"
28#include "arcane/accelerator/core/RunQueuePool.h"
30#include "arcane/materials/MeshBlock.h"
31#include "arcane/materials/AllCellToAllEnvCellConverter.h"
32#include "arcane/materials/internal/MeshMaterial.h"
33#include "arcane/materials/internal/MeshEnvironment.h"
34#include "arcane/materials/internal/MeshMaterialSynchronizer.h"
68 friend class MeshMaterialBackup;
77 explicit RunnerInfo(
Runner& runner);
81 void initializeAsyncPool(
Int32 nb_queue);
92 Runner m_sequential_runner;
94 Runner m_multi_thread_runner;
103 explicit InternalApi(MeshMaterialMng* mm)
111 return m_material_mng->getAllCellToAllEnvCellContainer();
115 return m_material_mng->createAllCellToAllEnvCell();
119 return m_material_mng->_variablesIndexer();
123 return m_material_mng->_addVariable(var);
127 return m_material_mng->_removeVariable(var);
131 return m_material_mng->_modifier();
135 return m_material_mng->_allCellsMatEnvSynchronizer();
139 return m_material_mng->_allCellsEnvOnlySynchronizer();
143 return m_material_mng->componentItemSharedInfo(level);
147 return m_material_mng->runQueue();
151 return m_material_mng->asyncRunQueuePool();
155 return m_material_mng->additionalCapacityRatio();
159 return m_material_mng->m_is_use_accelerator_for_constituent_item_vector;
163 return m_material_mng->m_runner_info->runQueue(policy);
167 return m_material_mng->identitySelectionView();
172 MeshMaterialMng* m_material_mng =
nullptr;
197 void endCreate(
bool is_continue)
override;
214 return m_is_allocate_scalar_environment_variable_as_material;
236 void dumpInfos(std::ostream& o)
override;
245 return &m_variable_lock;
255 Int32 nbVariable()
const {
return static_cast<Int32
>(m_full_name_variable_map.size()); }
259 AllEnvCellVectorView _view(SmallSpan<const Int32> cells_local_id);
263 return this->_view(cells.view().localIds());
268 return this->_view(cells.localIds());
273 return this->_view(cells_local_id);
284 m_synchronize_variable_version = version;
289 return m_synchronize_variable_version;
296 return m_variable_factory_mng;
301 m_is_use_material_value_when_removing_partial_value = v;
303 bool isUseMaterialValueWhenRemovingPartialValue()
const override
305 return m_is_use_material_value_when_removing_partial_value;
310 AllEnvData* allEnvData() {
return m_all_env_data.get(); }
311 ComponentItemSharedInfo* componentItemSharedInfo(Int32 level)
const;
315 void dumpInfos2(std::ostream& o);
317 const MeshHandle& meshHandle()
const {
return m_mesh_handle; }
321 m_is_use_accelerator_envcell_container = is_enable;
323 createAllCellToAllEnvCell();
325 bool isCellToAllEnvCellForRunCommand()
const override {
return m_is_use_accelerator_envcell_container; }
332 Runner& runner()
const {
return m_runner_info->m_runner; }
333 RunQueue& runQueue()
const {
return m_runner_info->m_run_queue; }
334 Accelerator::RunQueuePool& asyncRunQueuePool()
const {
return m_runner_info->m_async_queue_pool; }
335 Real additionalCapacityRatio()
const {
return m_additional_capacity_ratio; }
336 SmallSpan<const Int32> identitySelectionView();
342 void createAllCellToAllEnvCell();
351 using VariableToMaterialVariableMap = std::map<IVariable*, IMeshMaterialVariable*>;
352 using VariableToMaterialVariablePair = VariableToMaterialVariableMap::value_type;
357 std::unique_ptr<InternalApi> m_internal_api;
360 bool m_is_end_create =
false;
361 bool m_is_verbose =
false;
362 bool m_keep_values_after_change =
true;
363 bool m_is_data_initialisation_with_zero =
false;
364 bool m_is_mesh_modification_notified =
false;
365 bool m_is_allocate_scalar_environment_variable_as_material =
false;
366 bool m_is_use_material_value_when_removing_partial_value =
false;
367 int m_modification_flags = 0;
368 Real m_additional_capacity_ratio = 0.05;
370 Mutex m_variable_lock;
372 std::unique_ptr<MeshMaterialModifierImpl> m_modifier;
387 VariableToMaterialVariableMap m_var_to_mat_var_map;
389 std::unique_ptr<Properties> m_properties;
390 std::unique_ptr<AllEnvData> m_all_env_data;
392 std::unique_ptr<IMeshMaterialVariableSynchronizer> m_all_cells_mat_env_synchronizer;
393 std::unique_ptr<IMeshMaterialVariableSynchronizer> m_all_cells_env_only_synchronizer;
394 Integer m_synchronize_variable_version = 1;
395 std::unique_ptr<MeshMaterialExchangeMng> m_exchange_mng;
397 std::unique_ptr<ObserverPool> m_observer_pool;
398 String m_data_compressor_service_name;
401 std::unique_ptr<RunnerInfo> m_runner_info;
405 bool m_is_use_accelerator_envcell_container =
false;
407 bool m_is_use_accelerator_for_constituent_item_vector =
true;
411 std::mutex m_indexed_selection_identity_mutex;
422 void _checkEndCreate();
424 void _saveInfosInProperties();
425 void _checkCreateProperties();
426 void _onMeshDestroyed();
427 void _unregisterAllVariables();
433 return m_variables_indexer;
437 return m_all_cells_mat_env_synchronizer.get();
441 return m_all_cells_env_only_synchronizer.get();
Execution queue for an accelerator.
Execution manager for accelerator.
Base class for 1D data vectors.
Constant view of an array of type T.
Interface of a functor with an argument but without a return value.
Variable manager interface.
Connectivity table of 'Cell' to its 'AllEnvCell' intended for use on accelerator.
View over a list of cells with environment information.
Information on environment values.
Conversion of 'Cell' to 'AllEnvCell'.
Interface of a mesh block.
Interface of a mesh environment.
Internal Arcane API for 'IMeshMaterialMng'.
Interface for the material and environment manager of a mesh.
Interface of the material variable factory manager.
Interface of the material variable synchronizer.
Interface of a material variable on a mesh.
Brief: Information for the creation of a block.
Information for creating an environment.
Info about a material of a mesh.
bool isUseAcceleratorForConstituentItemVector() const override
Indicates whether the accelerator API is used to position the values of ConstituentItemVectorImpl.
Real additionalCapacityRatio() const override
Ratio for additional capacity to allocate when resizing variables.
RunQueue runQueue(Accelerator::eExecutionPolicy policy) const override
Run queue for the policy.
SmallSpan< const Int32 > identitySelectionView() const override
View of the array corresponding to a selection across all entities.
ComponentItemSharedInfo * componentItemSharedInfo(Int32 level) const override
ComponentItemSharedInfo instance for a constituent.
MeshMaterialModifierImpl * modifier() override
Modifier implementation.
IMeshMaterialVariableSynchronizer * allCellsEnvOnlySynchronizer() override
Synchronizer for medium-only variables across all cells.
void removeVariable(IMeshMaterialVariable *var) override
Removes the variable var.
AllCellToAllEnvCellContainer * getAllCellToAllEnvCellContainer() const override
Returns the "connectivity" table CellLocalId -> AllEnvCell intended to be used in a RUNCOMMAND_ENUMER...
void createAllCellToAllEnvCell() override
Constructs the "connectivity" table CellLocalId -> AllEnvCell intended to be used in a RUNCOMMAND_ENU...
void addVariable(IMeshMaterialVariable *var) override
Adds the variable var.
RunQueue & runQueue() const override
Default run queue.
Accelerator::RunQueuePool & asyncRunQueuePool() const override
List of asynchronous queues.
IMeshMaterialVariableSynchronizer * allCellsMatEnvSynchronizer() override
Synchronizer for material and medium variables across all cells.
ConstArrayView< MeshMaterialVariableIndexer * > variablesIndexer() override
List of information to index material variables.
Implementation of a material manager.
bool isInMeshMaterialExchange() const override
True if a mesh exchange with material management is underway.
void removeEnvironmentToBlock(IMeshBlock *block, IMeshEnvironment *env) override
Removes an environment from an existing block.
IMeshMaterialVariableFactoryMng * variableFactoryMng() const override
Interface of the variable factory.
String dataCompressorServiceName() const override
Virtual name of the service used to compress data.
std::map< String, IMeshMaterialVariable * > FullNameVariableMap
Type of the list of variables by full name.
AllEnvCellVectorView view(const CellGroup &cells) final
View of environment cells corresponding to the group cells.
Int64 m_timestamp
Counter for the number of material modifications.
void setDataCompressorServiceName(const String &name) override
Name of the service used to compress data during forceRecompute().
void visitVariables(IFunctorWithArgumentT< IMeshMaterialVariable * > *functor) override
Applies the functor functor to all material variables.
void endCreate(bool is_continue) override
Indicates that environment creation is finished.
IMeshBlock * createBlock(const MeshBlockBuildInfo &infos) override
Creates a block.
Integer synchronizeVariableVersion() const override
Version of the implementation for synchronizing material variables.
bool isKeepValuesAfterChange() const override
Indicates if variable values are preserved between modifications.
ITraceMng * traceMng() override
Trace manager.
FullNameVariableMap::value_type FullNameVariablePair
Pair of the list of variables by full name.
Int64 timestamp() const override
Counter for the number of modifications of the material list and environments.
IMesh * mesh() override
Associated mesh.
IMeshMaterialVariableSynchronizer * _allCellsEnvOnlySynchronizer() override
Synchronizer for environment-only variables on all cells.
CellToAllEnvCellConverter cellToAllEnvCellConverter() override
Creates an instance to convert from 'Cell' to 'AllEnvCell'.
void addEnvironmentToBlock(IMeshBlock *block, IMeshEnvironment *env) override
Adds an environment to an existing block.
void dumpInfos(std::ostream &o) override
Writes the material and environment info to the stream o.
IMeshMaterialVariableSynchronizer * _allCellsMatEnvSynchronizer() override
Synchronizer for material and environment variables on all cells.
MeshMaterialInfo * registerMaterialInfo(const String &name) override
Registers the material info with name name.
void setMeshModificationNotified(bool v) override
Indicates if environments and materials follow changes in the mesh topology.
ConstArrayView< IMeshComponent * > components() const override
List of all components.
void setAllocateScalarEnvironmentVariableAsMaterial(bool v) override
Sets the option indicating whether scalar variables of environments are allocated on materials.
ConstArrayView< IMeshMaterial * > materials() const override
List of materials.
IMeshEnvironment * createEnvironment(const MeshEnvironmentBuildInfo &infos) override
Creation of an environment.
void recreateFromDump() override
Recreates the material and environment info from the dump info.
void enableCellToAllEnvCellForRunCommand(bool is_enable, bool force_create=false) override
Activates or deactivates the construction and update of the table of "connectivity" CellLocalId -> Al...
int modificationFlags() const override
Flags to parameterize modifications.
void fillWithUsedVariables(Array< IMeshMaterialVariable * > &variables) override
Fills the array variables with the list of used material variables.
ConstArrayView< IMeshComponent * > environmentsAsComponents() const override
List of environments viewed as components.
ConstArrayView< IMeshEnvironment * > environments() const override
List of environments.
IMeshMaterialVariable * checkVariable(IVariable *global_var) override
Material variable associated with the global variable global_var (nullptr if none).
void forceRecompute() override
Forces the recalculation of material information.
void _endUpdate()
Updates the structures following a modification of material or environment cells.
void setDataInitialisationWithZero(bool v) override
Indicates how to initialize new values in material and environment cells.
void setKeepValuesAfterChange(bool v) override
Sets the saving of values between two modifications of the materials.
AllEnvCellVectorView view(CellVectorView cells) final
View of environment cells corresponding to the group cells.
bool isMeshModificationNotified() const override
Indicates if environments and materials follow changes in the mesh topology.
IMeshMaterialMngInternal * _internalApi() const override
Internal API for Arcane.
void checkMaterialsInCells(Integer max_print) override
Checks that material cells are consistent between subdomains.
IMeshEnvironment * findEnvironment(const String &name, bool throw_exception=true) override
Returns the environment with name name.
bool isDataInitialisationWithZero() const override
Indicates how to initialize new values in material and environment cells.
Mutex * variableLock() override
Lock used for multi-threading.
void setSynchronizeVariableVersion(Integer version) override
Sets the version of the implementation for synchronizing material variables.
bool synchronizeMaterialsInCells() override
Synchronizes material cells.
ConstArrayView< IMeshComponent * > materialsAsComponents() const override
List of materials viewed as components.
IMeshMaterialVariable * findVariable(const String &name) override
Variable with name name or nullptr if none of this name exists.
void setUseMaterialValueWhenRemovingPartialValue(bool v) override
Indicates whether the material or environment value is used when transforming a cell from a partial c...
void dumpCellInfos(Cell cell, std::ostream &o) override
Writes the cell info cell to the stream o.
std::unique_ptr< AllCellToAllEnvCellContainer > m_accelerator_envcell_container
Container for AllEnvCellToAllEnvCell for accelerator.
ConstArrayView< IMeshBlock * > blocks() const override
List of blocks.
void checkValid() override
Checks the validity of internal structures.
void syncVariablesReferences(bool check_resize)
Updates the variable references.
MeshMaterial * _createMaterial(MeshEnvironment *env, MeshMaterialInfo *infos, const String &name)
Creation of a material.
AllEnvCellVectorView view(SmallSpan< const Int32 > cells_local_id) final
View of environment cells corresponding to local cell IDs cells_local_id.
bool isAllocateScalarEnvironmentVariableAsMaterial() const override
Indicates if environment scalar variables are allocated on materials.
String name() const override
Manager name.
UniqueArray< Int32 > m_indexed_selection_identity
Identity array for selection.
IMeshBlock * findBlock(const String &name, bool throw_exception=true) override
Returns the block with name name.
void setModificationFlags(int v) override
Sets the flags to parameterize material/environment modifications.
Synchronization of the list of materials/media of entities.
Indexer for material variables.
View of an array of elements of type T.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
ItemGroupT< Cell > CellGroup
Group of cells.
ItemVectorViewT< Cell > CellVectorView
View over a vector of cells.
eExecutionPolicy
Execution policy for a Runner.
Always enables tracing in Arcane parts concerning materials.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.