ensightOutputSurface.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) 2020 OpenCFD Ltd.
9  Copyright (C) 2026 Keysight Technologies
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::ensightOutputSurface
29 
30 Description
31  A variant of ensightFaces that holds references to contiguous
32  points/faces with its own encapsulated write methods.
33  The surface is assumed to have been merged prior, thus the output is
34  serial-only.
35 
36 Note
37  The primary use is for the Foam::surfaceWriters::ensightWriter
38  but can be used independently as well.
39 
40 SourceFiles
41  ensightOutputSurface.C
42  ensightOutputSurface.txx
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_ensightOutputSurface_H
47 #define Foam_ensightOutputSurface_H
48 
49 #include "ensightFaces.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class ensightOutputSurface Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 :
62  public ensightFaces
63 {
64  // Private Data
65 
66  //- The referenced pointField
67  const pointField& points_;
68 
69  //- The referenced faces
70  const faceList& faces_;
71 
72  //- Output as 1D vertex/point elements instead of faces
73  bool vertexOutput_;
74 
75 
76 public:
77 
78  // Generated Methods
79 
80  //- No copy construct
82 
83  //- No copy assignment
84  void operator=(const ensightOutputSurface&) = delete;
85 
86 
87  // Constructors
88 
89  //- Construct from points and faces.
90  //- Part receives the specified name (default: "surface").
92  (
93  const pointField& points,
94  const faceList& faces,
95  const string& description = "surface"
96  );
97 
98 
99  //- Destructor
100  virtual ~ensightOutputSurface() = default;
101 
102 
103  // Member Functions
104 
105  //- Output as 1D vertex/point elements instead of faces
106  bool vertexOutput() const noexcept { return vertexOutput_; }
107 
108  //- Output as 1D vertex/point elements instead of faces
109  bool vertexOutput(bool on) noexcept
110  {
111  bool old(vertexOutput_);
112  vertexOutput_ = on;
113  return old;
114  }
115 
116  //- Processor-local test for any elements
117  bool empty() const noexcept
118  {
119  return (vertexOutput_ ? points_.empty() : ensightFaces::empty());
120  }
121 
122  //- Processor-local size of all elements
123  label size() const noexcept
124  {
125  return (vertexOutput_ ? points_.size() : ensightFaces::size());
126  }
127 
128 
129  // Member Functions
130 
131  //- Write processor-local geometry (serial-only).
132  //- No beginGeometry() marker.
133  void write(ensightGeoFile& os) const;
134 
135  //- Write a field of cell or point values (serial-only)
136  template<class Type>
137  void writeData
138  (
139  ensightFile& os,
140  const Field<Type>& fld,
141  const bool isPointData = false
142  ) const;
143 
144  //- Write a field of cell (face or vertex) values (serial-only)
145  template<class Type>
146  void writeCellData(ensightFile& os, const Field<Type>& fld) const;
147 
148  //- Write a field of point values (serial-only)
149  template<class Type>
150  void writePointData(ensightFile& os, const Field<Type>& fld) const;
151 
152 
153  // Housekeeping
154 
155  //- Cannot write geometry with a mesh reference.
156  //- No beginGeometry() marker.
157  virtual void write(ensightGeoFile&, const polyMesh&, bool) const
158  {}
159 };
160 
161 
162 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 
164 } // End namespace Foam
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 #ifdef NoRepository
169  #include "ensightOutputSurface.txx"
170 #endif
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
A variant of OFstream with specialised handling for Ensight writing of strings, integers and floats (...
Definition: ensightFile.H:48
bool empty() const noexcept
Processor-local test for any elements.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:119
void writePointData(ensightFile &os, const Field< Type > &fld) const
Write a field of point values (serial-only)
label size() const noexcept
Processor-local size of all elements.
Definition: ensightPart.H:193
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:702
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information...
void writeData(ensightFile &os, const Field< Type > &fld, const bool isPointData=false) const
Write a field of cell or point values (serial-only)
Sorting/classification of faces (2D) into corresponding ensight types.
Definition: ensightFaces.H:67
bool vertexOutput() const noexcept
Output as 1D vertex/point elements instead of faces.
bool empty() const noexcept
Processor-local test for any elements.
Definition: ensightPart.H:185
const pointField & points
label size() const noexcept
Processor-local size of all elements.
void operator=(const ensightOutputSurface &)=delete
No copy assignment.
ensightOutputSurface(const ensightOutputSurface &)=delete
No copy construct.
const direction noexcept
Definition: scalarImpl.H:265
A variant of ensightFaces that holds references to contiguous points/faces with its own encapsulated ...
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual ~ensightOutputSurface()=default
Destructor.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
void write(ensightGeoFile &os) const
Write processor-local geometry (serial-only). No beginGeometry() marker.
void writeCellData(ensightFile &os, const Field< Type > &fld) const
Write a field of cell (face or vertex) values (serial-only)
Namespace for OpenFOAM.