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