Dual.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) 2013-2018 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 
94  //- Private static member functions
95 
96  //- Return the size of the FieldField parts
97  static autoPtr<labelList> size(const fvMesh &mesh);
98 
99 
100  //- Private member functions
101 
102  //- Sync point data over processor boundaries
103  void syncDualData();
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("dual");
110 
111 
112  //- Constructors
113 
114  //- Construct from components
115  Dual
116  (
117  const IOobject& io,
118  const dictionary& dict,
119  const fvMesh &mesh
120  );
121 
122  //- Construct a copy
123  Dual(const Dual<Type>& am);
124 
125  //- Construct and return a clone
126  virtual autoPtr<AveragingMethod<Type>> clone() const
127  {
129  (
130  new Dual<Type>(*this)
131  );
132  }
133 
134 
135  //- Destructor
136  virtual ~Dual();
137 
138 
139  //- Member Functions
140 
141  //- Add point value to interpolation
142  void add
143  (
144  const barycentric& coordinates,
145  const tetIndices& tetIs,
146  const Type& value
147  );
148 
149  //- Interpolate
150  Type interpolate
151  (
152  const barycentric& coordinates,
153  const tetIndices& tetIs
154  ) const;
155 
156  //- Interpolate gradient
157  TypeGrad interpolateGrad
158  (
159  const barycentric& coordinates,
160  const tetIndices& tetIs
161  ) const;
162 
163  //- Calculate the average
164  void average();
165  void average(const AveragingMethod<scalar>& weight);
166 
167  //- Return an internal field of the average
169 
170  //- Return an internal field of the gradient
172 };
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace AveragingMethods
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #ifdef NoRepository
183  #include "Dual.C"
184 #endif
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
TypeName("dual")
Runtime type information.
tmp< Field< Type > > primitiveField() const
Return an internal field of the average.
Definition: Dual.C:224
dictionary dict
Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate.
Definition: Dual.C:146
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
outerProduct< vector, Type >::type TypeGrad
Protected typedefs.
Dual(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Constructors.
Definition: Dual.C:48
virtual autoPtr< AveragingMethod< Type > > clone() const
Construct and return a clone.
Definition: Dual.H:125
TypeGrad interpolateGrad(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate gradient.
Definition: Dual.C:164
virtual ~Dual()
Destructor.
Definition: Dual.C:101
dynamicFvMesh & mesh
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
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
PtrList< coordinateSystem > coordinates(solidRegions.size())
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void average()
Calculate the average.
Definition: Dual.C:202
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A class for managing temporary objects.
Definition: PtrList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
tmp< Field< TypeGrad > > internalFieldGrad() const
Return an internal field of the gradient.
Namespace for OpenFOAM.
void add(const barycentric &coordinates, const tetIndices &tetIs, const Type &value)
Member Functions.
Definition: Dual.C:123