CloudAverageField.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) 2025 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::CloudAverageField
26 
27 Description
28  A cloud field that is averaged and then interpolated back to the cloud. Uses
29  CloudDerivedField to provide flexible access and caching.
30 
31 See also
32  Foam::CloudDerivedField
33 
34 SourceFiles
35  CloudAverageField.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef CloudAverageField_H
40 #define CloudAverageField_H
41 
42 #include "CloudStateField.H"
43 #include "CloudDerivedField.H"
44 #include "LagrangianAverage.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class volMesh;
52 
53 /*---------------------------------------------------------------------------*\
54  Class CloudAverageField Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class Type>
59 :
60  public CloudDerivedField<Type>
61 {
62  // Private Data
63 
64  //- The name of the average
65  const word name_;
66 
67  //- The cell weight sum
68  const tmp<DimensionedField<scalar, volMesh>> tcellWeightSum_;
69 
70  //- Reference to the weight state field
71  const CloudStateField<scalar>& weightState_;
72 
73  //- Reference to the weight derived field
74  const CloudDerivedField<scalar>& weightDerived_;
75 
76  //- Reference to the state field
77  const CloudStateField<Type>& weightPsiOrPsiState_;
78 
79  //- Reference to the derived field
80  const CloudDerivedField<Type>& weightPsiOrPsiDerived_;
81 
82  //- Averaging engine
83  mutable autoPtr<LagrangianAverage<Type>> psiAveragePtr_;
84 
85  //- Current state of the average
86  mutable enum class psiAverageState
87  {
88  removed,
89  complete,
90  cached
91  } psiAverageState_;
92 
93 
94  // Private Member Functions
95 
96  //- Run an operation on the averaging engine
97  template<class MethodWeightSum, class MethodNoWeightSum, class ... Args>
98  void op
99  (
100  MethodWeightSum,
101  MethodNoWeightSum,
102  const LagrangianSubMesh&,
103  const Args& ... args
104  ) const;
105 
106  //- Interpolate and return the result
107  tmp<LagrangianSubField<Type>> interpolate
108  (
109  const LagrangianModelRef&,
110  const LagrangianSubMesh&
111  ) const;
112 
113 
114 public:
115 
116  // Constructors
117 
118  //- Construct from a name, a cell weight sum and a derived field
120  (
121  const word& name,
122  const DimensionedField<scalar, volMesh>& cellWeightSum,
123  const CloudDerivedField<Type>& weightPsi
124  );
125 
126 
127  // Member Functions
128 
129  //- Remove this sub-mesh from the average
130  void remove(const LagrangianSubMesh& subMesh);
131 
132  //- Add this sub-mesh to the average
133  void add(const LagrangianSubMesh& subMesh, const bool cache);
134 
135  //- Correct the average with values from the sub-mesh
136  void correct(const LagrangianSubMesh& subMesh, const bool cache);
137 
138  //- Reset
139  void reset();
140 };
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 } // End namespace Foam
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 #ifdef NoRepository
149  #include "CloudAverageField.C"
150 #endif
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
A cloud field that is averaged and then interpolated back to the cloud. Uses CloudDerivedField to pro...
void remove(const LagrangianSubMesh &subMesh)
Remove this sub-mesh from the average.
CloudAverageField(const word &name, const DimensionedField< scalar, volMesh > &cellWeightSum, const CloudDerivedField< Type > &weightPsi)
Construct from a name, a cell weight sum and a derived field.
void add(const LagrangianSubMesh &subMesh, const bool cache)
Add this sub-mesh to the average.
void correct(const LagrangianSubMesh &subMesh, const bool cache)
Correct the average with values from the sub-mesh.
A field derived from other state fields of the cloud. Stores and virtualises a function or a method w...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Simple wrapper to provide an optional reference to a Lagrangian model.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Foam::argList args(argc, argv)