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-2015 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
83 
84  //- Volume of the point-centered regions
86 
87  //- Data on the cells
89 
90  //- Data on the points
92 
93  //- Tet vertex labels
94  mutable List<label> tetVertices_;
95 
96  //- Tet barycentric coordinates
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
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
181  tmp<Field<Type> > internalField() const;
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 // ************************************************************************* //
Foam::AveragingMethod
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::AveragingMethods::Dual::internalField
tmp< Field< Type > > internalField() const
Return an internal field of the average.
Definition: Dual.C:247
Foam::AveragingMethods::Dual::interpolateGrad
TypeGrad interpolateGrad(const point position, const tetIndices &tetIs) const
Interpolate gradient.
Definition: Dual.C:187
Foam::AveragingMethods::Dual::internalFieldGrad
tmp< Field< TypeGrad > > internalFieldGrad() const
Return an internal field of the gradient.
AveragingMethod.H
Foam::AveragingMethods::Dual::clone
virtual autoPtr< AveragingMethod< Type > > clone() const
Construct and return a clone.
Definition: Dual.H:138
Foam::AveragingMethods::Dual::TypeGrad
AveragingMethod< Type >::TypeGrad TypeGrad
Public typedefs.
Definition: Dual.H:73
Foam::AveragingMethods::Dual::~Dual
virtual ~Dual()
Destructor.
Definition: Dual.C:105
Foam::AveragingMethods::Dual::TypeName
TypeName("dual")
Runtime type information.
Foam::AveragingMethods::Dual::dataCell_
Field< Type > & dataCell_
Data on the cells.
Definition: Dual.H:87
Foam::AveragingMethods::Dual::syncDualData
void syncDualData()
Sync point data over processor boundaries.
Definition: Dual.C:131
Foam::Field< scalar >
Foam::AveragingMethods::Dual::size
static autoPtr< labelList > size(const fvMesh &mesh)
Private static member functions.
Definition: Dual.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::AveragingMethods::Dual::volumeCell_
const Field< scalar > & volumeCell_
Private data.
Definition: Dual.H:81
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::AveragingMethods::Dual::Dual
Dual(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Constructors.
Definition: Dual.C:48
Foam::AveragingMethods::Dual::tetVertices_
List< label > tetVertices_
Tet vertex labels.
Definition: Dual.H:93
Foam::AveragingMethods::Dual::tetCoordinates_
List< scalar > tetCoordinates_
Tet barycentric coordinates.
Definition: Dual.H:96
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::AveragingMethods::Dual::tetGeometry
void tetGeometry(const point position, const tetIndices &tetIs) const
Private member functions.
Definition: Dual.C:113
Foam::tetIndices
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:73
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::Vector< scalar >
Foam::List< label >
Foam::AveragingMethods::Dual::interpolate
Type interpolate(const point position, const tetIndices &tetIs) const
Interpolate.
Definition: Dual.C:169
Foam::AveragingMethods::Dual
Dual-mesh lagrangian averaging procedure.
Definition: Dual.H:64
Foam::AveragingMethods::Dual::volumeDual_
Field< scalar > volumeDual_
Volume of the point-centered regions.
Definition: Dual.H:84
Foam::AveragingMethods::Dual::add
void add(const point position, const tetIndices &tetIs, const Type &value)
Member Functions.
Definition: Dual.C:146
Foam::AveragingMethods::Dual::average
void average()
Calculate the average.
Definition: Dual.C:225
Dual.C
Foam::AveragingMethods::Dual::dataDual_
Field< Type > & dataDual_
Data on the points.
Definition: Dual.H:90
tetIndices.H
pointMesh.H