x3dSurfaceWriter.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) 2019-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::surfaceWriters::x3dWriter
28 
29 Description
30  A surfaceWriter for X3D files.
31 
32  The formatOptions for x3d:
33  \table
34  Property | Description | Required | Default
35  range | The min/max range for colour table | no | automatic
36  colourMap | The colour map for rendering | no | coolToWarm
37  compression | Use file compression | no | false
38  scale | Output geometry scaling | no | 1
39  transform | Output coordinate transform | no |
40  fieldLevel | Subtract field level before scaling | no | empty dict
41  fieldScale | Output field scaling | no | empty dict
42  \endtable
43 
44  \section Output file locations
45 
46  The \c rootdir normally corresponds to something like
47  \c postProcessing/<name>
48 
49  \subsection Geometry
50  \verbatim
51  rootdir
52  `-- timeName
53  `-- surfaceName.x3d
54  \endverbatim
55 
56  \subsection Fields
57  \verbatim
58  rootdir
59  `-- timeName
60  |-- <field0>_surfaceName.x3d
61  `-- <field1>_surfaceName.x3d
62  \endverbatim
63 
64 Note
65  The range is applied after any field scaling.
66 
67 SourceFiles
68  x3dSurfaceWriter.C
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #ifndef Foam_surfaceWriters_x3dWriter_H
73 #define Foam_surfaceWriters_x3dWriter_H
74 
75 #include "surfaceWriter.H"
76 #include "X3DsurfaceFormatCore.H"
77 #include "colourTable.H"
78 #include "MinMax.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace surfaceWriters
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class x3dWriter Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class x3dWriter
92 :
93  public surfaceWriter,
94  protected fileFormats::X3DsurfaceFormatCore
95 {
96  // Private Data
97 
98  //- Output stream option
99  IOstreamOption streamOpt_;
100 
101  //- Range of values
102  // The lower/upper limits for the colour table output
103  // Undefined means calculate from the data
104  scalarMinMax range_;
105 
106  //- Selected colour table
107  const colourTable* colourTablePtr_;
108 
109 
110  // Private Member Functions
111 
112  //- Templated write operation
113  template<class Type>
114  fileName writeTemplate
115  (
116  const word& fieldName,
117  const Field<Type>& localValues
118  );
119 
120 
121 public:
122 
123  //- Declare type-name, virtual type (without debug switch)
124  TypeNameNoDebug("x3d");
125 
127  // Constructors
128 
129  //- Default construct
130  x3dWriter();
131 
132  //- Construct with some output options
133  explicit x3dWriter(const dictionary& options);
134 
135  //- Construct from components
136  x3dWriter
137  (
138  const meshedSurf& surf,
139  const fileName& outputPath,
140  bool parallel = UPstream::parRun(),
141  const dictionary& options = dictionary()
142  );
143 
144  //- Construct from components
145  x3dWriter
146  (
147  const pointField& points,
148  const faceList& faces,
149  const fileName& outputPath,
150  bool parallel = UPstream::parRun(),
151  const dictionary& options = dictionary()
152  );
153 
154 
155  //- Destructor
156  virtual ~x3dWriter() = default;
157 
158 
159  // Member Functions
160 
161  //- Write surface geometry to file.
162  virtual fileName write(); // override
163 
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace surfaceWriters
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:97
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:43
const pointField & points
virtual fileName write()
Write surface geometry to file.
virtual ~x3dWriter()=default
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Tensor of scalars, i.e. Tensor<scalar>.
TypeNameNoDebug("x3d")
Declare type-name, virtual type (without debug switch)
Namespace for OpenFOAM.