mappedPatchFieldBase.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) 2013-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::mappedPatchFieldBase
28 
29 Description
30  Functionality for sampling fields using mappedPatchBase. Every call to
31  mappedField() returns a sampled field, optionally scaled to maintain an
32  area-weighted average.
33 
34  Example usage:
35 
36  {
37  field T; // default is same as fvPatchField
38  setAverage false;
39  average 1.0; // only if setAverage=true
40  interpolationScheme cellPoint; // default is cell
41  }
42 
43  \table
44  Property | Description | Required | Default
45  field | name of field to be mapped | no | this field name
46  setAverage | use average value | no | false |
47  average | average value to apply if \c setAverage = yes | partly |
48  interpolationScheme | interpolation scheme | partly | cell |
49  \endtable
50 
51 SourceFiles
52  mappedPatchFieldBase.C
53 
54 \*---------------------------------------------------------------------------*/
55 
56 #ifndef mappedPatchFieldBase_H
57 #define mappedPatchFieldBase_H
58 
60 #include "volFieldsFwd.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declarations
68 class mappedPatchBase;
69 template<class> class interpolation;
70 
71 /*---------------------------------------------------------------------------*\
72  Class mappedPatchFieldBase Declaration
73 \*---------------------------------------------------------------------------*/
74 
75 template<class Type>
76 class mappedPatchFieldBase
77 {
78  // Private Member Functions
79 
80  //- Selective retrieval of "average" entry from the dictionary
81  static Type getAverage(const dictionary& dict, bool mandatory);
82 
83 protected:
84 
85  // Protected data
86 
87  //- Mapping engine
88  const mappedPatchBase& mapper_;
89 
90  //- Underlying patch field
91  const fvPatchField<Type>& patchField_;
92 
93  //- Name of field to sample
94  word fieldName_;
95 
96  //- If true adjust the mapped field to maintain average value average_
97  const bool setAverage_;
98 
99  //- Average value the mapped field is adjusted to maintain if
100  //- setAverage_ is set true
101  const Type average_;
102 
103  //- Interpolation scheme to use for nearestcell mode
105 
106 
107 public:
108 
109  // Constructors
110 
111  //- Construct from components
113  (
114  const mappedPatchBase& mapper,
115  const fvPatchField<Type>& patchField,
116  const word& fieldName,
117  const bool setAverage,
118  const Type average,
119  const word& interpolationScheme
120  );
121 
122  //- Construct from dictionary
124  (
125  const mappedPatchBase& mapper,
126  const fvPatchField<Type>& patchField,
128  );
129 
130  //- Construct empty
132  (
133  const mappedPatchBase& mapper,
134  const fvPatchField<Type>& patchField
135  );
136 
137  //- Construct copy
139  (
140  const mappedPatchFieldBase<Type>& mapper
141  );
142 
143  //- Construct copy, resetting patch and field
145  (
146  const mappedPatchBase& mapper,
147  const fvPatchField<Type>& patchField,
148  const mappedPatchFieldBase<Type>& base
149  );
150 
151 
152  //- Destructor
153  virtual ~mappedPatchFieldBase<Type>() = default;
154 
155 
156  // Member Functions
157 
158  //- Field to sample. Either on my or nbr mesh
160 
161  //- Map sampleField onto *this patch
162  virtual tmp<Field<Type>> mappedField() const;
163 
164  //- Write
165  virtual void write(Ostream& os) const;
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
176  #include "mappedPatchFieldBase.C"
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
volFieldsFwd.H
Foam::mappedPatchFieldBase::average_
const Type average_
Definition: mappedPatchFieldBase.H:127
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::mappedPatchFieldBase::mappedPatchFieldBase
mappedPatchFieldBase(const mappedPatchBase &mapper, const fvPatchField< Type > &patchField, const word &fieldName, const bool setAverage, const Type average, const word &interpolationScheme)
Construct from components.
Definition: mappedPatchFieldBase.C:55
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::mappedPatchFieldBase::patchField_
const fvPatchField< Type > & patchField_
Underlying patch field.
Definition: mappedPatchFieldBase.H:117
Foam::mappedPatchFieldBase::mappedField
virtual tmp< Field< Type > > mappedField() const
Map sampleField onto *this patch.
Definition: mappedPatchFieldBase.C:183
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:105
Foam::mappedPatchFieldBase::fieldName_
word fieldName_
Name of field to sample.
Definition: mappedPatchFieldBase.H:120
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:95
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mappedPatchFieldBase
Functionality for sampling fields using mappedPatchBase. Every call to mappedField() returns a sample...
Definition: mappedPatchFieldBase.H:102
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::mappedPatchFieldBase::interpolationScheme_
word interpolationScheme_
Interpolation scheme to use for nearestcell mode.
Definition: mappedPatchFieldBase.H:130
Foam::mappedPatchFieldBase::write
virtual void write(Ostream &os) const
Write.
Definition: mappedPatchFieldBase.C:326
Foam::mappedPatchFieldBase::mapper_
const mappedPatchBase & mapper_
Mapping engine.
Definition: mappedPatchFieldBase.H:114
Foam::mappedPatchFieldBase::sampleField
const GeometricField< Type, fvPatchField, volMesh > & sampleField() const
Field to sample. Either on my or nbr mesh.
Definition: mappedPatchFieldBase.C:154
fixedValueFvPatchFields.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
mappedPatchFieldBase.C
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::mappedPatchFieldBase::setAverage_
const bool setAverage_
If true adjust the mapped field to maintain average value average_.
Definition: mappedPatchFieldBase.H:123
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328