265 info() <<
"[XmfMeshWriter::writeMeshToFile] nNodes=" <<
mesh->nbNode() <<
" nCells="<<
mesh->nbCell()
266 <<
" all=" <<
mesh->allNodes().size() <<
", own=" <<
mesh->ownNodes().size();
271 XdmfRoot *xmfRoot=
new XdmfRoot();
272 XdmfDOM *xmfDom=
new XdmfDOM();
276 String xmfDomFileName(file_name+
".xmf");
277 if (xmfDom->SetWorkingDirectory(
".")!= XDMF_SUCCESS)
throw IOException(
"writeMeshToFile",
"SetOutputFileName");
278 if (xmfDom->SetOutputFileName(xmfDomFileName.
localstr())!= XDMF_SUCCESS)
throw IOException(
"writeMeshToFile",
"SetOutputFileName");
279 xmfRoot->SetDOM(xmfDom);
281 info() <<
"XDMF-side initialisation done";
284 XdmfDomain *xmfDomain =
new XdmfDomain();
285 xmfDomain->SetName(file_name.
localstr());
286 xmfRoot->Insert(xmfDomain);
287 info() <<
"[XmfMeshWriter] Domain initialisation done";
290 XdmfGrid *xmfGrid =
new XdmfGrid();
291 xmfGrid->SetGridType(XDMF_GRID_UNIFORM);
292 info() <<
"[XmfMeshWriter] Grid initialisation done";
297 XdmfAttribute *xmfCellAttribute=
new XdmfAttribute();
298 xmfCellAttribute->SetName(
"CellsUniqueIDs");
299 xmfCellAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_CELL);
300 xmfCellAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);
301 XdmfArray *xmfCellsUniqueIDs = xmfCellAttribute->GetValues();
302 String heavyDataForCellsUniqueIDs(file_name+
".h5:/CellsUniqueIDs");
303 xmfCellsUniqueIDs->SetHeavyDataSetName(heavyDataForCellsUniqueIDs.
localstr());
304 xmfCellsUniqueIDs->SetNumberType(XDMF_INT32_TYPE);
305 xmfCellsUniqueIDs->SetNumberOfElements(
mesh->nbCell());
306 XdmfInt64 cellIndex=0;
311 XdmfAttribute *xmfNodeAttribute=
new XdmfAttribute();
312 xmfNodeAttribute->SetName(
"NodesUniqueIDs");
313 xmfNodeAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE);
314 xmfNodeAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);
315 XdmfArray *xmfNodesUniqueIDs = xmfNodeAttribute->GetValues();
316 String heavyDataForNodesUniqueIDs(file_name+
".h5:/NodesUniqueIDs");
317 xmfNodesUniqueIDs->SetHeavyDataSetName(heavyDataForNodesUniqueIDs.
localstr());
318 xmfNodesUniqueIDs->SetNumberType(XDMF_INT32_TYPE);
319 xmfNodesUniqueIDs->SetNumberOfElements(
mesh->nbNode());
325 XdmfAttribute *xmfOwnerAttribute=
new XdmfAttribute();
326 xmfOwnerAttribute->SetName(
"NodesOwner");
327 xmfOwnerAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE);
328 xmfOwnerAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);
329 XdmfArray *xmfNodesOwners = xmfOwnerAttribute->GetValues();
330 String heavyDataForOwners(file_name+
".h5:/NodesOwners");
331 xmfNodesOwners->SetHeavyDataSetName(heavyDataForOwners.
localstr());
332 xmfNodesOwners->SetNumberType(XDMF_INT32_TYPE);
333 xmfNodesOwners->SetNumberOfElements(
mesh->nbNode());
334 XdmfInt64 nodeIndex=0;
336 nodesUniqueIDs.
add(iNode->uniqueId().asInteger());
337 xmfNodesUniqueIDs->SetValue(nodeIndex, iNode->uniqueId().asInteger());
338 xmfNodesOwners->SetValue(nodeIndex++, iNode->owner());
342 info() <<
"[XmfMeshWriter] Focussing on the topology";
343 XdmfTopology *xmfTopology = xmfGrid->GetTopology();
344 xmfTopology->SetTopologyType(XDMF_MIXED);
345 xmfTopology->SetNumberOfElements(
mesh->nbCell());
346 XdmfArray *xmfConnectivityArray= xmfTopology->GetConnectivity();
347 String heavyDataForConnections(file_name+
".h5:/Connections");
348 xmfConnectivityArray->SetHeavyDataSetName(heavyDataForConnections.
localstr());
349 xmfConnectivityArray->SetNumberType(XDMF_INT32_TYPE);
354 xmfCellsUniqueIDs->SetValue(cellIndex++, iCell->uniqueId().asInteger());
355 _switchXmfType(cell.
type(), arcCellConnectivityArray);
357 for(
Integer j=0; j<nbNodes;++j){
359 for(
Integer i=0; i<meshNbNodes; ++i){
361 if (nodesUniqueIDs[i] != uid)
363 arcCellConnectivityArray.
add(i);
368 xmfConnectivityArray->SetNumberOfElements(arcCellConnectivityArray.
size());
369 info() <<
"[XmfMeshWriter] arcCellConnectivityArray.size()=" << arcCellConnectivityArray.
size();
370 for(XdmfInt32 idx=0; idx<arcCellConnectivityArray.
size();++idx)
371 xmfConnectivityArray->SetValue(idx,arcCellConnectivityArray[idx]);
372 info() <<
"[XmfMeshWriter] Work on grid->topology done";
375 XdmfGeometry *xmfGeometry = xmfGrid->GetGeometry();
376 xmfGeometry->SetGeometryType(XDMF_GEOMETRY_XYZ);
378 XdmfArray *xmfNodeGeometryArray= xmfGeometry->GetPoints();
379 String heavyDataForGeometry(file_name+
".h5:/XYZ");
380 xmfNodeGeometryArray->SetHeavyDataSetName(heavyDataForGeometry.
localstr());
381 xmfNodeGeometryArray->SetNumberType(XDMF_FLOAT32_TYPE);
382 xmfNodeGeometryArray->SetNumberOfElements(3*
mesh->nbNode());
386 const Node& node = *iNode;
387 xmfNodeGeometryArray->SetValue(Index++,
Convert::toDouble(nodes_coords[iNode].x));
388 xmfNodeGeometryArray->SetValue(Index++,
Convert::toDouble(nodes_coords[iNode].y));
389 xmfNodeGeometryArray->SetValue(Index++,
Convert::toDouble(nodes_coords[iNode].z));
392 info() <<
"[XmfMeshWriter] Work on Geometry done";
393 xmfDomain->Insert(xmfGrid);
402 info() <<
"[XmfMeshWriter] Working on Groups";
404 if ( (*arcGroup ==
mesh->cellFamily()->allItems())||(*arcGroup ==
mesh->nodeFamily()->allItems())||\
405 (*arcGroup ==
mesh->edgeFamily()->allItems())||(*arcGroup ==
mesh->faceFamily()->allItems()))
continue;
406 info() <<
"[writeMeshToFile] Found a " << arcGroup->itemKind() <<
"-group " << arcGroup->name();
407 XdmfAttribute *xmfAttribute=
new XdmfAttribute();
408 xmfAttribute->SetName(arcGroup->name().localstr());
409 xmfAttribute->SetAttributeCenter(XDMF_ATTRIBUTE_CENTER_NODE);
410 xmfAttribute->SetAttributeType(XDMF_ATTRIBUTE_TYPE_SCALAR);
411 XdmfArray *xmfGroup = xmfAttribute->GetValues();
412 String heavyDataForGroup(file_name+
".h5:/" + arcGroup->name());
413 xmfGroup->SetHeavyDataSetName(heavyDataForGroup.
localstr());
414 xmfGroup->SetNumberType(XDMF_INT32_TYPE);
415 xmfGroup->SetNumberOfElements(1+arcGroup->size());
417 xmfGroup->SetValue(Index++, arcGroup->itemKind());
419 xmfGroup->SetValue(Index++, iItem->uniqueId().asInteger());
421 xmfGrid->Insert(xmfAttribute);
423 xmfGrid->Insert(xmfCellAttribute);
424 xmfGrid->Insert(xmfNodeAttribute);
425 xmfGrid->Insert(xmfOwnerAttribute);
434 delete xmfCellAttribute;
435 delete xmfNodeAttribute;
436 delete xmfOwnerAttribute;
442 info() <<
"[XmfMeshWriter] Done";