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-2020 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 NASCore_H
38 #define 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 
49 namespace Foam
50 {
51 
52 namespace fileFormats
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class fileFormats::NASCore Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class NASCore
60 {
61 public:
62 
63  //- File field formats
64  enum fieldFormat
65  {
67  LONG,
68  FREE
69  };
70 
71  //- Selection names for the NASTRAN file field formats
73 
74  //- Output load format
75  enum loadFormat
76  {
78  PLOAD4
79  };
80 
81  //- Selection names for the NASTRAN file field formats
82  static const Enum<loadFormat> loadFormatNames;
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,
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  //- Calculate face decomposition for non tri/quad faces
125  //
126  // \param points the surface points
127  // \param faces the surface faces
128  // \param decompOffsets begin/end offsets (size+1) into decompFaces
129  // \param decompFaces List of non-tri/quad decomposed into triangles
130  //
131  // \return number of decomposed faces
132  static label faceDecomposition
133  (
134  const UList<point>& points,
135  const UList<face>& faces,
136  labelList& decompOffsets,
137  DynamicList<face>& decompFaces
138  );
139 };
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace fileFormats
145 } // End namespace Foam
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 #endif
150 
151 // ************************************************************************* //
Foam::Enum< fieldFormat >
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileFormats::NASCore::LONG
Long format (field width = 16)
Definition: NASCore.H:66
Foam::fileFormats::NASCore
Core routines used when reading/writing NASTRAN files.
Definition: NASCore.H:58
Foam::fileFormats::NASCore::SHORT
Short format (field width = 8)
Definition: NASCore.H:65
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:55
Foam::fileFormats::NASCore::FREE
Free format (comma-separated fields)
Definition: NASCore.H:67
point.H
Foam::fileFormats::NASCore::loadFormatNames
static const Enum< loadFormat > loadFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:81
face.H
string.H
Foam::fileFormats::NASCore::PLOAD4
Definition: NASCore.H:77
Foam::fileFormats::NASCore::NASCore
NASCore()=default
Default construct.
Foam::fileFormats::NASCore::setPrecision
static void setPrecision(Ostream &os, const fieldFormat format)
Set output stream precision and format flags.
Definition: NASCore.C:131
Foam::fileFormats::NASCore::faceDecomposition
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:201
format
word format(conversionProperties.get< word >("format"))
Foam::fileFormats::NASCore::writeKeyword
static Ostream & writeKeyword(Ostream &os, const word &keyword, const fieldFormat format)
Definition: NASCore.C:165
Foam::fileFormats::NASCore::nextNasField
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:107
size_type
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:76
scalar.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileFormats::NASCore::loadFormat
loadFormat
Output load format.
Definition: NASCore.H:74
Foam::List< label >
Foam::UList
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:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::fileFormats::NASCore::readNasScalar
static scalar readNasScalar(const std::string &str)
Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
Definition: NASCore.C:60
DynamicList.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fileFormats::NASCore::fieldFormatNames
static const Enum< fieldFormat > fieldFormatNames
Selection names for the NASTRAN file field formats.
Definition: NASCore.H:71
Foam::fileFormats::NASCore::fieldFormat
fieldFormat
File field formats.
Definition: NASCore.H:63
Foam::fileFormats::NASCore::PLOAD2
Definition: NASCore.H:76
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177
Enum.H