abaqusSurfaceWriter.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-2022 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::surfaceWriters::abaqusWriter
28 
29 Description
30  A surface writer for the ABAQUS file format - both surface mesh and fields
31 
32  The formatOptions for abaqus:
33  \table
34  Property | Description | Reqd | Default
35  scale | Output geometry scaling | no | 1
36  transform | Output coordinate transform | no |
37  fieldLevel | Subtract field level before scaling | no | empty dict
38  fieldScale | Output field scaling | no | empty dict
39  noGeometry | Suppress geometry output (beta feature) | no | false
40  \endtable
41 
42  For example,
43  \verbatim
44  formatOptions
45  {
46  abaqus
47  {
48  scale 1000; // [m] -> [mm]
49  fieldLevel
50  {
51  p 1e5; // Absolute -> gauge [Pa]
52  }
53  fieldScale
54  {
55  "p.*" 0.01; // [Pa] -> [mbar]
56  }
57  }
58  }
59  \endverbatim
60 
61  \section Output file locations
62 
63  The \c rootdir normally corresponds to something like
64  \c postProcessing/<name>
65 
66  \subsection Geometry
67  \verbatim
68  rootdir
69  `-- surfaceName0
70  `-- geometry
71  `-- surfaceName0_<time>.abq
72  \endverbatim
73 
74  \subsection Fields
75  \verbatim
76  rootdir
77  `-- surfaceName0
78  `-- field0
79  | `-- surfaceName0_<time>.{inp}
80  `-- field1
81  `-- surfaceName0_<time>.{inp}
82  \endverbatim
83 
84 Note
85  Output variable scaling does not apply to integer types such as Ids.
86 
87 SourceFiles
88  abaqusSurfaceWriter.C
89  abaqusSurfaceWriterImpl.C
90 
91 \*---------------------------------------------------------------------------*/
92 
93 #ifndef Foam_surfaceWriters_abaqusWriter_H
94 #define Foam_surfaceWriters_abaqusWriter_H
95 
96 #include "surfaceWriter.H"
97 #include "ABAQUSCore.H"
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 namespace Foam
102 {
103 namespace surfaceWriters
104 {
105 
106 /*---------------------------------------------------------------------------*\
107  Class abaqusWriter Declaration
108 \*---------------------------------------------------------------------------*/
109 
110 class abaqusWriter
111 :
112  public surfaceWriter
113 {
114  // Private Data
115 
116  //- BETA feature
117  bool noGeometry_;
118 
119  //- Output directory layouts
120  enum class outputLayoutType
121  {
122  BY_TIME = 0,
123  BY_FIELD,
124  };
125 
126  //- Output directory layout
127  outputLayoutType outputLayout_;
128 
129 
130  // Private Member Functions
131 
132  //- Write face element (tri/quad)
133  void writeFace
134  (
136  const labelUList& f,
137  const label elemId,
138  const label propId,
139  const bool header = true
140  ) const;
141 
142  //- Write the surface mesh geometry, tracking face decomposition
143  //
144  // \param decompOffsets begin/end offsets (size+1) into decompFaces
145  // \param decompFaces Non tri/quad decomposed into triangles
146  void writeGeometry
147  (
148  Ostream& os,
149  const meshedSurf& surf,
150  labelList& decompOffsets,
151  DynamicList<face>& decompFaces
152  ) const;
153 
154  //- Write a face-based value
155  template<class Type>
156  Ostream& writeFaceValue
157  (
158  Ostream& os,
159  const Type& value,
160  const label elemId
161  ) const;
162 
163  //- Templated write operation
164  template<class Type>
165  fileName writeTemplate
166  (
167  const word& fieldName,
168  const Field<Type>& localValues
169  );
170 
171 
172 public:
173 
174  //- Declare type-name, virtual type (with debug switch)
175  TypeNameNoDebug("abaqus");
176 
177 
178  // Constructors
179 
180  //- Default construct
181  abaqusWriter();
182 
183  //- Construct with some output options
184  explicit abaqusWriter(const dictionary& options);
185 
186  //- Construct from components
188  (
189  const meshedSurf& surf,
190  const fileName& outputPath,
191  bool parallel = UPstream::parRun(),
192  const dictionary& options = dictionary()
193  );
194 
195  //- Construct from components
197  (
198  const pointField& points,
199  const faceList& faces,
200  const fileName& outputPath,
201  bool parallel = UPstream::parRun(),
202  const dictionary& options = dictionary()
203  );
204 
205 
206  //- Destructor
207  virtual ~abaqusWriter() = default;
208 
209 
210  // Member Functions
211 
212  //- Format uses faceIds as part of its output
213  virtual bool usesFaceIds() const // override
214  {
215  return true;
216  }
217 
218  //- Write surface geometry to file.
219  virtual fileName write(); // override
220 
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace surfaceWriters
233 } // End namespace Foam
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:43
const pointField & points
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
TypeNameNoDebug("abaqus")
Declare type-name, virtual type (with debug switch)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
labelList f(nPoints)
virtual ~abaqusWriter()=default
Destructor.
virtual fileName write()
Write surface geometry to file.
virtual bool usesFaceIds() const
Format uses faceIds as part of its output.
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.