timeVaryingMappedFixedValueFvPatchField.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 | Copyright (C) 2011-2016 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::timeVaryingMappedFixedValueFvPatchField
26 
27 Group
28  grpInletBoundaryConditions grpCoupledBoundaryConditions
29 
30 Description
31  This boundary conditions interpolates the values from a set of supplied
32  points in space and time. Supplied data should be specified in
33  constant/boundaryData/<patchname> where:
34  - points : pointField with locations
35  - ddd : supplied values at time ddd
36  The default mode of operation (mapMethod planarInterpolation) is
37  to project the points onto a plane (constructed from the first threee
38  points) and construct a 2D triangulation and finds for the face centres
39  the triangle it is in and the weights to the 3 vertices.
40 
41  The optional mapMethod nearest will avoid all projection and
42  triangulation and just use the value at the nearest vertex.
43 
44  Values are interpolated linearly between times.
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  setAverage | flag to activate setting of average value | yes |
50  perturb | perturb points for regular geometries | no | 1e-5
51  fieldTableName | alternative field name to sample | no| this field name
52  mapMethod | type of mapping | no | planarInterpolation
53  offset | for applying offset to mapped values | no | constant 0.0
54  \endtable
55 
56  \verbatim
57  <patchName>
58  {
59  type timeVaryingMappedFixedValue;
60  setAverage false;
61  //perturb 0.0;
62  //fieldTableName samples;
63  //offset constant 0.2;
64  }
65  \endverbatim
66 
67 See also
68  Foam::fixedValueFvPatchField
69  Foam::Function1Types
70 
71 SourceFiles
72  timeVaryingMappedFixedValueFvPatchField.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef timeVaryingMappedFixedValueFvPatchField_H
77 #define timeVaryingMappedFixedValueFvPatchField_H
78 
80 #include "FixedList.H"
81 #include "instantList.H"
83 #include "Function1.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 
90 /*---------------------------------------------------------------------------*\
91  Class timeVaryingMappedFixedValueFvPatchField Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 template<class Type>
95 class timeVaryingMappedFixedValueFvPatchField
96 :
97  public fixedValueFvPatchField<Type>
98 {
99  // Private data
100 
101  //- Name of the field data table, defaults to the name of the field
102  word fieldTableName_;
103 
104  //- If true adjust the mapped field to maintain average value
105  bool setAverage_;
106 
107  //- Fraction of perturbation (fraction of bounding box) to add
108  scalar perturb_;
109 
110  //- Interpolation scheme to use
111  word mapMethod_;
112 
113  //- 2D interpolation (for 'planarInterpolation' mapMethod)
114  autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
115 
116  //- List of boundaryData time directories
117  instantList sampleTimes_;
118 
119  //- Current starting index in sampleTimes
120  label startSampleTime_;
121 
122  //- Interpolated values from startSampleTime
123  Field<Type> startSampledValues_;
125  //- If setAverage: starting average value
126  Type startAverage_;
127 
128  //- Current end index in sampleTimes
129  label endSampleTime_;
130 
131  //- Interpolated values from endSampleTime
132  Field<Type> endSampledValues_;
133 
134  //- If setAverage: end average value
135  Type endAverage_;
136 
137  //- Time varying offset values to interpolated data
138  autoPtr<Function1<Type>> offset_;
139 
140 
141 public:
142 
143  //- Runtime type information
144  TypeName("timeVaryingMappedFixedValue");
145 
146 
147  // Constructors
148 
149  //- Construct from patch and internal field
151  (
152  const fvPatch&,
154  );
155 
156  //- Construct from patch, internal field and dictionary
158  (
159  const fvPatch&,
161  const dictionary&
162  );
163 
164  //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
165  // onto a new patch
167  (
169  const fvPatch&,
171  const fvPatchFieldMapper&
172  );
173 
174  //- Construct as copy
176  (
178  );
179 
180  //- Construct and return a clone
181  virtual tmp<fvPatchField<Type>> clone() const
182  {
183  return tmp<fvPatchField<Type>>
184  (
186  );
187  }
188 
189  //- Construct as copy setting internal field reference
191  (
194  );
195 
196  //- Construct and return a clone setting internal field reference
198  (
200  ) const
201  {
202  return tmp<fvPatchField<Type>>
203  (
205  );
206  }
207 
208 
209  // Member functions
211  // Access
212 
213  //- Return startSampledValues
215  {
216  return startSampledValues_;
217  }
218 
219 
220  // Mapping functions
221 
222  //- Map (and resize as needed) from self given a mapping object
223  virtual void autoMap
224  (
225  const fvPatchFieldMapper&
226  );
228  //- Reverse map the given fvPatchField onto this fvPatchField
229  virtual void rmap
230  (
231  const fvPatchField<Type>&,
232  const labelList&
233  );
234 
235 
236  // Utility functions
237 
238  //- Find boundary data inbetween current time and interpolate
239  void checkTable();
240 
241 
242  // Evaluation functions
244  //- Update the coefficients associated with the patch field
245  virtual void updateCoeffs();
246 
247 
248  //- Write
249  virtual void write(Ostream&) const;
250 };
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace Foam
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #ifdef NoRepository
261 #endif
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 #endif
266 
267 // ************************************************************************* //
List< instant > instantList
List of instants.
Definition: instantList.H:42
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
This boundary conditions interpolates the values from a set of supplied points in space and time...
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fvPatchFieldMapper.
void checkTable()
Find boundary data inbetween current time and interpolate.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
TypeName("timeVaryingMappedFixedValue")
Runtime type information.
const Field< Type > startSampledValues()
Return startSampledValues.
timeVaryingMappedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
A class for managing temporary objects.
Definition: PtrList.H:54
Namespace for OpenFOAM.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.