14#include "arcane/std/SimpleMeshGenerator.h"
16#include "arcane/utils/Array.h"
17#include "arcane/utils/HashTableMap.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/ITraceMng.h"
20#include "arcane/utils/Real3.h"
21#include "arcane/utils/FixedArray.h"
23#include "arcane/core/IMeshReader.h"
24#include "arcane/core/ISubDomain.h"
25#include "arcane/core/ICaseDocument.h"
26#include "arcane/core/XmlNode.h"
27#include "arcane/core/Service.h"
28#include "arcane/core/IParallelMng.h"
29#include "arcane/core/Item.h"
30#include "arcane/core/ItemGroup.h"
31#include "arcane/core/IMesh.h"
32#include "arcane/core/IMeshSubMeshTransition.h"
33#include "arcane/core/IItemFamily.h"
34#include "arcane/core/MeshVariable.h"
36#include "arcane/core/ItemPrinter.h"
37#include "arcane/core/FactoryService.h"
38#include "arcane/core/AbstractService.h"
39#include "arcane/core/IMeshModifier.h"
40#include "arcane/core/internal/IMeshModifierInternal.h"
55, m_mesh_modifier_internal(
mesh->modifier()->_modifierInternalApi())
63_addNode(
const Real3& pos)
65 auto i = m_coords_to_uid.find(pos);
66 if (i==m_coords_to_uid.end()){
67 Integer current_id = m_nodes_unique_id.size();
68 m_nodes_unique_id.add(current_id);
69 m_nodes_coords.add(pos);
70 m_coords_to_uid.insert(std::make_pair(pos,current_id));
81_addNode(Real x,Real y,Real z)
83 return _addNode(Real3(x,y,z));
89void SimpleMeshGenerator::
90_addCell(Int16 type_id, ConstArrayView<Int64> nodes_id)
92 Integer current_id = m_current_nb_cell;
94 m_mesh_modifier_internal->addCell(ItemUniqueId(current_id), ItemTypeId(type_id), nodes_id);
100bool SimpleMeshGenerator::
101readOptions(XmlNode node)
103 XmlNode modeNode = node.child(String(
"mode"));
104 m_mode = modeNode.valueAsInteger();
105 if (m_mode < 1 || m_mode > 3) {
106 info() <<
"Bad syntax for <meshgenerator>";
107 info() <<
"Expected is <meshgenerator><simple><mode>mode</simple></meshgenerator>";
108 info() <<
"with mode between 1 and 3";
109 error() <<
"Bad syntax for <meshgenerator>";
118void SimpleMeshGenerator::
119_createSimpleHemiHexa7(Real x0,Real y0,Real z1,Real z2)
121 FixedArray<Int64, 7> ids;
122 ids[0] = _addNode(x0 ,y0 ,z1);
123 ids[1] = _addNode(x0+1.,y0 ,z1);
124 ids[2] = _addNode(x0+1.,y0 ,z2);
125 ids[3] = _addNode(x0+1.,y0+1.,z2);
126 ids[4] = _addNode(x0 ,y0+1.,z2);
127 ids[5] = _addNode(x0 ,y0+1.,z1);
128 ids[6] = _addNode(x0 + 1., y0 + 1., z1);
129 _addCell(IT_HemiHexa7, ids.view());
135void SimpleMeshGenerator::
136_createSimpleHemiHexa6(Real x0, Real y0, Real z1, Real z2)
138 FixedArray<Int64, 6> ids;
139 ids[0] = _addNode(x0 ,y0 ,z1);
140 ids[1] = _addNode(x0+1.,y0 ,z1);
141 ids[2] = _addNode(x0+1.,y0 ,z2);
142 ids[3] = _addNode(x0+1.,y0+1.,z1);
143 ids[4] = _addNode(x0, y0 + 1., z2);
144 ids[5] = _addNode(x0, y0 + 1., z1);
145 _addCell(IT_HemiHexa6, ids.view());
151void SimpleMeshGenerator::
152_createSimpleHemiHexa5(Real x0, Real y0, Real z1, Real z2)
154 FixedArray<Int64, 5> ids;
155 ids[0] = _addNode(x0 ,y0 ,z1);
156 ids[1] = _addNode(x0+1.,y0 ,z1);
157 ids[2] = _addNode(x0+1.,y0 ,z2);
158 ids[3] = _addNode(x0 + 1., y0 + 1., z1);
159 ids[4] = _addNode(x0, y0 + 1., z1);
160 _addCell(IT_HemiHexa5, ids.view());
166void SimpleMeshGenerator::
167_createSimpleAntiWedgeLeft6(Real x0, Real y0, Real z1, Real z2)
169 FixedArray<Int64, 6> ids;
170 ids[0] = _addNode(x0 ,y0 ,z1);
171 ids[1] = _addNode(x0 ,y0+1.,z1);
172 ids[2] = _addNode(x0 ,y0+.5,z2);
173 ids[3] = _addNode(x0+1.,y0 ,z1);
174 ids[4] = _addNode(x0 + 1., y0 + 1., z1);
175 ids[5] = _addNode(x0 + 1., y0 + .5, (z1 + z2) / 2);
176 _addCell(IT_AntiWedgeLeft6, ids.view());
182void SimpleMeshGenerator::
183_createSimpleAntiWedgeRight6(Real x0, Real y0, Real z1, Real z2)
185 FixedArray<Int64, 6> ids;
186 ids[0] = _addNode(x0 ,y0 ,z1);
187 ids[1] = _addNode(x0 ,y0+1.,z1);
188 ids[2] = _addNode(x0 ,y0+.5,(z1+z2)/2);
189 ids[3] = _addNode(x0 + 1., y0, z1);
190 ids[4] = _addNode(x0 + 1., y0 + 1., z1);
191 ids[5] = _addNode(x0 + 1., y0 + .5, z2);
192 _addCell(IT_AntiWedgeRight6, ids.view());
198void SimpleMeshGenerator::
199_createSimpleDiTetra5(Real x0, Real y0, Real z1, Real z2)
201 FixedArray<Int64, 5> ids;
202 ids[0] = _addNode(x0 ,y0 ,z2);
203 ids[1] = _addNode(x0+1.,y0 ,z1);
204 ids[2] = _addNode(x0 + 2., y0, z2);
205 ids[3] = _addNode(x0 + 1., y0 + 1., (z2 + z1) / 2);
206 ids[4] = _addNode(x0 + 1., y0 - 1., (z2 + z1) / 2);
207 _addCell(IT_DiTetra5, ids.view());
213void SimpleMeshGenerator::
214_createSimpleHexaedron8(Real x0, Real y0, Real z1, Real z2)
216 FixedArray<Int64, 8> ids;
217 ids[0] = _addNode(x0 ,y0 ,z1);
218 ids[1] = _addNode(x0+1.,y0 ,z1);
219 ids[2] = _addNode(x0+1.,y0+1.,z1);
220 ids[3] = _addNode(x0, y0 + 1., z1);
221 ids[4] = _addNode(x0, y0, z2);
222 ids[5] = _addNode(x0 + 1., y0, z2);
223 ids[6] = _addNode(x0 + 1., y0 + 1., z2);
224 ids[7] = _addNode(x0, y0 + 1., z2);
225 _addCell(IT_Hexaedron8, ids.view());
231void SimpleMeshGenerator::
232_createSimpleOctaedron12(Real x0, Real y0, Real z1, Real z2)
234 FixedArray<Int64, 12> ids;
235 ids[0] = _addNode(x0 ,y0 + 0.5,z1);
236 ids[1] = _addNode(x0 + 0.25,y0 ,z1);
237 ids[2] = _addNode(x0 + 0.75,y0 ,z1);
238 ids[3] = _addNode(x0 + 1.0 ,y0 + 0.5,z1);
239 ids[4] = _addNode(x0 + 0.75,y0 + 1. ,z1);
240 ids[5] = _addNode(x0 + 0.25,y0 + 1. ,z1);
242 ids[6] = _addNode(x0 ,y0 + 0.5,z2);
243 ids[7] = _addNode(x0 + 0.25,y0 ,z2);
244 ids[8] = _addNode(x0 + 0.75, y0, z2);
245 ids[9] = _addNode(x0 + 1., y0 + 0.5, z2);
246 ids[10] = _addNode(x0 + 0.75, y0 + 1., z2);
247 ids[11] = _addNode(x0 + 0.25, y0 + 1., z2);
248 _addCell(IT_Octaedron12, ids.view());
254void SimpleMeshGenerator::
255_createSimpleHeptaedron10(Real x0, Real y0, Real z1, Real z2)
257 FixedArray<Int64, 10> ids;
258 ids[0] = _addNode(x0 ,y0 + 0.5 ,z1);
259 ids[1] = _addNode(x0 + 1./2.,y0 ,z1);
260 ids[2] = _addNode(x0 + 2./2.,y0 + 0.25,z1);
261 ids[3] = _addNode(x0 + 2./2.,y0 + 0.75,z1);
262 ids[4] = _addNode(x0 + 1./2.,y0 + 1 ,z1);
264 ids[5] = _addNode(x0 ,y0 + 0.5 ,z2);
265 ids[6] = _addNode(x0 + 1. / 2., y0, z2);
266 ids[7] = _addNode(x0 + 2. / 2., y0 + 0.25, z2);
267 ids[8] = _addNode(x0 + 2. / 2., y0 + 0.75, z2);
268 ids[9] = _addNode(x0 + 1. / 2., y0 + 1., z2);
269 _addCell(IT_Heptaedron10, ids.view());
275void SimpleMeshGenerator::
276_createSimplePentaedron6(Real x0, Real y0, Real z1, Real z2)
278 FixedArray<Int64, 6> ids;
279 ids[0] = _addNode(x0 ,y0 ,z1);
280 ids[1] = _addNode(x0 + 1., y0 + 1. / 2., z1);
281 ids[2] = _addNode(x0, y0 + 1., z1);
282 ids[3] = _addNode(x0, y0, z2);
283 ids[4] = _addNode(x0 + 1., y0 + 1. / 2., z2);
284 ids[5] = _addNode(x0, y0 + 1., z2);
285 _addCell(IT_Pentaedron6, ids.view());
291void SimpleMeshGenerator::
292_createSimplePyramid5(Real x0, Real y0, Real z1, Real z2)
294 FixedArray<Int64, 5> ids;
295 ids[0] = _addNode(x0 ,y0 ,z1);
296 ids[1] = _addNode(x0 + 1., y0, z1);
297 ids[2] = _addNode(x0 + 1., y0 + 1., z1);
298 ids[3] = _addNode(x0, y0 + 1., z1);
299 ids[4] = _addNode(x0 + 0.5, y0 + 0.5, z2);
300 _addCell(IT_Pyramid5, ids.view());
306void SimpleMeshGenerator::
307_createSimpleTetraedron4(Real x0, Real y0, Real z1, Real z2)
309 FixedArray<Int64, 4> ids;
310 ids[0] = _addNode(x0, y0, z1);
311 ids[1] = _addNode(x0 + 1., y0, z1);
312 ids[2] = _addNode(x0 + 0.5, y0 + 1., z1);
313 ids[3] = _addNode(x0 + 0.5, y0 + 0.5, z2);
314 _addCell(IT_Tetraedron4, ids.view());
320bool SimpleMeshGenerator::
323 IPrimaryMesh* mesh = m_mesh;
325 info() <<
"Using simple mesh generator";
326 mesh->setDimension(3);
329 _createSimpleHexaedron8(2.,0.,0.,1.);
330 _createSimpleOctaedron12(4.,0.,0.,1.);
331 _createSimpleHeptaedron10(6.,0.,0.,1.);
332 _createSimplePentaedron6(8.,0.,0.,1.);
333 _createSimplePyramid5(10.,0.,0.,1.);
334 _createSimpleTetraedron4(12.,0.,0.,1.);
335 _createSimpleHemiHexa7(14.,0.,0.,1.);
336 _createSimpleHemiHexa6(16.,0.,0.,1.);
337 _createSimpleHemiHexa5(18.,0.,0.,1.);
338 _createSimpleAntiWedgeLeft6(20.,0.,0.,1.);
339 _createSimpleAntiWedgeRight6(22.,0.,0.,1.);
340 _createSimpleDiTetra5(24.,0.,0.,1.);
344 _createSimpleHexaedron8(0. ,0.,0.,1.);
345 _createSimpleHemiHexa7(0.,0.,1.,2.);
346 _createSimpleHexaedron8(1. ,0.,0.,1.);
348 _createSimpleHexaedron8(2. ,0.,0.,1.);
349 _createSimpleHemiHexa6(2.,0.,1.,2.);
350 _createSimpleHexaedron8(3. ,0.,0.,1.);
352 _createSimpleHexaedron8(4. ,0.,0.,1.);
353 _createSimpleHemiHexa5(4.,0.,1.,2.);
354 _createSimpleHexaedron8(5. ,0.,0.,1.);
356 _createSimpleHexaedron8(6. ,0.,0.,1.);
357 _createSimpleAntiWedgeLeft6(6.,0.,1.,2.);
358 _createSimpleHexaedron8(7. ,0.,0.,1.);
360 _createSimpleHexaedron8(8. ,0.,0.,1.);
361 _createSimpleAntiWedgeRight6(8.,0.,1.,2.);
362 _createSimpleHexaedron8(9. ,0.,0.,1.);
364 _createSimpleHexaedron8(10.,0.,0.,1.);
365 _createSimplePyramid5(10.,0.,1.,2.);
366 _createSimpleHexaedron8(11.,0.,0.,1.);
370 _createSimpleHexaedron8(2.,0.,0.,1.);
371 _createSimpleOctaedron12(4.,0.,0.,1.);
372 _createSimpleHeptaedron10(6.,0.,0.,1.);
373 _createSimplePentaedron6(8.,0.,0.,1.);
374 _createSimplePyramid5(10.,0.,0.,1.);
375 _createSimpleTetraedron4(12.,0.,0.,1.);
378 UniqueArray<Int64> cells_infos(m_cells_infos.size());
379 for (Integer i = 0; i < m_cells_infos.size(); ++i)
380 cells_infos[i] = m_cells_infos[i];
383 UniqueArray<Int64> nodes_unique_id(m_nodes_unique_id.size());
384 for(Integer i=0;i<m_nodes_unique_id.size();++i)
385 nodes_unique_id[i] = m_nodes_unique_id[i];
390 UniqueArray<Int32> nodes_local_id(nodes_unique_id.size());
391 IItemFamily* family = mesh->itemFamily(IK_Node);
392 family->itemsUniqueIdToLocalId(nodes_local_id,nodes_unique_id);
393 NodeInfoListView nodes_internal(family);
394 Integer nb_node_local_id = nodes_local_id.size();
395 for( Integer i=0; i<nb_node_local_id; ++i ){
396 Node node = nodes_internal[nodes_local_id[i]];
398 nodes_coord_var[node] = m_nodes_coords[i];
402 nodes_coord_var.synchronize();
Fonctions utilitaires sur le maillage.
Classe d'accès aux traces.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.