GCC Code Coverage Report


Directory: ./
File: Executable/mesh2ensight.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 28 33 84.8%
Branches: 35 78 44.9%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: Vicente Mataix Ferrandiz
13 //
14
15 // System includes
16
17 // External includes
18
19 // Project includes
20 #include "Core/filesystemUtil.hpp"
21 #include "InputOutput/io.hpp"
22 #include "Geometry/geometricMeshRegion.hpp"
23 #include "Tools/simple_cmd.hpp"
24
25 1 bool replace(std::string& str, const std::string& from, const std::string& to) {
26 1 size_t start_pos = str.rfind(from);
27
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(start_pos == std::string::npos)
28 1 return false;
29 str.replace(start_pos, from.length(), to);
30 return true;
31 }
32
33 1 int main(int argc, const char* argv[])
34 {
35 struct Options
36 {
37 std::string InputFile{""};
38 bool IncludeNodes{false};
39 };
40
41 3 auto parser = CmdOptions<Options>::Create({
42 {"--file", &Options::InputFile },
43 {"--include_nodes", &Options::IncludeNodes }
44
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
1 });
45
46
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto options = parser->parse(argc, argv);
47
48
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if (options.InputFile == "") {
49 std::cout << "The following input values must be set: " << std::endl;
50 std::cout << "\tInput file:\t--file"<< std::endl;
51 return 1;
52 }
53
54
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::cout << "The following input values has been considered" << std::endl;
55
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
1 std::cout << "\tInput file =\t" << options.InputFile << std::endl;
56
3/6
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
1 std::cout << "\tInclude nodes =\t" << options.IncludeNodes << std::endl;
57
58 // Parameters instance
59
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto& r_instance = felisce::FelisceParam::instance();
60 1 r_instance.readNodesReferences = options.IncludeNodes;
61
62
2/4
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 std::string current_path = std::filesystem::current_path();
63
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 current_path += "/";
64
3/6
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
1 replace(options.InputFile, ".mesh", "");
65
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
2 auto p_io = felisce::make_shared<felisce::IO>( current_path, options.InputFile + ".mesh" , options.InputFile + ".mesh", options.InputFile + ".out.mesh", current_path, current_path, "mesh");
66
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 auto p_mesh_region = felisce::make_shared<felisce::GeometricMeshRegion>();
67
1/2
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
1 p_io->readMesh(*p_mesh_region, 1.0);
68
69 // Convert into ensight format
70
4/8
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
2 auto p_io_ensigth_post = felisce::make_shared<felisce::IO>( current_path, options.InputFile + ".geo" , options.InputFile + ".geo", options.InputFile + ".out.geo", current_path, current_path, "ensight");
71 1 r_instance.outputFileFormat = felisce::ENSIGHT6;
72
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 p_io_ensigth_post->initializeOutput();
73
2/4
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
1 p_io_ensigth_post->writeMesh(*p_mesh_region, options.InputFile + ".out.geo");
74 1 double time = 0.0;
75
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 p_io_ensigth_post->postProcess(time, 0);
76
77 1 return 0;
78 1 }
79