Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
CartesianMeshGenerationInfo.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* CartesianMeshGenerationInfo.cc (C) 2000-2021 */
9/* */
10/* Informations sur la génération des maillages cartésiens. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/internal/CartesianMeshGenerationInfo.h"
15
16#include "arcane/utils/String.h"
17#include "arcane/utils/IUserDataList.h"
18#include "arcane/utils/AutoDestroyUserData.h"
19#include "arcane/utils/FatalErrorException.h"
20
21#include "arcane/IMesh.h"
22#include "arcane/Properties.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::impl
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33CartesianMeshGenerationInfo::
34CartesianMeshGenerationInfo(IMesh* mesh)
35: m_mesh(mesh)
36, m_mesh_dimension(mesh->dimension())
37{
38 m_global_nb_cells = Int64ArrayView(NB_DIM, m_global_nb_cell_ptr);
39 m_sub_domain_offsets = Int32ArrayView(NB_DIM, m_sub_domain_offset_ptr);
40 m_nb_sub_domains = Int32ArrayView(NB_DIM, m_nb_sub_domain_ptr);
41 m_own_nb_cells = Int32ArrayView(NB_DIM, m_own_nb_cell_ptr);
42 m_own_cell_offsets = Int64ArrayView(NB_DIM, m_own_cell_offset_ptr);
43
44 m_global_nb_cells.fill(-1);
45 m_sub_domain_offsets.fill(-1);
46 m_nb_sub_domains.fill(-1);
47 m_own_nb_cells.fill(-1);
48 m_own_cell_offsets.fill(-1);
49
50 _init();
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56void CartesianMeshGenerationInfo::
57setOwnCellOffsets(Int64 x,Int64 y,Int64 z)
58{
59 m_own_cell_offsets[0] = x;
60 m_own_cell_offsets[1] = y;
61 m_own_cell_offsets[2] = z;
62
63 Properties* p = m_mesh->properties();
64 p->setInt64("OwnCellOffsetX", x);
65 p->setInt64("OwnCellOffsetY", y);
66 p->setInt64("OwnCellOffsetZ", z);
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
72void CartesianMeshGenerationInfo::
73setGlobalNbCells(Int64 x, Int64 y, Int64 z)
74{
75 m_global_nb_cells[0] = x;
76 m_global_nb_cells[1] = y;
77 m_global_nb_cells[2] = z;
78
79 Properties* p = m_mesh->properties();
80 p->setInt64("GlobalNbCellX", x);
81 p->setInt64("GlobalNbCellY", y);
82 p->setInt64("GlobalNbCellZ", z);
83
84 m_global_nb_cell = x;
85 if (y > (-1))
86 m_global_nb_cell *= y;
87 if (z > (-1))
88 m_global_nb_cell *= z;
89}
90
91/*---------------------------------------------------------------------------*/
92/*---------------------------------------------------------------------------*/
93
94void CartesianMeshGenerationInfo::
95setSubDomainOffsets(Int32 x, Int32 y, Int32 z)
96{
97 m_sub_domain_offsets[0] = x;
98 m_sub_domain_offsets[1] = y;
99 m_sub_domain_offsets[2] = z;
100
101 Properties* p = m_mesh->properties();
102 p->setInt32("SubDomainOffsetX", x);
103 p->setInt32("SubDomainOffsetY", y);
104 p->setInt32("SubDomainOffsetZ", z);
105}
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110void CartesianMeshGenerationInfo::
111setNbSubDomains(Int32 x, Int32 y, Int32 z)
112{
113 m_nb_sub_domains[0] = x;
114 m_nb_sub_domains[1] = y;
115 m_nb_sub_domains[2] = z;
116
117 Properties* p = m_mesh->properties();
118 p->setInt32("NbSubDomainX", x);
119 p->setInt32("NbSubDomainY", y);
120 p->setInt32("NbSubDomainZ", z);
121}
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
126void CartesianMeshGenerationInfo::
127setOwnNbCells(Int32 x, Int32 y, Int32 z)
128{
129 m_own_nb_cells[0] = x;
130 m_own_nb_cells[1] = y;
131 m_own_nb_cells[2] = z;
132
133 Properties* p = m_mesh->properties();
134 p->setInt32("OwnNbCellX", x);
135 p->setInt32("OwnNbCellY", y);
136 p->setInt32("OwnNbCellZ", z);
137}
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142void CartesianMeshGenerationInfo::
143setFirstOwnCellUniqueId(Int64 uid)
144{
145 m_first_own_cell_unique_id = uid;
146
147 Properties* p = m_mesh->properties();
148 p->setInt64("CartesianFirstOnwCellUniqueId", uid);
149}
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
154void CartesianMeshGenerationInfo::
155setGlobalOrigin(Real3 pos)
156{
157 m_global_origin = pos;
158 Properties* p = m_mesh->properties();
159 p->setReal("GlobalMeshOriginX", m_global_origin.x);
160 p->setReal("GlobalMeshOriginY", m_global_origin.y);
161 p->setReal("GlobalMeshOriginZ", m_global_origin.z);
162}
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
167void CartesianMeshGenerationInfo::
168setGlobalLength(Real3 length)
169{
170 m_global_length = length;
171 Properties* p = m_mesh->properties();
172 p->setReal("GlobalMeshLengthX", m_global_length.x);
173 p->setReal("GlobalMeshLengthY", m_global_length.y);
174 p->setReal("GlobalMeshLengthZ", m_global_length.z);
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
180void CartesianMeshGenerationInfo::
181_init()
182{
183 Properties* p = m_mesh->properties();
184 m_global_nb_cells[MD_DirX] = p->getInt64WithDefault("GlobalNbCellX", -1);
185 m_global_nb_cells[MD_DirY] = p->getInt64WithDefault("GlobalNbCellY", -1);
186 m_global_nb_cells[MD_DirZ] = p->getInt64WithDefault("GlobalNbCellZ", -1);
187
188 m_own_nb_cells[MD_DirX] = p->getInt32WithDefault("OwnNbCellX", -1);
189 m_own_nb_cells[MD_DirY] = p->getInt32WithDefault("OwnNbCellY", -1);
190 m_own_nb_cells[MD_DirZ] = p->getInt32WithDefault("OwnNbCellZ", -1);
191
192 m_sub_domain_offsets[MD_DirX] = p->getInt32WithDefault("SubDomainOffsetX", -1);
193 m_sub_domain_offsets[MD_DirY] = p->getInt32WithDefault("SubDomainOffsetY", -1);
194 m_sub_domain_offsets[MD_DirZ] = p->getInt32WithDefault("SubDomainOffsetZ", -1);
195
196 m_own_cell_offsets[MD_DirX] = p->getInt64WithDefault("OwnCellOffsetX", -1);
197 m_own_cell_offsets[MD_DirY] = p->getInt64WithDefault("OwnCellOffsetY", -1);
198 m_own_cell_offsets[MD_DirZ] = p->getInt64WithDefault("OwnCellOffsetZ", -1);
199
200 m_nb_sub_domains[MD_DirX] = p->getInt32WithDefault("NbSubDomainX", -1);
201 m_nb_sub_domains[MD_DirY] = p->getInt32WithDefault("NbSubDomainY", -1);
202 m_nb_sub_domains[MD_DirZ] = p->getInt32WithDefault("NbSubDomainZ", -1);
203
204 m_first_own_cell_unique_id = p->getInt64WithDefault("CartesianFirstOnwCellUniqueId", -1);
205
206 m_global_origin.x = p->getRealWithDefault("GlobalMeshOriginX", 0.0);
207 m_global_origin.y = p->getRealWithDefault("GlobalMeshOriginY", 0.0);
208 m_global_origin.z = p->getRealWithDefault("GlobalMeshOriginZ", 0.0);
209
210 m_global_length.x = p->getRealWithDefault("GlobalMeshLengthX", 0.0);
211 m_global_length.y = p->getRealWithDefault("GlobalMeshLengthY", 0.0);
212 m_global_length.z = p->getRealWithDefault("GlobalMeshLengthZ", 0.0);
213}
214
215/*---------------------------------------------------------------------------*/
216/*---------------------------------------------------------------------------*/
217
218} // End namespace Arcane::impl
219
220/*---------------------------------------------------------------------------*/
221/*---------------------------------------------------------------------------*/
222
223namespace Arcane
224{
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229ICartesianMeshGenerationInfo* ICartesianMeshGenerationInfo::
230getReference(IMesh* mesh,bool create)
231{
232 //TODO: faire lock pour multi-thread
233 const char* name = "CartesianMeshGenerationInfo";
234 IUserDataList* udlist = mesh->userDataList();
235
236 IUserData* ud = udlist->data(name,true);
237 if (!ud){
238 if (!create)
239 return nullptr;
240 ICartesianMeshGenerationInfo* cm = new impl::CartesianMeshGenerationInfo(mesh);
241 udlist->setData(name,new AutoDestroyUserData<ICartesianMeshGenerationInfo>(cm));
242 return cm;
243 }
244 auto* adud = dynamic_cast<AutoDestroyUserData<ICartesianMeshGenerationInfo>*>(ud);
245 if (!adud)
246 ARCANE_FATAL("Can not cast to ICartesianMeshGenerationInfo");
247 return adud->data();
248}
249
250/*---------------------------------------------------------------------------*/
251/*---------------------------------------------------------------------------*/
252
253}
254
255/*---------------------------------------------------------------------------*/
256/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:609
@ MD_DirZ
Direction Z.
@ MD_DirY
Direction Y.
@ MD_DirX
Direction X.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:611