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 -------------------------------------------------------------------------------
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::debugWriter
28 
29 Description
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 | blocking/nonBlocking/scheduled | no | scheduled
48  merge | Enable geometry/field merging | no | true
49  write | Write file(s) | no | false
50  \endtable
51 
52 Note
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 
58 SourceFiles
59  debugSurfaceWriter.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef Foam_debugSurfaceWriter_H
64 #define Foam_debugSurfaceWriter_H
65 
66 #include "surfaceWriter.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 // Forward Declarations
74 class regIOobject;
75 
76 namespace surfaceWriters
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class debugWriter Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 class 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 
120 public:
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 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~debugWriter()=default
Destructor.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1049
TypeNameNoDebug("debug")
Declare type-name, virtual type (without debug switch)
A simple container for options an IOstream can normally have.
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:43
const pointField & points
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual fileName write()
Write surface geometry to file.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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))
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.