NASCore.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) 2017-2024 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::NASCore
28 
29 Description
30  Core routines used when reading/writing NASTRAN files.
31 
32 SourceFiles
33  NASCore.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_fileFormats_NASCore_H
38 #define Foam_fileFormats_NASCore_H
39 
40 #include "scalar.H"
41 #include "Enum.H"
42 #include "face.H"
43 #include "point.H"
44 #include "DynamicList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace fileFormats
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class fileFormats::NASCore Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class NASCore
58 {
59 public:
60 
61  // Public Data
62 
63  //- Named/registered debug switch: 'nastran.debug'
64  static int debug;
65 
66 
67  //- File field formats
68  enum fieldFormat
69  {
71  LONG,
72  FREE
73  };
74 
75  //- Selection names for the NASTRAN file field formats
77 
78  //- Output load format
79  enum loadFormat
80  {
81  PLOAD2,
83  };
84 
85  //- Selection names for the NASTRAN load formats
86  static const Enum<loadFormat> loadFormatNames;
87 
88 
89  // Constructors
90 
91  //- Default construct
92  NASCore() noexcept = default;
93 
94 
95  // Public Static Member Functions
96 
97  //- Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
98  static scalar readNasScalar(const std::string& str);
99 
100  //- A std::string::substr() variant to handle fixed-format and
101  //- free-format NASTRAN.
102  // Returns the substr until the next comma (if found)
103  // or the given fixed width
104  static std::string nextNasField
105  (
107  const std::string& str,
109  std::string::size_type& pos,
111  const std::string::size_type width,
113  const bool free_format = false
114  );
115 
116 
117  //- Set output stream precision and format flags
118  static void setPrecision(Ostream& os, const fieldFormat format);
119 
120 
121  //- Write initial keyword (eg, 'GRID' or 'GRID*') followed by the
122  //- requisite number of spaces for the field-width
123  static Ostream& writeKeyword
124  (
125  Ostream& os,
126  const word& keyword,
127  const fieldFormat format
128  );
129 
130  //- Write a GRID point
131  static void writeCoord
132  (
133  Ostream& os,
134  const point& p,
135  const label pointId,
136  const fieldFormat format
137  );
138 
139  //- Calculate face decomposition for non tri/quad faces
140  //
141  // \param points the surface points
142  // \param faces the surface faces
143  // \param decompOffsets begin/end offsets (size+1) into decompFaces
144  // \param decompFaces List of non-tri/quad decomposed into triangles
145  //
146  // \return number of decomposed faces
147  static label faceDecomposition
148  (
149  const UList<point>& points,
150  const UList<face>& faces,
151  labelList& decompOffsets,
152  DynamicList<face>& decompFaces
153  );
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace fileFormats
160 } // End namespace Foam
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 #endif
165 
166 // ************************************************************************* //
Long format (field width = 16)
Definition: NASCore.H:70
static const Enum< fieldFormat > fieldFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:77
static std::string nextNasField(const std::string &str, std::string::size_type &pos, const std::string::size_type width, const bool free_format=false)
A std::string::substr() variant to handle fixed-format and free-format NASTRAN.
Definition: NASCore.C:129
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:68
loadFormat
Output load format.
Definition: NASCore.H:82
Core routines used when reading/writing NASTRAN files.
Definition: NASCore.H:52
static const Enum< loadFormat > loadFormatNames
Selection names for the NASTRAN load formats.
Definition: NASCore.H:91
Short format (field width = 8)
Definition: NASCore.H:69
fieldFormat
File field formats.
Definition: NASCore.H:67
static int debug
Named/registered debug switch: &#39;nastran.debug&#39;.
Definition: NASCore.H:61
dimensionedScalar pos(const dimensionedScalar &ds)
static void setPrecision(Ostream &os, const fieldFormat format)
Set output stream precision and format flags.
Definition: NASCore.C:162
const pointField & points
Face load (eg, pressure)
Definition: NASCore.H:84
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:51
A class for handling words, derived from Foam::string.
Definition: word.H:63
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:67
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:105
static void writeCoord(Ostream &os, const point &p, const label pointId, const fieldFormat format)
Write a GRID point.
Definition: NASCore.C:230
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
NASCore() noexcept=default
Default construct.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Free format (comma-separated fields)
Definition: NASCore.H:71
OBJstream os(runTime.globalPath()/outputName)
static scalar readNasScalar(const std::string &str)
Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
Definition: NASCore.C:82
word format(conversionProperties.get< word >("format"))
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: NASCore.C:296
volScalarField & p
static Ostream & writeKeyword(Ostream &os, const word &keyword, const fieldFormat format)
Write initial keyword (eg, &#39;GRID&#39; or &#39;GRID*&#39;) followed by the requisite number of spaces for the fiel...
Definition: NASCore.C:196
Namespace for OpenFOAM.