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 | Copyright (C) 2013-2016 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 "IOdictionary.H"
40 #include "autoPtr.H"
41 #include "runTimeSelectionTables.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class AveragingMethod Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
53 class AveragingMethod
54 :
55  public regIOobject,
56  public FieldField<Field, Type>
57 {
58 protected:
59 
60  //- Protected typedefs
61 
62  //- Gradient type
64 
65 
66  //- Protected data
67 
68  //- Dictionary
69  const dictionary& dict_;
70 
71  //- The mesh on which the averaging is to be done
72  const fvMesh& mesh_;
73 
74 
75  //- Protected member functions
76 
77  //- Update the gradient calculation
78  virtual void updateGrad();
79 
80 
81 public:
82 
83  //- Runtime type information
84  TypeName("averagingMethod");
85 
86  //- Declare runtime constructor selection table
88  (
89  autoPtr,
91  dictionary,
92  (
93  const IOobject& io,
94  const dictionary& dict,
95  const fvMesh& mesh
96  ),
97  (io, dict, mesh)
98  );
99 
100 
101  //- Constructors
102 
103  //- Construct from components
105  (
106  const IOobject& io,
107  const dictionary& dict,
108  const fvMesh& mesh,
109  const labelList& size
110  );
111 
112  //- Construct a copy
114 
115  //- Construct and return a clone
116  virtual autoPtr<AveragingMethod<Type>> clone() const = 0;
117 
118 
119  //- Selector
121  (
122  const IOobject& io,
123  const dictionary& dict,
124  const fvMesh& mesh
125  );
126 
127 
128  //- Destructor
129  virtual ~AveragingMethod();
130 
131 
132  //- Member Functions
133 
134  //- Add point value to interpolation
135  virtual void add
136  (
137  const point position,
138  const tetIndices& tetIs,
139  const Type& value
140  ) = 0;
141 
142  //- Interpolate
143  virtual Type interpolate
144  (
145  const point position,
146  const tetIndices& tetIs
147  ) const = 0;
148 
149  //- Interpolate gradient
150  virtual TypeGrad interpolateGrad
151  (
152  const point position,
153  const tetIndices& tetIs
154  ) const = 0;
155 
156  //- Calculate the average
157  virtual void average();
158  virtual void average(const AveragingMethod<scalar>& weight);
159 
160  //- Dummy write
161  virtual bool writeData(Ostream&) const;
162 
163  //- Write using setting from DB
164  virtual bool write() const;
165 
166  //- Return an internal field of the average
167  virtual tmp<Field<Type>> primitiveField() const = 0;
168 
169  //- Assign to another average
170  inline void operator=(const AveragingMethod<Type>& x);
171 
172  //- Assign to value
173  inline void operator=(const Type& x);
174 
175  //- Assign to tmp
176  inline void operator=(tmp<FieldField<Field, Type>> x);
177 
178  //- Add-equal tmp
179  inline void operator+=(tmp<FieldField<Field, Type>> x);
180 
181  //- Multiply-equal tmp
182  inline void operator*=(tmp<FieldField<Field, Type>> x);
183 
184  //- Divide-equal tmp
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace Foam
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #include "AveragingMethodI.H"
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #ifdef NoRepository
200  #include "AveragingMethod.C"
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
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:137
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
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
virtual bool write() const
Write using setting from DB.
virtual void add(const point position, const tetIndices &tetIs, const Type &value)=0
Member Functions.
dynamicFvMesh & mesh
Base class for lagrangian averaging methods.
Definition: MPPICParcel.H:55
virtual TypeGrad interpolateGrad(const point position, 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:53
const dictionary & dict_
Protected data.
virtual autoPtr< AveragingMethod< Type > > clone() const =0
Construct and return a clone.
virtual void updateGrad()
Protected member functions.
void operator/=(tmp< FieldField< Field, scalar >> x)
Divide-equal tmp.
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:53
Macros to ease declaration of run-time selection tables.
A class for managing temporary objects.
Definition: PtrList.H:54
virtual Type interpolate(const point position, const tetIndices &tetIs) const =0
Interpolate.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
AveragingMethod(const IOobject &io, const dictionary &dict, const fvMesh &mesh, const labelList &size)
Constructors.
Namespace for OpenFOAM.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
virtual bool writeData(Ostream &) const
Dummy write.
virtual ~AveragingMethod()
Destructor.