Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::ensightOutputSurface
28
29Description
30 A variant of ensightFaces that holds references to contiguous
31 points/faces with its own encapsulated write methods.
32 The surface is assumed to have been merged prior, thus the output is
33 serial-only.
34
35Note
36 The primary use is for the Foam::surfaceWriters::ensightWriter
37 but can be used independently as well.
38
39SourceFiles
40 ensightOutputSurface.C
41 ensightOutputSurface.txx
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef Foam_ensightOutputSurface_H
46#define Foam_ensightOutputSurface_H
47
48#include "ensightFaces.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
55/*---------------------------------------------------------------------------*\
56 Class ensightOutputSurface Declaration
57\*---------------------------------------------------------------------------*/
58
60:
61 public ensightFaces
62{
63 // Private Data
64
65 //- The referenced pointField
66 const pointField& points_;
67
68 //- The referenced faces
69 const faceList& faces_;
70
71
72public:
73
74 // Generated Methods
75
76 //- No copy construct
79 //- No copy assignment
80 void operator=(const ensightOutputSurface&) = delete;
81
82
83 // Constructors
84
85 //- Construct from points and faces.
86 //- Part receives the specified name (default: "surface").
88 (
89 const pointField& points,
90 const faceList& faces,
91 const string& description = "surface"
92 );
93
94
95 //- Destructor
96 virtual ~ensightOutputSurface() = default;
97
98
99 // Member Functions
100
101 //- Write processor-local geometry (serial-only).
102 //- No beginGeometry() marker.
103 void write(ensightGeoFile& os) const;
104
105 //- Write a field of face or point values (serial-only)
106 template<class Type>
107 void writeData
108 (
110 const Field<Type>& fld,
111 const bool isPointData = false
112 ) const;
113
114 //- Write a field of face values (serial-only)
115 template<class Type>
116 void writeFaceData(ensightFile& os, const Field<Type>& fld) const;
117
118 //- Write a field of point values (serial-only)
119 template<class Type>
120 void writePointData(ensightFile& os, const Field<Type>& fld) const;
121
122
123 // Housekeeping
124
125 //- Cannot write geometry with a mesh reference.
126 //- No beginGeometry() marker.
127 virtual void write(ensightGeoFile&, const polyMesh&, bool) const
128 {}
130
131
132// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133
134} // End namespace Foam
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138#ifdef NoRepository
139 #include "ensightOutputSurface.txx"
140#endif
141
142// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143
144#endif
145
146// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
ensightFaces()
Default construct, with part index 0.
A variant of OFstream with specialised handling for Ensight writing of strings, integers and floats (...
Definition ensightFile.H:50
A variant of ensightFile (Ensight writing) that includes the extra geometry file header information.
void writePointData(ensightFile &os, const Field< Type > &fld) const
Write a field of point values (serial-only).
virtual ~ensightOutputSurface()=default
Destructor.
ensightOutputSurface(const ensightOutputSurface &)=delete
No copy construct.
void writeFaceData(ensightFile &os, const Field< Type > &fld) const
Write a field of face values (serial-only).
void operator=(const ensightOutputSurface &)=delete
No copy assignment.
void writeData(ensightFile &os, const Field< Type > &fld, const bool isPointData=false) const
Write a field of face or point values (serial-only).
virtual void write(ensightGeoFile &, const polyMesh &, bool) const
Cannot write geometry with a mesh reference. No beginGeometry() marker.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
vectorField pointField
pointField is a vectorField.
runTime write()