timeVaryingMappedFixedValueFvPatchField.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-2018 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 Description
28  This boundary conditions interpolates the values from a set of supplied
29  points in space and time.
30 
31  By default the data files should be provide in
32  constant/boundaryData/<patch name>/ directory:
33  - points : pointField of locations
34  - <time>/<field> : field of values at time <time>
35 
36  Alternatively the names and locations of the points and field files may be
37  specified explicitly via the optional dictionary entries:
38  - dataDir <optional top-level directory of the points and field data>;
39  - points <optional path including name of points file relative to
40  dataDir>;
41  - sample <optional name of the sub-directory in the time directories
42  containing the fields>;
43  This is particularly useful when mapping data from another case for which
44  the \c sample \c functionObject is used to obtain the patch field data for
45  mapping.
46 
47  The default mode of operation (mapMethod planarInterpolation) is to project
48  the points onto a plane (constructed from the first three points) and
49  construct a 2D triangulation and finds for the face centres the triangle it
50  is in and the weights to the 3 vertices.
51 
52  The optional mapMethod nearest will avoid all projection and triangulation
53  and just use the value at the nearest vertex.
54 
55  Values are interpolated linearly between times.
56 
57 Usage
58  \table
59  Property | Description | Required | Default value
60  setAverage | Switch to activate setting of average value | no | false
61  perturb | Perturb points for regular geometries | no | 1e-5
62  fieldTable | Alternative field name to sample | no| this field name
63  mapMethod | Type of mapping | no | planarInterpolation
64  offset | Offset to mapped values | no | Zero
65  dataDir | Top-level directory of the points and field data \\
66  | no | constant/boundaryData/<patch name>
67  points | Path including name of points file relative to dataDir \\
68  | no | points
69  sample | Name of the sub-directory in the time directories \\
70  containing the fields | no | ""
71  \endtable
72 
73  \verbatim
74  <patch name>
75  {
76  type timeVaryingMappedFixedValue;
77  }
78  \endverbatim
79 
80  \verbatim
81  <patch name>
82  {
83  type timeVaryingMappedFixedValue;
84  dataDir "../<source case name>/postProcessing/sample";
85  points "0/<sample name>/faceCentres";
86  sample <sample name>;
87  }
88  \endverbatim
89 
90 See also
91  Foam::fixedValueFvPatchField
92  Foam::Function1Types
93 
94 SourceFiles
95  timeVaryingMappedFixedValueFvPatchField.C
96 
97 \*---------------------------------------------------------------------------*/
98 
99 #ifndef timeVaryingMappedFixedValueFvPatchField_H
100 #define timeVaryingMappedFixedValueFvPatchField_H
101 
102 #include "fixedValueFvPatchFields.H"
103 #include "FixedList.H"
104 #include "instantList.H"
106 #include "Function1.H"
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 namespace Foam
111 {
112 
113 /*---------------------------------------------------------------------------*\
114  Class timeVaryingMappedFixedValueFvPatchField Declaration
115 \*---------------------------------------------------------------------------*/
116 
117 template<class Type>
118 class timeVaryingMappedFixedValueFvPatchField
119 :
120  public fixedValueFvPatchField<Type>
121 {
122  // Private data
123 
124  //- Name of the field data table, defaults to the name of the field
125  word fieldTableName_;
126 
127  //- Optional name of the data directory,
128  // defaults to "constant/boundaryData/<patch name>"
129  fileName dataDir_;
130 
131  //- Optional name of the points file, defaults to "points"
132  fileName pointsName_;
133 
134  //- Optional name of the sample sub-directory from which the field are
135  // read, defaults to ""
136  fileName sampleName_;
137 
138  //- If true adjust the mapped field to maintain average value
139  Switch setAverage_;
140 
141  //- Fraction of perturbation (fraction of bounding box) to add
142  scalar perturb_;
143 
144  //- Interpolation scheme to use
145  word mapMethod_;
146 
147  //- 2D interpolation (for 'planarInterpolation' mapMethod)
148  autoPtr<pointToPointPlanarInterpolation> mapperPtr_;
149 
150  //- List of boundaryData time directories
151  instantList sampleTimes_;
152 
153  //- Current starting index in sampleTimes
154  label startSampleTime_;
155 
156  //- Interpolated values from startSampleTime
157  Field<Type> startSampledValues_;
158 
159  //- If setAverage: starting average value
160  Type startAverage_;
161 
162  //- Current end index in sampleTimes
163  label endSampleTime_;
164 
165  //- Interpolated values from endSampleTime
166  Field<Type> endSampledValues_;
167 
168  //- If setAverage: end average value
169  Type endAverage_;
170 
171  //- Time varying offset values to interpolated data
172  autoPtr<Function1<Type>> offset_;
173 
174  //- Helper function to find the field files
175  fileName findFieldFile(const word& timeName) const;
176 
177  //- Find boundary data in between current time and interpolate
178  void checkTable();
179 
180 
181 public:
182 
183  //- Runtime type information
184  TypeName("timeVaryingMappedFixedValue");
185 
186 
187  // Constructors
188 
189  //- Construct from patch and internal field
191  (
192  const fvPatch&,
194  );
195 
196  //- Construct from patch, internal field and dictionary
198  (
199  const fvPatch&,
201  const dictionary&
202  );
203 
204  //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
205  // onto a new patch
207  (
209  const fvPatch&,
211  const fvPatchFieldMapper&
212  );
213 
214  //- Construct as copy
216  (
218  );
219 
220  //- Construct and return a clone
221  virtual tmp<fvPatchField<Type>> clone() const
222  {
223  return tmp<fvPatchField<Type>>
224  (
226  );
227  }
228 
229  //- Construct as copy setting internal field reference
231  (
234  );
235 
236  //- Construct and return a clone setting internal field reference
238  (
240  ) const
241  {
242  return tmp<fvPatchField<Type>>
243  (
245  );
246  }
247 
248 
249  // Member functions
250 
251  // Access
252 
253  //- Return startSampledValues
255  {
256  return startSampledValues_;
257  }
258 
259 
260  // Mapping functions
261 
262  //- Map (and resize as needed) from self given a mapping object
263  virtual void autoMap
264  (
265  const fvPatchFieldMapper&
266  );
267 
268  //- Reverse map the given fvPatchField onto this fvPatchField
269  virtual void rmap
270  (
271  const fvPatchField<Type>&,
272  const labelList&
273  );
274 
275 
276  // Evaluation functions
277 
278  //- Update the coefficients associated with the patch field
279  virtual void updateCoeffs();
280 
281 
282  //- Write
283  virtual void write(Ostream&) const;
284 };
285 
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 } // End namespace Foam
290 
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
292 
293 #ifdef NoRepository
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
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 class for handling file names.
Definition: fileName.H:69
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:66
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
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
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
word timeName
Definition: getTimeIndex.H:3
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:52
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.