GCC Code Coverage Report


Directory: ./
File: InputOutput/medit.hpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 2 2 100.0%
Branches: 0 0 -%

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: J.Castelneau & J.Foulon
13 //
14
15 #ifndef _MEDIT_HPP
16 #define _MEDIT_HPP
17
18 // System includes
19 #include <limits>
20 #include <string>
21 #include <unordered_map>
22
23 // External includes
24 extern "C" {
25 #include <libmeshb7.h>
26 #undef call
27 // call conflicts with boost/regex.hpp and will be remove from libmesh5.h
28 // in future versions.
29
30 extern int64_t GmfOpenMesh(const char *, int, ...);
31 extern int GmfCloseMesh(int64_t);
32 extern int64_t GmfStatKwd(int64_t, int, ...);
33 extern int GmfGotoKwd(int64_t, int);
34 extern int GmfSetKwd(int64_t, int, int64_t, ...);
35 extern int GmfGetLin(int64_t, int, ...);
36 extern int GmfSetLin(int64_t, int, ...);
37
38 }
39
40 // Project includes
41 #include "Geometry/geometricMeshRegion.hpp"
42 #include "Core/util_string.hpp"
43
44 namespace felisce {
45
46 /*!
47 * \class Medit
48 * \authors J. Castelneau, J. Foulon
49 * \brief manage input/output with Medit Software
50 * \date 12/05/2010
51 *
52 * Use libmesh5 which is library developped by Loic Marechal (equipe-projet GAMMA, INRIA)
53 */
54
55 class Medit
56 {
57 public:
58 typedef GeometricMeshRegion::ElementType ElementType;
59 typedef std::map<int, std::vector<felInt>> RefToElements_type;
60 typedef std::unordered_map<std::string, std::pair<ElementType, GmfKwdCod> > StringToMeditPair_type;
61 static constexpr double Infinity = std::numeric_limits<double>::infinity();
62 private:
63 static StringToMeditPair_type m_eltFelNameToMeditPair; //!<std::unordered_map to link element geometric name in felisce to medit format
64 std::string m_inputMesh;
65 std::string m_outputMesh;
66 std::string m_meshDir;
67 std::string m_resultDir;
68 int m_meshVersion; //!<value of the mesh version only in medit format
69 void initMap();//! Function to initialize m_eltFelNameToMeditPair
70 public:
71 1055 Medit() = default;
72 Medit(const std::string& inputMesh, const std::string& outputMesh,
73 const std::string& meshDir, const std::string& resultDir);
74 void initialize(const std::string& inputMesh, const std::string& outputMesh,
75 const std::string& meshDir, const std::string& resultDir);
76
77 /**
78 * @brief This is an auxiliary method to read the vertices of a mesh
79 * @param rMesh The mesh to fill the vertices
80 * @param spaceUnit The rescale factor
81 * @param InpMsh The type of input mesh
82 * @ttparam TType To consider float or double
83 * @ttparam TReadRefNodes If we read the references of the nodes
84 */
85 template<class TType, bool TReadRefNodes>
86 void ReadVertices(
87 GeometricMeshRegion& rMesh,
88 const double spaceUnit,
89 int64_t& InpMsh,
90 RefToElements_type* RefToElementsMaps
91 );
92
93 std::string& outputMesh() {
94 return m_outputMesh;
95 }
96
97 1055 ~Medit() = default;
98
99 //! Copy constructor, to avoid warning due to user-declared destructor.
100 Medit(const Medit&) = default;
101
102 void readerMedit(GeometricMeshRegion& mesh,double spaceUnit, const std::size_t verbose = 0);//!<It reads INRIA MESH file using Loic Marechal's libmesh5
103 void writerMedit(GeometricMeshRegion& mesh);//!<It writes INRIA MESH file using Loic Marechal's libmesh5
104 void writeSolution(double& time,int iteration, const int & typeVariable, const std::string nameVariable, const double* solution, felInt size, int dimension);
105 };
106
107 }
108
109 #endif
110