Loading...
Searching...
No Matches
debugSurfaceWriter.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) 2022-2023 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::surfaceWriters::debugWriter
28
29Description
30 A surfaceWriter for special purpose debugging.
31 Its definition and behaviour are subject to change at any time.
32
33 \verbatim
34 formatOptions
35 {
36 debug
37 {
38 merge true;
39 write true;
40 }
41 }
42 \endverbatim
43
44 Format options:
45 \table
46 Property | Description | Required | Default
47 commsType | scheduled/nonBlocking/buffered | no | scheduled
48 merge | Enable geometry/field merging | no | true
49 write | Write file(s) | no | false
50 \endtable
51
52Note
53 Disabling geometry/field merging (in parallel) implicitly deactivates
54 writing as well.
55
56 Output files (if any) are written as boundaryData (binary + header).
57
58SourceFiles
59 debugSurfaceWriter.C
60
61\*---------------------------------------------------------------------------*/
62
63#ifndef Foam_debugSurfaceWriter_H
64#define Foam_debugSurfaceWriter_H
65
66#include "surfaceWriter.H"
67
68// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69
70namespace Foam
71{
72
73// Forward Declarations
74class regIOobject;
75
76namespace surfaceWriters
77{
78
79/*---------------------------------------------------------------------------*\
80 Class debugWriter Declaration
81\*---------------------------------------------------------------------------*/
82
83class debugWriter
84:
85 public surfaceWriter
86{
87 // Private Data
88
89 //- Enable/disable all merging in parallel
90 bool enableMerge_;
91
92 //- Output writing?
93 bool enableWrite_;
94
95 //- Output files with FoamFile header
96 bool header_;
97
98 //- Output stream option
99 IOstreamOption streamOpt_;
100
101
102 // Private Member Functions
103
104 //- Write serial surface geometry to "points" file.
105 void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
106
107 //- Gather (merge) fields with renumbering and shrinking for point data
108 template<class Type>
109 tmp<Field<Type>> mergeField(const Field<Type>& fld) const;
110
111 //- Templated write operation
112 template<class Type>
113 fileName writeTemplate
114 (
115 const word& fieldName,
116 const Field<Type>& localValues
117 );
118
119
120public:
121
122 //- Declare type-name, virtual type (without debug switch)
123 TypeNameNoDebug("debug");
124
125
126 // Constructors
127
128 //- Default construct
129 debugWriter();
130
131 //- Construct with some output options
132 explicit debugWriter(const dictionary& options);
133
134 //- Construct from components
136 (
137 const meshedSurf& surf,
138 const fileName& outputPath,
139 bool parallel = UPstream::parRun(),
140 const dictionary& options = dictionary()
141 );
142
143 //- Construct from components
145 (
146 const pointField& points,
147 const faceList& faces,
148 const fileName& outputPath,
149 bool parallel = UPstream::parRun(),
150 const dictionary& options = dictionary()
151 );
152
153
154 //- Destructor
155 virtual ~debugWriter() = default;
156
157
158 // Member Functions
159
160 //- Write surface geometry to file.
161 virtual fileName write(); // override
162
169};
170
171
172// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174} // End namespace surfaceWriters
175} // End namespace Foam
176
177// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178
179#endif
180
181// ************************************************************************* //
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
A simple container for options an IOstream can normally have.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Abstract definition of a meshed surface defined by faces and points.
Definition meshedSurf.H:44
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
surfaceWriter()
Default construct.
A surfaceWriter for special purpose debugging. Its definition and behaviour are subject to change at ...
virtual ~debugWriter()=default
Destructor.
declareSurfaceWriterWriteMethod(sphericalTensor)
TypeNameNoDebug("debug")
Declare type-name, virtual type (without debug switch).
virtual fileName write()
Write surface geometry to file.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
const pointField & points
Namespace for surface writers.
Namespace for OpenFOAM.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Tensor< scalar > tensor
Definition symmTensor.H:57
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55
#define declareSurfaceWriterWriteMethod(Type)
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61