vtkMesh.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 | Copyright (C) 2011-2016 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 
72  // Private Member Functions
73 
74  //- Disallow default bitwise copy construct
75  vtkMesh(const vtkMesh&);
76 
77  //- Disallow default bitwise assignment
78  void operator=(const vtkMesh&);
79 
80 
81 public:
82 
83  // Constructors
84 
85  //- Construct from components
86  vtkMesh(fvMesh& baseMesh, const word& setName = "");
87 
88 
89  // Member Functions
90 
91  // Access
92 
93  //- Whole mesh
94  const fvMesh& baseMesh() const
95  {
96  return baseMesh_;
97  }
98 
99  const fvMeshSubset& subsetter() const
100  {
101  return subsetter_;
102  }
103 
104  //- Check if running subMesh
105  bool useSubMesh() const
106  {
107  return setName_.size();
108  }
109 
110  //- topology
111  const vtkTopo& topo() const
112  {
113  if (topoPtr_.empty())
114  {
115  topoPtr_.reset(new vtkTopo(mesh()));
116  }
117  return topoPtr_();
118  }
119 
120  //- Access either mesh or submesh
121  const fvMesh& mesh() const
122  {
123  if (useSubMesh())
124  {
125  return subsetter_.subMesh();
126  }
127  else
128  {
129  return baseMesh_;
130  }
131  }
132 
133  //- Number of field cells
134  label nFieldCells() const
135  {
136  return topo().cellTypes().size();
137  }
138 
139  //- Number of field points
140  label nFieldPoints() const
141  {
142  return mesh().nPoints() + topo().addPointCellLabels().size();
143  }
144 
145 
146  // Edit
147 
148  //- Read mesh
150 
151 
152  //- Map volume field (does in fact do very little interpolation;
153  // just copied from fvMeshSubset)
154  template<class GeoField>
155  tmp<GeoField> interpolate(const GeoField& fld) const
156  {
157  if (useSubMesh())
158  {
159  tmp<GeoField> subFld = subsetter_.interpolate(fld);
160  subFld.ref().rename(fld.name());
161  return subFld;
162  }
163  else
164  {
165  return fld;
166  }
167  }
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
const labelList & addPointCellLabels() const
Definition: vtkTopo.H:118
const fvMesh & mesh() const
Access either mesh or submesh.
Definition: vtkMesh.H:119
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:133
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
const labelList & cellTypes() const
Definition: vtkTopo.H:113
label nFieldPoints() const
Number of field points.
Definition: vtkMesh.H:139
tmp< GeoField > interpolate(const GeoField &fld) const
Map volume field (does in fact do very little interpolation;.
Definition: vtkMesh.H:153
polyMesh::readUpdateState readUpdate()
Read mesh.
const fvMeshSubset & subsetter() const
Definition: vtkMesh.H:97
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:103
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:92
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:110
Namespace for OpenFOAM.