-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGMSHInterface.h
More file actions
134 lines (111 loc) · 3.89 KB
/
Copy pathGMSHInterface.h
File metadata and controls
134 lines (111 loc) · 3.89 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/**
* \file
* \author Thomas Fischer
* \date 2010-04-29
* \brief Definition of the GMSHInterface class.
*
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef GMSHINTERFACE_H_
#define GMSHINTERFACE_H_
#include <list>
#include <map>
#include <string>
// FileIO
#include "Writer.h"
#include "GmshIO/GMSHPoint.h"
#include "GmshIO/GMSHPolygonTree.h"
#include "GmshIO/GMSHMeshDensityStrategy.h"
namespace GeoLib
{
class GEOObjects;
class Polygon;
}
namespace MeshLib
{
class Mesh;
class Element;
class Node;
}
namespace FileIO
{
namespace GMSH {
enum class MeshDensityAlgorithm {
NoMeshDensity = 0, //!< do not set the parameter
FixedMeshDensity, //!< set the parameter with a fixed value
AdaptiveMeshDensity //!< computing the mesh density employing a QuadTree
};
}
/**
* \brief Reads and writes GMSH-files to and from OGS data structures.
*/
class GMSHInterface : public Writer
{
public:
/**
*
* @param geo_objs reference tp instance of class GEOObject that maintains the geometries.
* The instance is used for preparation geometries for writing them to the gmsh file format.
* @param include_stations_as_constraints switch to enable writing stations as constraints
* @param mesh_density_algorithm one of the mesh density algorithms (\@see enum MeshDensityAlgorithm)
* @param param1 parameter that can be used for the mesh density algorithm
* @param param2 parameter that can be used for the mesh density algorithm
* @param param3 parameter that can be used for the mesh density algorithm
* @param selected_geometries vector of names of geometries, that should be employed for mesh generation.
* @return
*/
GMSHInterface (GeoLib::GEOObjects & geo_objs,
bool include_stations_as_constraints,
GMSH::MeshDensityAlgorithm mesh_density_algorithm,
double param1, double param2, std::size_t param3,
std::vector<std::string> & selected_geometries);
/**
* checks if there is a GMSH mesh file header
* @param fname the file name of the mesh (including the path)
* @return true, if the file seems to be a valid GMSH file, else false
*/
static bool isGMSHMeshFile (const std::string& fname);
/**
* reads a mesh created by GMSH - this implementation is based on the former function GMSH2MSH
* @param fname the file name of the mesh (including the path)
* @return
*/
static MeshLib::Mesh* readGMSHMesh (std::string const& fname);
/**
* Export script for writing geo files.
* To do this, all geometries currently loaded are merged, the merged result is written to a
* file and then the merged geometry is removed again.
* @return error code, i.e. 0 = okay, 1 = geo_objects is empty, 2 = error while merging, 3 = error writing file
*/
static int writeGeoFile(GeoLib::GEOObjects &geo_objects, std::string const& file_name);
protected:
bool write();
private:
/// Reads a mesh element from the input stream
static std::pair<MeshLib::Element*, int> readElement(std::ifstream &in,
std::vector<MeshLib::Node*> const& nodes,
std::map<unsigned, unsigned> const& id_map);
/**
* 1. get and merge data from _geo_objs
* 2. compute topological hierarchy
* @param out
*/
void writeGMSHInputFile(std::ostream & out);
static void readNodeIDs(std::ifstream &in, unsigned n_nodes, std::vector<unsigned> &node_ids, std::map<unsigned, unsigned> const& id_map);
void writePoints(std::ostream& out) const;
std::size_t _n_lines;
std::size_t _n_plane_sfc;
GeoLib::GEOObjects & _geo_objs;
std::vector<std::string>& _selected_geometries;
std::string _gmsh_geo_name;
std::list<GMSH::GMSHPolygonTree*> _polygon_tree_list;
std::vector<FileIO::GMSH::GMSHPoint*> _gmsh_pnts;
GMSH::GMSHMeshDensityStrategy *_mesh_density_strategy;
};
}
#endif /* GMSHINTERFACE_H_ */