143 std::map<Int64,Integer> uid_to_idx_map;
144 info() <<
"[VtuMeshWriter::writeMeshToFile] mesh_nb_node=" <<mesh_nb_node <<
" mesh_nb_cell="<< mesh_nb_cell
145 <<
" all=" <<
mesh->allNodes().size() <<
", own=" <<
mesh->ownNodes().size();
151 vtkPoints* points = vtkPoints::New();
152 points->SetDataTypeToDouble();
153 vtkUnstructuredGrid* grid = vtkUnstructuredGrid::New();
154 grid->Allocate(mesh_nb_cell, mesh_nb_cell);
164 info() <<
"[writeMeshToFile] Creating array of CELLS Unique IDs";
165 vtkCellData* vtk_cell_data = grid->GetCellData();
166 vtkLongArray* vtk_cell_uids = vtkLongArray::New();
167 vtk_cell_uids->SetName(
"CellsUniqueIDs");
170 vtk_cell_uids->InsertNextValue(cell.
uniqueId());
172 vtk_cell_data->AddArray(vtk_cell_uids);
173 vtk_cell_uids->Delete();
178 info() <<
"[writeMeshToFile] Creating array of NODES Unique IDs";
179 vtkPointData *vtk_point_data=grid->GetPointData();
180 vtkLongArray *vtk_point_uids = vtkLongArray::New();
181 vtk_point_uids->SetName(
"NodesUniqueIDs");
182 vtkIntArray *vtk_point_owners = vtkIntArray::New();
183 vtk_point_owners->SetName(
"NodesOwner");
188 Real3 coord = nodes_coords[inode];
192 uid_to_idx_map.insert(std::make_pair(uid,index));
193 vtk_point_uids->InsertNextValue(uid);
194 vtk_point_owners->InsertNextValue(node.
owner());
197 vtk_point_data->AddArray(vtk_point_uids);
198 vtk_point_uids->Delete();
200 vtk_point_data->AddArray(vtk_point_owners);
201 vtk_point_owners->Delete();
206 info() <<
"[writeMeshToFile] Now setting point into grid";
207 grid->SetPoints(points);
212 info() <<
"[writeMeshToFile] Now scanning cells' nodes to create connectivity";
213 vtkIdList* vtk_point_ids = vtkIdList::New();
216 int nb_node = cell.
nbNode();
217 vtk_point_ids->Allocate(nb_node);
219 for(
Integer j=0; j<nb_node; ++j ){
221 auto x = uid_to_idx_map.find(node_uid);
222 if (x==uid_to_idx_map.end())
223 ARCANE_FATAL(
"InternalError: no index for uid '{0}'",node_uid);
224 vtk_point_ids->InsertNextId(x->second);
227 int vtk_item = IT_NullType;
230 case(IT_Tetraedron4):
231 vtk_item = VTK_TETRA;
234 vtk_item = VTK_HEXAHEDRON;
237 vtk_item = VTK_PYRAMID;
241 case(IT_Octaedron12):
242 vtk_item = VTK_HEXAGONAL_PRISM;
244 case(IT_Heptaedron10):
245 vtk_item = VTK_PENTAGONAL_PRISM;
249 case(IT_Pentaedron6):
250 vtk_item = VTK_WEDGE;
255 info() <<
"VTK_POLY_VERTEX";
256 vtk_item = VTK_POLY_VERTEX;
259 info() <<
"VTK_POLY_VERTEX";
260 vtk_item = VTK_POLY_VERTEX;
263 info() <<
"VTK_POLY_VERTEX";
264 vtk_item = VTK_POLY_VERTEX;
266 case(IT_AntiWedgeLeft6):
267 info() <<
"VTK_POLY_VERTEX";
268 vtk_item = VTK_POLY_VERTEX;
270 case(IT_AntiWedgeRight6):
271 info() <<
"VTK_POLY_VERTEX";
272 vtk_item = VTK_POLY_VERTEX;
275 info() <<
"VTK_POLY_VERTEX";
276 vtk_item = VTK_POLY_VERTEX;
280 info() <<
"[writeMeshToFile] Cell type not suported (" << cell.
type() <<
")";
283 grid->InsertNextCell(vtk_item, vtk_point_ids);
284 vtk_point_ids->Reset();
286 vtk_point_ids->Delete();
292 info() <<
"[writeMeshToFile] ## Now Fetching Groups ##";
293 vtkFieldData* vtkFieldDataGroups = grid->GetFieldData();
296 if (igroup->isAllItems())
298 info() <<
"[writeMeshToFile] Found a " << igroup->itemKind() <<
"-group " << igroup->name();
299 _writeFieldGroupsFromData(vtkFieldDataGroups, *igroup);
305 vtkXMLUnstructuredGridWriter* vtk_grid_writer = vtkXMLUnstructuredGridWriter::New();
306 vtk_grid_writer->SetInputData(grid);
307 String fileNameDotVtu(file_name +
".vtu");
308 vtk_grid_writer->SetFileName(fileNameDotVtu.
localstr());
309 info() <<
"[writeMeshToFile] SetFileName " << fileNameDotVtu;
312 vtk_grid_writer->SetDataModeToAscii();
314 vtk_grid_writer->SetDataModeToBinary();
315 vtk_grid_writer->Write();
322 vtk_grid_writer->Delete();
323 info() <<
"[writeMeshToFile] Done";