Dual.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) 2013-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::AveragingMethods::Dual
26 
27 Description
28  Dual-mesh lagrangian averaging procedure.
29 
30  Point values are summed using the tetrahedral decomposition of the
31  computational cells. Summation is done in the cells, and also in the
32  terahedrons surrounding each point. The latter forms a type of dual mesh.
33  The interpolation is weighted by proximity to the cell centre or point, as
34  calculated by the barycentric coordinate within the tethrahedron.
35 
36  Values are interpolated linearly across the tethrahedron. Gradients are
37  calculated directly from the point values using a first order finite
38  element basis. The computed gradient is assumed constant over the
39  tethrahedron.
40 
41 SourceFiles
42  Dual.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Dual_H
47 #define Dual_H
48 
49 #include "AveragingMethod.H"
50 #include "pointMesh.H"
51 #include "tetIndices.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 namespace AveragingMethods
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class Dual Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class Type>
65 class Dual
66 :
67  public AveragingMethod<Type>
68 {
69 public:
70 
71  //- Public typedefs
72 
73  //- Gradient type
75 
76 
77 private:
78 
79  //- Private data
80 
81  //- Volume of the cell-centered regions
82  const Field<scalar>& volumeCell_;
83 
84  //- Volume of the point-centered regions
85  Field<scalar> volumeDual_;
86 
87  //- Data on the cells
88  Field<Type>& dataCell_;
89 
90  //- Data on the points
91  Field<Type>& dataDual_;
92 
93  //- Tet vertex labels
94  mutable List<label> tetVertices_;
95 
96  //- Tet barycentric coordinates
97  mutable List<scalar> tetCoordinates_;
98 
99 
100  //- Private static member functions
101 
102  //- Return the size of the FieldField parts
103  static autoPtr<labelList> size(const fvMesh &mesh);
104 
105 
106  //- Private member functions
107 
108  //- Calculate indices and barycentric coordinates within a tetrahedron
109  void tetGeometry
110  (
111  const point position,
112  const tetIndices& tetIs
113  ) const;
114 
115  //- Sync point data over processor boundaries
116  void syncDualData();
117 
118 
119 public:
120 
121  //- Runtime type information
122  TypeName("dual");
123 
124 
125  //- Constructors
126 
127  //- Construct from components
128  Dual
129  (
130  const IOobject& io,
131  const dictionary& dict,
132  const fvMesh &mesh
133  );
134 
135  //- Construct a copy
136  Dual(const Dual<Type>& am);
137 
138  //- Construct and return a clone
139  virtual autoPtr<AveragingMethod<Type>> clone() const
140  {
142  (
143  new Dual<Type>(*this)
144  );
145  }
146 
147 
148  //- Destructor
149  virtual ~Dual();
150 
151 
152  //- Member Functions
153 
154  //- Add point value to interpolation
155  void add
156  (
157  const point position,
158  const tetIndices& tetIs,
159  const Type& value
160  );
161 
162  //- Interpolate
163  Type interpolate
164  (
165  const point position,
166  const tetIndices& tetIs
167  ) const;
168 
169  //- Interpolate gradient
170  TypeGrad interpolateGrad
171  (
172  const point position,
173  const tetIndices& tetIs
174  ) const;
175 
176  //- Calculate the average
177  void average();
178  void average(const AveragingMethod<scalar>& weight);
179 
180  //- Return an internal field of the average
182 
183  //- Return an internal field of the gradient
185 };
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace AveragingMethods
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #ifdef NoRepository
196  #include "Dual.C"
197 #endif
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #endif
202 
203 // ************************************************************************* //
TypeName("dual")
Runtime type information.
dictionary dict
tmp< Field< TypeGrad > > internalFieldGrad() const
Return an internal field of the gradient.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual autoPtr< AveragingMethod< Type > > clone() const
Construct and return a clone.
Definition: Dual.H:138
TypeGrad interpolateGrad(const point position, const tetIndices &tetIs) const
Interpolate gradient.
Definition: Dual.C:187
outerProduct< vector, Type >::type TypeGrad
Protected typedefs.
Dual(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Constructors.
Definition: Dual.C:48
void add(const point position, const tetIndices &tetIs, const Type &value)
Member Functions.
Definition: Dual.C:146
virtual ~Dual()
Destructor.
Definition: Dual.C:105
dynamicFvMesh & mesh
Type interpolate(const point position, const tetIndices &tetIs) const
Interpolate.
Definition: Dual.C:169
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
Dual-mesh lagrangian averaging procedure.
Definition: Dual.H:64
AveragingMethod< Type >::TypeGrad TypeGrad
Public typedefs.
Definition: Dual.H:73
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void average()
Calculate the average.
Definition: Dual.C:225
tmp< Field< Type > > primitiveField() const
Return an internal field of the average.
Definition: Dual.C:247
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
A class for managing temporary objects.
Definition: PtrList.H:54
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Namespace for OpenFOAM.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29