Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
XmfMeshReader.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/* XmfMeshReader.cc (C) 2000-2010 */
9/* */
10/* Lecture/Ecriture d'un fichier au format XMF. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/ArcaneTypes.h"
15#include "arcane/utils/ArcanePrecomp.h"
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/StdHeader.h"
18#include "arcane/utils/HashTableMap.h"
19#include "arcane/utils/ValueConvert.h"
20#include "arcane/utils/ScopedPtr.h"
21#include "arcane/utils/ITraceMng.h"
22#include "arcane/utils/String.h"
23#include "arcane/utils/IOException.h"
24#include "arcane/utils/Collection.h"
25#include "arcane/utils/Enumerator.h"
26#include "arcane/utils/NotImplementedException.h"
27#include "arcane/utils/Real3.h"
28
29#include "arcane/AbstractService.h"
30#include "arcane/FactoryService.h"
31#include "arcane/IMainFactory.h"
32#include "arcane/IMeshReader.h"
33#include "arcane/ISubDomain.h"
34#include "arcane/IPrimaryMesh.h"
35#include "arcane/IItemFamily.h"
36#include "arcane/Item.h"
37#include "arcane/ItemEnumerator.h"
38#include "arcane/VariableTypes.h"
39#include "arcane/IVariableAccessor.h"
40#include "arcane/IParallelMng.h"
41#include "arcane/IIOMng.h"
42#include "arcane/IXmlDocumentHolder.h"
43#include "arcane/XmlNodeList.h"
44#include "arcane/XmlNode.h"
45#include "arcane/IMeshUtilities.h"
46#include "arcane/IMeshWriter.h"
47#include "arcane/BasicService.h"
48
49#define XDMF_USE_ANSI_STDLIB
50#include "vtkxdmf2/XdmfArray.h"
51#include "vtkxdmf2/XdmfAttribute.h"
52#include "vtkxdmf2/XdmfDOM.h"
53#include "vtkxdmf2/XdmfDataDesc.h"
54#include "vtkxdmf2/XdmfDataItem.h"
55#include "vtkxdmf2/XdmfGrid.h"
56#include "vtkxdmf2/XdmfTopology.h"
57#include "vtkxdmf2/XdmfGeometry.h"
58#include "vtkxdmf2/XdmfTime.h"
59
60/*#define H5_USE_16_API
61#include <hdf5.h>*/
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65ARCANE_BEGIN_NAMESPACE
66
67using namespace xdmf2;
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
76 public:
78
79 public:
80 virtual void build() {}
81
82 bool allowExtension(const String& str){return (str=="xmf");}
83
84 virtual eReturnType readMeshFromFile(IPrimaryMesh* mesh,const XmlNode& mesh_node,
86
87 ISubDomain* subDomain() { return m_sub_domain; }
88
89 private:
90 ISubDomain* m_sub_domain;
91 eReturnType _readTopology(XdmfTopology*, XdmfInt64&, Int32Array&, Int32Array&, Int32Array&, SharedArray<Int32>);
92 eReturnType _readMixedTopology(XdmfTopology*, XdmfInt64, Int32Array&, Int32Array&, Int32Array&, SharedArray<Int32>);
93};
94
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98ARCANE_REGISTER_SUB_DOMAIN_FACTORY(XmfMeshReader, IMeshReader, XmfNewMeshReader);
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102XmfMeshReader::XmfMeshReader(const ServiceBuildInfo& sbi):AbstractService(sbi), m_sub_domain(sbi.subDomain()){}
103
104
105
106/*****************************************************************************\
107* [_addThisConnectivity] *
108\*****************************************************************************/
109#define _addThisConnectivity(nNodes, arcType)\
110 cells_type.add(arcType);\
111 cells_nb_node.add(nNodes);\
112 for (XdmfInt32 z=0; z<nNodes; ++z)\
113 cells_connectivity.add(nodesUidArray[xdmfConnectivity->GetValueAsInt32(i++)]);
114
115
116
117/*****************************************************************************\
118* [_readMixedTopology] *
119\*****************************************************************************/
120IMeshReader::eReturnType XmfMeshReader::
121_readMixedTopology(XdmfTopology *Topology,
122 XdmfInt64 nb_elements,
123 Int32Array& cells_nb_node,
124 Int32Array& cells_connectivity,
125 Int32Array& cells_type,
126 SharedArray<Int32> nodesUidArray)
127{
128 info() << "[_readMixedTopology] Entering";
129 XdmfArray *xdmfConnectivity=Topology->GetConnectivity(NULL, XDMF_TRUE);
130 XdmfInt32 numType=xdmfConnectivity->GetNumberType();
131 info() << "xdmfConnectivity.CoreLength=" << xdmfConnectivity->GetCoreLength()<< " numType=" << numType;
132 if (numType != XDMF_INT32_TYPE)
133 throw NotSupportedException(A_FUNCINFO, "Not supported connectivity num type");
134 XdmfInt32 nNodesForThisElement;
135 XdmfInt64 iElementsScaned=0;
136 for(XdmfInt64 i=0; iElementsScaned < nb_elements; iElementsScaned++){
137 // info() << "[_readMixedTopology] scan=" << iElementsScaned << "/" << nb_elements;
138 switch (xdmfConnectivity->GetValueAsInt32(i++)){
139 case (XDMF_POLYVERTEX): // 0x1
140 nNodesForThisElement=xdmfConnectivity->GetValueAsInt32(i++);
141 // info() << "[_readMixedTopology] XDMF_POLYVERTEX(" << nNodesForThisElement << ")";
142 switch (nNodesForThisElement){
143 case (1): _addThisConnectivity(1, IT_Vertex); break;
144 case (12): _addThisConnectivity(12, IT_Octaedron12); break;
145 case (14): _addThisConnectivity(14, IT_Enneedron14); break;
146 case (16): _addThisConnectivity(16, IT_Decaedron16); break;
147 case (7): _addThisConnectivity(7, IT_HemiHexa7); break;
148 case (6): _addThisConnectivity(6, IT_HemiHexa6); break;
149 // GG: je commente ces deux cas car dans la version de Oct2015 cela ne compile
150 // pas car IT_AntiWedgetLeft6 vaut 16 et donc la même valeur dans le switch
151 // que pour le IT_Decaedron16. De toute facon, je pense que le case avant ne fonctionnait
152 // pas car la valeur pour 6 noeuds est déjà prise par IT_HemiHexa6.
153 //case (IT_AntiWedgeLeft6): _addThisConnectivity(6, IT_AntiWedgeLeft6); break;
154 //case (IT_AntiWedgeRight6): _addThisConnectivity(6, IT_AntiWedgeRight6); break;
155 case (5): _addThisConnectivity(5, IT_HemiHexa5); break;
156 case (55): _addThisConnectivity(5, IT_DiTetra5); break;
157 default:
158 throw FatalErrorException(A_FUNCINFO, "XDMF_POLYVERTEX with unknown number of nodes");
159 }
160 break;
161 case (XDMF_POLYLINE): // 0x2
162 nNodesForThisElement=xdmfConnectivity->GetValueAsInt32(i++);
163 // info() << "[_readMixedTopology] XDMF_POLYLINE("<<nNodesForThisElement<<")";
164 switch (nNodesForThisElement){
165 case (2): _addThisConnectivity(2, IT_Line2); break;
166 default: throw FatalErrorException(A_FUNCINFO, "XDMF_POLYLINE with unknown number of nodes");
167 }
168 break;
169 case (XDMF_POLYGON): // 0x3
170 nNodesForThisElement=xdmfConnectivity->GetValueAsInt32(i++);
171 // info() << "[_readMixedTopology] XDMF_POLYGON("<<nNodesForThisElement<<")";
172 switch (nNodesForThisElement){
173 case (5): _addThisConnectivity(5, IT_Pentagon5); break;
174 case (6): _addThisConnectivity(6, IT_Hexagon6); break;
175 default: throw FatalErrorException(A_FUNCINFO, "XDMF_POLYGON with unknown number of nodes");
176 }
177 break;
178 case (XDMF_TRI):_addThisConnectivity(3, IT_Triangle3); break;// 0x4
179 case (XDMF_QUAD):_addThisConnectivity(4, IT_Quad4); break;// 0x5
180 case (XDMF_TET):_addThisConnectivity(4, IT_Tetraedron4); break;// 0x6
181 case (XDMF_PYRAMID):_addThisConnectivity(5, IT_Pyramid5); break;// 0x7
182 case (XDMF_WEDGE ):_addThisConnectivity(6, IT_Pentaedron6); break;// 0x8
183 case (XDMF_HEX):_addThisConnectivity(8, IT_Hexaedron8); break;// 0x9
184 case (XDMF_TET_10):_addThisConnectivity(10, IT_Heptaedron10); break;// 0x0026
185 case (XDMF_EDGE_3):
186 case (XDMF_TRI_6):
187 case (XDMF_QUAD_8):
188 case (XDMF_PYRAMID_13):
189 case (XDMF_WEDGE_15):
190 case (XDMF_HEX_20):
191 default: throw NotSupportedException(A_FUNCINFO, "Not supported topology type in a mixed one");
192 }
193 }
194// delete xdmfConnectivity;
195 info() << "[_readMixedTopology] Done";
196 return RTOk;
197}
198
199
200/*****************************************************************************\
201* [_readTopology] *
202 XML Element : Topology
203 XML Attribute : Name = Any String
204 XML Attribute : TopologyType = Polyvertex | Polyline | Polygon |
205 Triangle | Quadrilateral | Tetrahedron | Pyramid| Wedge | Hexahedron |
206 Edge_3 | Triagle_6 | Quadrilateral_8 | Tetrahedron_10 | Pyramid_13 |
207 Wedge_15 | Hexahedron_20 |
208 Mixed |
209 2DSMesh | 2DRectMesh | 2DCoRectMesh |
210 3DSMesh | 3DRectMesh | 3DCoRectMesh
211 XML Attribute : NumberOfElements = Number of Cells
212 XML Attribute : NodesPerElement = # (Only Important for Polyvertex, Polygon and Polyline)
213 XML Attribute : Order = Order of Nodes if not Default
214 XML BaseOffset: Offset if not 0
215\*****************************************************************************/
216IMeshReader::eReturnType XmfMeshReader::
217_readTopology(XdmfTopology *Topology,
218 XdmfInt64& nb_elements,
219 Int32Array& cells_nb_node,
220 Int32Array& cells_connectivity,
221 Int32Array& cells_type,
222 SharedArray<Int32> nodesUidArray)
223{
224 info() << "[_readTopology] Entering";
225 if (!Topology) throw FatalErrorException(A_FUNCINFO, "Null topology");
226 if (Topology->UpdateInformation() != XDMF_SUCCESS) throw FatalErrorException(A_FUNCINFO, "Error in UpdateInformation");
227 if (Topology->Update() != XDMF_SUCCESS) throw FatalErrorException(A_FUNCINFO, "Error in Update");
228 nb_elements = Topology->GetNumberOfElements();
229 info() << "\tHave found a " << Topology->GetClassAsString() << " "
230 << Topology->GetTopologyTypeAsString() << " topology with " << nb_elements << " elements";
231 switch (Topology->GetTopologyType()){
232 case (XDMF_2DSMESH): // 0x0100
233 case (XDMF_2DRECTMESH): // 0x0101
234 case (XDMF_2DCORECTMESH): // 0x0102
235 case (XDMF_3DRECTMESH): // 0x1101
236 case (XDMF_3DCORECTMESH): // 0x1102
237 case (XDMF_3DSMESH):{ // 0x1100
238 // Try to do something with these kind of structured topologies
239 if ((nb_elements%3)==0){
240 for(XdmfInt64 i=0; i<nb_elements/3; i+=3){
241 cells_type.add(IT_Triangle3);
242 cells_nb_node.add(3);
243 for (Integer z=0; z<3; ++z)
244 cells_connectivity.add(i+z);
245 }
246 }else if ((nb_elements%4)==0){
247 for(XdmfInt64 i=0; i<nb_elements/4; i+=4){
248 cells_type.add(IT_Quad4);
249 cells_nb_node.add(4);
250 for (Integer z=0; z<4; ++z)
251 cells_connectivity.add(i+z);
252 }
253 }else throw FatalErrorException(A_FUNCINFO, "Could not match XDMF_3DSMESH with a known mesh");
254 return RTOk;
255 }
256 // Otherwise, read a mixed topology should do the trick
257 case (XDMF_POLYVERTEX): // 0x1
258 case (XDMF_POLYLINE): // 0x2
259 case (XDMF_POLYGON): // 0x3
260 case (XDMF_TRI): // 0x4
261 case (XDMF_QUAD): // 0x5
262 case (XDMF_TET): // 0x6
263 case (XDMF_PYRAMID): // 0x7
264 case (XDMF_WEDGE ): // 0x8
265 case (XDMF_HEX): // 0x9
266 case (XDMF_EDGE_3): // 0x0022
267 case (XDMF_TRI_6): // 0x0024
268 case (XDMF_QUAD_8): // 0x0025
269 case (XDMF_TET_10): // 0x0026
270 case (XDMF_PYRAMID_13): // 0x0027
271 case (XDMF_WEDGE_15): // 0x0028
272 case (XDMF_HEX_20): // 0x0029
273 case (XDMF_MIXED): // 0x0070
274 if (_readMixedTopology(Topology, nb_elements, cells_nb_node, cells_connectivity, cells_type, nodesUidArray) != RTOk)
275 throw FatalErrorException(A_FUNCINFO, "Error in _readMixedTopology");
276 break;
277 case (XDMF_NOTOPOLOGY): // 0x0
278 default: throw NotSupportedException(A_FUNCINFO, "Not supported topology type");
279 }
280// Topology->Release();
281// delete Topology;
282 info() << "[_readTopology] Release & Done";
283 return RTOk;
284}
285
286
287
288/*****************************************************************************
289 [readMeshFromFile]
290The organization of XDMF begins with the Xdmf element. So that parsers can
291distinguish from previous versions of XDMF, there exists a Version attribute
292(currently at 2.0).
293
294Xdmf elements contain one or more Domain elements (computational
295domain). There is seldom motivation to have more than one Domain.
296
297A Domain can have one or more Grid elements.
298
299Each Grid contains a Topology, Geometry, and zero or more Attribute elements.
300
301Topology specifies the connectivity of the grid while
302Geometry specifies the location of the grid nodes.
303*****************************************************************************/
307{
308 IParallelMng* pm = mesh->parallelMng();
309 bool is_parallel = pm->isParallel();
310 Integer sid = pm->commRank();
311 bool itWasAnArcanProduction=true;
312
313 info() << "[readMeshFromFile] Entering";
314 XdmfDOM *DOM = new XdmfDOM();
315
316 // Parse the XML File
317 if (DOM->SetInputFileName(file_name.localstr()) != XDMF_SUCCESS) throw FatalErrorException(A_FUNCINFO, "SetInputFileName");
318 if (DOM->Parse() != XDMF_SUCCESS) throw FatalErrorException(A_FUNCINFO, "Parse");
319 XdmfXmlNode XdmfRoot = DOM->GetTree();
320
321 // Version verification
322 if (strcmp(DOM->Get(XdmfRoot, "Version"), "2.0")<0) throw NotSupportedException(A_FUNCINFO, "Not supported Xdmf-file version");
323
324 // Now scan all of its children
325 XdmfInt64 nRootChildren=DOM->GetNumberOfChildren(XdmfRoot);
326 info() << "GetNumberOfChildren=" << nRootChildren;
327
328 //Xdmf elements contain one or more Domain elements
329 XdmfInt32 nDomains= DOM->FindNumberOfElements("Domain");
330 info() << "nDomains=" << nDomains;
331
332
334 XdmfXmlNode foundDomain=DOM->FindElement("Domain", iDomain, XdmfRoot, 0);
335 if (foundDomain != NULL) info() << "Have found domain" << iDomain;
336
337 // A Domain can have one or more Grid elements.
338 XdmfInt32 nGrids= DOM->FindNumberOfElements("Grid", foundDomain);
339 info() << "nGrids=" << nGrids;
340 for(XdmfInt32 iGrid=0; iGrid < nGrids; ++iGrid){
341 /*****************************
342 Looking for the domain's Grid
343 ******************************/
344 XdmfXmlNode foundGrid=DOM->FindElement("Grid", iGrid, foundDomain, 0);
345 if (foundGrid == NULL) throw FatalErrorException(A_FUNCINFO, "Grid not found for domain");
346 XdmfGrid *Grid = new XdmfGrid();
347 Grid->SetDOM(DOM);
348 Grid->SetElement(foundGrid);
349 Grid->UpdateInformation();
350 info() << "Have found a " << Grid->GetGridTypeAsString() << " grid";
351 if (Grid->GetGridType() != XDMF_GRID_UNIFORM) throw NotSupportedException(A_FUNCINFO, "Not supported GRID type");
352
353 /*****************************************************
354 Looking for XML attribute which Name="CellsUniqueIDs"
355 ******************************************************/
356 XdmfXmlNode cellsUniqueIDsXmlNode = DOM->FindElementByAttribute ("Name", "CellsUniqueIDs", 0, foundGrid);
359 info() << "[XmfMeshReader] cellsUidArray were found";
361 attribute->SetDOM(DOM);
362 attribute->SetElement(cellsUniqueIDsXmlNode);
363 attribute->UpdateInformation();
364 attribute->Update();
365 XdmfArray *xmfGroup = attribute->GetValues();
366 info() << attribute->GetName() << "(" << attribute->GetAttributeTypeAsString() << ", "
367 << attribute->GetAttributeCenterAsString() << ", " << xmfGroup->GetNumberOfElements() <<")";
368 XdmfInt64 nb_item = xmfGroup->GetNumberOfElements();
369 for(XdmfInt64 uid=0; uid<nb_item; ++uid)
370 cellsUidArray.add(xmfGroup->GetValueAsInt32(uid));
371 }else itWasAnArcanProduction=false;
372
373 /*****************************************************
374 Looking for XML attribute which Name="NodesUniqueIDs"
375 ******************************************************/
376 XdmfXmlNode nodesUniqueIDsXmlNode = DOM->FindElementByAttribute ("Name", "NodesUniqueIDs", 0, foundGrid);
379 info() << "[XmfMeshReader] nodesUidArray were found";
381 attribute->SetDOM(DOM);
382 attribute->SetElement(nodesUniqueIDsXmlNode);
383 attribute->UpdateInformation();
384 attribute->Update();
385 XdmfArray *xmfGroup = attribute->GetValues();
386 info() << attribute->GetName() << "(" << attribute->GetAttributeTypeAsString() << ", "
387 << attribute->GetAttributeCenterAsString() << ", " << xmfGroup->GetNumberOfElements() <<")";
388 XdmfInt64 nb_item = xmfGroup->GetNumberOfElements();
389 for(XdmfInt64 uid=0; uid<nb_item; ++uid)
390 nodesUidArray.add(xmfGroup->GetValueAsInt32(uid));
391 }
392 else itWasAnArcanProduction=false;
393
394 /*****************************************************
395 Looking for XML attribute which Name="NodesOwner"
396 ******************************************************/
397 XdmfXmlNode nodesOwnerXmlNode = DOM->FindElementByAttribute ("Name", "NodesOwner", 0, foundGrid);
399 if (nodesOwnerXmlNode) {
400 info() << "[XmfMeshReader] nodesOwnerArray were found";
402 attribute->SetDOM(DOM);
403 attribute->SetElement(nodesOwnerXmlNode);
404 attribute->UpdateInformation();
405 attribute->Update();
406 XdmfArray *xmfGroup = attribute->GetValues();
407 info() << attribute->GetName() << "(" << attribute->GetAttributeTypeAsString() << ", "
408 << attribute->GetAttributeCenterAsString() << ", " << xmfGroup->GetNumberOfElements() <<")";
409 XdmfInt64 nb_item = xmfGroup->GetNumberOfElements();
410 for(XdmfInt64 uid=0; uid<nb_item; ++uid)
411 nodesOwnerArray.add(xmfGroup->GetValueAsInt32(uid));
412 }
413 else
415
416 /******************************
417 Each Grid contains a Geometry,
418 *******************************/
419 XdmfGeometry* xmfGometry = Grid->GetGeometry();
420 if (!xmfGometry)
421 ARCANE_FATAL("No xmfGeometry");
422 info() << "\tHave found a " << xmfGometry->GetGeometryTypeAsString() << " geometry";
423 if (xmfGometry->GetGeometryType() != XDMF_GEOMETRY_XYZ)
424 throw NotSupportedException(A_FUNCINFO, "Not supported geometry type");
425 xmfGometry->UpdateInformation();
426 xmfGometry->Update();
427 HashTableMapT<Int64,Real3> nodes_coords(xmfGometry->GetNumberOfPoints(),true);
428 XdmfInt64 nbOfNodes = xmfGometry->GetNumberOfPoints();
429
430 /****************************************************
431 If it is not ours, just fake the indirection process
432 *****************************************************/
434 info() << "If it is not ours, just fake the indirection process";
435 for(Integer uid=0; uid<nbOfNodes; ++uid){
436 nodesUidArray.add(uid);
437 cellsUidArray.add(uid);
438 nodesOwnerArray.add(uid);
439 }
440 }
441
442 XdmfArray *xdmfPoints = xmfGometry->GetPoints(XDMF_TRUE);// true to create the array
443 XdmfInt32 numType=xdmfPoints->GetNumberType();
444 if (numType!=XDMF_FLOAT32_TYPE) throw NotSupportedException(A_FUNCINFO, "Not supported geometry number type");
446 for(XdmfInt64 i=0; iNode<nbOfNodes; iNode++, i+=3){
447 Real3 coords=Real3(xdmfPoints->GetValueAsFloat32(i),
448 xdmfPoints->GetValueAsFloat32(i+1),
449 xdmfPoints->GetValueAsFloat32(i+2));
450 nodes_coords.nocheckAdd(nodesUidArray[iNode], coords);
451 }
452
453
454 /******************************
455 Each Grid contains a Topology,
456 *******************************/
457 XdmfInt64 nb_elements;
458 Int32UniqueArray cells_nb_node;
459 Int32UniqueArray cells_connectivity;
460 Int32UniqueArray cells_type;
461 XdmfTopology *topology=Grid->GetTopology();
462 if (_readTopology(topology, nb_elements, cells_nb_node, cells_connectivity, cells_type, nodesUidArray) != RTOk)
463 throw IOException("XmfMeshReader", "_readTopology error");
464
465 // Create hash table for nodes owner.
468 info() << "[_XmfMeshReader] Create hash table for nodes owner";
469 for(Integer i=0; i<nbOfNodes; ++i ){
470 //info() << nodesUidArray[i] <<":"<<nodesOwnerArray[i];
472 }
473 }
474
475 /****************************
476 * Now building cells_infos *
477 ****************************/
479 info() << "[_XmfMeshReader] Création des mailles, nb_cell=" << nb_elements << " cells_type.size=" << cells_type.size();
480 Integer connectivity_index = 0;
481 for(Integer i=0; i<cells_type.size(); ++i ){
482 cells_infos.add(cells_type[i]);
484 for (Integer z=0; z<cells_nb_node[i]; ++z )
485 cells_infos.add(cells_connectivity[connectivity_index+z]);
486 connectivity_index += cells_nb_node[i];
487 }
488
489 /********************************
490 * Setting Dimension & Allocating *
491 ********************************/
492 info() << "[XmfMeshReader] ## Mesh 3D ##";
493 mesh->setDimension(3);
494 info() << "[XmfMeshReader] ## Allocating ##";
495 mesh->allocateCells(cells_type.size(), cells_infos, false);
496
497 /**********************************************************************
498 Positionne les propriétaires des noeuds à partir des groupes de noeuds
499 ***********************************************************************/
500 ItemInternalList internalNodes(mesh->itemsInternal(IK_Node));
501 info() << "[XmfMeshReader] internalNodes.size()="<<internalNodes.size();
503 info() << "[XmfMeshReader] Setting nodes owners from xmf file";
504 for(Integer i=0, is=internalNodes.size(); i<is; ++i){
505 ItemInternal* internal_node = internalNodes[i];
506 //info() << "[XmfMeshReader] "<<internal_node->uniqueId()<<":"<<nodes_owner_map[internal_node->uniqueId()];
508 internal_node->setOwner(true_owner,sid);
509 }
510 }
511 else{
512 for(Integer i=0, is=internalNodes.size(); i<is; ++i)
513 internalNodes[i]->setOwner(sid,sid);
514 }
515 ItemInternalList internalCells(mesh->itemsInternal(IK_Cell));
516 info() << "[XmfMeshReader] internalCells.size()="<<internalCells.size();
517 for(Integer i=0, is=internalCells.size(); i<is; ++i)
518 internalCells[i]->setOwner(sid,sid);
519
520 /********************************************
521 * Now finishing & preparing for ghost layout *
522 ********************************************/
523 info() << "[XmfMeshReader] ## Ending with endAllocate ##";
524 mesh->endAllocate();
525 if (is_parallel){
526 info() << "[XmfMeshReader] ## setOwnersFromCells ##";
527 mesh->setOwnersFromCells();
528 }
529 info() << "\n\n[XmfMeshReader] ## Now dealing with ghost's layer ##";
530 info() << "[XmfMeshReader] mesh.nbNode=" <<mesh->nbNode() << " mesh.nbCell="<< mesh->nbCell();
531
532 /***********************************************************
533 and zero or more Attribute elements (fetching Other Groups)
534 ************************************************************/
535 XdmfInt32 nAttributes=Grid->GetNumberOfAttributes();
536 info() << "nAttributes=" << nAttributes;
538 XdmfAttribute *attribute = Grid->GetAttribute(iAttribute);
539 if ((attribute == NULL || (!itWasAnArcanProduction))) continue;
540 if ((strcasecmp(attribute->GetName(), "NodesUniqueIDs")==0)||
541 (strcasecmp(attribute->GetName(), "CellsUniqueIDs")==0)||
542 (strcasecmp(attribute->GetName(), "NodesOwner")==0)){
543 info() << "Skipping " << attribute->GetName();
544 continue;
545 }
546 attribute->Update();
547 XdmfArray *xmfGroup = attribute->GetValues();
548 info() << attribute->GetName() << "(" << attribute->GetAttributeTypeAsString() << ", "
549 << attribute->GetAttributeCenterAsString() << ", " << xmfGroup->GetNumberOfElements() <<")";
550
551 eItemKind itemKind=(eItemKind)xmfGroup->GetValueAsInt32(0);
552 IItemFamily* family = mesh->itemFamily(itemKind);
553 Integer nb_item = xmfGroup->GetNumberOfElements() - 1;
555
556 // Les éléments suivant contiennent les uniqueId() des entités du groupe.
557 for(XdmfInt64 z=0; z<nb_item; ++z )
558 unique_ids[z] = xmfGroup->GetValueAsInt32(z+1);
559
560 // Récupère le localId() correspondant.
563
564 // Tous les entités ne sont pas forcément dans le maillage actuel et
565 // il faut donc les filtrer.
567 for(Integer i=0; i<nb_item; ++i )
568 if (local_ids[i]!=NULL_ITEM_LOCAL_ID)
569 ids.add(local_ids[i]);
570
571 info() << "Create group family=" << family->name() << " name=" << attribute->GetName() << " ids=" << ids.size();
572 family->createGroup(attribute->GetName(),ids,true);
573 }
574
575 /*********************
576 * Now insert coords *
577 *********************/
578 info() << "[XmfMeshReader] ## Now insert coords ##";
581 nodes_coord_var[iNode] = nodes_coords[iNode->uniqueId()];
582 }
583
584 /****************************************
585 * Synchronizing groups/variables & nodes *
586 ****************************************/
588 }
589 }
590
591 info() << "[readMeshFromFile] RTOk";
592 // delete DOM;
593 // delete geometry;
594 // delete topology;
595 return RTOk;
596}
597
598
599
600/*---------------------------------------------------------------------------*/
601/*---------------------------------------------------------------------------*/
602
603ARCANE_END_NAMESPACE
604
605/*---------------------------------------------------------------------------*/
606/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ENUMERATE_NODE(name, group)
Enumérateur générique d'un groupe de noeuds.
#define ARCANE_REGISTER_SUB_DOMAIN_FACTORY(aclass, ainterface, aname)
Enregistre un service de fabrique pour la classe aclass.
Classe de base d'un service.
Interface d'une famille d'entités.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual String name() const =0
Nom de la famille.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converti un tableau de numéros uniques en numéros locaux.
virtual NodeGroup ownNodes()=0
Groupe de tous les noeuds propres au domaine.
virtual Integer nbCell()=0
Nombre de mailles du maillage.
virtual IItemFamily * itemFamily(eItemKind ik)=0
Retourne la famille d'entité de type ik.
virtual Integer nbNode()=0
Nombre de noeuds du maillage.
Interface du service gérant la lecture d'un maillage.
Definition IMeshReader.h:37
eReturnType
Types des codes de retour d'une lecture ou écriture.
Definition IMeshReader.h:42
@ RTOk
Opération effectuée avec succès.
Definition IMeshReader.h:43
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
virtual ItemInternalList itemsInternal(eItemKind)=0
Tableau interne des éléments du maillage de type type.
virtual void synchronizeGroupsAndVariables()=0
Synchronise tous les groupes et les variables du maillage.
Exception lorsqu'une erreur d'entrée/sortie est détectée.
Definition IOException.h:32
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual bool isParallel() const =0
Retourne true si l'exécution est parallèle.
virtual VariableNodeReal3 & nodesCoordinates()=0
Coordonnées des noeuds.
virtual void allocateCells(Integer nb_cell, Int64ConstArrayView cells_infos, bool one_alloc=true)=0
Allocation d'un maillage.
virtual void setOwnersFromCells()=0
Positionne les propriétaires des entités à partir du propriétaire des mailles.
virtual void endAllocate()=0
Indique une fin d'allocation de mailles.
virtual void setDimension(Integer dim)=0
Positionne la dimension du maillage (1D, 2D ou 3D).
Interface du gestionnaire d'un sous-domaine.
Definition ISubDomain.h:74
Structure interne d'une entité de maillage.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Structure contenant les informations pour créer un service.
Lecteur des fichiers de maillage aux format msh.
virtual void build()
Construction de niveau build du service.
bool allowExtension(const String &str)
Vérifie si le service supporte les fichiers avec l'extension str.
virtual eReturnType readMeshFromFile(IPrimaryMesh *mesh, const XmlNode &mesh_node, const String &file_name, const String &dir_name, bool use_internal_partition)
Lit un maillage à partir d'un fichier.
Noeud d'un arbre DOM.
Definition XmlNode.h:51
Integer size() const
Nombre d'éléments du vecteur.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Exception lorsqu'une erreur fatale est survenue.
Exception lorsqu'une opération n'est pas supportée.
Chaîne de caractères unicode.
TraceMessage info() const
Flot pour un message d'information.
Vecteur 1D de données avec sémantique par valeur (style STL).
@ Grid
Utilise un noyau de calcul avec une synchronisations entre les blocs.
eItemKind
Genre d'entité de maillage.
@ IK_Node
Entité de maillage de genre noeud.
@ IK_Cell
Entité de maillage de genre maille.
Array< Int32 > Int32Array
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:327