AveragingMethod.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::AveragingMethod
26 
27 Description
28  Base class for lagrangian averaging methods.
29 
30 SourceFiles
31  AveragingMethod.C
32  AveragingMethodI.H
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef AveragingMethod_H
37 #define AveragingMethod_H
38 
39 #include "barycentric.H"
40 #include "tetIndices.H"
41 #include "FieldField.H"
42 #include "fvMesh.H"
43 #include "runTimeSelectionTables.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class AveragingMethod Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class Type>
55 class AveragingMethod
56 :
57  public regIOobject,
58  public FieldField<Field, Type>
59 {
60 protected:
61 
62  //- Protected typedefs
63 
64  //- Gradient type
66 
67 
68  //- Protected data
69 
70  //- Dictionary
71  const dictionary& dict_;
72 
73  //- The mesh on which the averaging is to be done
74  const fvMesh& mesh_;
75 
76 
77  //- Protected member functions
78 
79  //- Update the gradient calculation
80  virtual void updateGrad();
81 
82 
83 public:
84 
85  //- Runtime type information
86  TypeName("averagingMethod");
87 
88  //- Declare runtime constructor selection table
90  (
91  autoPtr,
93  dictionary,
94  (
95  const IOobject& io,
96  const dictionary& dict,
97  const fvMesh& mesh
98  ),
99  (io, dict, mesh)
100  );
101 
102 
103  //- Constructors
104 
105  //- Construct from components
107  (
108  const IOobject& io,
109  const dictionary& dict,
110  const fvMesh& mesh,
111  const labelList& size
112  );
113 
114  //- Construct a copy
116 
117  //- Construct and return a clone
118  virtual autoPtr<AveragingMethod<Type>> clone() const = 0;
119 
120 
121  //- Selector
123  (
124  const IOobject& io,
125  const dictionary& dict,
126  const fvMesh& mesh
127  );
128 
129 
130  //- Destructor
131  virtual ~AveragingMethod();
132 
133 
134  //- Member Functions
135 
136  //- Add point value to interpolation
137  virtual void add
138  (
139  const barycentric& coordinates,
140  const tetIndices& tetIs,
141  const Type& value
142  ) = 0;
143 
144  //- Interpolate
145  virtual Type interpolate
146  (
147  const barycentric& coordinates,
148  const tetIndices& tetIs
149  ) const = 0;
150 
151  //- Interpolate gradient
152  virtual TypeGrad interpolateGrad
153  (
154  const barycentric& coordinates,
155  const tetIndices& tetIs
156  ) const = 0;
157 
158  //- Calculate the average
159  virtual void average();
160  virtual void average(const AveragingMethod<scalar>& weight);
161 
162  //- Dummy write
163  virtual bool writeData(Ostream&) const;
164 
165  //- Write using setting from DB
166  virtual bool write(const bool write = true) const;
167 
168  //- Return an internal field of the average
169  virtual tmp<Field<Type>> primitiveField() const = 0;
170 
171  //- Assign to another average
172  inline void operator=(const AveragingMethod<Type>& x);
173 
174  //- Assign to value
175  inline void operator=(const Type& x);
176 
177  //- Assign to tmp
178  inline void operator=(tmp<FieldField<Field, Type>> x);
179 
180  //- Add-equal tmp
181  inline void operator+=(tmp<FieldField<Field, Type>> x);
182 
183  //- Multiply-equal tmp
184  inline void operator*=(tmp<FieldField<Field, Type>> x);
185 
186  //- Divide-equal tmp
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #include "AveragingMethodI.H"
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 #ifdef NoRepository
202  #include "AveragingMethod.C"
203 #endif
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 #endif
208 
209 // ************************************************************************* //
dictionary dict
virtual tmp< Field< Type > > primitiveField() const =0
Return an internal field of the average.
static autoPtr< AveragingMethod< Type > > New(const IOobject &io, const dictionary &dict, const fvMesh &mesh)
Selector.
void operator=(const AveragingMethod< Type > &x)
Assign to another average.
void operator*=(tmp< FieldField< Field, Type >> x)
Multiply-equal tmp.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
outerProduct< vector, Type >::type TypeGrad
Protected typedefs.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
virtual void add(const barycentric &coordinates, const tetIndices &tetIs, const Type &value)=0
Member Functions.
declareRunTimeSelectionTable(autoPtr, AveragingMethod, dictionary,(const IOobject &io, const dictionary &dict, const fvMesh &mesh),(io, dict, mesh))
Declare runtime constructor selection table.
Generic field type.
Definition: FieldField.H:51
dynamicFvMesh & mesh
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
virtual TypeGrad interpolateGrad(const barycentric &coordinates, const tetIndices &tetIs) const =0
Interpolate gradient.
TypeName("averagingMethod")
Runtime type information.
Storage and named access for the indices of a tet which is part of the decomposition of a cell...
Definition: tetIndices.H:81
void operator+=(tmp< FieldField< Field, Type >> x)
Add-equal tmp.
const fvMesh & mesh_
The mesh on which the averaging is to be done.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const dictionary & dict_
Protected data.
virtual autoPtr< AveragingMethod< Type > > clone() const =0
Construct and return a clone.
virtual bool write(const bool write=true) const
Write using setting from DB.
virtual void updateGrad()
Protected member functions.
virtual bool writeData(Ostream &) const
Dummy write.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
void operator/=(tmp< FieldField< Field, scalar >> x)
Divide-equal tmp.
virtual Type interpolate(const barycentric &coordinates, const tetIndices &tetIs) const =0
Interpolate.
virtual void average()
Calculate the average.
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
Macros to ease declaration of run-time selection tables.
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
AveragingMethod(const IOobject &io, const dictionary &dict, const fvMesh &mesh, const labelList &size)
Constructors.
Namespace for OpenFOAM.
virtual ~AveragingMethod()
Destructor.