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 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  write true;
39  }
40  }
41  \endverbatim
42 
43  Format options:
44  \table
45  Property | Description | Required | Default
46  commsType | blocking/nonBlocking/scheduled | no | scheduled
47  gatherv | Use MPI gatherv when merging | no | false
48  write | Write boundaryData (binary + header) | no | false
49  \endtable
50 
51 SourceFiles
52  debugSurfaceWriter.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef Foam_debugSurfaceWriter_H
57 #define Foam_debugSurfaceWriter_H
58 
59 #include "surfaceWriter.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 // Forward Declarations
67 class regIOobject;
68 
69 namespace surfaceWriters
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class debugWriter Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class debugWriter
77 :
78  public surfaceWriter
79 {
80  // Private Data
81 
82  //- Use MPI gatherv in globalIndex gathering
83  bool mpiGatherv_;
84 
85  //- Output writing?
86  bool enableWrite_;
87 
88  //- Output files with FoamFile header
89  bool header_;
90 
91  //- Output stream option
92  IOstreamOption streamOpt_;
93 
94 
95  // Private Member Functions
96 
97  //- Write serial surface geometry to "points" file.
98  void serialWriteGeometry(const regIOobject&, const meshedSurf& surf);
99 
100  //- Gather (merge) fields with renumbering and shrinking for point data
101  template<class Type>
102  tmp<Field<Type>> mergeField(const Field<Type>& fld) const;
103 
104  //- Templated write operation
105  template<class Type>
106  fileName writeTemplate
107  (
108  const word& fieldName,
109  const Field<Type>& localValues
110  );
111 
112 
113 public:
114 
115  //- Declare type-name, virtual type (without debug switch)
116  TypeNameNoDebug("debug");
117 
118 
119  // Constructors
120 
121  //- Default construct
122  debugWriter();
123 
124  //- Construct with some output options
125  explicit debugWriter(const dictionary& options);
126 
127  //- Construct from components
129  (
130  const meshedSurf& surf,
131  const fileName& outputPath,
132  bool parallel = Pstream::parRun(),
133  const dictionary& options = dictionary()
134  );
135 
136  //- Construct from components
138  (
139  const pointField& points,
140  const faceList& faces,
141  const fileName& outputPath,
142  bool parallel = Pstream::parRun(),
143  const dictionary& options = dictionary()
144  );
145 
146 
147  //- Destructor
148  virtual ~debugWriter() = default;
149 
150 
151  // Member Functions
152 
153  //- Write surface geometry to file.
154  virtual fileName write(); // override
155 
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace surfaceWriters
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #endif
173 
174 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:71
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual ~debugWriter()=default
Destructor.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:639
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:61
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:69
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.