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-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::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  compression | Use file compression | no | false
36  range | The min/max range for colour table | no | automatic
37  colourMap | The colour map for rendering | no | coolToWarm
38  \endtable
39 
40  \heading Output file locations
41 
42  The \c rootdir normally corresponds to something like
43  \c postProcessing/<name>
44 
45  \subheading Geometry
46  \verbatim
47  rootdir
48  `-- timeName
49  `-- surfaceName.x3d
50  \endverbatim
51 
52  \subheading Fields
53  \verbatim
54  rootdir
55  `-- timeName
56  |-- <field0>_surfaceName.x3d
57  `-- <field1>_surfaceName.x3d
58  \endverbatim
59 
60 SourceFiles
61  x3dSurfaceWriter.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef x3dSurfaceWriter_H
66 #define x3dSurfaceWriter_H
67 
68 #include "surfaceWriter.H"
69 #include "X3DsurfaceFormatCore.H"
70 #include "colourTable.H"
71 #include "MinMax.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 namespace surfaceWriters
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class x3dWriter Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 class x3dWriter
85 :
86  public surfaceWriter,
87  protected fileFormats::X3DsurfaceFormatCore
88 {
89  // Private Data
90 
91  //- Output stream option
92  IOstreamOption streamOpt_;
93 
94  //- Range of values
95  // The lower/upper limits for the colour table output
96  // Undefined means calculate from the data
97  scalarMinMax range_;
98 
99  //- Selected colour table
100  const colourTable* colourTablePtr_;
101 
102 
103  // Private Member Functions
104 
105  //- Templated write operation
106  template<class Type>
107  fileName writeTemplate
108  (
109  const word& fieldName,
110  const Field<Type>& localValues
111  );
112 
113 
114 public:
115 
116  //- Declare type-name, virtual type (without debug switch)
117  TypeNameNoDebug("x3d");
118 
119 
120  // Constructors
121 
122  //- Default construct
123  x3dWriter();
124 
125  //- Construct with some output options
126  explicit x3dWriter(const dictionary& options);
127 
128  //- Construct from components
129  x3dWriter
130  (
131  const meshedSurf& surf,
132  const fileName& outputPath,
133  bool parallel = Pstream::parRun(),
134  const dictionary& options = dictionary()
135  );
136 
137  //- Construct from components
138  x3dWriter
139  (
140  const pointField& points,
141  const faceList& faces,
142  const fileName& outputPath,
143  bool parallel = Pstream::parRun(),
144  const dictionary& options = dictionary()
145  );
146 
147 
148  //- Destructor
149  virtual ~x3dWriter() = default;
150 
151 
152  // Member Functions
153 
154  //- Write surface geometry to file.
155  virtual fileName write(); // override
156 
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace surfaceWriters
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
Foam::Tensor< scalar >
Foam::surfaceWriters::x3dWriter
A surfaceWriter for X3D files.
Definition: x3dSurfaceWriter.H:103
Foam::SymmTensor< scalar >
Foam::fileFormats::X3DsurfaceFormatCore
Internal class used by the X3DsurfaceFormat.
Definition: X3DsurfaceFormatCore.H:52
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::surfaceWriter
Base class for surface writers.
Definition: surfaceWriter.H:111
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:415
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
MinMax.H
surfaceWriter.H
Foam::surfaceWriters::x3dWriter::~x3dWriter
virtual ~x3dWriter()=default
Destructor.
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::surfaceWriters::x3dWriter::x3dWriter
x3dWriter()
Default construct.
Definition: x3dSurfaceWriter.C:106
colourTable.H
Foam::scalarMinMax
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition: MinMax.H:117
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
X3DsurfaceFormatCore.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::SphericalTensor< scalar >
Foam::surfaceWriters::x3dWriter::TypeNameNoDebug
TypeNameNoDebug("x3d")
Declare type-name, virtual type (without debug switch)
Foam::surfaceWriters::x3dWriter::write
virtual fileName write()
Write surface geometry to file.
Definition: x3dSurfaceWriter.C:198
Foam::Vector< scalar >
Foam::List< face >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::colourTable
Base class for generating a colour table from node points.
Definition: colourTable.H:79
Foam::surfaceWriters::x3dWriter::declareSurfaceWriterWriteMethod
declareSurfaceWriterWriteMethod(label)
Foam::MinMax< scalar >