14#include "arcane/impl/internal/MeshFactoryMng.h"
16#include "arcane/impl/internal/MeshMng.h"
18#include "arcane/utils/FatalErrorException.h"
20#include "arcane/core/MeshHandle.h"
21#include "arcane/core/IPrimaryMesh.h"
22#include "arcane/core/ServiceBuilder.h"
23#include "arcane/core/IMeshFactory.h"
24#include "arcane/core/ItemGroup.h"
25#include "arcane/core/MeshBuildInfo.h"
39 String factory_name = mbi.factoryName();
44 service_builder.getServicesNames(valid_names);
45 String valid_str = String::join(
", ", valid_names);
46 ARCANE_FATAL(
"No mesh factory named '{0}' found for creating mesh '{1}'."
47 " Valid values are {2}",
48 factory_name, mbi.name(), valid_str);
82 ARCANE_FATAL(
"Can not create mesh with null factoryName()");
91 _checkValidBuildInfo(build_info);
93 if (parent_group.
null())
94 return _createMesh(build_info);
95 return _createSubMesh(build_info);
105 ARCANE_FATAL(
"Can not create mesh with null parallelMngRef()");
109 if (old_mesh_handle) {
114 ARCANE_FATAL(
"A mesh with same name already exists and is not a primary mesh");
119 Ref<IMeshFactory> mesh_factory(_getMeshFactory(m_application, build_info));
129 IPrimaryMesh* mesh = mesh_factory->createMesh(m_mesh_mng, build_info);
130 m_mesh_mng->addMesh(mesh);
138IPrimaryMesh* MeshFactoryMng::
139_createSubMesh(
const MeshBuildInfo& orig_build_info)
141 ItemGroup group = orig_build_info.parentGroup();
142 IMesh* mesh = group.
mesh();
145 if (mesh->meshMng() != m_mesh_mng)
146 ARCANE_FATAL(
"This mesh has not been created by this factory");
147 if (group.isAllItems())
148 ARCANE_FATAL(
"Cannot create sub-mesh from all-items group");
150 MeshBuildInfo build_info(orig_build_info);
151 String name = build_info.
name();
156 Ref<IMeshFactory> mesh_factory(_getMeshFactory(m_application, build_info));
161 m_mesh_mng->createMeshHandle(name);
162 IPrimaryMesh* sub_mesh = mesh_factory->createMesh(m_mesh_mng, build_info);
163 m_mesh_mng->addMesh(sub_mesh);
165 sub_mesh->defineParentForBuild(mesh, group);
167 mesh->addChildMesh(sub_mesh);
#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 createMeshHandle(const String &name)=0
Creates and returns a handle for a mesh with name name.
virtual MeshHandle * findMeshHandle(const String &name, bool throw_exception)=0
Searches for the mesh with name name.
bool null() const
true means the group is the null group
Parameters necessary for building a mesh.
const String & name() const
Name of the new mesh.
const ItemGroup & parentGroup() const
Parent group in the case of a sub-mesh, null otherwise.
MeshBuildInfo & addParallelMng(Ref< IParallelMng > pm)
Sets the parallelism manager to create the mesh.
Ref< IParallelMng > parallelMngRef() const
Parallelism manager in the case of a new mesh.
const String & factoryName() const
Factory name to create the mesh (via IMeshFactory).
IMesh * mesh() const
Associated mesh.
IMesh * _internalMeshOrNull() const
Reference to an instance.
Utility class for instantiating a service of a given interface.
Unicode character string.
bool empty() const
True if the string is empty (null or "").
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ SB_AllowNull
Allows the service to be absent.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.