14#include "arcane/impl/internal/MeshMng.h"
16#include "arcane/utils/String.h"
17#include "arcane/utils/FatalErrorException.h"
19#include "arcane/core/IPrimaryMesh.h"
20#include "arcane/core/MeshHandle.h"
21#include "arcane/core/IVariableMng.h"
22#include "arcane/core/internal/IVariableMngInternal.h"
24#include "arcane/impl/internal/MeshFactoryMng.h"
49 delete m_mesh_factory_mng;
59 String name = mesh->name();
60 info() <<
"Add mesh name=" << mesh->name() <<
" count=" << meshes().size();
64 MeshHandle* handle_ptr = findMeshHandle(name,
false);
71 if (handle_ptr->hasMesh()) {
72 IMesh* current_mesh = handle_ptr->mesh();
75 if (current_mesh != mesh)
76 ARCANE_FATAL(
"MeshHandle '{0}' already have mesh", name);
79 handle_ptr->_setMesh(mesh);
82 MeshHandle handle = _addMeshHandle(name);
83 handle._setMesh(mesh);
92getMesh(Integer index)
const
94 return m_meshes_handle[index].mesh();
100IPrimaryMesh* MeshMng::
101getPrimaryMesh(Integer index)
const
103 return getMesh(index)->toPrimaryMesh();
110findMeshHandle(
const String& name,
bool throw_exception)
112 for (
auto& handle : m_meshes_handle)
113 if (handle.meshName() == name)
124findMeshHandle(
const String& name)
136createMeshHandle(
const String& name)
140 ARCANE_FATAL(
"mesh handle already exists for name '{0}'", name);
141 return _addMeshHandle(name);
148findMesh(
const String& name,
bool throw_exception)
150 const MeshHandle* handle = findMeshHandle(name, throw_exception);
154 if (!
mesh && throw_exception)
162ConstArrayView<IMesh*> MeshMng::
174 for (MeshHandle& handle : m_meshes_handle) {
175 IMesh* x = handle.
mesh();
177 m_variable_mng->_internalApi()->detachMeshVariables(x);
181 m_meshes_handle.clear();
194 if (!
mesh->isPrimaryMesh())
195 ARCANE_FATAL(
"Can not destroy mesh '{0}' because it is not a primary mesh",
mesh->name());
196 _destroyMesh(
mesh->toPrimaryMesh());
205 IMesh* m = primary_mesh;
208 m_variable_mng->_internalApi()->detachMeshVariables(m);
212 for (
Integer i = 0, n = m_meshes.size(); i < n; ++i) {
213 if (m_meshes[i] == m) {
220 for (Integer i = 0, n = m_meshes_handle.size(); i < n; ++i) {
221 if (m_meshes_handle[i].meshName() == name) {
222 m_meshes_handle.remove(i);
234_addMeshHandle(
const String& name)
237 MeshHandle handle(m_variable_mng->_internalApi()->internalSubDomain(), name);
238 m_meshes_handle.add(handle);
249 for (MeshHandle& h : m_meshes_handle) {
252 m_meshes.add(h.mesh());
260meshFactoryMng()
const
262 return m_mesh_factory_mng;
269createDefaultMeshHandle(
const String& name)
271 m_default_mesh_handle = createMeshHandle(name);
272 return m_default_mesh_handle;
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
virtual MeshHandle handle() const =0
Handle on this mesh.
virtual String name() const =0
Mesh name.
Interface of the mesh factory manager.
Variable manager interface.
bool hasMesh() const
Indicates if the associated mesh has already been created (i.e.: mesh() is valid).
IMesh * mesh() const
Associated mesh.
MeshHandle * findMeshHandle(const String &name, bool throw_exception) override
Searches for the mesh with name name.
Unicode character string.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.