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"
36MeshMng(IApplication* app,IVariableMng* vm)
37: TraceAccessor(vm->traceMng())
39, m_mesh_factory_mng(new MeshFactoryMng(app,this))
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)
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)
126 MeshHandle* handle = findMeshHandle(name,
true);
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();
181 m_meshes_handle.clear();
195 ARCANE_FATAL(
"Can not destroy mesh '{0}' because it is not a primary mesh",mesh->
name());
208 m_variable_mng->_internalApi()->detachMeshVariables(m);
212 for( Integer i=0, n=m_meshes.size(); i<n; ++i ){
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 retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
virtual MeshHandle handle() const =0
Handle sur ce maillage.
virtual String name() const =0
Nom du maillage.
Interface du gestionnaire de fabriques de maillages.
virtual IMeshInternal * _internalApi()=0
API interne à Arcane.
virtual IPrimaryMesh * toPrimaryMesh()=0
Retourne l'instance sous la forme d'un IPrimaryMesh.
virtual bool isPrimaryMesh() const =0
Indique si l'instance est un maillage primaire.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
bool hasMesh() const
Indique si le maillage associé a déjà été créé (i.e: mesh() est valide)
IMesh * mesh() const
Maillage associé.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-