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 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 | Required | Default
35  scale | output geometry scaling | no | 1
36  fieldScale | output field scaling (dictionary) | no | empty
37  noGeometry | Suppress geometry output (beta feature) | no | false
38  \endtable
39 
40  For example,
41  \verbatim
42  formatOptions
43  {
44  abaqus
45  {
46  scale 1000; // [m] -> [mm]
47  fieldScale
48  {
49  "p.*" 0.01; // [Pa] -> [mbar]
50  }
51  }
52  }
53  \endverbatim
54 
55  \section Output file locations
56 
57  The \c rootdir normally corresponds to something like
58  \c postProcessing/<name>
59 
60  \subsection Geometry
61  \verbatim
62  rootdir
63  `-- surfaceName0
64  `-- geometry
65  `-- surfaceName0_<time>.abq
66  \endverbatim
67 
68  \subsection Fields
69  \verbatim
70  rootdir
71  `-- surfaceName0
72  `-- field0
73  | `-- surfaceName0_<time>.{inp}
74  `-- field1
75  `-- surfaceName0_<time>.{inp}
76  \endverbatim
77 
78 Note
79  Output variable scaling does not apply to integer types such as Ids.
80 
81 SourceFiles
82  abaqusSurfaceWriter.C
83  abaqusSurfaceWriterImpl.C
84 
85 \*---------------------------------------------------------------------------*/
86 
87 #ifndef abaqusSurfaceWriter_H
88 #define abaqusSurfaceWriter_H
89 
90 #include "surfaceWriter.H"
91 #include "ABAQUSCore.H"
92 
93 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
94 
95 namespace Foam
96 {
97 namespace surfaceWriters
98 {
99 
100 /*---------------------------------------------------------------------------*\
101  Class abaqusWriter Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 class abaqusWriter
105 :
106  public surfaceWriter
107 {
108  // Private Data
109 
110  //- Output geometry scaling
111  const scalar geometryScale_;
112 
113  //- Output field scaling
114  const dictionary fieldScale_;
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  (
135  Ostream& os,
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 = Pstream::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 = Pstream::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 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::SymmTensor< scalar >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:114
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::surfaceWriters::abaqusWriter::TypeNameNoDebug
TypeNameNoDebug("abaqus")
Declare type-name, virtual type (with debug switch)
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
surfaceWriter.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::surfaceWriters::abaqusWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: abaqusSurfaceWriter.C:291
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::surfaceWriters::abaqusWriter::abaqusWriter
abaqusWriter()
Default construct.
Definition: abaqusSurfaceWriter.C:237
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::surfaceWriters::abaqusWriter::~abaqusWriter
virtual ~abaqusWriter()=default
Destructor.
Foam::surfaceWriters::abaqusWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
f
labelList f(nPoints)
Foam::Vector< scalar >
Foam::UPstream::parRun
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Foam::List< label >
Foam::surfaceWriters::abaqusWriter::usesFaceIds
virtual bool usesFaceIds() const
Format uses faceIds as part of its output.
Definition: abaqusSurfaceWriter.H:232
Foam::UList< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
ABAQUSCore.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::surfaceWriters::abaqusWriter
A surface writer for the ABAQUS file format - both surface mesh and fields.
Definition: abaqusSurfaceWriter.H:123