NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
gmshGeoMesh.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_GMSHGEOMESH_H_
30 #define NEMOSYS_GMSHGEOMESH_H_
31 
32 #include "Mesh/geoMeshBase.H"
33 
34 namespace NEM {
35 namespace MSH {
36 
37 /**
38  * @class gmshGeoMesh
39  * A concrete implementation of @c geoMeshBase representing a Gmsh mesh.
40  */
41 class NEMOSYS_EXPORT gmshGeoMesh : public geoMeshBase {
42  public:
43  static gmshGeoMesh *New();
44  vtkTypeMacro(gmshGeoMesh, geoMeshBase)
45 
46  public:
47  /**
48  * Create a gmshGeoMesh from a file
49  * @param fileName file name that gmsh can read
50  * @return new gmshGeoMesh object
51  */
52  static gmshGeoMesh *Read(const std::string &fileName);
53  /**
54  * Convert gmsh cell type to VTK cell type
55  * @param gmshType gmsh cell type
56  * @return VTK cell type
57  */
58  static VTKCellType getVTKTypeFromGmshType(const std::string &gmshType);
59 
60  public:
61  /**
62  * Construct a gmshGeoMesh with an empty mesh.
63  */
64  gmshGeoMesh();
65 
66  /**
67  * Construct a gmshGeoMesh from an existing gmsh model
68  * @param gmshMesh name of gmsh model created from @c gmsh::open or @c
69  * gmsh::add
70  */
71  explicit gmshGeoMesh(const std::string &gmshMesh);
72 
73  ~gmshGeoMesh() override;
74 
75  public:
76  void write(const std::string &fileName) override;
77  void report(std::ostream &out) const override;
78 
79  private:
80  /**
81  * Convert @p gmshMesh (name of a gmsh model) to GeoMesh
82  */
83  static GeoMesh gmsh2GM(const std::string &gmshMesh);
84  /**
85  * Add the mesh from @p geoMesh to the gmsh model in @p geoMesh
86  */
87  static std::string GM2gmsh(const GeoMesh &geoMesh);
88 
89  void resetNative() override;
90 
91  private:
92  std::string _gmshMesh;
93 };
94 
95 } // namespace MSH
96 } // namespace NEM
97 
98 #endif // NEMOSYS_GMSHGEOMESH_H_
geoMeshBase * Read(const std::string &fileName)
Read a mesh from file.
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
A concrete implementation of geoMeshBase representing a Gmsh mesh.
Definition: gmshGeoMesh.H:41
std::string _gmshMesh
Definition: gmshGeoMesh.H:92
abstract class to specify geometry and mesh data
Definition: geoMeshBase.H:102