nastranCoordSetWriter.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) 2018-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::coordSetWriters::nastranWriter
28 
29 Description
30  Write coordSet(s) as Nastran plot lines. Does not do field data.
31 
32  The formatOptions for nastran:
33  \table
34  Property | Description | Required | Default
35  format | short / long / free | no | free
36  \endtable
37 
38  \section Output file locations
39 
40  The \c rootdir normally corresponds to something like
41  \c postProcessing/<name>
42 
43  \subsection Geometry
44  \verbatim
45  rootdir
46  `-- <time>
47  |-- setName0.{nas}
48  `-- setName1.{nas}
49  \endverbatim
50 
51 SourceFiles
52  nastranCoordSetWriter.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef Foam_coordSetWriters_nastranWriter_H
57 #define Foam_coordSetWriters_nastranWriter_H
58 
59 #include "coordSetWriter.H"
60 #include "NASCore.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 namespace coordSetWriters
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class nastranWriter Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 class nastranWriter
74 :
75  public coordSetWriter
76 {
77 public:
78 
79  //- File field formats
81 
82  //- Output load format
84 
85 
86 private:
87 
88  //- Field format (width and separator)
89  fieldFormat writeFormat_;
90 
91  //- Separator used for free format
92  word separator_;
93 
94 
95  // Private Member Functions
96 
97  //- Write the formatted keyword to the output stream
98  Ostream& writeKeyword(Ostream& os, const word& keyword) const;
99 
100  //- Templated write operation
101  template<class Type>
102  fileName writeTemplate
103  (
104  const word& fieldName,
105  const Field<Type>& values
106  );
107 
108  //- Templated write operation
109  template<class Type>
110  fileName writeTemplate
111  (
112  const word& fieldName,
113  const List<Field<Type>>& fieldValues
114  );
115 
116  //- Write geometry to file.
117  void writeGeometry(Ostream& os, label nTracks) const;
118 
119 
120 public:
121 
122  //- Runtime type information (no debug)
123  TypeNameNoDebug("nastran");
124 
125 
126  // Constructors
127 
128  //- Default construct
129  nastranWriter();
130 
131  //- Default construct with specified options
132  explicit nastranWriter(const dictionary& options);
133 
134  //- Construct from components
136  (
137  const coordSet& coords,
138  const fileName& outputPath,
139  const dictionary& options = dictionary()
140  );
141 
142  //- Construct from components
144  (
145  const UPtrList<coordSet>& tracks,
146  const fileName& outputPath,
147  const dictionary& options = dictionary()
148  );
149 
150 
151  //- Destructor. Calls close()
152  virtual ~nastranWriter();
153 
154 
155  // Member Functions
156 
157  //- Characteristic output file name - information only
158  virtual fileName path() const; // override
159 
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace coordSetWriters
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
TypeNameNoDebug("nastran")
Runtime type information (no debug)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
loadFormat
Output load format.
Definition: NASCore.H:83
fieldFormat
File field formats.
Definition: NASCore.H:68
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:164
Holds list of sampling positions.
Definition: coordSet.H:49
Generic templated field type.
Definition: Field.H:62
virtual ~nastranWriter()
Destructor. Calls close()
A class for handling words, derived from Foam::string.
Definition: word.H:63
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
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...
OBJstream os(runTime.globalPath()/outputName)
virtual fileName path() const
Characteristic output file name - information only.
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.