Moment.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::AveragingMethods::Moment
28 
29 Group
30  grpLagrangianIntermediateMPPICAveragingMethods
31 
32 Description
33  Moment lagrangian averaging procedure.
34 
35  Point values and moments from the cell centroid are summed over
36  computational cells. A linear function is generated which has the same
37  integrated moment as that of the point data.
38 
39  The computed linear function is used to interpolate values within a cell.
40  The gradient is calculated from the coefficients of the function, and is
41  assumed constant over the cell.
42 
43 SourceFiles
44  Moment.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef Moment_H
49 #define Moment_H
50 
51 #include "AveragingMethod.H"
52 #include "pointMesh.H"
53 #include "tetIndices.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 namespace AveragingMethods
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class Moment Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 template<class Type>
67 class Moment
68 :
69  public AveragingMethod<Type>
70 {
71 public:
72 
73  //- Public typedefs
74 
75  //- Gradient type
77 
78 
79 private:
80 
81  //- Private data
82 
83  //- Data mean
84  Field<Type>& data_;
85 
86  //- X-data moment
87  Field<Type>& dataX_;
88 
89  //- Y-data moment
90  Field<Type>& dataY_;
91 
92  //- Z-data moment
93  Field<Type>& dataZ_;
94 
95  //- Transform tensor from moment to gradient
96  Field<symmTensor> transform_;
97 
98  //- Length scale for moment values
99  Field<scalar> scale_;
100 
101 
102  //- Private member functions
103 
104  //- Re-calculate gradient
105  virtual void updateGrad();
106 
107 
108 public:
109 
110  //- Runtime type information
111  TypeName("moment");
112 
113 
114  //- Constructors
115 
116  //- Construct from components
117  Moment
118  (
119  const IOobject& io,
120  const dictionary& dict,
121  const fvMesh &mesh
122  );
123 
124  //- Construct a copy
125  Moment(const Moment<Type>& am);
126 
127  //- Construct and return a clone
128  virtual autoPtr<AveragingMethod<Type>> clone() const
129  {
131  (
132  new Moment<Type>(*this)
133  );
134  }
135 
136 
137  //- Destructor
138  virtual ~Moment();
139 
140 
141  //- Member Functions
142 
143  //- Add point value to interpolation
144  void add
145  (
146  const barycentric& coordinates,
147  const tetIndices& tetIs,
148  const Type& value
149  );
150 
151  //- Interpolate
152  Type interpolate
153  (
154  const barycentric& coordinates,
155  const tetIndices& tetIs
156  ) const;
157 
158  //- Interpolate gradient
160  (
161  const barycentric& coordinates,
162  const tetIndices& tetIs
163  ) const;
164 
165  //- Return an internal field of the average
167 
168  //- Return an internal field of the gradient
170 };
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 } // End namespace AveragingMethods
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #ifdef NoRepository
181  #include "Moment.C"
182 #endif
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
Foam::AveragingMethod
Base class for lagrangian averaging methods.
Definition: KinematicParcel.H:69
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::AveragingMethods::Moment::~Moment
virtual ~Moment()
Destructor.
Definition: Moment.C:117
AveragingMethod.H
Foam::AveragingMethods::Moment::internalFieldGrad
tmp< Field< TypeGrad > > internalFieldGrad() const
Return an internal field of the gradient.
Foam::AveragingMethods::Moment::TypeName
TypeName("moment")
Runtime type information.
Foam::Field
Generic templated field type.
Definition: Field.H:63
coordinates
PtrList< coordinateSystem > coordinates(solidRegions.size())
Foam::AveragingMethods::Moment::Moment
Moment(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Constructors.
Definition: Moment.C:35
Foam::Barycentric< scalar >
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::AveragingMethods::Moment::interpolate
Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate.
Definition: Moment.C:159
Foam::AveragingMethods::Moment::clone
virtual autoPtr< AveragingMethod< Type > > clone() const
Construct and return a clone.
Definition: Moment.H:127
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Moment.C
Foam::tetIndices
Storage and named access for the indices of a tet which is part of the decomposition of a cell.
Definition: tetIndices.H:83
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::AveragingMethods::Moment
Moment lagrangian averaging procedure.
Definition: Moment.H:66
Foam::AveragingMethods::Moment::interpolateGrad
TypeGrad interpolateGrad(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate gradient.
Definition: Moment.C:190
Foam::AveragingMethods::Moment::add
void add(const barycentric &coordinates, const tetIndices &tetIs, const Type &value)
Member Functions.
Definition: Moment.C:132
Foam::AveragingMethods::Moment::TypeGrad
AveragingMethod< Type >::TypeGrad TypeGrad
Public typedefs.
Definition: Moment.H:75
tetIndices.H
pointMesh.H
Foam::AveragingMethods::Moment::primitiveField
tmp< Field< Type > > primitiveField() const
Return an internal field of the average.
Definition: Moment.C:209
Foam::AveragingMethod::TypeGrad
outerProduct< vector, Type >::type TypeGrad
Protected typedefs.
Definition: AveragingMethod.H:68