OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
VTKWriter_unit_tests.hpp
1/*
2 * VTKWriter_unit_tests.hpp
3 *
4 * Created on: May 6, 2015
5 * Author: Pietro Incardona
6 *
7 * Modified by Abhinav Singh May 17, 2021
8 */
9
10#ifndef VTKWRITER_UNIT_TESTS_HPP_
11#define VTKWRITER_UNIT_TESTS_HPP_
12
13#include "data_type/aggregate.hpp"
14#include <random>
15#include "VTKWriter.hpp"
16#include "util/SimpleRNG.hpp"
17
18BOOST_AUTO_TEST_SUITE( vtk_writer_test )
19
20
23struct vertex
24{
26 typedef boost::fusion::vector<float,float,float,float,size_t,double,unsigned char,long int> type;
27
29 typedef float s_type;
30
33 {
34 static const std::string name[];
35 };
36
39
41 static const unsigned int x = 0;
43 static const unsigned int y = 1;
45 static const unsigned int z = 2;
47 static const unsigned int prp1 = 3;
49 static const unsigned int prp2 = 4;
51 static const unsigned int prp3 = 5;
53 static const unsigned int prp4 = 6;
55 static const unsigned int prp5 = 7;
56
58 static const unsigned int max_prop = 8;
59
65 {
66
67 }
68
69 static inline bool noPointers()
70 {
71 return true;
72 }
73
81 vertex(float x, float y, float z)
82 {
83 boost::fusion::at_c<vertex::x>(data) = x;
84 boost::fusion::at_c<vertex::y>(data) = y;
85 boost::fusion::at_c<vertex::z>(data) = z;
86 }
87};
88
89const std::string vertex::attributes::name[] = {"x","y","z","prp1","prp2","prp3","prp4","prp5"};
90
91struct vertex2
92{
94 typedef boost::fusion::vector<float[3],size_t,double> type;
95
97 typedef float s_type;
98
101 {
102 static const std::string name[];
103 };
104
107
109 static const unsigned int x = 0;
110 static const unsigned int prp1 = 1;
111 static const unsigned int prp2 = 2;
112
114 static const unsigned int max_prop = 3;
115
121 {
122
123 }
124
125 static inline bool noPointers()
126 {
127 return true;
128 }
129
137 vertex2(float x, float y, float z)
138 {
139 boost::fusion::at_c<vertex::x>(data)[0] = x;
140 boost::fusion::at_c<vertex::x>(data)[1] = y;
141 boost::fusion::at_c<vertex::x>(data)[2] = z;
142 }
143};
144
145// use the vertex like the edge
146typedef vertex edge;
147
148const std::string vertex2::attributes::name[] = {"x","prp1","prp2"};
149
150
151
152BOOST_AUTO_TEST_CASE( vtk_writer_use_graph3D )
153{
154 Vcluster<> & v_cl = create_vcluster();
155
156 if (v_cl.getProcessUnitID() != 0)
157 return;
158
159 // Create some graphs and output them
160
161 // Graph
162
164
165 // Create a cube graph
166
167 gr.addVertex(vertex2(0.0,0.0,0.0));
168 gr.addVertex(vertex2(0.0,0.0,1.0));
169 gr.addVertex(vertex2(0.0,1.0,0.0));
170 gr.addVertex(vertex2(0.0,1.0,1.0));
171 gr.addVertex(vertex2(1.0,0.0,0.0));
172 gr.addVertex(vertex2(1.0,0.0,1.0));
173 gr.addVertex(vertex2(1.0,1.0,0.0));
174 gr.addVertex(vertex2(1.0,1.0,1.0));
175
176 gr.addEdge(0,6);
177 gr.addEdge(6,4);
178 gr.addEdge(4,0);
179
180 gr.addEdge(0,2);
181 gr.addEdge(2,6);
182 gr.addEdge(6,0);
183
184 gr.addEdge(0,3);
185 gr.addEdge(3,2);
186 gr.addEdge(2,0);
187
188 gr.addEdge(0,1);
189 gr.addEdge(1,3);
190 gr.addEdge(3,0);
191
192 gr.addEdge(2,7);
193 gr.addEdge(7,6);
194 gr.addEdge(6,2);
195
196 gr.addEdge(2,3);
197 gr.addEdge(3,7);
198 gr.addEdge(7,2);
199
200 gr.addEdge(4,6);
201 gr.addEdge(6,7);
202 gr.addEdge(7,4);
203
204 gr.addEdge(4,7);
205 gr.addEdge(7,5);
206 gr.addEdge(5,4);
207
208 gr.addEdge(0,4);
209 gr.addEdge(4,5);
210 gr.addEdge(5,0);
211
212 gr.addEdge(0,5);
213 gr.addEdge(5,1);
214 gr.addEdge(1,0);
215
216 gr.addEdge(1,5);
217 gr.addEdge(5,7);
218 gr.addEdge(7,1);
219
220 gr.addEdge(1,7);
221 gr.addEdge(7,3);
222 gr.addEdge(3,1);
223
224 // Write the VTK file
225
226#ifdef OPENFPM_PDATA
227
228 if (v_cl.rank() != 0) {return;}
229 std::string c2 = std::string("openfpm_io/test_data/vtk_graph_v2_test.vtk");
230
231#else
232
233 std::string c2 = std::string("test_data/vtk_graph_v2_test.vtk");
234
235#endif
236
237 VTKWriter<Graph_CSR<vertex2,edge>,VTK_GRAPH> vtk(gr);
238 vtk.write("vtk_graph_v2.vtk");
239
240 // check that match
241
242 bool test = compare("vtk_graph_v2.vtk",c2);
243 BOOST_REQUIRE_EQUAL(true,test);
244}
245
246BOOST_AUTO_TEST_CASE( vtk_writer_use_graph3D_edge )
247{
248 Vcluster<> & v_cl = create_vcluster();
249
250 if (v_cl.getProcessUnitID() != 0)
251 return;
252
253 // Create some graphs and output them
254
255 // Graph
256
258
259 // Create a cube graph
260
261 gr.addVertex(vertex2(0.0,0.0,0.0));
262 gr.addVertex(vertex2(0.0,0.0,1.0));
263 gr.addVertex(vertex2(0.0,1.0,0.0));
264 gr.addVertex(vertex2(0.0,1.0,1.0));
265 gr.addVertex(vertex2(1.0,0.0,0.0));
266 gr.addVertex(vertex2(1.0,0.0,1.0));
267 gr.addVertex(vertex2(1.0,1.0,0.0));
268 gr.addVertex(vertex2(1.0,1.0,1.0));
269
270 gr.addEdge(0,6,vertex2(0.0,0.0,1.0));
271 gr.addEdge(6,4,vertex2(0.0,0.0,1.0));
272 gr.addEdge(4,0,vertex2(0.0,0.0,1.0));
273
274 gr.addEdge(0,2,vertex2(0.0,0.0,1.0));
275 gr.addEdge(2,6,vertex2(0.0,0.0,1.0));
276 gr.addEdge(6,0,vertex2(0.0,0.0,1.0));
277
278 gr.addEdge(0,3,vertex2(0.0,0.0,1.0));
279 gr.addEdge(3,2,vertex2(0.0,0.0,1.0));
280 gr.addEdge(2,0,vertex2(0.0,0.0,1.0));
281
282 gr.addEdge(0,1,vertex2(0.0,0.0,1.0));
283 gr.addEdge(1,3,vertex2(0.0,0.0,1.0));
284 gr.addEdge(3,0,vertex2(0.0,0.0,1.0));
285
286 gr.addEdge(2,7,vertex2(0.0,0.0,1.0));
287 gr.addEdge(7,6,vertex2(0.0,0.0,1.0));
288 gr.addEdge(6,2,vertex2(0.0,0.0,1.0));
289
290 gr.addEdge(2,3,vertex2(0.0,0.0,1.0));
291 gr.addEdge(3,7,vertex2(0.0,0.0,1.0));
292 gr.addEdge(7,2,vertex2(0.0,0.0,1.0));
293
294 gr.addEdge(4,6,vertex2(0.0,0.0,1.0));
295 gr.addEdge(6,7,vertex2(0.0,0.0,1.0));
296 gr.addEdge(7,4,vertex2(0.0,0.0,1.0));
297
298 gr.addEdge(4,7,vertex2(0.0,0.0,1.0));
299 gr.addEdge(7,5,vertex2(0.0,0.0,1.0));
300 gr.addEdge(5,4,vertex2(0.0,0.0,1.0));
301
302 gr.addEdge(0,4,vertex2(0.0,0.0,1.0));
303 gr.addEdge(4,5,vertex2(0.0,0.0,1.0));
304 gr.addEdge(5,0,vertex2(0.0,0.0,1.0));
305
306 gr.addEdge(0,5,vertex2(0.0,0.0,1.0));
307 gr.addEdge(5,1,vertex2(0.0,0.0,1.0));
308 gr.addEdge(1,0,vertex2(0.0,0.0,1.0));
309
310 gr.addEdge(1,5,vertex2(0.0,0.0,1.0));
311 gr.addEdge(5,7,vertex2(0.0,0.0,1.0));
312 gr.addEdge(7,1,vertex2(0.0,0.0,1.0));
313
314 gr.addEdge(1,7,vertex2(0.0,0.0,1.0));
315 gr.addEdge(7,3,vertex2(0.0,0.0,1.0));
316 gr.addEdge(3,1,vertex2(0.0,0.0,1.0));
317
318 // Write the VTK file
319
320#ifdef OPENFPM_PDATA
321
322 if (v_cl.rank() != 0) {return;}
323 std::string c2 = std::string("openfpm_io/test_data/vtk_graph_v4_test.vtk");
324
325#else
326
327 std::string c2 = std::string("test_data/vtk_graph_v4_test.vtk");
328
329#endif
330
331 VTKWriter<Graph_CSR<vertex2,vertex2>,VTK_GRAPH> vtk(gr);
332 vtk.write("vtk_graph_v4.vtk");
333
334 // check that match
335
336 bool test = compare("vtk_graph_v4.vtk",c2);
337 BOOST_REQUIRE_EQUAL(true,test);
338}
339
341{
343 typedef boost::fusion::vector<float[2],size_t,double> type;
344
346 typedef float s_type;
347
350 {
351 static const std::string name[];
352 };
353
356
358 static const unsigned int x = 0;
359 static const unsigned int prp1 = 1;
360 static const unsigned int prp2 = 2;
361
363 static const unsigned int max_prop = 3;
364
370 {
371
372 }
373
374 static inline bool noPointers()
375 {
376 return true;
377 }
378
384 vertex3(float x, float y)
385 {
386 boost::fusion::at_c<vertex::x>(data)[0] = x;
387 boost::fusion::at_c<vertex::x>(data)[1] = y;
388 }
389};
390
391// use the vertex like the edge
392typedef vertex edge;
393
394const std::string vertex3::attributes::name[] = {"x","prp1","prp2"};
395
396BOOST_AUTO_TEST_CASE( vtk_writer_use_graph2D )
397{
398 Vcluster<> & v_cl = create_vcluster();
399
400 if (v_cl.getProcessUnitID() != 0)
401 return;
402
403 // Create some graphs and output them
404
405 // Graph
406
408
409 // Create a cube graph
410
411 gr.addVertex(vertex3(0.0,0.0));
412 gr.addVertex(vertex3(0.0,1.0));
413 gr.addVertex(vertex3(1.0,0.0));
414 gr.addVertex(vertex3(1.0,1.0));
415
416 gr.addEdge(0,1);
417 gr.addEdge(1,3);
418 gr.addEdge(3,2);
419 gr.addEdge(2,0);
420
421 // Write the VTK file
422
423#ifdef OPENFPM_PDATA
424
425 if (v_cl.rank() != 0) {return;}
426 std::string c2 = std::string("openfpm_io/test_data/vtk_graph_v3_test.vtk");
427
428#else
429
430 std::string c2 = std::string("test_data/vtk_graph_v3_test.vtk");
431
432#endif
433
434 VTKWriter<Graph_CSR<vertex3,edge>,VTK_GRAPH> vtk(gr);
435 vtk.write("vtk_graph_v3.vtk");
436
437 // check that match
438
439 bool test = compare("vtk_graph_v3.vtk",c2);
440 BOOST_REQUIRE_EQUAL(true,test);
441}
442
443BOOST_AUTO_TEST_CASE( vtk_writer_use_graph)
444{
445 Vcluster<> & v_cl = create_vcluster();
446
447 if (v_cl.getProcessUnitID() != 0)
448 return;
449
450 // Create some graphs and output them
451
452 std::cout << "Graph unit test start" << "\n";
453
454 // Graph
455
457
458 // Create a cube graph
459
460 gr.addVertex(vertex(0.0,0.0,0.0));
461 gr.addVertex(vertex(0.0,0.0,1.0));
462 gr.addVertex(vertex(0.0,1.0,0.0));
463 gr.addVertex(vertex(0.0,1.0,1.0));
464 gr.addVertex(vertex(1.0,0.0,0.0));
465 gr.addVertex(vertex(1.0,0.0,1.0));
466 gr.addVertex(vertex(1.0,1.0,0.0));
467 gr.addVertex(vertex(1.0,1.0,1.0));
468
469 gr.addEdge(0,6);
470 gr.addEdge(6,4);
471 gr.addEdge(4,0);
472
473 gr.addEdge(0,2);
474 gr.addEdge(2,6);
475 gr.addEdge(6,0);
476
477 gr.addEdge(0,3);
478 gr.addEdge(3,2);
479 gr.addEdge(2,0);
480
481 gr.addEdge(0,1);
482 gr.addEdge(1,3);
483 gr.addEdge(3,0);
484
485 gr.addEdge(2,7);
486 gr.addEdge(7,6);
487 gr.addEdge(6,2);
488
489 gr.addEdge(2,3);
490 gr.addEdge(3,7);
491 gr.addEdge(7,2);
492
493 gr.addEdge(4,6);
494 gr.addEdge(6,7);
495 gr.addEdge(7,4);
496
497 gr.addEdge(4,7);
498 gr.addEdge(7,5);
499 gr.addEdge(5,4);
500
501 gr.addEdge(0,4);
502 gr.addEdge(4,5);
503 gr.addEdge(5,0);
504
505 gr.addEdge(0,5);
506 gr.addEdge(5,1);
507 gr.addEdge(1,0);
508
509 gr.addEdge(1,5);
510 gr.addEdge(5,7);
511 gr.addEdge(7,1);
512
513 gr.addEdge(1,7);
514 gr.addEdge(7,3);
515 gr.addEdge(3,1);
516
517#ifdef OPENFPM_PDATA
518
519 if (v_cl.rank() != 0) {return;}
520 std::string c2 = std::string("openfpm_io/test_data/vtk_graph_test.vtk");
521
522#else
523
524 std::string c2 = std::string("test_data/vtk_graph_test.vtk");
525
526#endif
527
528 // Write the VTK file
529
530 VTKWriter<Graph_CSR<vertex,edge>,VTK_GRAPH> vtk(gr);
531 vtk.write("vtk_graph.vtk");
532
533 // check that match
534
535 bool test = compare("vtk_graph.vtk",c2);
536 BOOST_REQUIRE_EQUAL(true,test);
537}
538
539BOOST_AUTO_TEST_CASE( vtk_writer_use_vector_box)
540{
541 Vcluster<> & v_cl = create_vcluster();
542
543 if (v_cl.getProcessUnitID() != 0)
544 return;
545
546#ifdef OPENFPM_PDATA
547
548 if (v_cl.rank() != 0) {return;}
549 std::string c2 = std::string("openfpm_io/test_data/vtk_box_test.vtk");
550 std::string c3 = std::string("openfpm_io/test_data/vtk_box_3D_test.vtk");
551 std::string c4 = std::string("openfpm_io/test_data/vtk_box_3D_2_test.vtk");
552
553#else
554
555 std::string c2 = std::string("test_data/vtk_box_test.vtk");
556 std::string c3 = std::string("test_data/vtk_box_3D_test.vtk");
557 std::string c4 = std::string("test_data/vtk_box_3D_2_test.vtk");
558
559#endif
560
561 // Create a vector of boxes
563
564 vb.add(Box<2,float>({0.2,0.2},{1.0,0.5}));
565 vb.add(Box<2,float>({0.0,0.0},{0.2,0.2}));
566 vb.add(Box<2,float>({0.2,0.0},{0.5,0.2}));
567 vb.add(Box<2,float>({0.5,0.0},{1.0,0.2}));
568 vb.add(Box<2,float>({0.0,0.2},{0.2,0.5}));
569 vb.add(Box<2,float>({0.0,0.5},{1.0,1.0}));
570
571 // Create a writer and write
572 VTKWriter<openfpm::vector<Box<2,float>>,VECTOR_BOX> vtk_box;
573 vtk_box.add(vb);
574 vtk_box.write("vtk_box.vtk");
575
576 // Check that match
577 bool test = compare("vtk_box.vtk",c2);
578 BOOST_REQUIRE_EQUAL(test,true);
579
580 // Create a vector of boxes
582
583 vb2.add(Box<3,float>({0.2,0.2,0.0},{1.0,0.5,0.5}));
584 vb2.add(Box<3,float>({0.0,0.0,0.0},{0.2,0.2,0.5}));
585 vb2.add(Box<3,float>({0.2,0.0,0.0},{0.5,0.2,0.5}));
586 vb2.add(Box<3,float>({0.5,0.0,0.0},{1.0,0.2,0.5}));
587 vb2.add(Box<3,float>({0.0,0.2,0.0},{0.2,0.5,0.5}));
588 vb2.add(Box<3,float>({0.0,0.5,0.0},{1.0,1.0,0.5}));
589
590 // Create a writer and write
591 VTKWriter<openfpm::vector<Box<3,float>>,VECTOR_BOX> vtk_box2;
592 vtk_box2.add(vb2);
593 vtk_box2.write("vtk_box_3D.vtk");
594
595 // Check that match
596 test = compare("vtk_box_3D.vtk",c3);
597 BOOST_REQUIRE_EQUAL(test,true);
598
599 // Create a vector of boxes
601 vb3.add(Box<3,float>({0.2,0.2,0.5},{1.0,0.5,1.0}));
602 vb3.add(Box<3,float>({0.0,0.0,0.5},{0.2,0.2,1.0}));
603 vb3.add(Box<3,float>({0.2,0.0,0.5},{0.5,0.2,1.0}));
604 vb3.add(Box<3,float>({0.5,0.0,0.5},{1.0,0.2,1.0}));
605 vb3.add(Box<3,float>({0.0,0.2,0.5},{0.2,0.5,1.0}));
606 vb3.add(Box<3,float>({0.0,0.5,0.5},{1.0,1.0,1.0}));
607
608 // Create a writer and write
609 VTKWriter<openfpm::vector<Box<3,float>>,VECTOR_BOX> vtk_box3;
610 vtk_box3.add(vb2);
611 vtk_box3.add(vb3);
612 vtk_box3.write("vtk_box_3D_2.vtk");
613
614 // Check that match
615 test = compare("vtk_box_3D_2.vtk",c4);
616 BOOST_REQUIRE_EQUAL(test,true);
617}
618
624template<typename grid_type> void fill_grid_some_data(grid_type & g)
625{
626 typedef Point_test<float> p;
627
628 auto it = g.getIterator();
629
630 while (it.isNext())
631 {
632 g.template get<p::x>(it.get()) = it.get().get(0);
633 if (grid_type::dims != 1)
634 {g.template get<p::y>(it.get()) = it.get().get(1);}
635 else
636 {g.template get<p::y>(it.get()) = 0.0;}
637 g.template get<p::z>(it.get()) = 0;
638 g.template get<p::s>(it.get()) = 1.0;
639 g.template get<p::v>(it.get())[0] = g.getGrid().LinId(it.get());
640 g.template get<p::v>(it.get())[1] = g.getGrid().LinId(it.get());
641 g.template get<p::v>(it.get())[2] = g.getGrid().LinId(it.get());
642
643 g.template get<p::t>(it.get())[0][0] = g.getGrid().LinId(it.get());
644 g.template get<p::t>(it.get())[0][1] = g.getGrid().LinId(it.get());
645 g.template get<p::t>(it.get())[0][2] = g.getGrid().LinId(it.get());
646 g.template get<p::t>(it.get())[1][0] = g.getGrid().LinId(it.get());
647 g.template get<p::t>(it.get())[1][1] = g.getGrid().LinId(it.get());
648 g.template get<p::t>(it.get())[1][2] = g.getGrid().LinId(it.get());
649 g.template get<p::t>(it.get())[2][0] = g.getGrid().LinId(it.get());
650 g.template get<p::t>(it.get())[2][1] = g.getGrid().LinId(it.get());
651 g.template get<p::t>(it.get())[2][2] = g.getGrid().LinId(it.get());
652
653 ++it;
654 }
655}
656
662void fill_grid_some_data_prp(grid_cpu<2,Point_test_prp<float>> & g)
663{
664 typedef Point_test<float> p;
665
666 auto it = g.getIterator();
667
668 while (it.isNext())
669 {
670 g.template get<p::x>(it.get()) = it.get().get(0);
671 g.template get<p::y>(it.get()) = it.get().get(1);
672 g.template get<p::z>(it.get()) = 0;
673 g.template get<p::s>(it.get()) = 1.0;
674 g.template get<p::v>(it.get())[0] = g.getGrid().LinId(it.get());
675 g.template get<p::v>(it.get())[1] = g.getGrid().LinId(it.get());
676 g.template get<p::v>(it.get())[2] = g.getGrid().LinId(it.get());
677
678 g.template get<p::t>(it.get())[0][0] = g.getGrid().LinId(it.get());
679 g.template get<p::t>(it.get())[0][1] = g.getGrid().LinId(it.get());
680 g.template get<p::t>(it.get())[0][2] = g.getGrid().LinId(it.get());
681 g.template get<p::t>(it.get())[1][0] = g.getGrid().LinId(it.get());
682 g.template get<p::t>(it.get())[1][1] = g.getGrid().LinId(it.get());
683 g.template get<p::t>(it.get())[1][2] = g.getGrid().LinId(it.get());
684 g.template get<p::t>(it.get())[2][0] = g.getGrid().LinId(it.get());
685 g.template get<p::t>(it.get())[2][1] = g.getGrid().LinId(it.get());
686 g.template get<p::t>(it.get())[2][2] = g.getGrid().LinId(it.get());
687
688 ++it;
689 }
690}
691
696void fill_grid_some_data_scal(grid_cpu<2,Point_test_scal<float>> & g)
697{
698 typedef Point_test<float> p;
699
700 auto it = g.getIterator();
701
702 while (it.isNext())
703 {
704 g.template get<p::x>(it.get()) = it.get().get(0);
705 g.template get<p::y>(it.get()) = it.get().get(1);
706 g.template get<p::z>(it.get()) = 0;
707 g.template get<p::s>(it.get()) = 1.0;
708
709 ++it;
710 }
711}
712
713BOOST_AUTO_TEST_CASE( vtk_writer_use_grids)
714{
715 Vcluster<> & v_cl = create_vcluster();
716
717 if (v_cl.getProcessUnitID() != 0)
718 {return;}
719
720#ifdef OPENFPM_PDATA
721
722 if (v_cl.rank() != 0) {return;}
723 std::string c2 = std::string("openfpm_io/test_data/vtk_grids_test_1d.vtk");
724 std::string c3 = std::string("openfpm_io/test_data/vtk_grids_test.vtk");
725 std::string c4 = std::string("openfpm_io/test_data/vtk_grids_st_test.vtk");
726 std::string c5 = std::string("openfpm_io/test_data/vtk_grids_prp_test.vtk");
727 std::string c6 = std::string("openfpm_io/test_data/vtk_grids_test.vtk");
728
729#else
730
731 std::string c2 = std::string("test_data/vtk_grids_test_1d.vtk");
732 std::string c3 = std::string("test_data/vtk_grids_test.vtk");
733 std::string c4 = std::string("test_data/vtk_grids_st_test.vtk");
734 std::string c5 = std::string("test_data/vtk_grids_prp_test.vtk");
735 std::string c6 = std::string("test_data/vtk_grids_test.vtk");
736
737#endif
738
739 {
740
741 // Create box grids
742 Point<1,double> offset1({0.0});
743 Point<1,double> spacing1({0.1});
744 Box<1,size_t> d1({1},{14});
745
746 // Create box grids
747 Point<1,double> offset2({5.0});
748 Point<1,float> spacing2({0.2});
749 Box<1,size_t> d2({2},{13});
750
751 // Create box grids
752 Point<1,double> offset3({0.0});
753 Point<1,double> spacing3({0.05});
754 Box<1,size_t> d3({3},{11});
755
756 // Create box grids
757 Point<1,double> offset4({5.0});
758 Point<1,double> spacing4({0.1});
759 Box<1,size_t> d4({1},{7});
760
761 size_t sz[] = {16};
763 g1.setMemory();
764 fill_grid_some_data(g1);
766 g2.setMemory();
767 fill_grid_some_data(g2);
769 g3.setMemory();
770 fill_grid_some_data(g3);
772 g4.setMemory();
773 fill_grid_some_data(g4);
774
775 g4.template get<Point_test<double>::s>(0) = 1.0/3.0;
776
777 // Create a writer and write
779 vtk_g.add(g1,offset1,spacing1,d1);
780 vtk_g.add(g2,offset2,spacing2,d2);
781 vtk_g.add(g3,offset3,spacing3,d3);
782 vtk_g.add(g4,offset4,spacing4,d4);
783
785 vtk_g.write("vtk_grids_1d.vtk",prp_names);
786
787 #ifndef SE_CLASS3
788
789 // Check that match
790 bool test = compare("vtk_grids_1d.vtk",c2);
791 BOOST_REQUIRE_EQUAL(test,true);
792
793 #endif
794 }
795
796 {
797
798 // Create box grids
799 Point<2,float> offset1({0.0,0.0});
800 Point<2,float> spacing1({0.1,0.2});
801 Box<2,size_t> d1({1,2},{14,15});
802
803 // Create box grids
804 Point<2,float> offset2({5.0,7.0});
805 Point<2,float> spacing2({0.2,0.1});
806 Box<2,size_t> d2({2,1},{13,15});
807
808 // Create box grids
809 Point<2,float> offset3({0.0,7.0});
810 Point<2,float> spacing3({0.05,0.07});
811 Box<2,size_t> d3({3,2},{11,10});
812
813 // Create box grids
814 Point<2,float> offset4({5.0,0.0});
815 Point<2,float> spacing4({0.1,0.1});
816 Box<2,size_t> d4({1,1},{7,7});
817
818 size_t sz[] = {16,16};
820 g1.setMemory();
821 fill_grid_some_data(g1);
823 g2.setMemory();
824 fill_grid_some_data(g2);
826 g3.setMemory();
827 fill_grid_some_data(g3);
829 g4.setMemory();
830 fill_grid_some_data(g4);
831
832 // Create a writer and write
834 vtk_g.add(g1,offset1,spacing1,d1);
835 vtk_g.add(g2,offset2,spacing2,d2);
836 vtk_g.add(g3,offset3,spacing3,d3);
837 vtk_g.add(g4,offset4,spacing4,d4);
838
840 vtk_g.write("vtk_grids.vtk",prp_names);
841
842 #ifndef SE_CLASS3
843
844 // Check that match
845 bool test = compare("vtk_grids.vtk",c3);
846 BOOST_REQUIRE_EQUAL(test,true);
847
848 #endif
849 }
850
851 {
852 // Create box grids
853 Point<2,float> offset1({0.0,0.0});
854 Point<2,float> spacing1({0.1,0.1});
855 Box<2,size_t> d1({1,2},{14,15});
856
857 // Create box grids
858 Point<2,float> offset2({0.0,0.0});
859 Point<2,float> spacing2({0.1,0.1});
860 Box<2,size_t> d2({2,1},{13,15});
861
862 // Create box grids
863 Point<2,float> offset3({5.0,5.0});
864 Point<2,float> spacing3({0.1,0.1});
865 Box<2,size_t> d3({3,2},{11,10});
866
867 // Create box grids
868 Point<2,float> offset4({5.0,5.0});
869 Point<2,float> spacing4({0.1,0.1});
870 Box<2,size_t> d4({1,1},{7,7});
871
872 size_t sz[] = {16,16};
874 g1.setMemory();
875 fill_grid_some_data(g1);
877 g2.setMemory();
878 fill_grid_some_data(g2);
880 g3.setMemory();
881 fill_grid_some_data(g3);
883 g4.setMemory();
884 fill_grid_some_data(g4);
885
886 comb<2> cmb;
887 cmb.zero();
888
889 comb<2> cmb2;
890 cmb2.mone();
891
892 // Create a writer and write
893 VTKWriter<boost::mpl::pair<grid_cpu<2,Point_test<float>>,float>,VECTOR_ST_GRIDS> vtk_g;
894 vtk_g.add(0,g1,offset1,spacing1,d1,cmb);
895 vtk_g.add(0,g2,offset2,spacing2,d2,cmb);
896 vtk_g.add(1,g3,offset3,spacing3,d3,cmb);
897 vtk_g.add(1,g4,offset4,spacing4,d4,cmb2);
898
899 vtk_g.write("vtk_grids_st.vtk");
900
901 // Check that match
902 bool test = compare("vtk_grids_st.vtk",c4);
903 BOOST_REQUIRE_EQUAL(test,true);
904 }
905
906 {
907 // Create box grids
908 Point<2,float> offset1({0.0,0.0});
909 Point<2,float> spacing1({0.1,0.1});
910 Box<2,size_t> d1({1,2},{14,15});
911
912 // Create box grids
913 Point<2,float> offset2({0.0,0.0});
914 Point<2,float> spacing2({0.1,0.1});
915 Box<2,size_t> d2({2,1},{13,15});
916
917 // Create box grids
918 Point<2,float> offset3({5.0,5.0});
919 Point<2,float> spacing3({0.1,0.1});
920 Box<2,size_t> d3({3,2},{11,10});
921
922 // Create box grids
923 Point<2,float> offset4({5.0,5.0});
924 Point<2,float> spacing4({0.1,0.1});
925 Box<2,size_t> d4({1,1},{7,7});
926
927 size_t sz[] = {16,16};
929 g1.setMemory();
930 fill_grid_some_data_scal(g1);
932 g2.setMemory();
933 fill_grid_some_data_scal(g2);
935 g3.setMemory();
936 fill_grid_some_data_scal(g3);
938 g4.setMemory();
939 fill_grid_some_data_scal(g4);
940
941 // Create a writer and write
943 vtk_g.add(g1,offset1,spacing1,d1);
944 vtk_g.add(g2,offset2,spacing2,d2);
945 vtk_g.add(g3,offset3,spacing3,d3);
946 vtk_g.add(g4,offset4,spacing4,d4);
947
949 vtk_g.write("vtk_grids_prp.vtk",prp_names);
950
951 // Check that match
952 bool test = compare("vtk_grids_prp.vtk",c5);
953 BOOST_REQUIRE_EQUAL(test,true);
954 }
955
956 {
957 // Create box grids
958 Point<2,float> offset1({0.0,0.0});
959 Point<2,float> spacing1({0.1,0.2});
960 Box<2,size_t> d1({1,2},{14,15});
961
962 // Create box grids
963 Point<2,float> offset2({5.0,7.0});
964 Point<2,float> spacing2({0.2,0.1});
965 Box<2,size_t> d2({2,1},{13,15});
966
967 // Create box grids
968 Point<2,float> offset3({0.0,7.0});
969 Point<2,float> spacing3({0.05,0.07});
970 Box<2,size_t> d3({3,2},{11,10});
971
972 // Create box grids
973 Point<2,float> offset4({5.0,0.0});
974 Point<2,float> spacing4({0.1,0.1});
975 Box<2,size_t> d4({1,1},{7,7});
976
977 size_t sz[] = {16,16};
979 g1.setMemory();
980 fill_grid_some_data(g1);
982 g2.setMemory();
983 fill_grid_some_data(g2);
985 g3.setMemory();
986 fill_grid_some_data(g3);
988 g4.setMemory();
989 fill_grid_some_data(g4);
990
991 // Create a writer and write
993 vtk_g.add(g1,offset1,spacing1,d1);
994 vtk_g.add(g2,offset2,spacing2,d2);
995 vtk_g.add(g3,offset3,spacing3,d3);
996 vtk_g.add(g4,offset4,spacing4,d4);
997
999 vtk_g.write("vtk_grids_unk.vtk",prp_names);
1000
1001#ifndef SE_CLASS3
1002
1003 // Check that match
1004 bool test = compare("vtk_grids_unk.vtk",c6);
1005 BOOST_REQUIRE_EQUAL(test,true);
1006
1007#endif
1008
1009 }
1010
1011 // Try
1012
1013 {
1014 bool ret = is_vtk_writable<Point<3,float>>::value;
1015 BOOST_REQUIRE_EQUAL(ret,true);
1016 ret = is_vtk_writable<Point<3,double>>::value;
1017 BOOST_REQUIRE_EQUAL(ret,true);
1018
1019 int dims = vtk_dims<Point<3,float>>::value;
1020 BOOST_REQUIRE_EQUAL(dims,3);
1021
1023 BOOST_REQUIRE_EQUAL(dims,1);
1024 }
1025
1026}
1027
1028
1029BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set )
1030{
1031 Vcluster<> & v_cl = create_vcluster();
1032
1033 if (v_cl.getProcessUnitID() != 0)
1034 return;
1035
1036#ifdef OPENFPM_PDATA
1037
1038 if (v_cl.rank() != 0) {return;}
1039 std::string c2 = std::string("openfpm_io/test_data/vtk_points_test.vtk");
1040 std::string c3 = std::string("openfpm_io/test_data/vtk_points_pp_test.vtk");
1041 std::string c4 = std::string("openfpm_io/test_data/vtk_points_pp_header_test.vtk");
1042
1043#else
1044
1045 std::string c2 = std::string("test_data/vtk_points_test.vtk");
1046 std::string c3 = std::string("test_data/vtk_points_pp_test.vtk");
1047 std::string c4 = std::string("test_data/vtk_points_pp_header_test.vtk");
1048
1049#endif
1050
1051 {
1052 // Create 3 vectors with random particles
1060
1061 // set the seed
1062 // create the random generator engine
1063 SimpleRNG rng;
1064
1065 // fill the vector with random data
1066 v1ps.resize(100);
1067 v2ps.resize(100);
1068 v3ps.resize(100);
1069
1070 v1pp.resize(100);
1071 v2pp.resize(100);
1072 v3pp.resize(100);
1073 v4pp.resize(100);
1074
1075 for (size_t i = 0 ; i < v1ps.size(); i++)
1076 {
1077 v1ps.template get<0>(i)[0] = rng.GetUniform();
1078 v1ps.template get<0>(i)[1] = rng.GetUniform();
1079 v1ps.template get<0>(i)[2] = rng.GetUniform();
1080
1081 v2ps.template get<0>(i)[0] = rng.GetUniform()*0.5;
1082 v2ps.template get<0>(i)[1] = rng.GetUniform()*0.5;
1083 v2ps.template get<0>(i)[2] = rng.GetUniform()*0.5;
1084
1085 v3ps.template get<0>(i)[0] = rng.GetUniform()*0.3;
1086 v3ps.template get<0>(i)[1] = rng.GetUniform()*0.3;
1087 v3ps.template get<0>(i)[2] = rng.GetUniform()*0.3;
1088
1089 v1pp.template get<0>(i) = rng.GetUniform();
1090 v1pp.template get<1>(i)[0] = rng.GetUniform();
1091 v1pp.template get<1>(i)[1] = rng.GetUniform();
1092 v1pp.template get<1>(i)[2] = rng.GetUniform();
1093
1094 v2pp.template get<0>(i) = rng.GetUniform();
1095 v2pp.template get<1>(i)[0] = rng.GetUniform();
1096 v2pp.template get<1>(i)[1] = rng.GetUniform();
1097 v2pp.template get<1>(i)[2] = rng.GetUniform();
1098
1099 v3pp.template get<0>(i) = rng.GetUniform();
1100 v3pp.template get<1>(i)[0] = rng.GetUniform();
1101 v3pp.template get<1>(i)[1] = rng.GetUniform();
1102 v3pp.template get<1>(i)[2] = rng.GetUniform();
1103
1104 v4pp.template get<0>(i) = rng.GetUniform();
1105 v4pp.template get<1>(i).get(0) = rng.GetUniform();
1106 v4pp.template get<1>(i).get(1) = rng.GetUniform();
1107 v4pp.template get<1>(i).get(2) = rng.GetUniform();
1108 }
1109
1110 // Create a writer and write
1112 vtk_v.add(v1ps,v1pp,75);
1113 vtk_v.add(v2ps,v2pp,88);
1114 vtk_v.add(v3ps,v3pp,90);
1115
1117 vtk_v.write("vtk_points.vtp",prp_names);
1118 //auto &v_cl=create_vcluster();
1119 //size_t n=v_cl.size();
1120 vtk_v.write_pvtp("vtk_points",prp_names,2);
1121
1122
1123#ifndef SE_CLASS3
1124
1125 bool test = true;
1126
1127 // Check that match
1128 test = compare("vtk_points.vtp","test_data/vtk_points_test.vtp");
1129 BOOST_REQUIRE_EQUAL(test,true);
1130
1131 //It just checks generation of the format and not actual data (File names)
1132 test = compare("vtk_points.pvtp","test_data/pvtp_points_test.pvtp");
1133 BOOST_REQUIRE_EQUAL(test,true);
1134
1135#endif
1136
1137 // Create a writer and write
1139 vtk_v2.add(v1ps,v4pp,75);
1140
1141 vtk_v2.write("vtk_points_pp.vtp",prp_names);
1142
1143#ifndef SE_CLASS3
1144
1145 // Check that match
1146 test = compare("vtk_points_pp.vtp","test_data/vtk_points_pp_test.vtp");
1147 BOOST_REQUIRE_EQUAL(test,true);
1148
1149#endif
1150
1151 // Create a writer and write
1153 vtk_v3.add(v1ps,v4pp,75);
1154
1155 vtk_v3.write("vtk_points_pp_header.vtp",prp_names,"points","time=5.123");
1156
1157 // We try binary
1158 vtk_v3.write("vtk_points_pp_header_bin.vtp",prp_names,"points","time=5.123",file_type::BINARY);
1159
1160#ifndef SE_CLASS3
1161
1162 // Check that match
1163 test = compare("vtk_points_pp_header.vtp","test_data/vtk_points_pp_header_test.vtp");
1164 BOOST_REQUIRE_EQUAL(test,true);
1165
1166 test = compare("vtk_points_pp_header_bin.vtp","test_data/vtk_points_pp_header_bin_test.vtp");
1167 BOOST_REQUIRE_EQUAL(test,true);
1168
1169#endif
1170
1171 }
1172}
1173
1174BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_properties )
1175{
1176 Vcluster<> & v_cl = create_vcluster();
1177
1178 if (v_cl.getProcessUnitID() != 0)
1179 return;
1180
1181#ifdef OPENFPM_PDATA
1182
1183 if (v_cl.rank() != 0) {return;}
1184 std::string c2 = std::string("openfpm_io/test_data/vtk_points_with_prp_names_test.vtk");
1185
1186#else
1187
1188 std::string c2 = std::string("test_data/vtk_points_with_prp_names_test.vtk");
1189
1190#endif
1191
1192 {
1193 // Create 3 vectors with random particles
1196
1197 // set the seed
1198 // create the random generator engine
1199 SimpleRNG rng;
1200
1201 // fill the vector with random data
1202 v1ps.resize(100);
1203 v1pp.resize(100);
1204
1205 for (size_t i = 0 ; i < v1ps.size(); i++)
1206 {
1207 v1ps.template get<0>(i)[0] = rng.GetUniform();
1208 v1ps.template get<0>(i)[1] = rng.GetUniform();
1209 v1ps.template get<0>(i)[2] = rng.GetUniform();
1210
1211
1212 v1pp.template get<0>(i) = rng.GetUniform();
1213 v1pp.template get<1>(i)[0] = rng.GetUniform();
1214 v1pp.template get<1>(i)[1] = rng.GetUniform();
1215 v1pp.template get<1>(i)[2] = rng.GetUniform();
1216 }
1217
1219
1220 // Create a writer and write adding names to the properties
1222 vtk_v.add(v1ps,v1pp,75);
1223 openfpm::vector<std::string> prp_names({"scalar","vector"});
1224 vtk_v.write("vtk_points_with_prp_names.vtp",prp_names);
1225
1226#ifndef SE_CLASS3
1227
1228 // Check that match
1229 bool test = compare("vtk_points_with_prp_names.vtp","test_data/vtk_points_with_prp_names_test.vtp");
1230 BOOST_REQUIRE_EQUAL(test,true);
1231
1232#endif
1233
1234 }
1235}
1236
1237BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_check_out_precision )
1238{
1239 Vcluster<> & v_cl = create_vcluster();
1240
1241 if (v_cl.getProcessUnitID() != 0)
1242 return;
1243
1244#ifdef OPENFPM_PDATA
1245
1246 if (v_cl.rank() != 0) {return;}
1247 std::string c2 = std::string("openfpm_io/test_data/vtk_points_with_prp_names_prec_check_test.vtk");
1248
1249#else
1250
1251 std::string c2 = std::string("test_data/vtk_points_with_prp_names_prec_check_test.vtk");
1252
1253#endif
1254
1255 {
1256 // Create 3 vectors with random particles
1259
1260 // fill the vector with random data
1261 v1ps.resize(100);
1262 v1pp.resize(100);
1263
1264 for (size_t i = 0 ; i < v1ps.size(); i++)
1265 {
1266 v1ps.template get<0>(i)[0] = std::numeric_limits<double>::max();
1267 v1ps.template get<0>(i)[1] = std::numeric_limits<double>::max();
1268 v1ps.template get<0>(i)[2] = std::numeric_limits<double>::max();
1269
1270
1271 v1pp.template get<0>(i) = std::numeric_limits<float>::max();
1272 v1pp.template get<1>(i)[0] = std::numeric_limits<double>::max();
1273 v1pp.template get<1>(i)[1] = std::numeric_limits<double>::max();
1274 v1pp.template get<1>(i)[2] = std::numeric_limits<double>::max();
1275 }
1276
1278
1279 // Create a writer and write adding names to the properties
1281 vtk_v.add(v1ps,v1pp,75);
1282 openfpm::vector<std::string> prp_names({"scalar","vector"});
1283 vtk_v.write("vtk_points_with_prp_names_prec_check.vtp",prp_names);
1284
1285#ifndef SE_CLASS3
1286
1287 // Check that match
1288 bool test = compare("vtk_points_with_prp_names_prec_check.vtp","test_data/vtk_points_with_prp_names_prec_check_test.vtp");
1289 BOOST_REQUIRE_EQUAL(test,true);
1290
1291#endif
1292
1293 }
1294}
1295
1296BOOST_AUTO_TEST_CASE( vtk_writer_use_point_set_binary )
1297{
1298 Vcluster<> & v_cl = create_vcluster();
1299
1300 if (v_cl.getProcessUnitID() != 0)
1301 return;
1302
1303#ifdef OPENFPM_PDATA
1304
1305 if (v_cl.rank() != 0) {return;}
1306 std::string c2 = std::string("openfpm_io/test_data/vtk_points_bin_test.vtk");
1307 std::string c3 = std::string("openfpm_io/test_data/vtk_points_pp_bin_test.vtk");
1308 std::string c4 = std::string("openfpm_io/test_data/vtk_points_2d_bin_test.vtk");
1309 std::string c5 = std::string("openfpm_io/test_data/vtk_points_2d_pp_bin_test.vtk");
1310
1311#else
1312
1313 std::string c2 = std::string("test_data/vtk_points_bin_test.vtk");
1314 std::string c3 = std::string("test_data/vtk_points_pp_bin_test.vtk");
1315 std::string c4 = std::string("test_data/vtk_points_2d_bin_test.vtk");
1316 std::string c5 = std::string("test_data/vtk_points_2d_pp_bin_test.vtk");
1317
1318#endif
1319
1320 {
1321 // Create 3 vectors with random particles
1329
1330 // set the seed
1331 // create the random generator engine
1332 SimpleRNG rng;
1333
1334 // fill the vector with random data
1335 v1ps.resize(100);
1336 v2ps.resize(100);
1337 v3ps.resize(100);
1338
1339 v1pp.resize(100);
1340 v2pp.resize(100);
1341 v3pp.resize(100);
1342 v4pp.resize(100);
1343
1344 for (size_t i = 0 ; i < v1ps.size(); i++)
1345 {
1346 v1ps.template get<0>(i)[0] = rng.GetUniform();
1347 v1ps.template get<0>(i)[1] = rng.GetUniform();
1348 v1ps.template get<0>(i)[2] = rng.GetUniform();
1349
1350 v2ps.template get<0>(i)[0] = rng.GetUniform()*0.5;
1351 v2ps.template get<0>(i)[1] = rng.GetUniform()*0.5;
1352 v2ps.template get<0>(i)[2] = rng.GetUniform()*0.5;
1353
1354 v3ps.template get<0>(i)[0] = rng.GetUniform()*0.3;
1355 v3ps.template get<0>(i)[1] = rng.GetUniform()*0.3;
1356 v3ps.template get<0>(i)[2] = rng.GetUniform()*0.3;
1357
1358 v1pp.template get<0>(i) = rng.GetUniform();
1359 v1pp.template get<1>(i)[0] = rng.GetUniform();
1360 v1pp.template get<1>(i)[1] = rng.GetUniform();
1361 v1pp.template get<1>(i)[2] = rng.GetUniform();
1362
1363 v2pp.template get<0>(i) = rng.GetUniform();
1364 v2pp.template get<1>(i)[0] = rng.GetUniform();
1365 v2pp.template get<1>(i)[1] = rng.GetUniform();
1366 v2pp.template get<1>(i)[2] = rng.GetUniform();
1367
1368 v3pp.template get<0>(i) = rng.GetUniform();
1369 v3pp.template get<1>(i)[0] = rng.GetUniform();
1370 v3pp.template get<1>(i)[1] = rng.GetUniform();
1371 v3pp.template get<1>(i)[2] = rng.GetUniform();
1372
1373 v4pp.template get<0>(i) = rng.GetUniform();
1374 v4pp.template get<1>(i).get(0) = rng.GetUniform();
1375 v4pp.template get<1>(i).get(1) = rng.GetUniform();
1376 v4pp.template get<1>(i).get(2) = rng.GetUniform();
1377 }
1378
1379 // Create a writer and write
1381 vtk_v.add(v1ps,v1pp,75);
1382 vtk_v.add(v2ps,v2pp,88);
1383 vtk_v.add(v3ps,v3pp,90);
1384
1386 vtk_v.write("vtk_points_bin.vtp",prp_names,"vtk output","",file_type::BINARY);
1387 vtk_v.write("vtk_points_bin2.vtp",prp_names,"vtk output","",file_type::BINARY);
1388
1389#ifndef SE_CLASS3
1390
1391 bool test = true;
1392
1393 // Check that match
1394 test = compare("vtk_points_bin.vtp","test_data/vtk_points_bin_test.vtp");
1395 BOOST_REQUIRE_EQUAL(test,true);
1396 test = compare("vtk_points_bin2.vtp","test_data/vtk_points_bin_test.vtp");
1397 BOOST_REQUIRE_EQUAL(test,true);
1398
1399#endif
1400
1401 // Create a writer and write
1403 vtk_v2.add(v1ps,v4pp,75);
1404
1405 vtk_v2.write("vtk_points_pp_bin.vtp",prp_names,"vtk output","",file_type::BINARY);
1406
1407#ifndef SE_CLASS3
1408
1409 // Check that match
1410 test = compare("vtk_points_pp_bin.vtp","test_data/vtk_points_pp_bin_test.vtp");
1411 BOOST_REQUIRE_EQUAL(test,true);
1412
1413#endif
1414
1415 }
1416
1417
1418 {
1419 // Create 3 vectors with random particles
1427
1428 // set the seed
1429 // create the random generator engine
1430 SimpleRNG rng;
1431
1432 // fill the vector with random data
1433 v1ps.resize(100);
1434 v2ps.resize(100);
1435 v3ps.resize(100);
1436
1437 v1pp.resize(100);
1438 v2pp.resize(100);
1439 v3pp.resize(100);
1440 v4pp.resize(100);
1441
1442 for (size_t i = 0 ; i < v1ps.size(); i++)
1443 {
1444 v1ps.template get<0>(i)[0] = rng.GetUniform();
1445 v1ps.template get<0>(i)[1] = rng.GetUniform();
1446
1447 v2ps.template get<0>(i)[0] = rng.GetUniform()*0.5;
1448 v2ps.template get<0>(i)[1] = rng.GetUniform()*0.5;
1449
1450 v3ps.template get<0>(i)[0] = rng.GetUniform()*0.3;
1451 v3ps.template get<0>(i)[1] = rng.GetUniform()*0.3;
1452
1453 v1pp.template get<0>(i) = rng.GetUniform();
1454 v1pp.template get<1>(i)[0][0] = rng.GetUniform();
1455 v1pp.template get<1>(i)[0][1] = rng.GetUniform();
1456 v1pp.template get<1>(i)[0][2] = rng.GetUniform();
1457 v1pp.template get<1>(i)[1][0] = rng.GetUniform();
1458 v1pp.template get<1>(i)[1][1] = rng.GetUniform();
1459 v1pp.template get<1>(i)[1][2] = rng.GetUniform();
1460 v1pp.template get<1>(i)[2][0] = rng.GetUniform();
1461 v1pp.template get<1>(i)[2][1] = rng.GetUniform();
1462 v1pp.template get<1>(i)[2][2] = rng.GetUniform();
1463
1464 v2pp.template get<0>(i) = rng.GetUniform();
1465 v2pp.template get<1>(i)[0][0] = rng.GetUniform();
1466 v2pp.template get<1>(i)[0][1] = rng.GetUniform();
1467 v2pp.template get<1>(i)[0][2] = rng.GetUniform();
1468 v2pp.template get<1>(i)[1][0] = rng.GetUniform();
1469 v2pp.template get<1>(i)[1][1] = rng.GetUniform();
1470 v2pp.template get<1>(i)[1][2] = rng.GetUniform();
1471 v2pp.template get<1>(i)[2][0] = rng.GetUniform();
1472 v2pp.template get<1>(i)[2][1] = rng.GetUniform();
1473 v2pp.template get<1>(i)[2][2] = rng.GetUniform();
1474
1475 v3pp.template get<0>(i) = rng.GetUniform();
1476 v3pp.template get<1>(i)[0][0] = rng.GetUniform();
1477 v3pp.template get<1>(i)[0][1] = rng.GetUniform();
1478 v3pp.template get<1>(i)[0][2] = rng.GetUniform();
1479 v3pp.template get<1>(i)[1][0] = rng.GetUniform();
1480 v3pp.template get<1>(i)[1][1] = rng.GetUniform();
1481 v3pp.template get<1>(i)[1][2] = rng.GetUniform();
1482 v3pp.template get<1>(i)[2][0] = rng.GetUniform();
1483 v3pp.template get<1>(i)[2][1] = rng.GetUniform();
1484 v3pp.template get<1>(i)[2][2] = rng.GetUniform();
1485
1486 v4pp.template get<0>(i)[0] = rng.GetUniform();
1487 v4pp.template get<0>(i)[1] = rng.GetUniform();
1488 v4pp.template get<0>(i)[2] = rng.GetUniform();
1489 v4pp.template get<1>(i)[0] = rng.GetUniform();
1490 v4pp.template get<1>(i)[1] = rng.GetUniform();
1491 }
1492
1493 // Create a writer and write
1495 vtk_v.add(v1ps,v1pp,75);
1496 vtk_v.add(v2ps,v2pp,88);
1497 vtk_v.add(v3ps,v3pp,90);
1498
1500
1501 vtk_v.write("vtk_points_2d_bin.vtp",stub,"vtk output","",file_type::BINARY);
1502
1503#ifndef SE_CLASS3
1504
1505 bool test = true;
1506
1507 // Check that match
1508 test = compare("vtk_points_2d_bin.vtp","test_data/vtk_points_2d_bin_test.vtp");
1509 BOOST_REQUIRE_EQUAL(test,true);
1510
1511#endif
1512
1513 // Create a writer and write
1515 vtk_v2.add(v1ps,v4pp,75);
1516
1517 vtk_v2.write("vtk_points_2d_pp_bin.vtp",stub,"vtk output","",file_type::BINARY);
1518
1519#ifndef SE_CLASS3
1520
1521 // Check that match
1522 test = compare("vtk_points_2d_pp_bin.vtp","test_data/vtk_points_2d_pp_bin_test.vtp");
1523 BOOST_REQUIRE_EQUAL(test,true);
1524
1525#endif
1526 }
1527}
1528
1529BOOST_AUTO_TEST_SUITE_END()
1530
1531#endif /* VTKWRITER_UNIT_TESTS_HPP_ */
This class represent an N-dimensional box.
Definition Box.hpp:61
Structure that store a graph in CSR format or basically in compressed adjacency matrix format.
void addVertex(const V &vrt)
add vertex
auto addEdge(size_t v1, size_t v2, const E &ed) -> decltype(e.get(0))
add edge on the graph
Test structure used for several test.
point test with only scalar properties
Test structure used for several test.
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
SimpleRNG is a simple random number generator based on George Marsaglia's MWC (multiply with carry) g...
Definition SimpleRNG.hpp:19
size_t rank()
Get the process unit id.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
Definition VCluster.hpp:59
This is a distributed grid.
auto get(const grid_dist_key_dx< dim, bg_key > &v1) const -> typename std::add_lvalue_reference< decltype(loc_grid.get(v1.getSub()).template get< p >(v1.getKey()))>::type
Get the reference of the selected element.
static const unsigned int dims
Number of dimensions.
Implementation of 1-D std::vector like structure.
size_t size()
Stub size.
Position of the element of dimension d in the hyper-cube of dimension dim.
Definition comb.hpp:35
void mone()
Set all the elements to -1.
Definition comb.hpp:95
void zero()
Set all the elements to zero.
Definition comb.hpp:83
check for T to be writable
static const unsigned int x
computation property id in boost::fusion::vector
vertex2(float x, float y, float z)
Initialize the VTKVertex.
boost::fusion::vector< float[3], size_t, double > type
The node contain 3 unsigned long integer for communication computation memory and id.
static const unsigned int max_prop
total number of properties boost::fusion::vector
float s_type
type of the positional field
type data
The data.
float s_type
type of the positional field
boost::fusion::vector< float[2], size_t, double > type
The node contain 3 unsigned long integer for communication computation memory and id.
vertex3(float x, float y)
Initialize the VTKVertex.
static const unsigned int x
computation property id in boost::fusion::vector
type data
The data.
static const unsigned int max_prop
total number of properties boost::fusion::vector
Sub-domain vertex graph node.
boost::fusion::vector< float, float, float, float, size_t, double, unsigned char, long int > type
The node contain 3 unsigned long integer for communication computation memory and id.
float s_type
type of the positional field
type data
The data.
vertex(float x, float y, float z)
Initialize the VTKVertex.
If it has not dims property defined the object is considered scalar.