Loading...
Searching...
No Matches
Sampled.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) 2018-2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::PatchFunction1Types::Sampled
28
29Description
30 PatchFunction1 to sample an existing field.
31
32 It is the exact functionality from mappedField boundary condition
33 with the following differences:
34 - the field name is specified. So any derived fields will have the
35 same field name to sample.
36 - if used with uniformFixedValue boundary condition there is the problem
37 that that re-evaluates instead of reading/mapping.
38
39Usage
40 \table
41 Property | Description | Required | Default value
42 field | Field name | yes |
43 sampleMode | how to obtain samples | yes |
44 sampleRegion | mesh to sample | no | ""
45 samplePatch | patch to sample | no | ""
46 offsetMode | how to offset samples | no | uniform
47 offset | uniform offset vector | no | (0 0 0)
48 interpolationScheme | interpolation method | yes | cell
49 setAverage | optional average adjustment | no | false
50 average | optional average value | no |
51 \endtable
52
53 Example of the boundary condition specification:
54 \verbatim
55 <patchName>
56 {
57 // Field to sample
58 field U;
59
60 // Geometric/mapping info (equivalent of 'mappedPatch' patch type)
61 sampleMode nearestCell;
62 offset (0 -0.001 0);
63
64 // Field specific info (equivalent of 'mappedField' patch field type)
65 interpolationScheme cell;
66 }
67 \endverbatim
68
69SourceFiles
70 Sampled.C
71
72\*---------------------------------------------------------------------------*/
73
74#ifndef PatchFunction1Types_Sampled_H
75#define PatchFunction1Types_Sampled_H
76
77#include "PatchFunction1.H"
78#include "mappedPatchBase.H"
79#include "volFieldsFwd.H"
80
81// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82
83namespace Foam
84{
85namespace PatchFunction1Types
86{
87
88/*---------------------------------------------------------------------------*\
89 Class Sampled Declaration
90\*---------------------------------------------------------------------------*/
91
92template<class Type>
93class Sampled
94:
95 public PatchFunction1<Type>,
96 public mappedPatchBase
97{
98 // Private Member Functions
99
100 //- Selective retrieval of "average" entry from the dictionary
101 static Type getAverage(const dictionary& dict, bool mandatory);
102
103
104protected:
105
106 // Protected data
107
108 //- Name of the field
109 word fieldName_;
110
111 //- If true adjust the mapped field to maintain average value average_
112 const bool setAverage_;
113
114 //- Average value the mapped field is adjusted to maintain if
115 //- setAverage_ is set true
116 const Type average_;
117
118 //- Interpolation scheme to use for nearestcell mode
120
121
122 // Private Member Functions
123
124 //- Field to sample. Either on my or nbr mesh
125 bool haveSampleField() const;
126
127
128public:
129
130 // Runtime type information
131 TypeName("sampled");
132
133
134 // Generated Methods
135
136 //- No copy assignment
137 void operator=(const Sampled<Type>&) = delete;
139
140 // Constructors
141
142 //- Construct from entry name and dictionary
143 Sampled
144 (
145 const polyPatch& pp,
146 const word& redirectType,
147 const word& entryName,
148 const dictionary& dict,
149 const bool faceValues = true
150 );
151
152 //- Copy construct setting patch
153 explicit Sampled
154 (
155 const Sampled<Type>& rhs,
156 const polyPatch& pp
157 );
159 //- Copy construct
160 explicit Sampled(const Sampled<Type>& rhs);
161
162 //- Return a clone
164 {
165 return PatchFunction1<Type>::Clone(*this);
166 }
167
168 //- Return a clone, setting the patch
170 {
171 return PatchFunction1<Type>::Clone(*this, pp);
172 }
173
175 //- Destructor
176 virtual ~Sampled() = default;
177
178
179 // Member Functions
180
181 //- Field to sample. Either on my or nbr mesh
183
184 // Evaluation
185
186 //- Return sampled value
187 virtual tmp<Field<Type>> value(const scalar x) const;
189 //- Is value constant (i.e. independent of x)
190 virtual inline bool constant() const
191 {
192 return false;
193 }
194
195 //- Is value uniform (i.e. independent of coordinate)
196 virtual inline bool uniform() const
197 {
198 return false;
199 }
200
201 //- Integrate between two values
203 (
204 const scalar x1,
205 const scalar x2
206 ) const;
207
208
209 // I-O
210
211 //- Write in dictionary format
212 virtual void writeData(Ostream& os) const;
213};
214
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218} // End namespace PatchFunction1Types
219} // End namespace Foam
220
221// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222
223#ifdef NoRepository
224 #include "Sampled.C"
225#endif
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229#endif
231// ************************************************************************* //
Generic GeometricField class.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
PatchFunction1 to sample an existing field.
Definition Sampled.H:142
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition Sampled.C:307
virtual bool uniform() const
Is value uniform (i.e. independent of coordinate).
Definition Sampled.H:275
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition Sampled.C:319
virtual tmp< PatchFunction1< Type > > clone(const polyPatch &pp) const
Return a clone, setting the patch.
Definition Sampled.H:238
const Type average_
Average value the mapped field is adjusted to maintain if setAverage_ is set true.
Definition Sampled.H:169
bool haveSampleField() const
Field to sample. Either on my or nbr mesh.
Definition Sampled.C:118
virtual bool constant() const
Is value constant (i.e. independent of x).
Definition Sampled.H:267
virtual tmp< Field< Type > > value(const scalar x) const
Return sampled value.
Definition Sampled.C:139
virtual tmp< PatchFunction1< Type > > clone() const
Return a clone.
Definition Sampled.H:230
virtual ~Sampled()=default
Destructor.
Sampled(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
Definition Sampled.C:47
word fieldName_
Name of the field.
Definition Sampled.H:158
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
Definition Sampled.C:99
word interpolationScheme_
Interpolation scheme to use for nearestcell mode.
Definition Sampled.H:174
void operator=(const Sampled< Type > &)=delete
No copy assignment.
const bool setAverage_
If true adjust the mapped field to maintain average value average_.
Definition Sampled.H:163
const polyPatch const word const word & entryName
const polyPatch const word const word const dictionary & dict
static tmp< PatchFunction1< Type > > Clone(const Derived &fun)
Clone a PatchFunction1.
const polyPatch & pp
const polyPatch const word const word const dictionary const bool faceValues
mappedPatchBase(const polyPatch &)
Construct from patch.
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68
Forwards and collection of common volume field types.