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