All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::vtkMesh
26 
27 Description
28  Encapsulation of VTK mesh data. Holds mesh or meshsubset and
29  polyhedral-cell decomposition on it.
30 
31 SourceFiles
32  vtkMesh.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef vtkMesh_H
37 #define vtkMesh_H
38 
39 #include "vtkTopo.H"
40 #include "fvMeshSubset.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of classes
48 class Time;
49 
50 /*---------------------------------------------------------------------------*\
51  Class vtkMesh Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class vtkMesh
55 {
56  // Private Data
57 
58  //- Reference to mesh
59  fvMesh& baseMesh_;
60 
61  //- Subsetting engine + sub-fvMesh
62  fvMeshSubset subsetter_;
63 
64  //- Current cellSet (or empty)
65  const word setName_;
66 
67  //- Current decomposition of topology
68  mutable autoPtr<vtkTopo> topoPtr_;
69 
70 
71 public:
72 
73  // Constructors
74 
75  //- Construct from components
76  vtkMesh(fvMesh& baseMesh, const word& setName = "");
77 
78  //- Disallow default bitwise copy construction
79  vtkMesh(const vtkMesh&) = delete;
80 
81 
82  // Member Functions
83 
84  // Access
85 
86  //- Whole mesh
87  const fvMesh& baseMesh() const
88  {
89  return baseMesh_;
90  }
91 
92  const fvMeshSubset& subsetter() const
93  {
94  return subsetter_;
95  }
96 
97  //- Check if running subMesh
98  bool useSubMesh() const
99  {
100  return setName_.size();
101  }
102 
103  //- topology
104  const vtkTopo& topo() const
105  {
106  if (topoPtr_.empty())
107  {
108  topoPtr_.reset(new vtkTopo(mesh()));
109  }
110  return topoPtr_();
111  }
112 
113  //- Access either mesh or submesh
114  const fvMesh& mesh() const
115  {
116  if (useSubMesh())
117  {
118  return subsetter_.subMesh();
119  }
120  else
121  {
122  return baseMesh_;
123  }
124  }
125 
126  //- Number of field cells
127  label nFieldCells() const
128  {
129  return topo().cellTypes().size();
130  }
131 
132  //- Number of field points
133  label nFieldPoints() const
134  {
135  return mesh().nPoints() + topo().addPointCellLabels().size();
136  }
137 
138 
139  // Edit
140 
141  //- Read mesh
143 
144 
145  //- Map volume field (does in fact do very little interpolation;
146  // just copied from fvMeshSubset)
147  template<class GeoField>
148  tmp<GeoField> interpolate(const GeoField& fld) const
149  {
150  if (useSubMesh())
151  {
152  tmp<GeoField> subFld = subsetter_.interpolate(fld);
153  subFld.ref().rename(fld.name());
154  return subFld;
155  }
156  else
157  {
158  return fld;
159  }
160  }
161 
162 
163  // Member Operators
164 
165  //- Disallow default bitwise assignment
166  void operator=(const vtkMesh&) = delete;
167 };
168 
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
const labelList & addPointCellLabels() const
Definition: vtkTopo.H:113
const fvMesh & mesh() const
Access either mesh or submesh.
Definition: vtkMesh.H:100
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
label nFieldCells() const
Number of field cells.
Definition: vtkMesh.H:126
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const labelList & cellTypes() const
Definition: vtkTopo.H:108
label nFieldPoints() const
Number of field points.
Definition: vtkMesh.H:132
vtkMesh(fvMesh &baseMesh, const word &setName="")
Construct from components.
tmp< GeoField > interpolate(const GeoField &fld) const
Map volume field (does in fact do very little interpolation;.
Definition: vtkMesh.H:122
polyMesh::readUpdateState readUpdate()
Read mesh.
const fvMeshSubset & subsetter() const
Definition: vtkMesh.H:88
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Polyhedral cell decomposition for VTK.
Definition: vtkTopo.H:51
bool useSubMesh() const
Check if running subMesh.
Definition: vtkMesh.H:94
Encapsulation of VTK mesh data. Holds mesh or meshsubset and polyhedral-cell decomposition on it...
Definition: vtkMesh.H:52
Post-processing mesh subset tool. Given the original mesh and the list of selected cells...
Definition: fvMeshSubset.H:73
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const fvMesh & baseMesh() const
Whole mesh.
Definition: vtkMesh.H:83
label nPoints() const
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:88
A class for managing temporary objects.
Definition: PtrList.H:53
const vtkTopo & topo() const
topology
Definition: vtkMesh.H:103
Namespace for OpenFOAM.
void operator=(const vtkMesh &)=delete
Disallow default bitwise assignment.