Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
CartesianMeshAllocateBuildInfo.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/* CartesianMeshAllocateBuildInfo.cc (C) 2000-2023 */
9/* */
10/* Informations pour allouer les entités d'un maillage cartésien. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/CartesianMeshAllocateBuildInfo.h"
15#include "arcane/core/internal/CartesianMeshAllocateBuildInfoInternal.h"
16
17#include "arcane/utils/CheckedConvert.h"
18#include "arcane/utils/Vector3.h"
19#include "arcane/utils/Vector2.h"
20#include "arcane/utils/Array.h"
21#include "arcane/utils/ITraceMng.h"
22#include "arcane/utils/FatalErrorException.h"
23#include "arcane/utils/FixedArray.h"
24
25#include "arcane/core/IPrimaryMesh.h"
26#include "arcane/core/ItemTypeId.h"
27#include "arcane/core/IMeshInitialAllocator.h"
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
39{
40 public:
41
42 explicit Impl(IPrimaryMesh* mesh)
43 : m_mesh(mesh)
44 {
45 m_internal.m_p = this;
46 }
47
48 public:
49
50 IPrimaryMesh* m_mesh = nullptr;
51 Int32 m_mesh_dimension = -1;
52 Int32 m_face_builder_version = -1;
53 Int32 m_edge_builder_version = -1;
54 CartesianMeshAllocateBuildInfoInternal m_internal;
55
56 Int64x3 m_global_nb_cells = {};
57 Int32x3 m_own_nb_cells = {};
58 Int64x3 m_first_own_cell_offset;
59 Int64 m_cell_unique_id_offset = -1;
60 Int64 m_node_unique_id_offset = -1;
61};
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
69Int32 CartesianMeshAllocateBuildInfoInternal::
70meshDimension() const
71{
72 return m_p->m_mesh_dimension;
73}
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78void CartesianMeshAllocateBuildInfoInternal::
79setFaceBuilderVersion(Int32 version)
80{
81 m_p->m_face_builder_version = version;
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87Int32 CartesianMeshAllocateBuildInfoInternal::
88faceBuilderVersion() const
89{
90 return m_p->m_face_builder_version;
91}
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96void CartesianMeshAllocateBuildInfoInternal::
97setEdgeBuilderVersion(Int32 version)
98{
99 m_p->m_edge_builder_version = version;
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105Int32 CartesianMeshAllocateBuildInfoInternal::
106edgeBuilderVersion() const
107{
108 return m_p->m_edge_builder_version;
109}
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114const Int64x3& CartesianMeshAllocateBuildInfoInternal::
115globalNbCells() const
116{
117 return m_p->m_global_nb_cells;
118}
119
120/*---------------------------------------------------------------------------*/
121/*---------------------------------------------------------------------------*/
122
123const Int32x3& CartesianMeshAllocateBuildInfoInternal::
124ownNbCells() const
125{
126 return m_p->m_own_nb_cells;
127}
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
131
132const Int64x3& CartesianMeshAllocateBuildInfoInternal::
133firstOwnCellOffset() const
134{
135 return m_p->m_first_own_cell_offset;
136}
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141Int64 CartesianMeshAllocateBuildInfoInternal::
142cellUniqueIdOffset() const
143{
144 return m_p->m_cell_unique_id_offset;
145}
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150Int64 CartesianMeshAllocateBuildInfoInternal::
151nodeUniqueIdOffset() const
152{
153 return m_p->m_node_unique_id_offset;
154}
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
162CartesianMeshAllocateBuildInfo::
163CartesianMeshAllocateBuildInfo(IPrimaryMesh* mesh)
164: m_p(new Impl(mesh))
165{
166}
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
171CartesianMeshAllocateBuildInfo::
172~CartesianMeshAllocateBuildInfo()
173{
174 delete m_p;
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
181setInfos2D(std::array<Int64, 2> global_nb_cells,
182 std::array<Int32, 2> own_nb_cells,
183 Int64 cell_unique_id_offset,
184 Int64 node_unique_id_offset)
185{
186 setInfos2D(global_nb_cells, own_nb_cells, { 0, 0 }, cell_unique_id_offset);
187 m_p->m_node_unique_id_offset = node_unique_id_offset;
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
194setInfos2D(const Int64x2& global_nb_cells,
195 const Int32x2& own_nb_cells,
196 const Int64x2& first_own_cell_offset,
197 Int64 cell_unique_id_offset)
198{
199 m_p->m_mesh_dimension = 2;
200 m_p->m_global_nb_cells = { global_nb_cells.x, global_nb_cells.y, 0 };
201 m_p->m_own_nb_cells = { own_nb_cells.x, own_nb_cells.y, 0 };
202 m_p->m_first_own_cell_offset = { first_own_cell_offset.x, first_own_cell_offset.y, 0 };
203 m_p->m_cell_unique_id_offset = cell_unique_id_offset;
204 m_p->m_node_unique_id_offset = 0;
205}
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
209
211setInfos3D(std::array<Int64, 3> global_nb_cells,
212 std::array<Int32, 3> own_nb_cells,
213 Int64 cell_unique_id_offset,
214 Int64 node_unique_id_offset)
215{
216 setInfos3D(Int64x3(global_nb_cells), Int32x3(own_nb_cells), { 0, 0, 0 }, cell_unique_id_offset);
217 m_p->m_node_unique_id_offset = node_unique_id_offset;
218}
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
224setInfos3D(const Int64x3& global_nb_cells,
225 const Int32x3& own_nb_cells,
226 const Int64x3& first_own_cell_offset,
227 Int64 cell_unique_id_offset)
228{
229 m_p->m_mesh_dimension = 3;
230 m_p->m_global_nb_cells = global_nb_cells;
231 m_p->m_own_nb_cells = own_nb_cells;
232 m_p->m_first_own_cell_offset = first_own_cell_offset;
233 m_p->m_cell_unique_id_offset = cell_unique_id_offset;
234 m_p->m_node_unique_id_offset = 0;
235}
236
237/*---------------------------------------------------------------------------*/
238/*---------------------------------------------------------------------------*/
239
242{
243 IPrimaryMesh* pm = m_p->m_mesh;
244
246 if (!a)
247 ARCANE_FATAL("Mesh implementation has no IMeshInitialAllocator");
248
250 if (!specific_allocator)
251 ARCANE_FATAL("Mesh does not support 'ICartesianMeshInitialAllocator'");
252
253 pm->traceMng()->info() << "Allocate mesh from CartesianMeshAllocateBuildInfo";
254 specific_allocator->allocate(*this);
255}
256
257/*---------------------------------------------------------------------------*/
258/*---------------------------------------------------------------------------*/
259
260CartesianMeshAllocateBuildInfoInternal* CartesianMeshAllocateBuildInfo::
261_internal()
262{
263 return &m_p->m_internal;
264}
265
266/*---------------------------------------------------------------------------*/
267/*---------------------------------------------------------------------------*/
268
269} // End namespace Arcane
270
271/*---------------------------------------------------------------------------*/
272/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
void setInfos3D(std::array< Int64, 3 > global_nb_cells, std::array< Int32, 3 > own_nb_cells, Int64 cell_unique_id_offset, Int64 node_unique_id_offset)
Positionne les informations pour un maillage 3D.
CartesianMeshAllocateBuildInfoInternal * _internal()
Partie interne réservée à Arcane.
void setInfos2D(std::array< Int64, 2 > global_nb_cells, std::array< Int32, 2 > own_nb_cells, Int64 cell_unique_id_offset, Int64 node_unique_id_offset)
Positionne les informations pour un maillage 2D.
Allocateur pour les maillages cartésiens.
virtual ITraceMng * traceMng()=0
Gestionnaire de message associé
Interface d'allocation des entités du maillage.
virtual ICartesianMeshInitialAllocator * cartesianMeshAllocator()
Allocateur pour les maillages cartésiens.
virtual IMeshInitialAllocator * initialAllocator()
Allocateur initial spécifique.
Classe gérant un vecteur de dimension 2 de type T.
Definition Vector2.h:36
virtual TraceMessage info()=0
Flot pour un message d'information.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-