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-2020 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.sorted<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
61  label writeri = 0;
63  {
64  ok = true;
65  writer.write(field);
66  ++writeri;
67  }
68 
69  if (ok)
70  {
71  ++count;
72 
73  if (verbose_)
74  {
75  if (count == 1)
76  {
77  Log << " " << GeoField::typeName << '(';
78  }
79  else
80  {
81  Log << ' ';
82  }
83  Log << origField.name();
84  }
85  }
86  }
87 
88  if (verbose_ && count)
89  {
90  Log << ')' << endl;
91  }
92 
93  return count;
94 }
95 
96 
97 template<class GeoField>
98 Foam::label Foam::functionObjects::vtkWrite::writeVolFieldsImpl
99 (
104  const fvMeshSubset& proxy,
105  const wordHashSet& candidateNames
106 ) const
107 {
108  const fvMesh& baseMesh = proxy.baseMesh();
109 
110  label count = 0;
111 
112  for
113  (
114  const GeoField& origField
115  : baseMesh.sorted<GeoField>(candidateNames)
116  )
117  {
118  bool ok = false;
119  auto tfield = fvMeshSubsetProxy::interpolate(proxy, origField);
120  const auto& field = tfield();
121 
122  // Internal
123  if (internalWriter && pInterp)
124  {
125  ok = true;
126  internalWriter->write(field, *pInterp);
127  }
128 
129  // Boundary
130  label writeri = 0;
132  {
133  if (writeri < patchInterps.size() && patchInterps.set(writeri))
134  {
135  ok = true;
136  writer.write(field, patchInterps[writeri]);
137  }
138  ++writeri;
139  }
140 
141  if (ok)
142  {
143  ++count;
144 
145  if (verbose_)
146  {
147  if (count == 1)
148  {
149  Log << " " << GeoField::typeName << "->point(";
150  }
151  else
152  {
153  Log << ' ';
154  }
155  Log << origField.name();
156  }
157  }
158  }
159 
160  if (verbose_ && count)
161  {
162  Log << ')' << endl;
163  }
164 
165  return count;
166 }
167 
168 
169 // ************************************************************************* //
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
rDeltaTY field()
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
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:100
static tmp< GeoField > interpolate(const fvMeshSubset &subsetter, const GeoField &fld)
Wrapper for field or the subsetted field.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
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:79
#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
UPtrList< const regIOobject > sorted() const
Return sorted list of objects.
PtrList< vtk::patchWriter > patchWriters
autoPtr< volPointInterpolation > pInterp