writeAreaFields.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-2021 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 InNamespace
27  Foam
28 
29 Description
30  Read finite-area fields from disk
31  and write with vtk::uindirectPatchGeoFieldsWriter
32 
33 SourceFiles
34  writeAreaFields.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef writeAreaFields_H
39 #define writeAreaFields_H
40 
41 #include "readFields.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Writer type for finite-area mesh + fields
51 
52 template<class GeoField>
53 bool writeAreaField
54 (
56  const tmp<GeoField>& tfield
57 )
58 {
59  if (tfield.valid())
60  {
61  writer.write(tfield());
62  tfield.clear();
63 
64  return true;
65  }
66 
67  return false;
68 }
69 
70 
71 template<class GeoField>
72 label writeAreaFields
73 (
75  const typename GeoField::Mesh& mesh,
76  const IOobjectList& objects,
77  const bool syncPar
78 )
79 {
80  label count = 0;
81 
82  for (const word& fieldName : objects.sortedNames<GeoField>())
83  {
84  if
85  (
86  writeAreaField<GeoField>
87  (
88  writer,
89  getField<GeoField>(mesh, objects, fieldName, syncPar)
90  )
91  )
92  {
93  ++count;
94  }
95  }
96 
97  return count;
98 }
99 
100 
101 label writeAllAreaFields
102 (
104  const faMesh& mesh,
105  const IOobjectList& objects,
106  const bool syncPar
107 )
108 {
109  #undef foamToVtk_WRITE_FIELD
110  #define foamToVtk_WRITE_FIELD(FieldType) \
111  writeAreaFields<FieldType> \
112  ( \
113  writer, \
114  mesh, \
115  objects, \
116  syncPar \
117  )
118 
119  label count = 0;
125 
126  #undef foamToVtk_WRITE_FIELD
127  return count;
128 }
129 
130 
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:287
foamToVtk_WRITE_FIELD
#define foamToVtk_WRITE_FIELD(FieldType)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::writer::write
virtual void write(const coordSet &, const wordList &, const List< const Field< Type > * > &, Ostream &) const =0
General entry point for writing.
Foam::IOobjectList::sortedNames
wordList sortedNames() const
The sorted names of the IOobjects.
Definition: IOobjectList.C:345
Foam::vtk::GenericPatchGeoFieldsWriter
A Foam::vtk::GenericPatchWriter with support for geometric fields.
Definition: foamVtkGenericPatchGeoFieldsWriter.H:57
Foam::writeAreaField
bool writeAreaField(ensightCase &ensCase, const ensightFaMesh &ensMesh, const tmp< GeometricField< Type, faPatchField, areaMesh >> &tfield)
Definition: writeAreaFields.H:42
Foam::writeAreaFields
label writeAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
Definition: writeAreaFields.H:71
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
foamVtkUIndPatchGeoFieldsWriter.H
Foam::vtkWriterType_areaMesh
vtk::uindirectPatchGeoFieldsWriter vtkWriterType_areaMesh
Definition: writeAreaFields.H:50
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
readFields.H
Helper routines for reading a field or fields, optionally with a mesh subset (using fvMeshSubsetProxy...
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::writeAllAreaFields
label writeAllAreaFields(ensightCase &ensCase, const ensightFaMesh &ensMesh, const IOobjectList &objects)
Definition: writeAreaFields.H:105
Foam::tmp::valid
bool valid() const noexcept
Identical to good(), or bool operator.
Definition: tmp.H:292
Foam::GeometricField< scalar, faPatchField, areaMesh >