Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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 "Enum.H"
42#include "face.H"
43#include "point.H"
44#include "DynamicList.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50namespace fileFormats
51{
53/*---------------------------------------------------------------------------*\
54 Class fileFormats::NASCore Declaration
55\*---------------------------------------------------------------------------*/
56
57class NASCore
58{
59public:
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 {
72 FREE
73 };
74
75 //- Selection names for the NASTRAN file field formats
78 //- Output load format
79 enum loadFormat
80 {
81 PLOAD2,
83 };
85 //- Selection names for the NASTRAN load formats
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);
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// ************************************************************************* //
graph_traits< Graph >::vertices_size_type size_type
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition DynamicList.H:68
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition Enum.H:57
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
static Ostream & writeKeyword(Ostream &os, const word &keyword, const fieldFormat format)
Write initial keyword (eg, 'GRID' or 'GRID*') followed by the requisite number of spaces for the fiel...
Definition NASCore.C:196
static void writeCoord(Ostream &os, const point &p, const label pointId, const fieldFormat format)
Write a GRID point.
Definition NASCore.C:230
static void setPrecision(Ostream &os, const fieldFormat format)
Set output stream precision and format flags.
Definition NASCore.C:162
fieldFormat
File field formats.
Definition NASCore.H:68
@ SHORT
Short format (field width = 8).
Definition NASCore.H:69
@ LONG
Long format (field width = 16).
Definition NASCore.H:70
@ FREE
Free format (comma-separated fields).
Definition NASCore.H:71
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
static const Enum< loadFormat > loadFormatNames
Selection names for the NASTRAN load formats.
Definition NASCore.H:91
static const Enum< fieldFormat > fieldFormatNames
Selection names for the NASTRAN file field formats.
Definition NASCore.H:77
loadFormat
Output load format.
Definition NASCore.H:83
@ PLOAD2
Face load (eg, pressure).
Definition NASCore.H:84
@ PLOAD4
Vertex load.
Definition NASCore.H:85
static int debug
Named/registered debug switch: 'nastran.debug'.
Definition NASCore.H:61
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
static scalar readNasScalar(const std::string &str)
Extract numbers from things like "-2.358-8" (same as "-2.358e-8").
Definition NASCore.C:82
NASCore() noexcept=default
Default construct.
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace to isolate specifics for file formats, and some common utilities.
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
Definition List.H:62
vector point
Point is a vector.
Definition point.H:37
const direction noexcept
Definition scalarImpl.H:265
word format(conversionProperties.get< word >("format"))