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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::fileFormats::ABAQUSCore
28 
29 Description
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 
74 SourceFiles
75  ABAQUSCore.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef ABAQUSCore_H
80 #define 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 
91 namespace Foam
92 {
93 
94 namespace fileFormats
95 {
96 
97 /*---------------------------------------------------------------------------*\
98  Class fileFormats::ABAQUSCore Declaration
99 \*---------------------------------------------------------------------------*/
100 
101 class ABAQUSCore
102 {
103 public:
104 
105  // Public Data, Declarations
106 
107  //- Shape-Type - the values are for internal use only!
108  enum shapeType : uint8_t
109  {
110  abaqusUnknownShape = 0,
111  abaqusTria = 0x03,
112  abaqusQuad = 0x04,
113  abaqusTet = 0x84,
114  abaqusPyr = 0x85,
115  abaqusPrism = 0x86,
116  abaqusHex = 0x88
117  };
118 
119 
120  // Public Functions
121 
122  //- Classify named element type (eg, S4R) to known/supported
123  //- element types.
124  // The input string must be Uppercase!
125  static shapeType getElementType(const std::string& elemTypeName);
126 
127  //- The number of points associated with the element type
128  inline static int nPoints(shapeType tag)
129  {
130  return (tag & 0x3F);
131  }
132 
133  //- True if element type is not unknown/invalid
134  inline static bool isValidType(shapeType tag)
135  {
136  return tag;
137  }
138 
139  //- True if element type is a 2D shell
140  inline static bool isShellType(shapeType tag)
141  {
142  return (tag & 0x07) && !(tag & 0x80);
143  }
144 
145  //- True if element type is a 3D element
146  inline static bool isSolidType(shapeType tag)
147  {
148  return (tag & 0x80);
149  }
150 
151 
152 protected:
153 
154  // Protected Member Functions
155 
156  //- Face addressing from ABAQUS faces to OpenFOAM faces.
157  // For hex, prism, tet primitive shapes.
158  static const Map<labelList>& abaqusToFoamFaceAddr();
159 
160 
161  // Protected Classes
162 
163  //- Raw reader structure
164  struct readHelper
165  {
166  // General
167 
168  //- Additional verbosity
169  bool verbose_;
170 
171 
172  // Point Handling
173 
174  //- Locations of the points (nodes)
175  DynamicList<point> points_;
176 
177  //- The 1-based abaqus Id for the point (node)
178  DynamicList<label> nodeIds_;
179 
180 
181  // Element Handling
182 
183  //- The element connectivity.
184  // Initially uses the abaqus node Id (1-based)
185  // but remapped to 0-based compact form later.
186  DynamicList<labelList> connectivity_;
187 
188  //- The 1-based abaqus Id for the element
189  DynamicList<label> elemIds_;
190 
191  //- The element types
192  DynamicList<ABAQUSCore::shapeType> elemTypes_;
193 
194  //- The element set ids
195  DynamicList<label> elsetIds_;
196 
197  //- Mapping of elem set names
198  HashTable<label, string> elsetMap_;
199 
200 
201  // Constructos
202 
203  //- Default construct without verbosity
204  explicit readHelper(bool verbosity = false)
205  :
206  verbose_(verbosity)
207  {}
208 
209 
210  // Member Functions
211 
212  //- Clear out contents.
213  void clear()
214  {
215  points_.clear();
216  nodeIds_.clear();
217 
218  connectivity_.clear();
219  elemTypes_.clear();
220 
221  elemIds_.clear();
222  elsetIds_.clear();
223  elsetMap_.clear();
224  }
225 
226  //- Add a new element set name or return an existing one.
227  // Case-insensitive.
228  label addNewElset(const std::string& setName);
229 
230 
231  //- Read an abaqus input file
232  void read(ISstream& is);
233 
234  //- Read entries within a "*Nodes" section.
235  // Appends to points and nodeIds lists.
236  //
237  // \return the number of points read
238  label readPoints(ISstream& is);
239 
240  //- Read entries within an "*Element" section.
241  // If the shape is known/supported, appends to
242  // connectivity, elemType, elemIds lists.
243  //
244  // \return the number of elements read
245  label readElements
246  (
247  ISstream& is,
248  const ABAQUSCore::shapeType shape,
249  const label setId = 0
250  );
251 
252 
253  //- Remove non-shell elements and compact the points
254  void purge_solids();
255 
256  //- Compact unused points and relabel connectivity
258  };
259 
260 
261  // Constructors
262 
263  //- Default construct
264  ABAQUSCore() = default;
265 
266 
267 public:
268 
269  // Public Member Functions
270 
271  //- Write '*NODE' header and entries to file, optionally with scaling
272  // This is a no-op for an empty list
273  static void writePoints
274  (
275  Ostream& os,
276  const UList<point>& points,
277  const scalar scaleFactor = 1.0
278  );
279 
280  //- Calculate face decomposition for non tri/quad faces
281  //
282  // \param points the surface points
283  // \param faces the surface faces
284  // \param decompOffsets begin/end offsets (size+1) into decompFaces
285  // \param decompFaces List of non-tri/quad decomposed into triangles
286  //
287  // \return number of decomposed faces
288  static label faceDecomposition
289  (
290  const UList<point>& points,
291  const UList<face>& faces,
292  labelList& decompOffsets,
293  DynamicList<face>& decompFaces
294  );
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace fileFormats
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #endif
306 
307 // ************************************************************************* //
Foam::fileFormats::ABAQUSCore::readHelper::readElements
label readElements(ISstream &is, const ABAQUSCore::shapeType shape, const label setId=0)
Read entries within an "*Element" section.
Definition: ABAQUSCore.C:353
Foam::fileFormats::ABAQUSCore::readHelper::addNewElset
label addNewElset(const std::string &setName)
Add a new element set name or return an existing one.
Definition: ABAQUSCore.C:267
Foam::fileFormats::ABAQUSCore::readHelper::verbose_
bool verbose_
Additional verbosity.
Definition: ABAQUSCore.H:312
Foam::fileFormats::ABAQUSCore::abaqusQuad
Definition: ABAQUSCore.H:255
Foam::DynamicList< point >
point.H
Foam::fileFormats::ABAQUSCore::abaqusPyr
Definition: ABAQUSCore.H:257
Foam::fileFormats::ABAQUSCore::readHelper::elemIds_
DynamicList< label > elemIds_
The 1-based abaqus Id for the element.
Definition: ABAQUSCore.H:332
face.H
Foam::fileFormats::ABAQUSCore::readHelper::clear
void clear()
Clear out contents.
Definition: ABAQUSCore.H:356
Foam::ISstream
Generic input stream using a standard (STL) stream.
Definition: ISstream.H:55
Foam::fileFormats::ABAQUSCore::readHelper::read
void read(ISstream &is)
Read an abaqus input file.
Definition: ABAQUSCore.C:407
Foam::fileFormats::ABAQUSCore::isValidType
static bool isValidType(shapeType tag)
True if element type is not unknown/invalid.
Definition: ABAQUSCore.H:277
Foam::Map
A HashTable to objects of type <T> with a label key.
Definition: lumpedPointController.H:69
Foam::fileFormats::ABAQUSCore
Core routines used when reading/writing ABAQUS files.
Definition: ABAQUSCore.H:244
Foam::fileFormats::ABAQUSCore::readHelper::elsetMap_
HashTable< label, string > elsetMap_
Mapping of elem set names.
Definition: ABAQUSCore.H:341
Foam::fileFormats::ABAQUSCore::readHelper::compact_nodes
void compact_nodes()
Compact unused points and relabel connectivity.
Definition: ABAQUSCore.C:532
Map.H
Foam::fileFormats::ABAQUSCore::getElementType
static shapeType getElementType(const std::string &elemTypeName)
Definition: ABAQUSCore.C:203
Foam::fileFormats::ABAQUSCore::readHelper::readPoints
label readPoints(ISstream &is)
Read entries within a "*Nodes" section.
Definition: ABAQUSCore.C:315
Foam::fileFormats::ABAQUSCore::readHelper
Raw reader structure.
Definition: ABAQUSCore.H:307
Foam::fileFormats::ABAQUSCore::abaqusPrism
Definition: ABAQUSCore.H:258
Foam::fileFormats::ABAQUSCore::nPoints
static int nPoints(shapeType tag)
The number of points associated with the element type.
Definition: ABAQUSCore.H:271
Foam::DynamicList::clear
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:348
Foam::fileFormats::ABAQUSCore::faceDecomposition
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:662
Foam::fileFormats::ABAQUSCore::abaqusUnknownShape
Definition: ABAQUSCore.H:253
Foam::fileFormats::ABAQUSCore::abaqusToFoamFaceAddr
static const Map< labelList > & abaqusToFoamFaceAddr()
Face addressing from ABAQUS faces to OpenFOAM faces.
Definition: ABAQUSCore.C:189
Foam::fileFormats::ABAQUSCore::readHelper::points_
DynamicList< point > points_
Locations of the points (nodes)
Definition: ABAQUSCore.H:318
Foam::fileFormats::ABAQUSCore::ABAQUSCore
ABAQUSCore()=default
Default construct.
Foam::fileFormats::ABAQUSCore::abaqusHex
Definition: ABAQUSCore.H:259
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileFormats::ABAQUSCore::readHelper::purge_solids
void purge_solids()
Remove non-shell elements and compact the points.
Definition: ABAQUSCore.C:506
Foam::fileFormats::ABAQUSCore::abaqusTet
Definition: ABAQUSCore.H:256
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::fileFormats::ABAQUSCore::readHelper::elsetIds_
DynamicList< label > elsetIds_
The element set ids.
Definition: ABAQUSCore.H:338
Fstream.H
Input/output from file streams.
Foam::List< label >
Foam::fileFormats::ABAQUSCore::shapeType
shapeType
Shape-Type - the values are for internal use only!
Definition: ABAQUSCore.H:251
Foam::fileFormats::ABAQUSCore::isShellType
static bool isShellType(shapeType tag)
True if element type is a 2D shell.
Definition: ABAQUSCore.H:283
Foam::fileFormats::ABAQUSCore::readHelper::readHelper
readHelper(bool verbosity=false)
Default construct without verbosity.
Definition: ABAQUSCore.H:347
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::fileFormats::ABAQUSCore::readHelper::nodeIds_
DynamicList< label > nodeIds_
The 1-based abaqus Id for the point (node)
Definition: ABAQUSCore.H:321
Foam::fileFormats::ABAQUSCore::readHelper::connectivity_
DynamicList< labelList > connectivity_
The element connectivity.
Definition: ABAQUSCore.H:329
DynamicList.H
Foam::fileFormats::ABAQUSCore::writePoints
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:627
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fileFormats::ABAQUSCore::abaqusTria
Definition: ABAQUSCore.H:254
Foam::fileFormats::ABAQUSCore::readHelper::elemTypes_
DynamicList< ABAQUSCore::shapeType > elemTypes_
The element types.
Definition: ABAQUSCore.H:335
Foam::fileFormats::ABAQUSCore::isSolidType
static bool isSolidType(shapeType tag)
True if element type is a 3D element.
Definition: ABAQUSCore.H:289
Enum.H