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.
pntMesh.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_PNTMESH_H_
30 #define NEMOSYS_PNTMESH_H_
31 
32 // Nemosys headers
33 #include "nemosys_export.h"
34 #include "Mesh/meshBase.H"
35 
36 // VTK
37 #include <vtkCellTypes.h>
38 
39 // others
40 #include <set>
41 #include <map>
42 
43 namespace PNTMesh {
44 
45 using idTyp = int;
46 
47 enum class elementType {
48  BAR,
50  TRIANGLE,
51  HEXAGON,
52  SPHERICAL,
54  BRICK,
57  HEXPRISM,
58  PRISMATIC,
59  OTHER
60 };
61 
62 enum class surfaceBCTag {
63  REFLECTIVE,
64  VOID
65 };
66 
67 struct blockType {
71  int ordIntrp;
72  int ordEquat;
75  std::string regionName;
76  std::vector<int> elmIds;
77  std::vector<surfaceBCTag> srfBCTag;
78  std::vector<int> srfBCEleRef;
79  std::vector<int> glbSrfId;
80  std::vector<int> adjBlkId;
81  std::vector<int> adjElmId;
82  std::vector<int> adjRefId;
83  std::vector<std::vector<int>> eConn;
84 };
85 
86 using BlockMap = std::vector<blockType>;
87 
88 VTKCellType p2vEMap(elementType et);
89 elementType v2pEMap(VTKCellType vt);
90 surfaceBCTag bcTagNum(const std::string &tag);
91 std::string bcTagStr(surfaceBCTag tag);
92 elementType elmTypeNum(const std::string &tag);
93 std::string elmTypeStr(elementType tag);
94 int elmNumNde(elementType et, int order);
95 int elmNumSrf(elementType et);
96 
97 
98 class NEMOSYS_DEPRECATED_EXPORT pntMesh
99 {
100  public:
101  pntMesh();
102  explicit pntMesh(const std::string &ifname);
103  pntMesh(const meshBase *imb, int dim, int nBlk, const BlockMap &elmBlkMap);
104 
105  ~pntMesh() = default;
106 
107  public:
108  bool isCompatible() const { return isSupported; }
109  int getNumberOfPoints() const { return numVertices; }
110  int getNumberOfCells() const { return numElements; }
111  int getNumberOfBlocks() const { return numBlocks; }
112 
113  std::vector<double> getPointCrd(int id) const { return pntCrds[id]; }
114  std::vector<int> getElmConn(int id) const { return elmConn[id]; }
115 
116  std::vector<int> getElmConn(int id, VTKCellType vct) const;
117  std::vector<int>
118  getPntConn(std::vector<int> &ci, elementType et, int eo) const;
119  std::string getBlockName(int id) const;
120  elementType getBlockElmType(int id) const;
121 
122  elementType getElmType(int id) const;
123  int getElmOrder(int id) const;
124  VTKCellType getVtkCellTag(elementType et, int order) const;
125 
126  void write(const std::string &fname) const;
127 
128  private:
129  // populate quantities needed to write
130  // pntmesh file
131  void pntPopulate(const meshBase *imb);
132  void updElmBlk(int blkId);
133 
134  private:
135  std::string ifname;
143  std::vector<std::vector<double>> pntCrds;
144  std::vector<std::vector<int>> elmConn; // connectivities
145  std::vector<elementType> elmTyp; // type
146  std::vector<int> elmOrd; // order
147  std::vector<int> elmBlkId; // element block number
148  std::vector<int> elmLocalId; // elements local id indexed by global ids
149  std::vector<std::vector<int>> elmSrfId; // element surface/edge Ids
150  std::vector<blockType> elmBlks;
151 
152  bool isSupported; // false is non Tri/Tet elements were found
153 
154  // pnt topological information
155  std::set<std::set<int>> connSet;
156  std::map<std::set<int>, int> surfConnToId;
157  std::map<int, std::set<int>> surfIdToConn;
158  std::vector<bool> surfOnBndr;
159  std::map<int, std::vector<std::pair<int, int>>> surfAdjRefNum;
160  std::map<int, std::vector<int> > surfAdjElmNum;
161 };
162 
163 } // namespace PNTMesh
164 
165 #endif // NEMOSYS_PNTMESH_H_
bool isCompatible() const
Definition: pntMesh.H:108
std::vector< int > adjRefId
Definition: pntMesh.H:82
surfaceBCTag
Definition: pntMesh.H:62
std::vector< int > elmIds
Definition: pntMesh.H:76
std::vector< int > elmLocalId
Definition: pntMesh.H:148
std::string regionName
Definition: pntMesh.H:75
A brief description of meshBase.
Definition: meshBase.H:64
int numElementsInBlock
Definition: pntMesh.H:68
bool isSupported
Definition: pntMesh.H:152
std::string ifname
Definition: pntMesh.H:135
std::vector< int > adjElmId
Definition: pntMesh.H:81
std::string elmTypeStr(elementType tag)
Definition: pntMesh.C:117
int elmNumSrf(elementType et)
Definition: pntMesh.C:155
std::map< int, std::set< int > > surfIdToConn
Definition: pntMesh.H:157
std::vector< std::vector< int > > elmSrfId
Definition: pntMesh.H:149
std::vector< int > elmOrd
Definition: pntMesh.H:146
std::set< std::set< int > > connSet
Definition: pntMesh.H:155
int idTyp
Definition: pntMesh.H:45
std::vector< int > srfBCEleRef
Definition: pntMesh.H:78
int numSurfInternal
Definition: pntMesh.H:141
std::vector< int > glbSrfId
Definition: pntMesh.H:79
std::vector< double > getPointCrd(int id) const
Definition: pntMesh.H:113
std::vector< int > adjBlkId
Definition: pntMesh.H:80
std::vector< elementType > elmTyp
Definition: pntMesh.H:145
std::vector< std::vector< int > > elmConn
Definition: pntMesh.H:144
int numBoundarySurfacesInBlock
Definition: pntMesh.H:69
std::vector< blockType > elmBlks
Definition: pntMesh.H:150
vtkIdType id
id in .inp file
Definition: inpGeoMesh.C:128
surfaceBCTag bcTagNum(const std::string &tag)
Definition: pntMesh.C:78
std::vector< int > elmBlkId
Definition: pntMesh.H:147
std::map< int, std::vector< int > > surfAdjElmNum
Definition: pntMesh.H:160
std::vector< bool > surfOnBndr
Definition: pntMesh.H:158
int getNumberOfBlocks() const
Definition: pntMesh.H:111
std::map< std::set< int >, int > surfConnToId
Definition: pntMesh.H:156
elementType v2pEMap(VTKCellType vt)
Definition: pntMesh.C:58
int numSurfBoundary
Definition: pntMesh.H:142
elementType eTpe
Definition: pntMesh.H:74
VTKCellType p2vEMap(elementType et)
Definition: pntMesh.C:38
elementType
Definition: pntMesh.H:47
std::vector< std::vector< int > > eConn
Definition: pntMesh.H:83
std::vector< int > getElmConn(int id) const
Definition: pntMesh.H:114
int numSurfPerEleInBlock
Definition: pntMesh.H:73
std::map< int, std::vector< std::pair< int, int > > > surfAdjRefNum
Definition: pntMesh.H:159
std::vector< blockType > BlockMap
Definition: pntMesh.H:86
std::vector< std::vector< double > > pntCrds
Definition: pntMesh.H:143
int elmNumNde(elementType et, int order)
Definition: pntMesh.C:133
int getNumberOfPoints() const
Definition: pntMesh.H:109
elementType elmTypeNum(const std::string &tag)
Definition: pntMesh.C:97
std::vector< surfaceBCTag > srfBCTag
Definition: pntMesh.H:77
std::string bcTagStr(surfaceBCTag tag)
Definition: pntMesh.C:88
int getNumberOfCells() const
Definition: pntMesh.H:110