vtkWriteImpl.C
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-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 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class GeoField>
31 Foam::label Foam::functionObjects::vtkWrite::writeVolFieldsImpl
32 (
35  const fvMeshSubset& proxy,
36  const wordHashSet& candidateNames
37 ) const
38 {
39  const fvMesh& baseMesh = proxy.baseMesh();
40 
41  label count = 0;
42 
43  for
44  (
45  const GeoField& origField
46  : baseMesh.csorted<GeoField>(candidateNames)
47  )
48  {
49  bool ok = false;
50  auto tfield = fvMeshSubsetProxy::interpolate(proxy, origField);
51  const auto& field = tfield();
52 
53  // Internal
54  if (internalWriter)
55  {
56  ok = true;
57  internalWriter->write(field);
58  }
59 
60  // Boundary
62  {
63  ok = true;
64  writer.write(field);
65  }
66 
67  if (ok)
68  {
69  ++count;
70 
71  if (verbose_)
72  {
73  if (count == 1)
74  {
75  Log << " " << GeoField::typeName << '(';
76  }
77  else
78  {
79  Log << ' ';
80  }
81  Log << origField.name();
82  }
83  }
84  }
85 
86  if (verbose_ && count)
87  {
88  Log << ')' << endl;
89  }
90 
91  return count;
92 }
93 
94 
95 template<class GeoField>
96 Foam::label Foam::functionObjects::vtkWrite::writeVolFieldsImpl
97 (
102  const fvMeshSubset& proxy,
103  const wordHashSet& candidateNames
104 ) const
105 {
106  const fvMesh& baseMesh = proxy.baseMesh();
107 
108  label count = 0;
109 
110  for
111  (
112  const GeoField& origField
113  : baseMesh.csorted<GeoField>(candidateNames)
114  )
115  {
116  bool ok = false;
117  auto tfield = fvMeshSubsetProxy::interpolate(proxy, origField);
118  const auto& field = tfield();
119 
120  // Internal
121  if (internalWriter && pInterp)
122  {
123  ok = true;
124  internalWriter->write(field, *pInterp);
125  }
126 
127  // Boundary
128  label writeri = 0;
130  {
131  if (patchInterps.test(writeri))
132  {
133  ok = true;
134  writer.write(field, patchInterps[writeri]);
135  }
136  ++writeri;
137  }
138 
139  if (ok)
140  {
141  ++count;
142 
143  if (verbose_)
144  {
145  if (count == 1)
146  {
147  Log << " " << GeoField::typeName << "->point(";
148  }
149  else
150  {
151  Log << ' ';
152  }
153  Log << origField.name();
154  }
155  }
156  }
157 
158  if (verbose_ && count)
159  {
160  Log << ')' << endl;
161  }
162 
163  return count;
164 }
165 
166 
167 // ************************************************************************* //
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
rDeltaTY field()
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
UPtrList< const Type > csorted() const
Return sorted list of objects with a class satisfying isA<Type> or isType<Type> (with Strict) ...
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
const fvMesh & baseMesh() const noexcept
Original mesh.
Definition: fvMeshSubsetI.H:23
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of &#39;true&#39; entries.
Definition: BitOps.H:73
autoPtr< vtk::internalWriter > internalWriter
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:75
PtrList< PrimitivePatchInterpolation< primitivePatch > > patchInterps
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
#define Log
Definition: PDRblock.C:28
Write OpenFOAM patches and patch fields in VTP or legacy vtk format.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
PtrList< vtk::patchWriter > patchWriters
autoPtr< volPointInterpolation > pInterp