Loading...
Searching...
No Matches
ensightMeshReader.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::fileFormats::ensightMeshReader
28
29Description
30
31Notes
32
33SourceFiles
34 ensightMeshReader.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_ensightMeshReader_H
39#define Foam_ensightMeshReader_H
40
41#include "meshReader.H"
42//#include "ensightReadFile.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class ensightReadFile;
51
52namespace fileFormats
53{
55/*---------------------------------------------------------------------------*\
56 Class fileFormats::ensightMeshReader Declaration
57\*---------------------------------------------------------------------------*/
58
60:
61 public meshReader
62{
63 // Private Data
64
65 //- Merge distance
66 const scalar mergeTol_;
67
68 //- Check and correct handedness
69 const bool setHandedness_;
70
71
72protected:
73
74 // Protected Data
75
76 //- mesh point to original node_id
79 //- mesh cell to original element_id
81
82
83 // Protected Member Functions
84
85 //- Rotate face so lowest vertex is first
86 const face& rotateFace
87 (
88 const face& f,
89 face& rotatedFace
90 ) const;
92 //- Read set of vertices. Optional mapping
93 void readVerts
94 (
96 const label nVerts,
97 const Map<label>& nodeIdToPoints,
99 ) const;
101 //- Read set of element/node IDs
102 void readIDs
103 (
104 ensightReadFile& is,
105 const bool doRead,
106 const label nShapes,
107 labelList& foamToElem,
108 Map<label>& elemToFoam
109 ) const;
110
111 //- Swap handedness of hex if needed
112 void setHandedness
113 (
114 const cellModel& model,
115 DynamicList<label>& verts,
116 const pointField& points
117 ) const;
118
119 //- Read a single part until eof (return true) or until start of next
120 // part (return false)
121 bool readGoldPart
122 (
124 const bool read_node_ids,
125 const bool read_elem_ids,
126
128 labelList& pointToNodeIds,
129 Map<label>& nodeIdToPoints,
130
131 // 3D-elems : cells (cell-to-faces)
132 faceListList& cellFaces,
133 labelList& cellToElemIds,
134 Map<label>& elemIdToCells,
136 // 2D-elems : faces
137 faceList& faces,
138 labelList& faceToElemIDs,
139 Map<label>& elemIdToFaces
140 ) const;
141
142 //- Read the mesh from the file(s)
143 virtual bool readGeometry(const scalar scaleFactor = 1.0);
144
145
146public:
147
148 //- Runtime type information
149 TypeName("ensightMeshReader");
150
151
152 // Constructors
153
154 //- Construct from case name
156 (
157 const fileName& geomFile,
158 const objectRegistry& registry,
159 const scalar mergeTol = SMALL,
160 const scalar scaleFactor = 1.0,
161 const bool setHandedness = true
162 );
163
164
165 //- Destructor
166 virtual ~ensightMeshReader() = default;
168
169 // Access
170
171 //- Original node id (if supplied) or -1
172 const labelList& nodeIds() const noexcept
173 {
174 return nodeIds_;
176
177 //- Original element id (if supplied) or -1
178 const labelList& elementIds() const noexcept
179 {
180 return elementIds_;
181 }
182};
183
184
185// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186
187} // End namespace fileFormats
188} // End namespace Foam
189
190// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191
192#endif
193
194// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
Maps a geometry to a set of cell primitives.
Definition cellModel.H:73
A variant of IFstream with specialised handling for Ensight reading of strings, integers and floats (...
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
TypeName("ensightMeshReader")
Runtime type information.
const labelList & nodeIds() const noexcept
Original node id (if supplied) or -1.
void readVerts(ensightReadFile &is, const label nVerts, const Map< label > &nodeIdToPoints, DynamicList< label > &verts) const
Read set of vertices. Optional mapping.
virtual ~ensightMeshReader()=default
Destructor.
virtual bool readGeometry(const scalar scaleFactor=1.0)
Read the mesh from the file(s).
labelList nodeIds_
mesh point to original node_id
void readIDs(ensightReadFile &is, const bool doRead, const label nShapes, labelList &foamToElem, Map< label > &elemToFoam) const
Read set of element/node IDs.
bool readGoldPart(ensightReadFile &is, const bool read_node_ids, const bool read_elem_ids, pointField &points, labelList &pointToNodeIds, Map< label > &nodeIdToPoints, faceListList &cellFaces, labelList &cellToElemIds, Map< label > &elemIdToCells, faceList &faces, labelList &faceToElemIDs, Map< label > &elemIdToFaces) const
Read a single part until eof (return true) or until start of next.
const labelList & elementIds() const noexcept
Original element id (if supplied) or -1.
labelList elementIds_
mesh cell to original element_id
void setHandedness(const cellModel &model, DynamicList< label > &verts, const pointField &points) const
Swap handedness of hex if needed.
const face & rotateFace(const face &f, face &rotatedFace) const
Rotate face so lowest vertex is first.
ensightMeshReader(const fileName &geomFile, const objectRegistry &registry, const scalar mergeTol=SMALL, const scalar scaleFactor=1.0, const bool setHandedness=true)
Construct from case name.
A class for handling file names.
Definition fileName.H:75
Registry of regIOobjects.
const pointField & points
Namespace to isolate specifics for file formats, and some common utilities.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
List< faceList > faceListList
List of faceList.
Definition faceListFwd.H:44
const direction noexcept
Definition scalarImpl.H:265
vectorField pointField
pointField is a vectorField.
labelList f(nPoints)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68