-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_vtk_utilities.cpp
More file actions
63 lines (48 loc) · 2.16 KB
/
test_vtk_utilities.cpp
File metadata and controls
63 lines (48 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// ______ _____ _ ________
// / ____/___ / ___/(_)___ ___ / _/ __ |
// / / / __ \\__ \/ / __ `__ \ / // / / /
// / /___/ /_/ /__/ / / / / / / // // /_/ /
// \____/\____/____/_/_/ /_/ /_/___/\____/
// Kratos CoSimulationApplication
//
// License: BSD License, see license.txt
//
// Main authors: Philipp Bucher (https://github.com/philbucher)
//
// System includes
// Project includes
#include "co_sim_io_testing.hpp"
#include "includes/define.hpp"
#include "includes/vtk_utilities.hpp"
#include "includes/filesystem_inc.hpp"
namespace CoSimIO {
TEST_SUITE("VtkUtilities") {
TEST_CASE("write_read_vtk")
{
ModelPart model_part_write("vtk");
ModelPart model_part_read("vtk");
const int node_ids[] = {2, 159, 61};
const std::array<double, 3> node_coords = {1.0, -2.7, 9.44};
model_part_write.CreateNewNode(node_ids[0], node_coords[0], node_coords[1], node_coords[2]);
model_part_write.CreateNewNode(node_ids[1], node_coords[1], node_coords[2], node_coords[0]);
model_part_write.CreateNewNode(node_ids[2], node_coords[2], node_coords[0], node_coords[1]);
model_part_write.CreateNewElement(15, CoSimIO::ElementType::Point2D, {node_ids[0]});
model_part_write.CreateNewElement(73, CoSimIO::ElementType::Line2D2, {node_ids[1], node_ids[2]});
model_part_write.CreateNewElement(47, CoSimIO::ElementType::Triangle3D3, {node_ids[1], node_ids[2], node_ids[0]});
const std::string file_name = "vtk_read_write_test.vtk";
Info info_vtk;
info_vtk.Set<std::string>("file_name", file_name);
CoSimIO::VtkUtilities::WriteVtk(
info_vtk,
model_part_write,
{{std::string("pressure"),{1,2.5,3}}}, // nodal scalar data
{{std::string("Disp"),{{1,2.5,3}, {0,0,2}, {-215, 456, 98}}}}, // nodal vector data
{{std::string("AREA"),{1.02,25.5,-3}}}, // elemental scalar data
{{std::string("gradient"),{{1,2.5,3},{1,3,974},{0,0,0}}}} // elemental vector data
);
CoSimIO::VtkUtilities::ReadVtk(info_vtk, model_part_read);
// fs::remove(file_name);
CheckModelPartsAreEqual(model_part_write, model_part_read);
}
} // TEST_SUITE("VtkUtilities")
} // namespace CoSimIO