19 #include <openvdb/openvdb.h> 22 #include <vtk-7.1/vtkSmartPointer.h> 23 #include <vtk-7.1/vtkXMLImageDataWriter.h> 24 #include <vtk-7.1/vtkXMLImageDataReader.h> 25 #include <vtk-7.1/vtkImageData.h> 26 #include <vtk-7.1/vtkPointData.h> 27 #include <vtk-7.1/vtkCellData.h> 28 #include <vtk-7.1/vtkDataArray.h> 29 #include <vtk-7.1/vtkDoubleArray.h> 30 #include <vtk-7.1/vtkFloatArray.h> 31 #include <vtk-7.1/vtkIntArray.h> 32 #include <vtk-7.1/vtkTypeUInt64Array.h> 43 template<
class T_VDBGr
idType>
46 VTIWriter(std::shared_ptr<T_VDBGridType> VDBGrid_Ptr,
const std::string &FileName,
float voxelSize) {
47 m_FileNameExt = FileName +
".vti";
49 VDBGrid_Ptr->treePtr()->evalActiveVoxelBoundingBox(m_bbox);
51 m_VTKimageData_Ptr = vtkSmartPointer<vtkImageData>::New();
52 m_VTKimageData_Ptr->SetDimensions(m_bbox.dim().x(), m_bbox.dim().y(), m_bbox.dim().z());
53 m_VTKimageData_Ptr->SetExtent(m_bbox.min().x(), m_bbox.max().x(), m_bbox.min().y(), m_bbox.max().y(), m_bbox.min().z(), m_bbox.max().z());
54 m_VTKimageData_Ptr->SetSpacing(voxelSize, voxelSize, voxelSize);
55 m_pointNumber = m_VTKimageData_Ptr->GetNumberOfPoints();
56 m_VDBGrid_Ptr = VDBGrid_Ptr;
62 static std::shared_ptr<MF::RW::VTIWriter<T_VDBGridType>>
New(std::shared_ptr<T_VDBGridType> VDBGrid_Ptr,
const std::string &FileName,
float voxelSize) {
63 auto VTIWriter_Ptr = std::make_shared<MF::RW::VTIWriter<T_VDBGridType>>(VDBGrid_Ptr, FileName, voxelSize);
69 vtkSmartPointer<vtkImageData> m_VTKimageData_Ptr;
70 std::shared_ptr<T_VDBGridType> m_VDBGrid_Ptr;
71 std::string m_FileNameExt;
72 openvdb::CoordBBox m_bbox;
73 uint64_t m_pointNumber;
78 void addDataFromGrid(
const std::string &DataName,
unsigned int numComponents, std::shared_ptr<T_VDBGridType> VDBGrid_Ptr){
79 auto newData = vtkSmartPointer<T3>::New();
80 newData->SetNumberOfComponents(numComponents);
81 newData->SetNumberOfTuples(m_VTKimageData_Ptr->GetNumberOfPoints());
82 newData->SetName(DataName.c_str());
85 auto accessor = VDBGrid_Ptr->getAccessor();
88 double tuple[numComponents];
89 for (
unsigned int n=0; n<numComponents; ++n) tuple[n] = NAN;
90 int32_t &i = ijk[0], &j = ijk[1], &k = ijk[2];
92 for (k = m_bbox.min().z(); k <= m_bbox.max().z(); ++k) {
93 for (j = m_bbox.min().y(); j <= m_bbox.max().y(); ++j) {
94 for (i = m_bbox.min().x(); i <= m_bbox.max().x(); ++i) {
95 for(
unsigned int n=0; n<numComponents; ++n)
96 tuple[n] = accessor.getValue(ijk);
97 newData->SetTuple(nr, tuple);
102 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
105 template<
typename T3>
107 auto newData = vtkSmartPointer<T3>::New();
108 newData->SetNumberOfComponents(numComponents);
109 newData->SetNumberOfTuples(m_pointNumber);
110 newData->SetName(DataName.c_str());
113 auto accessor = m_VDBGrid_Ptr->getAccessor();
116 double tuple[numComponents];
117 for (
unsigned int n=0; n<numComponents; ++n)
120 int32_t &i = ijk[0], &j = ijk[1], &k = ijk[2];
122 for (k = m_bbox.min().z(); k <= m_bbox.max().z(); ++k) {
123 for (j = m_bbox.min().y(); j <= m_bbox.max().y(); ++j) {
124 for (i = m_bbox.min().x(); i <= m_bbox.max().x(); ++i) {
125 for(
unsigned int n=0; n<numComponents; ++n)
126 tuple[n] = accessor.getValue(ijk);
127 newData->SetTuple(nr, tuple);
132 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
136 auto newData = vtkSmartPointer<vtkTypeUInt64Array>::New();
137 newData->SetNumberOfComponents(1);
138 newData->SetNumberOfTuples(m_pointNumber);
139 newData->SetName(
"Node ID");
142 auto accessor = m_VDBGrid_Ptr->getAccessor();
145 double tuple[1] = {0};
146 int32_t &i = ijk[0], &j = ijk[1], &k = ijk[2];
148 for (k = m_bbox.min().z(); k <= m_bbox.max().z(); ++k) {
149 for (j = m_bbox.min().y(); j <= m_bbox.max().y(); ++j) {
150 for (i = m_bbox.min().x(); i <= m_bbox.max().x(); ++i) {
151 tuple[0] = accessor.getValue(ijk);
152 newData->SetTuple(nr, tuple);
157 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
161 auto newData = vtkSmartPointer<vtkIntArray>::New();
162 newData->SetNumberOfComponents(3);
163 newData->SetNumberOfTuples(m_pointNumber);
164 newData->SetName(
"MF NodeCoord");
167 auto accessor = m_VDBGrid_Ptr->getAccessor();
170 double tuple[3] ={NAN,NAN,NAN};
171 for (
auto i = 0; i < m_pointNumber; ++i) {
172 newData->SetTuple(i, tuple);
174 int32_t &i = ijk[0], &j = ijk[1], &k = ijk[2];
176 for (k = m_bbox.min().z(); k <= m_bbox.max().z(); ++k) {
177 for (j = m_bbox.min().y(); j <= m_bbox.max().y(); ++j) {
178 for (i = m_bbox.min().x(); i <= m_bbox.max().x(); ++i) {
179 if (accessor.getValue(ijk) != 0) {
183 newData->SetTuple(nr, tuple);
189 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
192 template<
typename T3_VTKArrayType,
typename T4>
193 void addDataFromTable(
const std::string &DataName,
unsigned int numComponents, std::vector<T4> &table_Ptr) {
194 vtkSmartPointer<T3_VTKArrayType> newData = vtkSmartPointer<T3_VTKArrayType>::New();
195 newData->SetNumberOfComponents(numComponents);
196 newData->SetNumberOfTuples(m_pointNumber);
197 newData->SetName(DataName.c_str());
199 double tuple[numComponents];
200 for (
unsigned int n=0; n<numComponents; ++n)
203 for (
auto i = 0; i < m_pointNumber; ++i) {
204 for(
unsigned int n=0; n<numComponents; ++n)
205 tuple[n] = table_Ptr[i*numComponents+n];
206 newData->SetTuple(i, tuple);
208 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
212 vtkSmartPointer<vtkIntArray> newData = vtkSmartPointer<vtkIntArray>::New();
213 newData->SetNumberOfComponents(3);
214 newData->SetNumberOfTuples(m_pointNumber);
215 newData->SetName(
"MF NodeCoord");
216 const uint32_t Nx = m_bbox.dim().x();
217 const uint32_t Ny = m_bbox.dim().y();
219 double tuple[3] = {NAN,NAN,NAN};
220 for (
auto i = 0; i < m_pointNumber; ++i) {
221 newData->SetTuple(i, tuple);
223 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
224 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
225 tuple[0] = thread->m_Coordinate_Ptr->operator[](node).x;
226 tuple[1] = thread->m_Coordinate_Ptr->operator[](node).y;
227 tuple[2] = thread->m_Coordinate_Ptr->operator[](node).z;
228 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
229 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
230 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
231 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
232 newData->SetTuple(node_nr, tuple);
235 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
239 vtkSmartPointer<vtkIntArray> newData = vtkSmartPointer<vtkIntArray>::New();
240 newData->SetNumberOfComponents(1);
241 newData->SetNumberOfTuples(m_pointNumber);
242 newData->SetName(
"Node type");
243 const uint32_t Nx = m_bbox.dim().x();
244 const uint32_t Ny = m_bbox.dim().y();
246 double tuple[1] = {0};
247 for (
auto i = 0; i < m_pointNumber; ++i) {
248 newData->SetTuple(i, tuple);
250 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
251 tuple[0] = thread.get()->m_NodeType;
252 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
253 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
254 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
255 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
256 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
257 newData->SetTuple(node_nr, tuple);
260 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
264 vtkSmartPointer<vtkIntArray> newData = vtkSmartPointer<vtkIntArray>::New();
265 newData->SetNumberOfComponents(1);
266 newData->SetNumberOfTuples(m_pointNumber);
267 newData->SetName(
"Node uidThreadNr");
268 const uint32_t Nx = m_bbox.dim().x();
269 const uint32_t Ny = m_bbox.dim().y();
271 double tuple[1] = {NAN};
272 for (
auto i = 0; i < m_pointNumber; ++i) {
273 newData->SetTuple(i, tuple);
275 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
276 tuple[0] = thread.get()->m_uidThreadNr;
277 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
278 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
279 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
280 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
281 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
282 newData->SetTuple(node_nr, tuple);
285 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
290 auto threadVectorName = std::vector<std::string>();
291 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
292 std::string threadName = thread.get()->m_ThreadName;
293 if (!threadName.empty()) {
294 unsigned int number = 0;
295 for (
auto & vec_it : threadVectorName) {
296 if (vec_it == threadName)
300 threadVectorName.push_back(threadName);
304 for (
auto & vec_it : threadVectorName) {
305 vtkSmartPointer<vtkIntArray> newData = vtkSmartPointer<vtkIntArray>::New();
306 newData->SetNumberOfComponents(1);
307 newData->SetNumberOfTuples(m_pointNumber);
308 newData->SetName(vec_it.c_str());
309 const uint32_t Nx = m_bbox.dim().x();
310 const uint32_t Ny = m_bbox.dim().y();
312 double tuple[1] = {0};
313 for (
auto i = 0; i < m_pointNumber; ++i)
314 newData->SetTuple(i, tuple);
316 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
317 if (vec_it == thread.get()->m_ThreadName) {
318 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
319 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
320 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
321 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
322 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
323 newData->SetTuple(node_nr, tuple);
327 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
332 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
333 newData->SetNumberOfComponents(3);
334 newData->SetNumberOfTuples(m_pointNumber);
335 newData->SetName(
"Velocity LB [-]");
336 const uint32_t Nx = m_bbox.dim().x();
337 const uint32_t Ny = m_bbox.dim().y();
339 double tuple[3] = {NAN,NAN,NAN};
340 for (
auto i = 0; i < m_pointNumber; ++i) {
341 newData->SetTuple(i, tuple);
343 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
344 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
346 tuple[0] = Vector4.
x;
347 tuple[1] = Vector4.
y;
348 tuple[2] = Vector4.
z;
349 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
350 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
351 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
352 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
353 newData->SetTuple(node_nr, tuple);
356 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
360 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
361 newData->SetNumberOfComponents(3);
362 newData->SetNumberOfTuples(m_pointNumber);
363 newData->SetName(
"Initial velocity LB [-]");
364 const uint32_t Nx = m_bbox.dim().x();
365 const uint32_t Ny = m_bbox.dim().y();
367 double tuple[3] = {NAN,NAN,NAN};
368 for (
auto i = 0; i < m_pointNumber; ++i) {
369 newData->SetTuple(i, tuple);
371 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
372 tuple[0] = thread.get()->m_BoundaryValue_ULB.x;
373 tuple[1] = thread.get()->m_BoundaryValue_ULB.y;
374 tuple[2] = thread.get()->m_BoundaryValue_ULB.z;
375 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
376 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
377 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
378 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
379 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
380 newData->SetTuple(node_nr, tuple);
383 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
387 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
388 newData->SetNumberOfComponents(3);
389 newData->SetNumberOfTuples(m_pointNumber);
390 newData->SetName(
"Velocity [m/s]");
391 const uint32_t Nx = m_bbox.dim().x();
392 const uint32_t Ny = m_bbox.dim().y();
394 double tuple[3] = {NAN,NAN,NAN};
395 for (
auto i = 0; i < m_pointNumber; ++i) {
396 newData->SetTuple(i, tuple);
398 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
399 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
404 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
405 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
406 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
407 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
408 newData->SetTuple(node_nr, tuple);
411 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
415 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
416 newData->SetNumberOfComponents(1);
417 newData->SetNumberOfTuples(m_pointNumber);
418 newData->SetName(
"Rho LB [-]");
419 const uint32_t Nx = m_bbox.dim().x();
420 const uint32_t Ny = m_bbox.dim().y();
422 double tuple[1] = {NAN};
423 for (
size_t i = 0; i < m_pointNumber; ++i) {
424 newData->SetTuple(i, tuple);
426 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
427 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
429 tuple[0] = Vector4.
rho;
430 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
431 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
432 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
433 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
434 newData->SetTuple(node_nr, tuple);
437 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
441 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
442 newData->SetNumberOfComponents(1);
443 newData->SetNumberOfTuples(m_pointNumber);
444 newData->SetName(
"Initial rho LB [-]");
445 const uint32_t Nx = m_bbox.dim().x();
446 const uint32_t Ny = m_bbox.dim().y();
448 double tuple[1] = {NAN};
449 for (
size_t i = 0; i < m_pointNumber; ++i) {
450 newData->SetTuple(i, tuple);
452 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
453 tuple[0] = thread.get()->m_BoundaryValue_RhoLB;
454 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
455 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
456 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
457 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
458 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
459 newData->SetTuple(node_nr, tuple);
462 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
466 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
467 newData->SetNumberOfComponents(1);
468 newData->SetNumberOfTuples(m_pointNumber);
469 newData->SetName(
"Rho [kg/m3]");
470 const uint32_t Nx = m_bbox.dim().x();
471 const uint32_t Ny = m_bbox.dim().y();
473 double tuple[1] = {NAN};
474 for (
auto i = 0; i < m_pointNumber; ++i) {
475 newData->SetTuple(i, tuple);
477 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
478 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
481 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
482 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
483 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
484 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
485 newData->SetTuple(node_nr, tuple);
488 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
492 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
493 newData->SetNumberOfComponents(1);
494 newData->SetNumberOfTuples(m_pointNumber);
495 newData->SetName(
"Gauge pressure [Pa]");
496 const uint32_t Nx = m_bbox.dim().x();
497 const uint32_t Ny = m_bbox.dim().y();
499 double tuple[1] = {NAN};
500 for (
auto i = 0; i < m_pointNumber; ++i) {
501 newData->SetTuple(i, tuple);
503 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
504 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
507 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
508 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
509 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
510 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
511 newData->SetTuple(node_nr, tuple);
514 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
518 vtkSmartPointer<vtkDoubleArray> newData = vtkSmartPointer<vtkDoubleArray>::New();
519 newData->SetNumberOfComponents(
MFQ19);
520 newData->SetNumberOfTuples(m_pointNumber);
521 newData->SetName(
"FQ19");
522 const uint32_t Nx = m_bbox.dim().x();
523 const uint32_t Ny = m_bbox.dim().y();
525 double tuple[
MFQ19] = {NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN, NAN};
526 for (
auto i = 0; i < m_pointNumber; ++i) {
527 newData->SetTuple(i, tuple);
529 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
530 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
531 for (
unsigned int i = 0; i <
MFQ19; i++)
532 tuple[i] = thread->m_NodeArray_Ptr->operator[](node).FQ19[i];
533 const uint32_t X = thread->m_Coordinate_Ptr->operator[](node).x - m_bbox.min().x();
534 const uint32_t Y = thread->m_Coordinate_Ptr->operator[](node).y - m_bbox.min().y();
535 const uint32_t Z = thread->m_Coordinate_Ptr->operator[](node).z - m_bbox.min().z();
536 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
537 newData->SetTuple(node_nr, tuple);
540 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
544 for (uint8_t k = 0; k <
MFQ19; k++) {
545 vtkSmartPointer<vtkIntArray> newData = vtkSmartPointer<vtkIntArray>::New();
546 newData->SetNumberOfComponents(3);
547 newData->SetNumberOfTuples(m_pointNumber);
548 const std::string dataName =
"PD" + std::to_string(k) +
" [x,y,z]";
549 newData->SetName(dataName.c_str());
550 const uint32_t Nx = m_bbox.dim().x();
551 const uint32_t Ny = m_bbox.dim().y();
552 double tuple[3] = {NAN, NAN, NAN};
553 for (
auto i = 0; i < m_pointNumber; ++i)
554 newData->SetTuple(i, tuple);
556 for (
auto & thread : *ThreadArray_Ptr->m_ThreadsTable_Ptr) {
557 for (
size_t node = 0; node < thread->m_NodeArray_Ptr->size(); node++) {
558 if (thread->getLinkedNodePointer(node, k) !=
nullptr) {
559 auto neighbNodeNr = thread->getLinkedNodePointer(node, k)-> pMyThread_Ptr->operator*().getNodeNr(thread->getLinkedNodePointer(node, k));
560 tuple[0] = thread->getLinkedNodePointer(node, k)-> pMyThread_Ptr->operator*().getNodeCoordX(neighbNodeNr);
561 tuple[1] = thread->getLinkedNodePointer(node, k)-> pMyThread_Ptr->operator*().getNodeCoordY(neighbNodeNr);
562 tuple[2] = thread->getLinkedNodePointer(node, k)-> pMyThread_Ptr->operator*().getNodeCoordZ(neighbNodeNr);
563 const uint32_t X = thread->getNodeCoordX(node) - m_bbox.min().x();
564 const uint32_t Y = thread->getNodeCoordY(node) - m_bbox.min().y();
565 const uint32_t Z = thread->getNodeCoordZ(node) - m_bbox.min().z();
566 const uint64_t node_nr = (Z * Ny + Y) * Nx + X;
567 newData->SetTuple(node_nr, tuple);
571 m_VTKimageData_Ptr->GetPointData()->AddArray(newData);
576 vtkSmartPointer<vtkXMLImageDataWriter> writer = vtkSmartPointer<vtkXMLImageDataWriter>::New();
577 writer->SetFileName(m_FileNameExt.c_str());
578 writer->SetInputData(m_VTKimageData_Ptr);
580 std::cout <<
"VTI file was saved successfully: ----> " << m_FileNameExt << std::endl;
void addPressPhysFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
#define MFQ19
Number of lattice directions D3Q19.
void addNodeTypeFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addNodeCoordinateFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addPropagationDirFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addDataFromGrid(const std::string &DataName, unsigned int numComponents, std::shared_ptr< T_VDBGridType > VDBGrid_Ptr)
VTIWriter(std::shared_ptr< T_VDBGridType > VDBGrid_Ptr, const std::string &FileName, float voxelSize)
void addRhoLBFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addNodeThreadsByNameThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addDataFromTable(const std::string &DataName, unsigned int numComponents, std::vector< T4 > &table_Ptr)
void addInitialRhoLBFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addRhoPhysFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addVelocityLBFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
static double RhoLB_toRhoPhys(double rho_LB)
Converts rho LB to physical density.
void addNodeCoordinateFromGrid()
void addFQ19FromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
static std::shared_ptr< MF::RW::VTIWriter< T_VDBGridType > > New(std::shared_ptr< T_VDBGridType > VDBGrid_Ptr, const std::string &FileName, float voxelSize)
void addDataFromGrid(const std::string &DataName, unsigned int numComponents)
void addVelocityPhysFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
static double RhoLB_toPressurePhys(double rho_LB)
Converts rho LB to physical pressure.
static double ULB_toPhys(double u_LB)
Converts LB velocity to physical velocity.
void addUidThreadFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
void addInitialVelocityLBFromThread(const std::shared_ptr< MF::Database::ThreadArray > &ThreadArray_Ptr)
The VTIWriter class provides a write interface for data storage in .vti format.