Loading...
Searching...
No Matches
nastranSurfaceWriter.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2015-2024 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::surfaceWriters::nastranWriter
29
30Description
31 A surface writer for the Nastran file format - both surface mesh and fields
32
33 The formatOptions for nastran:
34 \table
35 Property | Description | Reqd | Default
36 format | Nastran format (short/long/free) | no | free
37 scale | Output geometry scaling | no | 1
38 transform | Output coordinate transform | no |
39 fieldLevel | Subtract field level before scaling | no | empty dict
40 fieldScale | Output field scaling | no | empty dict
41 commonGeometry | use separate geometry files | no | false
42 PLOAD2 | Field selection (words/regex) for PLOAD2 | no |
43 PLOAD4 | Field selection (words/regex) for PLOAD4 | no |
44 fields | Compat: Field pairs for PLOAD2/PLOAD4 | no |
45 \endtable
46
47 For example,
48 \verbatim
49 formatOptions
50 {
51 nastran
52 {
53 format free; // format type
54
55 scale 1000; // [m] -> [mm]
56 fieldScale
57 {
58 "p.*" 0.01; // [Pa] -> [mbar]
59 }
60
61 // Specific NASTRAN load types
62 PLOAD2 ( pMean );
63 PLOAD4 ( "p.*" );
64
65 // old style specification
66 fields
67 (
68 (pMean PLOAD2)
69 (p PLOAD4)
70 );
71 }
72 }
73 \endverbatim
74
75 Unless otherwise specified, all fields will be treated as PLOAD2
76 output. Can optionally specify PLOAD4 output using a combination
77 of \c PLOAD4 (accept) and \c PLOAD2 (deny) entries. The older \c fields
78 specification is also accepted and will be transcribed to
79 corresponding PLOAD4, PLOAD2 entries.
80
81 \section Output file locations
82
83 The \c rootdir normally corresponds to something like
84 \c postProcessing/<name>
85
86 \subsection Geometry
87 \verbatim
88 rootdir
89 `-- <time>
90 |-- surfaceName0.{nas}
91 `-- surfaceName1.{nas}
92 \endverbatim
93
94 \subsection Fields
95 \verbatim
96 rootdir
97 `-- <time>
98 `-- field0
99 | |-- surfaceName0.{bdf}
100 | `-- surfaceName1.{bdf}
101 `-- field1
102 |-- surfaceName0.{bdf}
103 `-- surfaceName1.{bdf}
104 \endverbatim
105
106Note
107 Output variable scaling does not apply to integer types such as Ids.
108
109SourceFiles
110 nastranSurfaceWriter.C
111 nastranSurfaceWriterImpl.C
112
113\*---------------------------------------------------------------------------*/
114
115#ifndef Foam_surfaceWriters_nastranWriter_H
116#define Foam_surfaceWriters_nastranWriter_H
117
118#include "surfaceWriter.H"
119#include "NASCore.H"
120#include "wordRes.H"
121
122// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123
124namespace Foam
125{
126namespace surfaceWriters
127{
128
129/*---------------------------------------------------------------------------*\
130 Class nastranWriter Declaration
131\*---------------------------------------------------------------------------*/
132
133class nastranWriter
134:
135 public surfaceWriter
136{
137public:
138
139 //- File field formats
141
142 //- Output load format
144
145
146private:
147
148 // Private Data
149
150 //- Field format (width and separator)
151 fieldFormat writeFormat_;
152
153 //- Use common geometry file
154 bool commonGeometry_;
155
156 //- Separator (used for free format)
157 word separator_;
158
159 //- Explicit selection for PLOAD2 output (deselects for PLOAD4)
160 wordRes pload2_;
161
162 //- Explicit selection for PLOAD4 output
163 wordRes pload4_;
164
165
166 // Private Member Functions
167
168 //- Write a coordinate
169 void writeCoord
170 (
171 Ostream& os,
172 const point& p,
173 const label pointId
174 ) const;
175
176 //- Write a face element (CTRIA3 or CQUAD4)
177 void writeFace
179 Ostream& os,
180 const word& faceType,
181 const labelUList& facePts,
182 const label elemId,
183 const label propId
184 ) const;
185
186 //- Write the surface mesh geometry, tracking face decomposition
187 // Includes SHELL/MAT information
188 //
189 // \param decompOffsets begin/end offsets (size+1) into decompFaces
190 // \param decompFaces Non tri/quad decomposed into triangles
191 void writeGeometry
193 Ostream& os,
194 const meshedSurf& surf,
195 labelList& decompOffsets,
196 DynamicList<face>& decompFaces
197 ) const;
198
199 //- Write the formatted keyword to the output stream
200 Ostream& writeKeyword
201 (
202 Ostream& os,
203 const word& keyword
204 ) const;
205
206 //- Write a formatted value to the output stream
207 template<class Type>
208 Ostream& writeValue(Ostream& os, const Type& value) const;
209
210 //- Write a face-based value
211 template<class Type>
212 Ostream& writeFaceValue
213 (
214 Ostream& os,
215 const loadFormat format,
216 const Type& value,
217 const label elemId
218 ) const;
219
220
221 //- Templated write operation
222 template<class Type>
223 fileName writeTemplate
224 (
225 const word& fieldName,
226 const Field<Type>& localValues
227 );
228
229
230public:
231
232 //- Declare type-name, virtual type (with debug switch)
233 TypeNameNoDebug("nastran");
234
235
236 // Constructors
237
238 //- Default construct. Default FREE format
240
241 //- Construct with some output options. Default FREE format
242 explicit nastranWriter(const dictionary& options);
243
244 //- Construct from components
246 (
247 const meshedSurf& surf,
248 const fileName& outputPath,
249 bool parallel = UPstream::parRun(),
250 const dictionary& options = dictionary()
251 );
252
253 //- Construct from components
255 (
256 const pointField& points,
257 const faceList& faces,
258 const fileName& outputPath,
259 bool parallel = UPstream::parRun(),
260 const dictionary& options = dictionary()
261 );
262
263
264 //- Destructor
265 virtual ~nastranWriter() = default;
266
267
268 // Member Functions
269
270 //- Format uses faceIds as part of its output
271 virtual bool usesFaceIds() const // override
272 {
273 return true;
274 }
275
276 //- Write surface geometry to file.
277 virtual fileName write(); // override
278
285};
286
287
288// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289
290} // End namespace surfaceWriters
291} // End namespace Foam
292
293// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294
295#endif
296
297// ************************************************************************* //
writer writeGeometry()
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
fieldFormat
File field formats.
Definition NASCore.H:68
loadFormat
Output load format.
Definition NASCore.H:83
A class for handling file names.
Definition fileName.H:75
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
surfaceWriter()
Default construct.
A surface writer for the Nastran file format - both surface mesh and fields.
virtual ~nastranWriter()=default
Destructor.
Foam::fileFormats::NASCore::loadFormat loadFormat
Output load format.
declareSurfaceWriterWriteMethod(sphericalTensor)
TypeNameNoDebug("nastran")
Declare type-name, virtual type (with debug switch).
Foam::fileFormats::NASCore::fieldFormat fieldFormat
File field formats.
virtual bool usesFaceIds() const
Format uses faceIds as part of its output.
nastranWriter()
Default construct. Default FREE format.
virtual fileName write()
Write surface geometry to file.
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for surface writers.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Tensor< scalar > tensor
Definition symmTensor.H:57
vector point
Point is a vector.
Definition point.H:37
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
UList< label > labelUList
A UList of labels.
Definition UList.H:75
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55
word format(conversionProperties.get< word >("format"))
#define declareSurfaceWriterWriteMethod(Type)
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61