foamVtuCells.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) 2016-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 #include "polyMesh.H"
29 #include "foamVtuCells.H"
30 #include "foamVtkOutputOptions.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 Foam::vtk::vtuCells::vtuCells
35 (
36  const contentType output,
37  const bool decompose
38 )
39 :
40  vtk::vtuSizing(),
41  output_(output),
42  decomposeRequest_(decompose),
43  cellTypes_(),
44  vertLabels_(),
45  vertOffset_(),
46  faceLabels_(),
47  faceOffset_(),
48  maps_()
49 {}
50 
51 
52 Foam::vtk::vtuCells::vtuCells
53 (
54  const polyMesh& mesh,
55  const contentType output,
56  const bool decompose
57 )
58 :
59  vtuCells(output, decompose)
60 {
61  reset(mesh);
62 }
63 
64 
65 Foam::vtk::vtuCells::vtuCells
66 (
67  const vtk::outputOptions opts,
68  const bool decompose
69 )
70 :
71  vtuCells
72  (
73  (opts.legacy() ? contentType::LEGACY : contentType::XML),
74  decompose
75  )
76 {}
77 
78 
79 Foam::vtk::vtuCells::vtuCells
80 (
81  const polyMesh& mesh,
82  const vtk::outputOptions opts,
83  const bool decompose
84 )
85 :
86  vtuCells(opts, decompose)
87 {
88  reset(mesh);
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 {
97  cellTypes_.clear();
98  vertLabels_.clear();
99  vertOffset_.clear();
100  faceLabels_.clear();
101  faceOffset_.clear();
102 
103  maps_.clear();
104 }
105 
106 
107 void Foam::vtk::vtuCells::repopulate(const polyMesh& mesh)
108 {
109  // vtuSizing::reset() called prior to this method
110 
111  cellTypes_.resize(nFieldCells());
112  vertLabels_.resize(sizeOf(output_, slotType::CELLS));
113  vertOffset_.resize(sizeOf(output_, slotType::CELLS_OFFSETS));
114  faceLabels_.resize(sizeOf(output_, slotType::FACES));
115  faceOffset_.resize(sizeOf(output_, slotType::FACES_OFFSETS));
116 
117  switch (output_)
118  {
119  case contentType::LEGACY:
120  {
121  populateLegacy
122  (
123  mesh,
124  cellTypes_,
125  vertLabels_,
126  maps_
127  );
128  break;
129  }
130 
131  case contentType::XML:
132  {
133  populateXml
134  (
135  mesh,
136  cellTypes_,
137  vertLabels_,
138  vertOffset_,
139  faceLabels_,
140  faceOffset_,
141  maps_
142  );
143  break;
144  }
145 
146  case contentType::INTERNAL1:
147  case contentType::INTERNAL2:
148  {
149  populateInternal
150  (
151  mesh,
152  cellTypes_,
153  vertLabels_,
154  vertOffset_,
155  faceLabels_,
156  faceOffset_,
157  maps_,
158  output_
159  );
160  break;
161  }
162  }
163 }
164 
165 
167 {
168  vtuSizing::reset(mesh, decomposeRequest_);
169  repopulate(mesh);
170 }
171 
172 
174 (
175  const polyMesh& mesh,
176  const enum contentType output,
177  const bool decompose
178 )
179 {
180  output_ = output;
181  decomposeRequest_ = decompose;
182 
183  reset(mesh);
184 }
185 
186 
188 {
189  maps_.renumberCells(mapping);
190 }
191 
192 
194 {
195  maps_.renumberPoints(mapping);
196 }
197 
198 
199 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
Foam::vtk::vtuCells::reset
void reset(const polyMesh &mesh)
Definition: foamVtuCells.C:166
Foam::vtk::outputOptions::legacy
bool legacy() const
True if writer uses legacy file format.
Definition: foamVtkOutputOptionsI.H:88
Foam::vtk::dataArrayAttr::FACES
"faces"
polyMesh.H
foamVtuCells.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::vtk::fileTag::CELLS
"Cells"
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
foamVtkOutputOptions.H
Foam::vtk::vtuCells::renumberCells
void renumberCells(const labelUList &mapping)
Renumber cell ids to account for subset meshes.
Definition: foamVtuCells.C:187
Foam::vtk::vtuSizing::clear
void clear() noexcept
Reset all sizes to zero.
Definition: foamVtuSizing.C:66
clear
patchWriters clear()
Foam::vtk::vtuCells::clear
void clear()
Reset all sizes to zero.
Definition: foamVtuCells.C:94
Foam::vtk::vtuCells::renumberPoints
void renumberPoints(const labelUList &mapping)
Renumber point ids to account for subset meshes.
Definition: foamVtuCells.C:193
Foam::UList< label >
Foam::vtk::vtuCells
A deep-copy description of an OpenFOAM volume mesh in data structures suitable for VTK UnstructuredGr...
Definition: foamVtuCells.H:73
Foam::vtk::vtuSizing::reset
void reset(const polyMesh &mesh, const bool decompose=false)
Reset sizing by analyzing the mesh.
Definition: foamVtuSizing.C:84