Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DynamicMeshCartesianBuilder.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* DynamicMeshCartesianBuilder.cc (C) 2000-2023 */
9/* */
10/* Génération des maillages cartésiens pour DynamicMesh. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/CheckedConvert.h"
15
16#include "arcane/core/IMeshUniqueIdMng.h"
17#include "arcane/core/CartesianGridDimension.h"
18#include "arcane/core/internal/CartesianMeshAllocateBuildInfoInternal.h"
19
20#include "arcane/mesh/DynamicMesh.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::mesh
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
37class ARCANE_MESH_EXPORT DynamicMeshCartesianBuilder
38: public TraceAccessor
39{
40 public:
41
44
45 protected:
46
47 UniqueArray<Int64> m_cells_infos;
48 Int32 m_nb_cell = 0;
49 DynamicMesh* m_mesh = nullptr;
50 CartesianMeshAllocateBuildInfoInternal* m_build_info = nullptr;
51
52 public:
53
54 void allocate();
55
56 protected:
57
58 virtual void _buildCellList() = 0;
59};
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
63
66{
67 public:
68
72 {
73 }
74
75 protected:
76
77 void _buildCellList() override;
78};
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83void DynamicMeshCartesian2DBuilder::
84_buildCellList()
85{
86 UniqueArray<Int64>& cells_infos = m_cells_infos;
87
88 const Int64 cell_unique_id_offset = m_build_info->cellUniqueIdOffset();
89 const Int64 node_unique_id_offset = m_build_info->nodeUniqueIdOffset();
90
91 CartesianGridDimension all_grid_dimension(m_build_info->globalNbCells());
92 CartesianGridDimension own_grid_dimension(m_build_info->ownNbCells());
93 Int64x3 first_own_cell_offset(m_build_info->firstOwnCellOffset());
94
96
97 const Int64 own_nb_cell_xy = own_grid_dimension.totalNbCell();
99
100 cells_infos.resize(own_nb_cell_xy * (1 + 1 + 4));
101
102 Integer cells_infos_index = 0;
105
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;
115 std::array<Int64, 4> node_uids = node_uid_computer.computeForCell(gx, gy);
116 for (Int32 i = 0; i < 4; ++i)
119 }
120 }
121}
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
131{
132 public:
133
137 {
138 }
139
140 public:
141
142 void _buildCellList() override;
143};
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
148void DynamicMeshCartesian3DBuilder::
149_buildCellList()
150{
151 UniqueArray<Int64>& cells_infos = m_cells_infos;
152
153 const Int64 cell_unique_id_offset = m_build_info->cellUniqueIdOffset();
154 const Int64 node_unique_id_offset = m_build_info->nodeUniqueIdOffset();
155
156 CartesianGridDimension all_grid_dimension(m_build_info->globalNbCells());
157 CartesianGridDimension own_grid_dimension(m_build_info->ownNbCells());
158 Int64x3 first_own_cell_offset(m_build_info->firstOwnCellOffset());
159
161
162 const Int64 own_nb_cell_xyz = own_grid_dimension.totalNbCell();
164
165 cells_infos.resize(own_nb_cell_xyz * (1 + 1 + 8));
166
167 Integer cells_infos_index = 0;
170
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;
182 std::array<Int64, 8> node_uids = node_uid_computer.computeForCell(gx, gy, gz);
183 for (Int32 i = 0; i < 8; ++i)
186 }
187 }
188 }
189}
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197DynamicMeshCartesianBuilder::
198DynamicMeshCartesianBuilder(DynamicMesh* mesh, CartesianMeshAllocateBuildInfoInternal* build_info)
199: TraceAccessor(mesh->traceMng())
200, m_mesh(mesh)
201, m_build_info(build_info)
202{
203}
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
207
208void DynamicMeshCartesianBuilder::
209allocate()
210{
211 auto* x = m_build_info;
212 const Int32 dimension = m_build_info->meshDimension();
213
214 m_mesh->setDimension(dimension);
215
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);
222
223 _buildCellList();
224
225 m_mesh->allocateCells(m_nb_cell, m_cells_infos, true);
226}
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231ARCANE_MESH_EXPORT void
232allocateCartesianMesh(DynamicMesh* mesh, CartesianMeshAllocateBuildInfo& build_info)
233{
234 auto* x = build_info._internal();
235 Int32 dimension = x->meshDimension();
236
237 if (dimension == 3) {
238 DynamicMeshCartesian3DBuilder builder(mesh, x);
239 builder.allocate();
240 }
241 else if (dimension == 2) {
242 DynamicMeshCartesian2DBuilder builder(mesh, x);
243 builder.allocate();
244 }
245 else
246 ARCANE_FATAL("Not supported dimension '{0}'. Only 2 or 3 is supported", dimension);
247}
248
249/*---------------------------------------------------------------------------*/
250/*---------------------------------------------------------------------------*/
251
252} // namespace Arcane::mesh
253
254/*---------------------------------------------------------------------------*/
255/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classe pour calculer en 2D le uniqueId() d'une maille en fonction de sa position dans la grille.
Classe pour calculer en 3D le uniqueId() d'une maille en fonction de sa position dans la grille.
Classe pour calculer en 2D le uniqueId() d'un noeud en fonction de sa position dans la grille.
Classe pour calculer en 3D le uniqueId() d'un noeud en fonction de sa position dans la grille.
Informations sur les dimensions d'une grille cartésienne.
Partie interne de CartesianMeshAllocateBuildInfo.
virtual void setFaceBuilderVersion(Integer n)=0
Positionne la version de la numérotation des faces.
virtual void setEdgeBuilderVersion(Integer n)=0
Positionne la version de la numérotation des arêtes.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Informations pour un échange de maillage entre sous-domaines.
Implémentation d'un maillage.
Definition DynamicMesh.h:97
void setDimension(Integer dim) override
Positionne la dimension du maillage (1D, 2D ou 3D).
IMeshUniqueIdMng * meshUniqueIdMng() const override
Gestionnare de la numérotation des identifiants uniques.
void allocateCells(Integer mesh_nb_cell, Int64ConstArrayView cells_info, bool one_alloc) override
Allocation d'un maillage.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.