Moment.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-2020 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::Moment
26 
27 Description
28  Moment lagrangian averaging procedure.
29 
30  Point values and moments from the cell centroid are summed over
31  computational cells. A linear function is generated which has the same
32  integrated moment as that of the point data.
33 
34  The computed linear function is used to interpolate values within a cell.
35  The gradient is calculated from the coefficients of the function, and is
36  assumed constant over the cell.
37 
38 SourceFiles
39  Moment.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Moment_H
44 #define Moment_H
45 
46 #include "AveragingMethod.H"
47 #include "pointMesh.H"
48 #include "tetIndices.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 namespace AveragingMethods
55 {
56 
57 /*---------------------------------------------------------------------------*\
58  Class Moment Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 template<class Type>
62 class Moment
63 :
64  public AveragingMethod<Type>
65 {
66 public:
67 
68  // Public Typedefs
69 
70  //- Gradient type
72 
73 
74 private:
75 
76  // Private data
77 
78  //- Data mean
79  Field<Type>& data_;
80 
81  //- X-data moment
82  Field<Type>& dataX_;
83 
84  //- Y-data moment
85  Field<Type>& dataY_;
86 
87  //- Z-data moment
88  Field<Type>& dataZ_;
89 
90  //- Transform tensor from moment to gradient
91  Field<symmTensor> transform_;
92 
93  //- Length scale for moment values
94  Field<scalar> scale_;
95 
96 
97  // Private Member Functions
98 
99  //- Re-calculate gradient
100  virtual void updateGrad();
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("moment");
107 
108 
109  //- Constructors
110 
111  //- Construct from components
112  Moment
113  (
114  const IOobject& io,
115  const dictionary& dict,
116  const fvMesh &mesh
117  );
118 
119  //- Construct a copy
120  Moment(const Moment<Type>& am);
121 
122  //- Construct and return a clone
123  virtual autoPtr<AveragingMethod<Type>> clone() const
124  {
126  (
127  new Moment<Type>(*this)
128  );
129  }
130 
131 
132  //- Destructor
133  virtual ~Moment();
134 
135 
136  //- Member Functions
137 
138  //- Add point value to interpolation
139  void add
140  (
141  const barycentric& coordinates,
142  const tetIndices& tetIs,
143  const Type& value
144  );
145 
146  //- Interpolate
147  Type interpolate
148  (
149  const barycentric& coordinates,
150  const tetIndices& tetIs
151  ) const;
152 
153  //- Interpolate gradient
154  TypeGrad interpolateGrad
155  (
156  const barycentric& coordinates,
157  const tetIndices& tetIs
158  ) const;
159 
160  //- Return an internal field of the average
162 
163  //- Return an internal field of the gradient
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace AveragingMethods
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
176  #include "Moment.C"
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
dictionary dict
TypeName("moment")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
AveragingMethod< Type >::TypeGrad TypeGrad
Gradient type.
Definition: Moment.H:70
void add(const barycentric &coordinates, const tetIndices &tetIs, const Type &value)
Member Functions.
Definition: Moment.C:130
Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate.
Definition: Moment.C:157
outerProduct< vector, Type >::type TypeGrad
Protected typedefs.
virtual autoPtr< AveragingMethod< Type > > clone() const
Construct and return a clone.
Definition: Moment.H:122
Moment lagrangian averaging procedure.
Definition: Moment.H:61
dynamicFvMesh & mesh
Pre-declare SubField and related Field type.
Definition: Field.H:56
TypeGrad interpolateGrad(const barycentric &coordinates, const tetIndices &tetIs) const
Interpolate gradient.
Definition: Moment.C:188
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
tmp< Field< TypeGrad > > internalFieldGrad() const
Return an internal field of the gradient.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
tmp< Field< Type > > primitiveField() const
Return an internal field of the average.
Definition: Moment.C:207
PtrList< coordinateSystem > coordinates(solidRegions.size())
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Moment(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Constructors.
Definition: Moment.C:33
virtual ~Moment()
Destructor.
Definition: Moment.C:115
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
Namespace for OpenFOAM.