14#include "arcane/utils/CheckedConvert.h"
16#include "arcane/core/IMeshUniqueIdMng.h"
17#include "arcane/core/CartesianGridDimension.h"
18#include "arcane/core/internal/CartesianMeshAllocateBuildInfoInternal.h"
20#include "arcane/mesh/DynamicMesh.h"
37class ARCANE_MESH_EXPORT DynamicMeshCartesianBuilder
58 virtual void _buildCellList() = 0;
64class DynamicMeshCartesian2DBuilder
65:
public DynamicMeshCartesianBuilder
71 : DynamicMeshCartesianBuilder(
mesh, build_info)
77 void _buildCellList()
override;
83void DynamicMeshCartesian2DBuilder::
88 const Int64 cell_unique_id_offset = m_build_info->cellUniqueIdOffset();
89 const Int64 node_unique_id_offset = m_build_info->nodeUniqueIdOffset();
93 Int64x3 first_own_cell_offset(m_build_info->firstOwnCellOffset());
95 Int64x3 own_nb_cell = own_grid_dimension.nbCell();
97 const Int64 own_nb_cell_xy = own_grid_dimension.totalNbCell();
98 m_nb_cell = CheckedConvert::toInt32(own_nb_cell_xy);
100 cells_infos.
resize(own_nb_cell_xy * (1 + 1 + 4));
106 for (
Integer y = 0; y < own_nb_cell.y; ++y) {
107 for (
Integer x = 0; x < own_nb_cell.x; ++x) {
108 Int64 gx = x + first_own_cell_offset.x;
109 Int64 gy = y + first_own_cell_offset.y;
110 Int64 cell_unique_id = cell_uid_computer.compute(gx, gy);
111 cells_infos[cells_infos_index] = IT_Quad4;
113 cells_infos[cells_infos_index] = cell_unique_id;
115 std::array<Int64, 4> node_uids = node_uid_computer.computeForCell(gx, gy);
116 for (
Int32 i = 0; i < 4; ++i)
117 cells_infos[cells_infos_index + i] = node_uids[i];
118 cells_infos_index += 4;
129class DynamicMeshCartesian3DBuilder
130:
public DynamicMeshCartesianBuilder
136 : DynamicMeshCartesianBuilder(
mesh, build_info)
142 void _buildCellList()
override;
148void DynamicMeshCartesian3DBuilder::
153 const Int64 cell_unique_id_offset = m_build_info->cellUniqueIdOffset();
154 const Int64 node_unique_id_offset = m_build_info->nodeUniqueIdOffset();
158 Int64x3 first_own_cell_offset(m_build_info->firstOwnCellOffset());
160 Int64x3 own_nb_cell = own_grid_dimension.nbCell();
162 const Int64 own_nb_cell_xyz = own_grid_dimension.totalNbCell();
163 m_nb_cell = CheckedConvert::toInt32(own_nb_cell_xyz);
165 cells_infos.
resize(own_nb_cell_xyz * (1 + 1 + 8));
171 for (
Integer z = 0; z < own_nb_cell.z; ++z) {
172 for (
Integer y = 0; y < own_nb_cell.y; ++y) {
173 for (
Integer x = 0; x < own_nb_cell.x; ++x) {
174 Int64 gx = x + first_own_cell_offset.x;
175 Int64 gy = y + first_own_cell_offset.y;
176 Int64 gz = z + first_own_cell_offset.z;
177 Int64 cell_unique_id = cell_uid_computer.compute(gx, gy, gz);
178 cells_infos[cells_infos_index] = IT_Hexaedron8;
180 cells_infos[cells_infos_index] = cell_unique_id;
182 std::array<Int64, 8> node_uids = node_uid_computer.computeForCell(gx, gy, gz);
183 for (
Int32 i = 0; i < 8; ++i)
184 cells_infos[cells_infos_index + i] = node_uids[i];
185 cells_infos_index += 8;
197DynamicMeshCartesianBuilder::
198DynamicMeshCartesianBuilder(
DynamicMesh* mesh, CartesianMeshAllocateBuildInfoInternal* build_info)
199: TraceAccessor(mesh->traceMng())
201, m_build_info(build_info)
208void DynamicMeshCartesianBuilder::
211 auto* x = m_build_info;
212 const Int32 dimension = m_build_info->meshDimension();
214 m_mesh->setDimension(dimension);
216 Int32 face_builder_version = x->faceBuilderVersion();
217 if (face_builder_version >= 0)
218 m_mesh->meshUniqueIdMng()->setFaceBuilderVersion(face_builder_version);
219 Int32 edge_builder_version = x->edgeBuilderVersion();
220 if (edge_builder_version >= 0)
221 m_mesh->meshUniqueIdMng()->setEdgeBuilderVersion(edge_builder_version);
225 m_mesh->allocateCells(m_nb_cell, m_cells_infos,
true);
231ARCANE_MESH_EXPORT
void
232allocateCartesianMesh(
DynamicMesh* mesh, CartesianMeshAllocateBuildInfo& build_info)
234 auto* x = build_info._internal();
235 Int32 dimension = x->meshDimension();
237 if (dimension == 3) {
241 else if (dimension == 2) {
246 ARCANE_FATAL(
"Not supported dimension '{0}'. Only 2 or 3 is supported", dimension);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
void resize(Int64 s)
Changes the number of elements in the array to s.
Class for calculating the uniqueId() of a cell in 2D based on its position in the grid.
Class for calculating the uniqueId() of a cell in 3D based on its position in the grid.
Class for calculating the uniqueId() of a node in 2D based on its position in the grid.
Class for calculating the uniqueId() of a node in 3D based on its position in the grid.
Information about the dimensions of a Cartesian grid.
Internal part of CartesianMeshAllocateBuildInfo.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
Implementation of a mesh.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.