9 void writeLocalTree(
const u32vector2D& nodes,
const u32vector2D& connectivity,
10 const u32vector2D& ghostNodes,
const u32vector2D& ghostConnectivity,
14 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-p" << std::setfill(
'0') << std::setw(4) << ptree.
rank <<
"-" << filename <<
".vtu";
16 ofstream out(name.str().c_str());
19 ss << filename <<
"*.vtu cannot be opened and it won't be written.";
23 int nofNodes = nodes.size();
24 int nofGhostNodes = ghostNodes.size();
25 int nofOctants = connectivity.size();
26 int nofGhosts = ghostConnectivity.size();
27 int nofAll = nofGhosts + nofOctants;
28 out <<
"<?xml version=\"1.0\"?>" << endl
29 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
30 <<
" <UnstructuredGrid>" << endl
31 <<
" <Piece NumberOfCells=\"" << connectivity.size() + ghostConnectivity.size() <<
"\" NumberOfPoints=\"" << nodes.size() + ghostNodes.size() <<
"\">" << endl;
32 out <<
" <Points>" << endl
33 <<
" <DataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\""<< 3 <<
"\" format=\"ascii\">" << endl
35 for(
int i = 0; i < nofNodes; i++)
37 for(
int j = 0; j < 3; ++j)
38 out << std::setprecision(6) << nodes[i][j] <<
" ";
39 if((i+1)%4==0 && i!=nofNodes-1)
42 for(
int i = 0; i < nofGhostNodes; i++)
44 for(
int j = 0; j < 3; ++j)
45 out << std::setprecision(6) << ghostNodes[i][j] <<
" ";
46 if((i+1)%4==0 && i!=nofNodes-1)
49 out << endl <<
" </DataArray>" << endl
50 <<
" </Points>" << endl
52 <<
" <DataArray type=\"UInt64\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
54 for(
int i = 0; i < nofOctants; i++)
56 for(
int j = 0; j < global2D.
nnodes; j++)
68 out << connectivity[i][jj] <<
" ";
70 if((i+1)%3==0 && i!=nofOctants-1)
73 for(
int i = 0; i < nofGhosts; i++)
75 for(
int j = 0; j < global2D.
nnodes; j++)
87 out << ghostConnectivity[i][jj] + nofNodes <<
" ";
89 if((i+1)%3==0 && i!=nofGhosts-1)
92 out << endl <<
" </DataArray>" << endl
93 <<
" <DataArray type=\"UInt64\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
95 for(
int i = 0; i < nofAll; i++)
97 out << (i+1)*global2D.
nnodes <<
" ";
98 if((i+1)%12==0 && i!=nofAll-1)
101 out << endl <<
" </DataArray>" << endl
102 <<
" <DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
104 for(
int i = 0; i < nofAll; i++)
109 if((i+1)%12==0 && i!=nofAll-1)
112 out << endl <<
" </DataArray>" << endl
113 <<
" </Cells>" << endl
114 <<
" </Piece>" << endl
115 <<
" </UnstructuredGrid>" << endl
116 <<
"</VTKFile>" << endl;
121 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-" << filename <<
".pvtu";
122 ofstream pout(name.str().c_str());
125 ss << filename <<
"*.pvtu cannot be opened and it won't be written.";
130 pout <<
"<?xml version=\"1.0\"?>" << endl
131 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
132 <<
" <PUnstructuredGrid GhostLevel=\"0\">" << endl
133 <<
" <PPointData>" << endl
134 <<
" </PPointData>" << endl
135 <<
" <PCellData Scalars=\"\">" << endl;
136 pout <<
" </PCellData>" << endl
137 <<
" <PPoints>" << endl
138 <<
" <PDataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\"3\"/>" << endl
139 <<
" </PPoints>" << endl;
140 for(
int i = 0; i < ptree.
nproc; i++)
141 pout <<
" <Piece Source=\"s" << std::setw(4) << std::setfill(
'0') << ptree.
nproc <<
"-p" << std::setw(4) << std::setfill(
'0') << i <<
"-" << filename <<
".vtu\"/>" << endl;
142 pout <<
" </PUnstructuredGrid>" << endl
149 MPI_Barrier(MPI_COMM_WORLD);
156 void writePhysicalTree(
const vector<vector<double> >& nodes,
const u32vector2D& connectivity,
157 const vector<vector<double> >& ghostNodes,
const u32vector2D& ghostConnectivity,
161 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-p" << std::setfill(
'0') << std::setw(4) << ptree.
rank <<
"-" << filename <<
".vtu";
163 ofstream out(name.str().c_str());
166 ss << filename <<
"*.vtu cannot be opened and it won't be written.";
170 int nofNodes = nodes.size();
171 int nofGhostNodes = ghostNodes.size();
172 int nofOctants = connectivity.size();
173 int nofGhosts = ghostConnectivity.size();
174 int nofAll = nofGhosts + nofOctants;
175 out <<
"<?xml version=\"1.0\"?>" << endl
176 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
177 <<
" <UnstructuredGrid>" << endl
178 <<
" <Piece NumberOfCells=\"" << connectivity.size() + ghostConnectivity.size() <<
"\" NumberOfPoints=\"" << nodes.size() + ghostNodes.size() <<
"\">" << endl;
179 out <<
" <Points>" << endl
180 <<
" <DataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\""<< 3 <<
"\" format=\"ascii\">" << endl
181 <<
" " << std::fixed;
182 for(
int i = 0; i < nofNodes; i++)
184 for(
int j = 0; j < 3; ++j)
185 out << std::setprecision(6) << nodes[i][j] <<
" ";
186 if((i+1)%4==0 && i!=nofNodes-1)
189 for(
int i = 0; i < nofGhostNodes; i++)
191 for(
int j = 0; j < 3; ++j)
192 out << std::setprecision(6) << ghostNodes[i][j] <<
" ";
193 if((i+1)%4==0 && i!=nofNodes-1)
196 out << endl <<
" </DataArray>" << endl
197 <<
" </Points>" << endl
198 <<
" <Cells>" << endl
199 <<
" <DataArray type=\"UInt64\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
201 for(
int i = 0; i < nofOctants; i++)
203 for(
int j = 0; j < global2D.
nnodes; j++)
215 out << connectivity[i][jj] <<
" ";
217 if((i+1)%3==0 && i!=nofOctants-1)
220 for(
int i = 0; i < nofGhosts; i++)
222 for(
int j = 0; j < global2D.
nnodes; j++)
234 out << ghostConnectivity[i][jj] + nofNodes <<
" ";
236 if((i+1)%3==0 && i!=nofGhosts-1)
239 out << endl <<
" </DataArray>" << endl
240 <<
" <DataArray type=\"UInt64\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
242 for(
int i = 0; i < nofAll; i++)
244 out << (i+1)*global2D.
nnodes <<
" ";
245 if((i+1)%12==0 && i!=nofAll-1)
248 out << endl <<
" </DataArray>" << endl
249 <<
" <DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
251 for(
int i = 0; i < nofAll; i++)
256 if((i+1)%12==0 && i!=nofAll-1)
259 out << endl <<
" </DataArray>" << endl
260 <<
" </Cells>" << endl
261 <<
" </Piece>" << endl
262 <<
" </UnstructuredGrid>" << endl
263 <<
"</VTKFile>" << endl;
268 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-" << filename <<
".pvtu";
269 ofstream pout(name.str().c_str());
272 ss << filename <<
"*.pvtu cannot be opened and it won't be written.";
277 pout <<
"<?xml version=\"1.0\"?>" << endl
278 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
279 <<
" <PUnstructuredGrid GhostLevel=\"0\">" << endl
280 <<
" <PPointData>" << endl
281 <<
" </PPointData>" << endl
282 <<
" <PCellData Scalars=\"\">" << endl;
283 pout <<
" </PCellData>" << endl
284 <<
" <PPoints>" << endl
285 <<
" <PDataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\"3\"/>" << endl
286 <<
" </PPoints>" << endl;
287 for(
int i = 0; i < ptree.
nproc; i++)
288 pout <<
" <Piece Source=\"s" << std::setw(4) << std::setfill(
'0') << ptree.
nproc <<
"-p" << std::setw(4) << std::setfill(
'0') << i <<
"-" << filename <<
".vtu\"/>" << endl;
289 pout <<
" </PUnstructuredGrid>" << endl
296 MPI_Barrier(MPI_COMM_WORLD);
303 void writeLocalTree(
const u32vector2D& nodes,
const u32vector2D& connectivity,
304 const u32vector2D& ghostNodes,
const u32vector2D& ghostConnectivity,
308 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-p" << std::setfill(
'0') << std::setw(4) << ptree.
rank <<
"-" << filename <<
".vtu";
310 ofstream out(name.str().c_str());
313 ss << filename <<
"*.vtu cannot be opened and it won't be written.";
317 int nofNodes = nodes.size();
318 int nofGhostNodes = ghostNodes.size();
319 int nofOctants = connectivity.size();
320 int nofGhosts = ghostConnectivity.size();
321 int nofAll = nofGhosts + nofOctants;
322 out <<
"<?xml version=\"1.0\"?>" << endl
323 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
324 <<
" <UnstructuredGrid>" << endl
325 <<
" <Piece NumberOfCells=\"" << connectivity.size() + ghostConnectivity.size() <<
"\" NumberOfPoints=\"" << nodes.size() + ghostNodes.size() <<
"\">" << endl;
326 out <<
" <Points>" << endl
327 <<
" <DataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\""<< 3 <<
"\" format=\"ascii\">" << endl
328 <<
" " << std::fixed;
329 for(
int i = 0; i < nofNodes; i++)
331 for(
int j = 0; j < 3; ++j)
332 out << std::setprecision(6) << nodes[i][j] <<
" ";
333 if((i+1)%4==0 && i!=nofNodes-1)
336 for(
int i = 0; i < nofGhostNodes; i++)
338 for(
int j = 0; j < 3; ++j)
339 out << std::setprecision(6) << ghostNodes[i][j] <<
" ";
340 if((i+1)%4==0 && i!=nofNodes-1)
343 out << endl <<
" </DataArray>" << endl
344 <<
" </Points>" << endl
345 <<
" <Cells>" << endl
346 <<
" <DataArray type=\"UInt64\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
348 for(
int i = 0; i < nofOctants; i++)
350 for(
int j = 0; j < global3D.
nnodes; j++)
352 out << connectivity[i][j] <<
" ";
354 if((i+1)%3==0 && i!=nofOctants-1)
357 for(
int i = 0; i < nofGhosts; i++)
359 for(
int j = 0; j < global3D.
nnodes; j++)
361 out << ghostConnectivity[i][j] + nofNodes <<
" ";
363 if((i+1)%3==0 && i!=nofGhosts-1)
366 out << endl <<
" </DataArray>" << endl
367 <<
" <DataArray type=\"UInt64\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
369 for(
int i = 0; i < nofAll; i++)
371 out << (i+1)*global2D.
nnodes <<
" ";
372 if((i+1)%12==0 && i!=nofAll-1)
375 out << endl <<
" </DataArray>" << endl
376 <<
" <DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
378 for(
int i = 0; i < nofAll; i++)
383 if((i+1)%12==0 && i!=nofAll-1)
386 out << endl <<
" </DataArray>" << endl
387 <<
" </Cells>" << endl
388 <<
" </Piece>" << endl
389 <<
" </UnstructuredGrid>" << endl
390 <<
"</VTKFile>" << endl;
395 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-" << filename <<
".pvtu";
396 ofstream pout(name.str().c_str());
399 ss << filename <<
"*.pvtu cannot be opened and it won't be written.";
404 pout <<
"<?xml version=\"1.0\"?>" << endl
405 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
406 <<
" <PUnstructuredGrid GhostLevel=\"0\">" << endl
407 <<
" <PPointData>" << endl
408 <<
" </PPointData>" << endl
409 <<
" <PCellData Scalars=\"\">" << endl;
410 pout <<
" </PCellData>" << endl
411 <<
" <PPoints>" << endl
412 <<
" <PDataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\"3\"/>" << endl
413 <<
" </PPoints>" << endl;
414 for(
int i = 0; i < ptree.
nproc; i++)
415 pout <<
" <Piece Source=\"s" << std::setw(4) << std::setfill(
'0') << ptree.
nproc <<
"-p" << std::setw(4) << std::setfill(
'0') << i <<
"-" << filename <<
".vtu\"/>" << endl;
416 pout <<
" </PUnstructuredGrid>" << endl
423 MPI_Barrier(MPI_COMM_WORLD);
430 void writePhysicalTree(
const vector<vector<double> >& nodes,
const u32vector2D& connectivity,
431 const vector<vector<double> >& ghostNodes,
const u32vector2D& ghostConnectivity,
435 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-p" << std::setfill(
'0') << std::setw(4) << ptree.
rank <<
"-" << filename <<
".vtu";
437 ofstream out(name.str().c_str());
440 ss << filename <<
"*.vtu cannot be opened and it won't be written.";
444 int nofNodes = nodes.size();
445 int nofGhostNodes = ghostNodes.size();
446 int nofOctants = connectivity.size();
447 int nofGhosts = ghostConnectivity.size();
448 int nofAll = nofGhosts + nofOctants;
449 out <<
"<?xml version=\"1.0\"?>" << endl
450 <<
"<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
451 <<
" <UnstructuredGrid>" << endl
452 <<
" <Piece NumberOfCells=\"" << connectivity.size() + ghostConnectivity.size() <<
"\" NumberOfPoints=\"" << nodes.size() + ghostNodes.size() <<
"\">" << endl;
453 out <<
" <Points>" << endl
454 <<
" <DataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\""<< 3 <<
"\" format=\"ascii\">" << endl
455 <<
" " << std::fixed;
456 for(
int i = 0; i < nofNodes; i++)
458 for(
int j = 0; j < 3; ++j)
459 out << std::setprecision(6) << nodes[i][j] <<
" ";
460 if((i+1)%4==0 && i!=nofNodes-1)
463 for(
int i = 0; i < nofGhostNodes; i++)
465 for(
int j = 0; j < 3; ++j)
466 out << std::setprecision(6) << ghostNodes[i][j] <<
" ";
467 if((i+1)%4==0 && i!=nofNodes-1)
470 out << endl <<
" </DataArray>" << endl
471 <<
" </Points>" << endl
472 <<
" <Cells>" << endl
473 <<
" <DataArray type=\"UInt64\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
475 for(
int i = 0; i < nofOctants; i++)
477 for(
int j = 0; j < global3D.
nnodes; j++)
479 out << connectivity[i][j] <<
" ";
481 if((i+1)%3==0 && i!=nofOctants-1)
484 for(
int i = 0; i < nofGhosts; i++)
486 for(
int j = 0; j < global3D.
nnodes; j++)
488 out << ghostConnectivity[i][j] + nofNodes <<
" ";
490 if((i+1)%3==0 && i!=nofGhosts-1)
493 out << endl <<
" </DataArray>" << endl
494 <<
" <DataArray type=\"UInt64\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
496 for(
int i = 0; i < nofAll; i++)
498 out << (i+1)*global2D.
nnodes <<
" ";
499 if((i+1)%12==0 && i!=nofAll-1)
502 out << endl <<
" </DataArray>" << endl
503 <<
" <DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" << endl
505 for(
int i = 0; i < nofAll; i++)
510 if((i+1)%12==0 && i!=nofAll-1)
513 out << endl <<
" </DataArray>" << endl
514 <<
" </Cells>" << endl
515 <<
" </Piece>" << endl
516 <<
" </UnstructuredGrid>" << endl
517 <<
"</VTKFile>" << endl;
522 name <<
"s" << std::setfill(
'0') << std::setw(4) << ptree.
nproc <<
"-" << filename <<
".pvtu";
523 ofstream pout(name.str().c_str());
526 ss << filename <<
"*.pvtu cannot be opened and it won't be written.";
531 pout <<
"<?xml version=\"1.0\"?>" << endl
532 <<
"<VTKFile type=\"PUnstructuredGrid\" version=\"0.1\" byte_order=\"BigEndian\">" << endl
533 <<
" <PUnstructuredGrid GhostLevel=\"0\">" << endl
534 <<
" <PPointData>" << endl
535 <<
" </PPointData>" << endl
536 <<
" <PCellData Scalars=\"\">" << endl;
537 pout <<
" </PCellData>" << endl
538 <<
" <PPoints>" << endl
539 <<
" <PDataArray type=\"Float64\" Name=\"Coordinates\" NumberOfComponents=\"3\"/>" << endl
540 <<
" </PPoints>" << endl;
541 for(
int i = 0; i < ptree.
nproc; i++)
542 pout <<
" <Piece Source=\"s" << std::setw(4) << std::setfill(
'0') << ptree.
nproc <<
"-p" << std::setw(4) << std::setfill(
'0') << i <<
"-" << filename <<
".vtu\"/>" << endl;
543 pout <<
" </PUnstructuredGrid>" << endl
550 MPI_Barrier(MPI_COMM_WORLD);
Parallel Octree Manager Class - 3D specialization.
Parallel Octree Manager Class - 2D specialization.