mappedValueFvPatchField.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) 2011-2023 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::mappedValueFvPatchField
26 
27 Description
28  This boundary condition maps the values from a neighbouring patch to this
29  patch.
30 
31 Usage
32  \table
33  Property | Description | Required | Default value
34  field | name of field to be mapped | no | this field name
35  setAverage | set the average value? | no | yes if average \\
36  is specified, \\
37  no otherwise
38  average | average value to apply | if setAverage is true |
39  \endtable
40 
41  Example of the boundary condition specification:
42  \verbatim
43  <patchName>
44  {
45  type mappedValue;
46  field T;
47  average 300;
48  value uniform 300;
49  }
50  \endverbatim
51 
52  This boundary condition will usually be applied to a patch which is of
53  mappedPatchBase type, and which holds all the necessary mapping
54  information. It can also create its own mapping data which overrides that
55  in the mapped patch, or so that it can be applied to a non-mapped patch.
56  This is triggered by the presence of controls relating to mappedPatchBase
57  (i.e., neighbourRegion, neighbourPatch, etc ...).
58 
59 See also
60  Foam::mappedPatchBase
61  Foam::mappedPolyPatch
62  Foam::mappedFvPatch
63 
64 SourceFiles
65  mappedValueFvPatchField.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef mappedValueFvPatchField_H
70 #define mappedValueFvPatchField_H
71 
73 #include "mappedPatchBase.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class mappedValueFvPatchField Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 template<class Type>
85 class mappedValueFvPatchField
86 :
87  public fixedValueFvPatchField<Type>
88 {
89 protected:
90 
91  // Protected Member Data
92 
93  //- The field to map
94  const word fieldName_;
95 
96  //- If true adjust the sampled field to maintain an average value
97  const bool setAverage_;
98 
99  //- Average value the sampled field is adjusted to
100  const Type average_;
101 
102  //- The mapping engine
104 
105 
106  // Protected Member Functions
107 
108  //- Return the mapping engine
109  const mappedPatchBase& mapper() const;
110 
111  //- Return the neighbouring patch field
112  const fvPatchField<Type>& nbrPatchField() const;
113 
114  //- Return the mapped values, given the neighbouring field
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("mappedValue");
122 
123 
124  // Constructors
125 
126  //- Construct from patch and internal field
128  (
129  const fvPatch&,
131  );
132 
133  //- Construct from patch, internal field and dictionary
135  (
136  const fvPatch&,
138  const dictionary&
139  );
140 
141  //- Construct by mapping given mappedValueFvPatchField
142  // onto a new patch
144  (
146  const fvPatch&,
148  const fieldMapper&
149  );
150 
151  //- Disallow copy without setting internal field reference
153  (
155  ) = delete;
156 
157  //- Copy constructor setting internal field reference
159  (
162  );
163 
164  //- Construct and return a clone setting internal field reference
166  (
168  ) const
169  {
170  return tmp<fvPatchField<Type>>
171  (
172  new mappedValueFvPatchField<Type>(*this, iF)
173  );
174  }
175 
176 
177  // Member Functions
178 
179  // Mapping functions
180 
181  //- Map the given fvPatchField onto this fvPatchField
182  virtual void map(const fvPatchField<Type>&, const fieldMapper&);
183 
184  //- Reset the fvPatchField to the given fvPatchField
185  // Used for mesh to mesh mapping
186  virtual void reset(const fvPatchField<Type>&);
187 
188 
189  // Evaluation functions
190 
191  //- Update the coefficients associated with the patch field
192  virtual void updateCoeffs();
193 
194 
195  //- Write
196  virtual void write(Ostream&) const;
197 };
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace Foam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 #ifdef NoRepository
207  #include "mappedValueFvPatchField.C"
208 #endif
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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 list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Engine and base class for poly patches which provides interpolative mapping between two globally conf...
This boundary condition maps the values from a neighbouring patch to this patch.
const mappedPatchBase & mapper() const
Return the mapping engine.
virtual void write(Ostream &) const
Write.
mappedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
const Type average_
Average value the sampled field is adjusted to.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
autoPtr< mappedPatchBase > mapperPtr_
The mapping engine.
const word fieldName_
The field to map.
const bool setAverage_
If true adjust the sampled field to maintain an average value.
tmp< Field< Type > > mappedValues(const Field< Type > &nbrPatchField) const
Return the mapped values, given the neighbouring field.
const fvPatchField< Type > & nbrPatchField() const
Return the neighbouring patch field.
TypeName("mappedValue")
Runtime type information.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.