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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::fileFormats::NASCore
28
29Description
30 Core routines used when reading/writing NASTRAN files.
31
32SourceFiles
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 "string.H"
42#include "Enum.H"
43#include "face.H"
44#include "point.H"
45#include "DynamicList.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52namespace fileFormats
53{
54
55/*---------------------------------------------------------------------------*\
56 Class fileFormats::NASCore Declaration
57\*---------------------------------------------------------------------------*/
59class NASCore
60{
61public:
62
63 //- File field formats
64 enum fieldFormat
65 {
67 LONG,
69 };
70
71 //- Selection names for the NASTRAN file field formats
73
74 //- Output load format
75 enum loadFormat
76 {
77 PLOAD2,
79 };
80
81 //- Selection names for the NASTRAN file field formats
83
84
85 // Constructors
86
87 //- Default construct
88 NASCore() = default;
89
90
91 // Public Static Member Functions
92
93 //- Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
94 static scalar readNasScalar(const std::string& str);
95
96 //- A string::substr() to handle fixed-format and free-format NASTRAN.
97 // Returns the substr to the next comma (if found) or the given length
98 //
99 // \param str The string to extract from
100 // \param pos On input, the position of the first character of the
101 // substring. On output, advances to the next position to use.
102 // \param len The fixed-format length to use if a comma is not found.
103 static std::string nextNasField
104 (
105 const std::string& str,
106 std::string::size_type& pos,
107 std::string::size_type len
108 );
109
110
111 //- Set output stream precision and format flags
112 static void setPrecision(Ostream& os, const fieldFormat format);
113
114
115 //- Write initial keyword (eg, 'GRID' or 'GRID*') followed by the
116 //- requisite number of spaces for the field-width
117 static Ostream& writeKeyword
118 (
119 Ostream& os,
120 const word& keyword,
121 const fieldFormat format
122 );
123
124 //- Write a GRID point
125 static void writeCoord
126 (
127 Ostream& os,
128 const point& p,
129 const label pointId,
130 const fieldFormat format
131 );
132
133 //- Calculate face decomposition for non tri/quad faces
134 //
135 // \param points the surface points
136 // \param faces the surface faces
137 // \param decompOffsets begin/end offsets (size+1) into decompFaces
138 // \param decompFaces List of non-tri/quad decomposed into triangles
139 //
140 // \return number of decomposed faces
141 static label faceDecomposition
142 (
143 const UList<point>& points,
144 const UList<face>& faces,
145 labelList& decompOffsets,
146 DynamicList<face>& decompFaces
147 );
148};
149
150
151// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152
153} // End namespace fileFormats
154} // End namespace Foam
155
156// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157
158#endif
159
160// ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Core routines used when reading/writing NASTRAN files.
Definition: NASCore.H:59
static Ostream & writeKeyword(Ostream &os, const word &keyword, const fieldFormat format)
Definition: NASCore.C:180
static void writeCoord(Ostream &os, const point &p, const label pointId, const fieldFormat format)
Write a GRID point.
Definition: NASCore.C:214
static void setPrecision(Ostream &os, const fieldFormat format)
Set output stream precision and format flags.
Definition: NASCore.C:146
NASCore()=default
Default construct.
fieldFormat
File field formats.
Definition: NASCore.H:64
@ SHORT
Short format (field width = 8)
Definition: NASCore.H:65
@ LONG
Long format (field width = 16)
Definition: NASCore.H:66
@ FREE
Free format (comma-separated fields)
Definition: NASCore.H:67
static const Enum< loadFormat > loadFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:81
static const Enum< fieldFormat > fieldFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:71
loadFormat
Output load format.
Definition: NASCore.H:75
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:280
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:122
static scalar readNasScalar(const std::string &str)
Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
Definition: NASCore.C:75
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
word format(conversionProperties.get< word >("format"))