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-2023 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 
51 namespace fileFormats
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class fileFormats::NASCore Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class NASCore
59 {
60 public:
61 
62  // Public Data
63 
64  //- Named/registered debug switch: 'nastran.debug'
65  static int debug;
66 
67 
68  //- File field formats
69  enum fieldFormat
70  {
72  LONG,
73  FREE
74  };
75 
76  //- Selection names for the NASTRAN file field formats
78 
79  //- Output load format
80  enum loadFormat
81  {
82  PLOAD2,
84  };
85 
86  //- Selection names for the NASTRAN file field formats
87  static const Enum<loadFormat> loadFormatNames;
88 
89 
90  // Constructors
91 
92  //- Default construct
93  NASCore() = default;
94 
95 
96  // Public Static Member Functions
97 
98  //- Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
99  static scalar readNasScalar(const std::string& str);
100 
101  //- A string::substr() to handle fixed-format and free-format NASTRAN.
102  // Returns the substr to the next comma (if found) or the given length
103  //
104  // \param str The string to extract from
105  // \param pos On input, the position of the first character of the
106  // substring. On output, advances to the next position to use.
107  // \param len The fixed-format length to use if a comma is not found.
108  static std::string nextNasField
109  (
110  const std::string& str,
113  );
114 
115 
116  //- Set output stream precision and format flags
117  static void setPrecision(Ostream& os, const fieldFormat format);
118 
119 
120  //- Write initial keyword (eg, 'GRID' or 'GRID*') followed by the
121  //- requisite number of spaces for the field-width
122  static Ostream& writeKeyword
123  (
124  Ostream& os,
125  const word& keyword,
126  const fieldFormat format
127  );
128 
129  //- Write a GRID point
130  static void writeCoord
131  (
132  Ostream& os,
133  const point& p,
134  const label pointId,
135  const fieldFormat format
136  );
137 
138  //- Calculate face decomposition for non tri/quad faces
139  //
140  // \param points the surface points
141  // \param faces the surface faces
142  // \param decompOffsets begin/end offsets (size+1) into decompFaces
143  // \param decompFaces List of non-tri/quad decomposed into triangles
144  //
145  // \return number of decomposed faces
146  static label faceDecomposition
147  (
148  const UList<point>& points,
149  const UList<face>& faces,
150  labelList& decompOffsets,
151  DynamicList<face>& decompFaces
152  );
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace fileFormats
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
Long format (field width = 16)
Definition: NASCore.H:71
static const Enum< fieldFormat > fieldFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:78
loadFormat
Output load format.
Definition: NASCore.H:83
Core routines used when reading/writing NASTRAN files.
Definition: NASCore.H:53
static const Enum< loadFormat > loadFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:92
Short format (field width = 8)
Definition: NASCore.H:70
fieldFormat
File field formats.
Definition: NASCore.H:68
static int debug
Named/registered debug switch: &#39;nastran.debug&#39;.
Definition: NASCore.H:62
dimensionedScalar pos(const dimensionedScalar &ds)
static void setPrecision(Ostream &os, const fieldFormat format)
Set output stream precision and format flags.
Definition: NASCore.C:153
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
A class for handling words, derived from Foam::string.
Definition: word.H:63
static std::string nextNasField(const std::string &str, std::string::size_type &pos, std::string::size_type len)
A string::substr() to handle fixed-format and free-format NASTRAN.
Definition: NASCore.C:129
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:68
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:221
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...
Free format (comma-separated fields)
Definition: NASCore.H:72
NASCore()=default
Default construct.
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:287
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:187
Namespace for OpenFOAM.