Loading...
Searching...
No Matches
ABAQUSCore.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) 2020 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::ABAQUSCore
28
29Description
30 Core routines used when reading/writing ABAQUS files.
31
32 Face mappings for abaqus deduced from libmesh internals
33
34 Tet4 cells
35 \table
36 Face | OpenFOAM | libmesh | abaqus | starcd
37 (1 2 3) | 0 | 2 | 2 | 5
38 (0 3 2) | 1 | 3 | 3 | 4
39 (0 1 3) | 2 | 1 | 1 | 2
40 (0 2 1) | 3 | 0 | 0 | 0
41 \endtable
42
43 Pyr5 cells
44 \table
45 Face | OpenFOAM | libmesh | abaqus | starcd
46 (0 3 2 1) | 0 | 4 | n/a | 0
47 (0 4 3) | 1 | 3 | n/a | 4
48 (3 4 2) | 2 | 2 | n/a | 3
49 (1 2 4) | 3 | 1 | n/a | 5
50 (0 1 4) | 4 | 0 | n/a | 2
51 \endtable
52
53 Prism6 cells
54 \table
55 Face | OpenFOAM | libmesh | abaqus | starcd
56 (0 2 1) | 0 | 0 | 0 | 0
57 (3 4 5) | 1 | 4 | 1 | 1
58 (0 3 5 2) | 2 | 3 | 4 | 4
59 (1 2 5 4) | 3 | 2 | 3 | 5
60 (0 1 4 3) | 4 | 1 | 2 | 2
61 \endtable
62
63 Hex8 cells
64 \table
65 Face | OpenFOAM | libmesh | abaqus | starcd
66 (0 4 7 3) | 0 | 4 | 5 | 4
67 (1 2 6 5) | 1 | 2 | 3 | 5
68 (0 1 5 4) | 2 | 1 | 2 | 2
69 (3 7 6 2) | 3 | 3 | 4 | 3
70 (0 3 2 1) | 4 | 0 | 0 | 0
71 (4 5 6 7) | 5 | 5 | 1 | 1
72 \endtable
73
74SourceFiles
75 ABAQUSCore.C
76
77\*---------------------------------------------------------------------------*/
78
79#ifndef Foam_ABAQUSCore_H
80#define Foam_ABAQUSCore_H
81
82#include "Fstream.H"
83#include "Enum.H"
84#include "Map.H"
85#include "face.H"
86#include "point.H"
87#include "DynamicList.H"
88
89// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90
91namespace Foam
92{
93namespace fileFormats
94{
95
96/*---------------------------------------------------------------------------*\
97 Class fileFormats::ABAQUSCore Declaration
98\*---------------------------------------------------------------------------*/
99
100class ABAQUSCore
101{
102public:
103
104 // Public Data, Declarations
105
106 //- Shape-Type - the values are for internal use only!
107 enum shapeType : uint8_t
108 {
110 abaqusTria = 0x03,
111 abaqusQuad = 0x04,
112 abaqusTet = 0x84,
113 abaqusPyr = 0x85,
114 abaqusPrism = 0x86,
115 abaqusHex = 0x88
116 };
117
118
119 // Public Functions
120
121 //- Classify named element type (eg, S4R) to known/supported
122 //- element types.
123 // The input string must be Uppercase!
124 static shapeType getElementType(const string& elemTypeName);
125
126 //- The number of points associated with the element type
127 inline static int nPoints(shapeType tag)
128 {
129 return (tag & 0x3F);
130 }
131
132 //- True if element type is not unknown/invalid
133 inline static bool isValidType(shapeType tag)
134 {
135 return tag;
136 }
137
138 //- True if element type is a 2D shell
139 inline static bool isShellType(shapeType tag)
140 {
141 return (tag & 0x07) && !(tag & 0x80);
142 }
143
144 //- True if element type is a 3D element
145 inline static bool isSolidType(shapeType tag)
146 {
147 return (tag & 0x80);
148 }
149
150 //- Is a combined (synthetic) face Id?
151 inline static bool isEncodedSolidId(const label combinedId)
152 {
153 return (combinedId < 0);
154 }
155
156 //- Combine solid element Id and side Id into synthetic face Id
157 inline static label encodeSolidId(const label id, const label side)
158 {
159 return -(10 * id + side);
160 }
161
162 //- Entangle solid element id from synthetic face Id
163 inline static label decodeSolidElementId(const label combinedId)
164 {
165 return
166 (
167 isEncodedSolidId(combinedId)
168 ? (-combinedId / 10)
169 : combinedId
170 );
171 }
172
173 //- Entangle solid side id from synthetic face Id
174 //- Synthesize faceId from solid element Id and sideId
175 inline static label decodeSolidSideNum(const label combinedId)
176 {
177 return
178 (
179 isEncodedSolidId(combinedId)
180 ? (-combinedId % 10)
181 : 0
182 );
183 }
184
185
186protected:
187
188 // Protected Member Functions
189
190 //- From 1-based to 0-based
191 inline static void renumber0_elemId(label& elemId)
192 {
193 if (isEncodedSolidId(elemId))
194 {
195 // Eg,
196 // 1-based (solid 4, side 2) is -42
197 // 0-based (solid 3, side 2) is -32
198 elemId += 10;
199 }
200 else
201 {
202 --elemId;
203 }
204 }
205
206 //- Face addressing from ABAQUS faces to OpenFOAM faces.
207 // For hex, prism, tet primitive shapes.
208 static const Map<labelList>& abaqusToFoamFaceAddr();
209
210
211 // Protected Classes
212
213 //- Raw reader structure
214 struct readHelper
215 {
216 // General
217
218 //- Additional verbosity
219 bool verbose_;
220
221
222 // Point Handling
223
224 //- Locations of the points (nodes)
225 DynamicList<point> points_;
226
227 //- The 1-based abaqus Id for the point (node)
228 DynamicList<label> nodeIds_;
229
230
231 // Element Handling
232
233 //- The element connectivity.
234 // Initially uses the abaqus node Id (1-based)
235 // but remapped to 0-based compact form later.
236 DynamicList<labelList> connectivity_;
237
238 //- The 1-based abaqus Id for the element
240
241 //- The element types
243
244 //- The element set ids
246
247 //- Mapping of elem set names
249
251 // Constructos
253 //- Default construct without verbosity
254 explicit readHelper(bool verbosity = false)
256 verbose_(verbosity)
257 {}
258
259
260 // Member Functions
261
262 //- Clear out contents.
263 void clear()
264 {
265 points_.clear();
266 nodeIds_.clear();
267
268 connectivity_.clear();
270
271 elemIds_.clear();
273 elsetMap_.clear();
274 }
275
276 //- Add a new element set name or return an existing one.
277 // Case-insensitive.
278 label addNewElset(const std::string& setName);
279
280
281 //- Read an abaqus input file
282 void read(ISstream& is);
283
284 //- Read entries within a "*Nodes" section.
285 // Appends to points and nodeIds lists.
286 //
287 // \return the number of points read
288 label readPoints(ISstream& is);
290 //- Read entries within an "*Element" section.
291 // If the shape is known/supported, appends to
292 // connectivity, elemType, elemIds lists.
293 //
294 // \return the number of elements read
295 label readElements
296 (
298 const ABAQUSCore::shapeType shape,
299 const label setId = 0
300 );
301
302 //- Read elements within an "*Surface" section.
303 // If the shape is known/supported, appends to
304 // connectivity, elemType, elemIds lists.
305 //
306 // \return the number of elements read
308 (
309 ISstream& is,
310 const label setId = 0
311 );
312
314 //- Remove non-shell elements and compact the points
315 void purge_solids();
316
317 //- Compact unused points and relabel connectivity
318 void compact_nodes();
319
320 //- Renumber elements from 1-based to 0-based
322 };
323
324
325 // Constructors
326
327 //- Default construct
328 ABAQUSCore() = default;
329
330
331public:
332
333 // Public Member Functions
334
335 //- Write '*NODE' header and entries to file, optionally with scaling
336 // This is a no-op for an empty list
337 static void writePoints
338 (
339 Ostream& os,
340 const UList<point>& points,
341 const scalar scaleFactor = 1.0
342 );
343
344 //- Calculate face decomposition for non tri/quad faces
345 //
346 // \param points the surface points
347 // \param faces the surface faces
348 // \param decompOffsets begin/end offsets (size+1) into decompFaces
349 // \param decompFaces List of non-tri/quad decomposed into triangles
350 //
351 // \return number of decomposed faces
352 static label faceDecomposition
354 const UList<point>& points,
355 const UList<face>& faces,
356 labelList& decompOffsets,
357 DynamicList<face>& decompFaces
358 );
359};
360
361
362// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363
364} // End namespace fileFormats
365} // End namespace Foam
366
367// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368
369#endif
370
371// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
Generic input stream using a standard (STL) stream.
Definition ISstream.H:54
A HashTable to objects of type <T> with a label key.
Definition Map.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Core routines used when reading/writing ABAQUS files.
Definition ABAQUSCore.H:240
static bool isValidType(shapeType tag)
True if element type is not unknown/invalid.
Definition ABAQUSCore.H:281
static shapeType getElementType(const string &elemTypeName)
Classify named element type (eg, S4R) to known/supported element types.
Definition ABAQUSCore.C:198
static void renumber0_elemId(label &elemId)
From 1-based to 0-based.
Definition ABAQUSCore.H:353
static int nPoints(shapeType tag)
The number of points associated with the element type.
Definition ABAQUSCore.H:273
static const Map< labelList > & abaqusToFoamFaceAddr()
Face addressing from ABAQUS faces to OpenFOAM faces.
Definition ABAQUSCore.C:184
static label encodeSolidId(const label id, const label side)
Combine solid element Id and side Id into synthetic face Id.
Definition ABAQUSCore.H:313
static label decodeSolidSideNum(const label combinedId)
Entangle solid side id from synthetic face Id Synthesize faceId from solid element Id and sideId.
Definition ABAQUSCore.H:335
static void writePoints(Ostream &os, const UList< point > &points, const scalar scaleFactor=1.0)
Write '*NODE' header and entries to file, optionally with scaling.
Definition ABAQUSCore.C:782
static bool isEncodedSolidId(const label combinedId)
Is a combined (synthetic) face Id?
Definition ABAQUSCore.H:305
static bool isSolidType(shapeType tag)
True if element type is a 3D element.
Definition ABAQUSCore.H:297
ABAQUSCore()=default
Default construct.
static label faceDecomposition(const UList< point > &points, const UList< face > &faces, labelList &decompOffsets, DynamicList< face > &decompFaces)
Calculate face decomposition for non tri/quad faces.
Definition ABAQUSCore.C:817
static label decodeSolidElementId(const label combinedId)
Entangle solid element id from synthetic face Id.
Definition ABAQUSCore.H:321
shapeType
Shape-Type - the values are for internal use only!
Definition ABAQUSCore.H:249
static bool isShellType(shapeType tag)
True if element type is a 2D shell.
Definition ABAQUSCore.H:289
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
label nPoints
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
DynamicList< label > elemIds_
The 1-based abaqus Id for the element.
Definition ABAQUSCore.H:417
label readPoints(ISstream &is)
Read entries within a "*Nodes" section.
Definition ABAQUSCore.C:310
DynamicList< point > points_
Locations of the points (nodes).
Definition ABAQUSCore.H:396
HashTable< label, string > elsetMap_
Mapping of elem set names.
Definition ABAQUSCore.H:432
void renumber_elements_1to0()
Renumber elements from 1-based to 0-based.
Definition ABAQUSCore.C:772
void read(ISstream &is)
Read an abaqus input file.
Definition ABAQUSCore.C:525
bool verbose_
Additional verbosity.
Definition ABAQUSCore.H:388
DynamicList< label > nodeIds_
The 1-based abaqus Id for the point (node).
Definition ABAQUSCore.H:401
DynamicList< labelList > connectivity_
The element connectivity.
Definition ABAQUSCore.H:412
label readElements(ISstream &is, const ABAQUSCore::shapeType shape, const label setId=0)
Read entries within an "*Element" section.
Definition ABAQUSCore.C:347
void purge_solids()
Remove non-shell elements and compact the points.
Definition ABAQUSCore.C:652
label readSurfaceElements(ISstream &is, const label setId=0)
Read elements within an "*Surface" section.
Definition ABAQUSCore.C:402
label addNewElset(const std::string &setName)
Add a new element set name or return an existing one.
Definition ABAQUSCore.C:262
DynamicList< label > elsetIds_
The element set ids.
Definition ABAQUSCore.H:427
readHelper(bool verbosity=false)
Default construct without verbosity.
Definition ABAQUSCore.H:440
void compact_nodes()
Compact unused points and relabel connectivity.
Definition ABAQUSCore.C:678
DynamicList< ABAQUSCore::shapeType > elemTypes_
The element types.
Definition ABAQUSCore.H:422