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.
vtkGeoMesh.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_VTKGEOMESH_H_
30 #define NEMOSYS_VTKGEOMESH_H_
31 
32 #include "Mesh/geoMeshBase.H"
33 
34 namespace NEM {
35 namespace MSH {
36 
37 /**
38  * @class vtkGeoMesh
39  * A concrete implementation of @c geoMeshBase representing a mesh in a @c
40  * vtkUnstructuredGrid
41  */
42 class NEMOSYS_EXPORT vtkGeoMesh : public geoMeshBase {
43  public:
44  static vtkGeoMesh *New();
45  vtkTypeMacro(vtkGeoMesh, geoMeshBase)
46 
47  public:
48  /**
49  * Create a vtkGeoMesh from a vtkUnstructuredGrid file.
50  * @param fileName name of file
51  * @param phyGrpArrayName name of a vtkDataArray in the CellData defining the
52  * physical group of each cell
53  * @return new vtkGeoMesh from file
54  */
55  static vtkGeoMesh *Read(const std::string &fileName,
56  const std::string &phyGrpArrayName = std::string());
57 
58  public:
59  /**
60  * Construct a vtkGeoMesh with an empty mesh
61  */
62  vtkGeoMesh();
63 
64  /**
65  * Construct a vtkGeoMesh from an existing vtkUnstructuredGrid
66  * @param inUnstructuredGrid existing vtkUnstructuredGrid; it is used, not
67  * copied
68  * @param phyGrpArrayName name of a vtkDataArray in @p inUnstructuredGrid 's
69  * CellData defining the physical group of each cell
70  */
71  explicit vtkGeoMesh(vtkUnstructuredGrid *inUnstructuredGrid,
72  const std::string &phyGrpArrayName = std::string());
73  ~vtkGeoMesh() override;
74 
75  public:
76  void write(const std::string &fileName) override;
77  void report(std::ostream &out) const override;
78 
79  public:
80  /**
81  * Copy the mesh
82  * @param dest copy the vtkUnstructuredGrid into @p dest
83  */
84  void getVtkMesh(vtkUnstructuredGrid *dest);
85  /**
86  * Set the vtkGeoMesh's mesh to @p vtkMesh
87  * @param vtkMesh existing vtkUnstructured grid; note the pointer is used,
88  * the vtkUnstructuredGrid is not copied
89  */
90  void setVtkMesh(vtkUnstructuredGrid *vtkMesh);
91 
92  private:
93  /**
94  * Create a @c GeoMesh from a @c vtkUnstructuredGrid
95  * @details Assumes gmsh has already been initialized.
96  * @param vtkMesh mesh
97  * @param phyGrpArrayName name of cell data array describing physical group of
98  * each cell
99  * @return @c GeoMesh
100  */
101  static GeoMesh vtk2GM(vtkUnstructuredGrid *vtkMesh,
102  const std::string &phyGrpArrayName = std::string());
103 
104  void resetNative() override;
105 };
106 
107 } // namespace MSH
108 } // namespace NEM
109 
110 #endif // NEMOSYS_VTKGEOMESH_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 mesh in a vtkUnstructuredGrid.
Definition: vtkGeoMesh.H:42
abstract class to specify geometry and mesh data
Definition: geoMeshBase.H:102