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/ArcanePrecomp.h"
21#include "arcane/utils/Real3.h"
23#include "arcane/IMeshReader.h"
24#include "arcane/ISubDomain.h"
25#include "arcane/ICaseDocument.h"
26#include "arcane/XmlNode.h"
27#include "arcane/Service.h"
28#include "arcane/IParallelMng.h"
29#include "arcane/Item.h"
30#include "arcane/ItemGroup.h"
31#include "arcane/IMesh.h"
32#include "arcane/IMeshSubMeshTransition.h"
33#include "arcane/IItemFamily.h"
34#include "arcane/MeshVariable.h"
35#include "arcane/MeshUtils.h"
36#include "arcane/ItemPrinter.h"
37#include "arcane/FactoryService.h"
38#include "arcane/AbstractService.h"
50SimpleMeshGenerator(IPrimaryMesh* mesh)
51: TraceAccessor(mesh->traceMng())
62_addNode(
const Real3& pos)
64 Real3Map::const_iterator i = m_coords_to_uid.find(pos);
65 if (i==m_coords_to_uid.end()){
66 Integer current_id = m_nodes_unique_id.size();
67 m_nodes_unique_id.add(current_id);
68 m_nodes_coords.add(pos);
69 m_coords_to_uid.insert(std::make_pair(pos,current_id));
82 return _addNode(Real3(x,y,z));
88void SimpleMeshGenerator::
89_addCell(Integer type_id,IntegerConstArrayView nodes_id)
91 Integer current_id = m_current_nb_cell;
92 m_cells_infos.add(type_id);
93 m_cells_infos.add(current_id);
94 for( Integer i=0, is=nodes_id.size(); i<is; ++i )
95 m_cells_infos.add(nodes_id[i]);
103bool SimpleMeshGenerator::
104readOptions(XmlNode node)
106 XmlNode modeNode = node.child(String(
"mode"));
107 m_mode = modeNode.valueAsInteger();
108 if (m_mode < 1 || m_mode > 3) {
109 info() <<
"Bad syntax for <meshgenerator>";
110 info() <<
"Expected is <meshgenerator><simple><mode>mode</simple></meshgenerator>";
111 info() <<
"with mode between 1 and 3";
112 error() <<
"Bad syntax for <meshgenerator>";
121void SimpleMeshGenerator::
125 ids[0] = _addNode(x0 ,y0 ,z1);
126 ids[1] = _addNode(x0+1.,y0 ,z1);
127 ids[2] = _addNode(x0+1.,y0 ,z2);
128 ids[3] = _addNode(x0+1.,y0+1.,z2);
129 ids[4] = _addNode(x0 ,y0+1.,z2);
130 ids[5] = _addNode(x0 ,y0+1.,z1);
131 ids[6] = _addNode(x0+1.,y0+1.,z1);
132 _addCell(IT_HemiHexa7,ConstArrayView<Integer>(7,ids));
138void SimpleMeshGenerator::
142 ids[0] = _addNode(x0 ,y0 ,z1);
143 ids[1] = _addNode(x0+1.,y0 ,z1);
144 ids[2] = _addNode(x0+1.,y0 ,z2);
145 ids[3] = _addNode(x0+1.,y0+1.,z1);
146 ids[4] = _addNode(x0 ,y0+1.,z2);
147 ids[5] = _addNode(x0 ,y0+1.,z1);
148 _addCell(IT_HemiHexa6,ConstArrayView<Integer>(6,ids));
154void SimpleMeshGenerator::
158 ids[0] = _addNode(x0 ,y0 ,z1);
159 ids[1] = _addNode(x0+1.,y0 ,z1);
160 ids[2] = _addNode(x0+1.,y0 ,z2);
161 ids[3] = _addNode(x0+1.,y0+1.,z1);
162 ids[4] = _addNode(x0 ,y0+1.,z1);
163 _addCell(IT_HemiHexa5,ConstArrayView<Integer>(5,ids));
169void SimpleMeshGenerator::
173 ids[0] = _addNode(x0 ,y0 ,z1);
174 ids[1] = _addNode(x0 ,y0+1.,z1);
175 ids[2] = _addNode(x0 ,y0+.5,z2);
176 ids[3] = _addNode(x0+1.,y0 ,z1);
177 ids[4] = _addNode(x0+1.,y0+1.,z1);
178 ids[5] = _addNode(x0+1.,y0+.5,(z1+z2)/2);
179 _addCell(IT_AntiWedgeLeft6,ConstArrayView<Integer>(6,ids));
185void SimpleMeshGenerator::
189 ids[0] = _addNode(x0 ,y0 ,z1);
190 ids[1] = _addNode(x0 ,y0+1.,z1);
191 ids[2] = _addNode(x0 ,y0+.5,(z1+z2)/2);
192 ids[3] = _addNode(x0+1.,y0 ,z1);
193 ids[4] = _addNode(x0+1.,y0+1.,z1);
194 ids[5] = _addNode(x0+1.,y0+.5,z2);
195 _addCell(IT_AntiWedgeRight6,ConstArrayView<Integer>(6,ids));
201void SimpleMeshGenerator::
205 ids[0] = _addNode(x0 ,y0 ,z2);
206 ids[1] = _addNode(x0+1.,y0 ,z1);
207 ids[2] = _addNode(x0+2.,y0 ,z2);
208 ids[3] = _addNode(x0+1.,y0+1.,(z2+z1)/2);
209 ids[4] = _addNode(x0+1.,y0-1.,(z2+z1)/2);
210 _addCell(IT_DiTetra5,ConstArrayView<Integer>(5,ids));
216void SimpleMeshGenerator::
220 ids[0] = _addNode(x0 ,y0 ,z1);
221 ids[1] = _addNode(x0+1.,y0 ,z1);
222 ids[2] = _addNode(x0+1.,y0+1.,z1);
223 ids[3] = _addNode(x0 ,y0+1.,z1);
224 ids[4] = _addNode(x0 ,y0 ,z2);
225 ids[5] = _addNode(x0+1.,y0 ,z2);
226 ids[6] = _addNode(x0+1.,y0+1.,z2);
227 ids[7] = _addNode(x0 ,y0+1.,z2);
234void SimpleMeshGenerator::
238 ids[0] = _addNode(x0 ,y0 + 0.5,z1);
239 ids[1] = _addNode(x0 + 0.25,y0 ,z1);
240 ids[2] = _addNode(x0 + 0.75,y0 ,z1);
241 ids[3] = _addNode(x0 + 1.0 ,y0 + 0.5,z1);
242 ids[4] = _addNode(x0 + 0.75,y0 + 1. ,z1);
243 ids[5] = _addNode(x0 + 0.25,y0 + 1. ,z1);
245 ids[6] = _addNode(x0 ,y0 + 0.5,z2);
246 ids[7] = _addNode(x0 + 0.25,y0 ,z2);
247 ids[8] = _addNode(x0 + 0.75,y0 ,z2);
248 ids[9] = _addNode(x0 + 1. ,y0 + 0.5,z2);
249 ids[10] = _addNode(x0 + 0.75,y0 + 1. ,z2);
250 ids[11] = _addNode(x0 + 0.25,y0 + 1. ,z2);
257void SimpleMeshGenerator::
261 ids[0] = _addNode(x0 ,y0 + 0.5 ,z1);
262 ids[1] = _addNode(x0 + 1./2.,y0 ,z1);
263 ids[2] = _addNode(x0 + 2./2.,y0 + 0.25,z1);
264 ids[3] = _addNode(x0 + 2./2.,y0 + 0.75,z1);
265 ids[4] = _addNode(x0 + 1./2.,y0 + 1 ,z1);
267 ids[5] = _addNode(x0 ,y0 + 0.5 ,z2);
268 ids[6] = _addNode(x0 + 1./2.,y0 ,z2);
269 ids[7] = _addNode(x0 + 2./2.,y0 + 0.25 ,z2);
270 ids[8] = _addNode(x0 + 2./2.,y0 + 0.75 ,z2);
271 ids[9] = _addNode(x0 + 1./2.,y0 + 1. ,z2);
278void SimpleMeshGenerator::
282 ids[0] = _addNode(x0 ,y0 ,z1);
283 ids[1] = _addNode(x0 + 1.,y0 + 1./2.,z1);
284 ids[2] = _addNode(x0 ,y0 + 1. ,z1);
285 ids[3] = _addNode(x0 ,y0 ,z2);
286 ids[4] = _addNode(x0 + 1.,y0 + 1./2.,z2);
287 ids[5] = _addNode(x0 ,y0 + 1. ,z2);
294void SimpleMeshGenerator::
298 ids[0] = _addNode(x0 ,y0 ,z1);
299 ids[1] = _addNode(x0 + 1.,y0 ,z1);
300 ids[2] = _addNode(x0 + 1.,y0 + 1. ,z1);
301 ids[3] = _addNode(x0 ,y0 + 1. ,z1);
302 ids[4] = _addNode(x0 +0.5,y0 + 0.5 ,z2);
309void SimpleMeshGenerator::
313 ids[0] = _addNode(x0 ,y0 ,z1);
314 ids[1] = _addNode(x0 + 1. ,y0 ,z1);
315 ids[2] = _addNode(x0 + 0.5,y0 + 1. ,z1);
316 ids[3] = _addNode(x0 + 0.5,y0 + 0.5,z2);
323bool SimpleMeshGenerator::
326 IPrimaryMesh* mesh = m_mesh;
328 info() <<
"Using simple mesh generator";
331 _createSimpleHexaedron8(2.,0.,0.,1.);
332 _createSimpleOctaedron12(4.,0.,0.,1.);
333 _createSimpleHeptaedron10(6.,0.,0.,1.);
334 _createSimplePentaedron6(8.,0.,0.,1.);
335 _createSimplePyramid5(10.,0.,0.,1.);
336 _createSimpleTetraedron4(12.,0.,0.,1.);
337 _createSimpleHemiHexa7(14.,0.,0.,1.);
338 _createSimpleHemiHexa6(16.,0.,0.,1.);
339 _createSimpleHemiHexa5(18.,0.,0.,1.);
340 _createSimpleAntiWedgeLeft6(20.,0.,0.,1.);
341 _createSimpleAntiWedgeRight6(22.,0.,0.,1.);
342 _createSimpleDiTetra5(24.,0.,0.,1.);
346 _createSimpleHexaedron8(0. ,0.,0.,1.);
347 _createSimpleHemiHexa7(0.,0.,1.,2.);
348 _createSimpleHexaedron8(1. ,0.,0.,1.);
350 _createSimpleHexaedron8(2. ,0.,0.,1.);
351 _createSimpleHemiHexa6(2.,0.,1.,2.);
352 _createSimpleHexaedron8(3. ,0.,0.,1.);
354 _createSimpleHexaedron8(4. ,0.,0.,1.);
355 _createSimpleHemiHexa5(4.,0.,1.,2.);
356 _createSimpleHexaedron8(5. ,0.,0.,1.);
358 _createSimpleHexaedron8(6. ,0.,0.,1.);
359 _createSimpleAntiWedgeLeft6(6.,0.,1.,2.);
360 _createSimpleHexaedron8(7. ,0.,0.,1.);
362 _createSimpleHexaedron8(8. ,0.,0.,1.);
363 _createSimpleAntiWedgeRight6(8.,0.,1.,2.);
364 _createSimpleHexaedron8(9. ,0.,0.,1.);
366 _createSimpleHexaedron8(10.,0.,0.,1.);
367 _createSimplePyramid5(10.,0.,1.,2.);
368 _createSimpleHexaedron8(11.,0.,0.,1.);
372 _createSimpleHexaedron8(2.,0.,0.,1.);
373 _createSimpleOctaedron12(4.,0.,0.,1.);
374 _createSimpleHeptaedron10(6.,0.,0.,1.);
375 _createSimplePentaedron6(8.,0.,0.,1.);
376 _createSimplePyramid5(10.,0.,0.,1.);
377 _createSimpleTetraedron4(12.,0.,0.,1.);
380 mesh->setDimension(3);
381 UniqueArray<Int64> cells_infos(m_cells_infos.size());
382 for(Integer i=0;i<m_cells_infos.size();++i)
383 cells_infos[i] = m_cells_infos[i];
384 mesh->allocateCells(m_current_nb_cell,cells_infos,
true);
386 UniqueArray<Int64> nodes_unique_id(m_nodes_unique_id.size());
387 for(Integer i=0;i<m_nodes_unique_id.size();++i)
388 nodes_unique_id[i] = m_nodes_unique_id[i];
393 UniqueArray<Int32> nodes_local_id(nodes_unique_id.size());
394 IItemFamily* family = mesh->itemFamily(IK_Node);
395 family->itemsUniqueIdToLocalId(nodes_local_id,nodes_unique_id);
396 NodeInfoListView nodes_internal(family);
397 Integer nb_node_local_id = nodes_local_id.size();
398 for( Integer i=0; i<nb_node_local_id; ++i ){
399 Node node = nodes_internal[nodes_local_id[i]];
401 nodes_coord_var[node] = m_nodes_coords[i];
405 nodes_coord_var.synchronize();
Lecteur des fichiers de maillage via la bibliothèque LIMA.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
ConstArrayView< Integer > IntegerConstArrayView
Equivalent C d'un tableau à une dimension d'entiers.
Int32 Integer
Type représentant un entier.