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