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 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::surfaceMeshWriter
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 template<class GeoField>
50 bool writeAreaField
51 (
53  const tmp<GeoField>& tfield
54 )
55 {
56  if (tfield.valid())
57  {
58  writer.write(tfield());
59  tfield.clear();
60 
61  return true;
62  }
63 
64  return false;
65 }
66 
67 
68 template<class GeoField>
69 label writeAreaFields
70 (
72  const typename GeoField::Mesh& mesh,
73  const IOobjectList& objects,
74  const bool syncPar
75 )
76 {
77  label count = 0;
78 
79  for (const word& fieldName : objects.sortedNames<GeoField>())
80  {
81  if
82  (
83  writeAreaField<GeoField>
84  (
85  writer,
86  getField<GeoField>(mesh, objects, fieldName, syncPar)
87  )
88  )
89  {
90  ++count;
91  }
92  }
93 
94  return count;
95 }
96 
97 
99 (
101  const faMesh& mesh,
102  const IOobjectList& objects,
103  const bool syncPar
104 )
105 {
106  #undef foamToVtk_WRITE_FIELD
107  #define foamToVtk_WRITE_FIELD(FieldType) \
108  writeAreaFields<FieldType> \
109  ( \
110  writer, \
111  mesh, \
112  objects, \
113  syncPar \
114  )
115 
116  label count = 0;
122 
123  #undef foamToVtk_WRITE_FIELD
124  return count;
125 }
126 
127 
128 } // End namespace Foam
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:291
Foam::writeAreaFields
label writeAreaFields(vtk::surfaceMeshWriter &writer, const typename GeoField::Mesh &mesh, const IOobjectList &objects, const bool syncPar)
Definition: writeAreaFields.H:70
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::writeAreaField
bool writeAreaField(vtk::surfaceMeshWriter &writer, const tmp< GeoField > &tfield)
Definition: writeAreaFields.H:51
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::writeAllAreaFields
label writeAllAreaFields(vtk::surfaceMeshWriter &writer, const faMesh &mesh, const IOobjectList &objects, const bool syncPar)
Definition: writeAreaFields.H:99
foamToVtk_WRITE_FIELD
#define foamToVtk_WRITE_FIELD(FieldType)
Foam::vtk::surfaceMeshWriter
Write faces (eg face-zones or face-sets) with fields.
Definition: foamVtkSurfaceMeshWriter.H:66
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:80
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:77
foamVtkSurfaceMeshWriter.H
Foam::tmp::valid
bool valid() const noexcept
True for non-null pointer/reference.
Definition: tmp.H:175
Foam::GeometricField< scalar, faPatchField, areaMesh >