reportFields.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) 2018-2026 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::foamToVtkReportFields
28 
29 Description
30  Collection of simple static methods for reporting field names
31  by category, which is used by foamToVTK.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef foamToVtkReportFields_H
36 #define foamToVtkReportFields_H
37 
38 #include "UPtrList.H"
39 #include "Ostream.H"
40 #include "areaFields.H"
41 #include "edgeFields.H"
42 #include "volFields.H"
43 #include "pointFields.H"
44 #include "IOobjectList.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class foamToVtkReportFields Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57  template<class GeoField>
58  static void print
59  (
60  const char* msg,
61  Ostream& os,
62  const UPtrList<const GeoField>& flds
63  )
64  {
65  if (flds.size())
66  {
67  os << msg;
68  for (const GeoField& fld : flds)
69  {
70  os << ' ' << fld.name();
71  }
72  os << endl;
73  }
74  }
75 
76  static void print
77  (
78  const char* msg,
79  Ostream& os,
80  const wordUList& fieldNames
81  )
82  {
83  if (fieldNames.size())
84  {
85  os << msg;
86  for (const word& fieldName : fieldNames)
87  {
88  os << ' ' << fieldName;
89  }
90  os << endl;
91  }
92  }
93 
94 
95  template<class FieldType>
96  static void print
97  (
98  const char* msg,
99  Ostream& os,
100  const IOobjectList& objects
101  )
102  {
103  print(msg, os, objects.sortedNames<FieldType>());
104  }
105 
106 
107  //- Supported volume field types
108  static void volume(Ostream& os, const IOobjectList& objects)
109  {
110  print<volScalarField>
111  (
112  " volScalar :", os, objects
113  );
114  print<volVectorField>
115  (
116  " volVector :", os, objects
117  );
118  print<volSphericalTensorField>
119  (
120  " volSphTensor :", os, objects
121  );
122  print<volSymmTensorField>
123  (
124  " volSymTensor :", os, objects
125  );
126  print<volTensorField>
127  (
128  " volTensor :", os, objects
129  );
130  }
131 
132  //- Supported volume internal field types
133  static void internal(Ostream& os, const IOobjectList& objects)
134  {
135  print<volScalarField::Internal>
136  (
137  " volScalar:Internal :", os, objects
138  );
139  print<volVectorField::Internal>
140  (
141  " volVector:Internal :", os, objects
142  );
143  print<volSphericalTensorField::Internal>
144  (
145  " volSphTensor:Internal :", os, objects
146  );
147  print<volSymmTensorField::Internal>
148  (
149  " volSymTensor:Internal :", os, objects
150  );
151  print<volTensorField::Internal>
152  (
153  " volTensor:Internal :", os, objects
154  );
155  }
156 
157 
158  //- Supported point field types
159  static void point(Ostream& os, const IOobjectList& objects)
160  {
161  }
162 
163  //- Supported finite-area area field types
164  static void area(Ostream& os, const IOobjectList& objects)
165  {
166  print<areaScalarField>
167  (
168  " areaScalar :", os, objects
169  );
170  print<areaVectorField>
171  (
172  " areaVector :", os, objects
173  );
174  print<areaSphericalTensorField>
175  (
176  " areaSphTensor :", os, objects
177  );
178  print<areaSymmTensorField>
179  (
180  " areaSymTensor :", os, objects
181  );
182  print<areaTensorField>
183  (
184  " areaTensor :", os, objects
185  );
186  }
187 
188 
189  //- Supported finite-area edge field types
190  static void edge(Ostream& os, const IOobjectList& objects)
191  {
192  print<edgeScalarField>
193  (
194  " edgeScalar :", os, objects
195  );
196  }
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #endif
207 
208 // ************************************************************************* //
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
static void volume(Ostream &os, const IOobjectList &objects)
Supported volume field types.
Definition: reportFields.H:103
Collection of simple static methods for reporting field names by category, which is used by foamToVTK...
Definition: reportFields.H:48
UList< word > wordUList
UList of word.
Definition: wordList.H:34
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:518
static void point(Ostream &os, const IOobjectList &objects)
Supported point field types.
Definition: reportFields.H:158
static void area(Ostream &os, const IOobjectList &objects)
Supported finite-area area field types.
Definition: reportFields.H:165
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
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))
static void print(const char *msg, Ostream &os, const UPtrList< const GeoField > &flds)
Definition: reportFields.H:52
static void edge(Ostream &os, const IOobjectList &objects)
Supported finite-area edge field types.
Definition: reportFields.H:193
Namespace for OpenFOAM.