All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
timeVaryingMappedFvPatchField.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-2019 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::timeVaryingMappedFvPatchField
26 
27 Description
28  Patch field mapper which 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 See also
74  Foam::timeVaryingMappedFixedValueFvPatchField
75  Foam::Function1s
76 
77 SourceFiles
78  timeVaryingMappedFvPatchField.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef timeVaryingMappedFvPatchField_H
83 #define timeVaryingMappedFvPatchField_H
84 
85 #include "fvPatchField.H"
86 #include "FixedList.H"
87 #include "instantList.H"
89 #include "Function1.H"
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 namespace Foam
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class timeVaryingMapped Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class timeVaryingMapped
101 {
102 public:
103 
104  //- Runtime type information
105  ClassName("timeVaryingMapped");
106 
107 
108  // Constructors
109 
110  //- Construct null
112  {}
113 };
114 
115 
116 /*---------------------------------------------------------------------------*\
117  Class timeVaryingMappedFvPatchField Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 template<class Type>
121 class timeVaryingMappedFvPatchField
122 :
123  public timeVaryingMapped
124 {
125  // Private Data
126 
127  //- Reference to the patch the data is mapped to
128  const fvPatch& patch_;
129 
130  //- Name of the field data table, defaults to the name of the field
131  word fieldTableName_;
132 
133  //- Optional name of the data directory,
134  // defaults to "constant/boundaryData/<patch name>"
135  fileName dataDir_;
136 
137  //- Optional name of the points file, defaults to "points"
138  fileName pointsName_;
139 
140  //- Optional name of the sample sub-directory from which the field are
141  // read, defaults to ""
142  fileName sampleName_;
143 
144  //- If true adjust the mapped field to maintain average value
145  Switch setAverage_;
146 
147  //- Fraction of perturbation (fraction of bounding box) to add
148  scalar perturb_;
149 
150  //- Interpolation scheme to use
151  word mapMethod_;
153  //- 2D interpolation (for 'planarInterpolation' mapMethod)
155 
156  //- List of boundaryData time directories
157  instantList sampleTimes_;
158 
159  //- Current starting index in sampleTimes
160  label startSampleTime_;
161 
162  //- Interpolated values from startSampleTime
163  Field<Type> startSampledValues_;
164 
165  //- If setAverage: starting average value
166  Type startAverage_;
167 
168  //- Current end index in sampleTimes
169  label endSampleTime_;
170 
171  //- Interpolated values from endSampleTime
172  Field<Type> endSampledValues_;
173 
174  //- If setAverage: end average value
175  Type endAverage_;
176 
177  //- Time varying offset values to interpolated data
178  autoPtr<Function1<Type>> offset_;
179 
180  //- Helper function to find the field files
181  fileName findFieldFile(const word& timeName) const;
182 
183  //- Find boundary data in between current time and interpolate
184  void checkTable();
185 
186 
187 public:
188 
189  // Constructors
190 
191  //- Construct from patch and field name
192  timeVaryingMappedFvPatchField(const fvPatch&, const word& fieldName);
193 
194  //- Construct from patch, dictionary and field name
196  (
197  const fvPatch&,
198  const dictionary&,
199  const word& fieldName
200  );
201 
202  //- Copy constructor
204  (
206  );
207 
208 
209  // Member Functions
210 
211  const Time& time() const
212  {
213  return patch_.boundaryMesh().mesh().time();
214  }
215 
216  // Mapping functions
217 
218  //- Map (and resize as needed) from self given a mapping object
219  void autoMap(const fvPatchFieldMapper&);
220 
221  //- Reverse map the given timeVaryingMappedFvPatchField
222  // onto this timeVaryingMappedFvPatchField
223  void rmap
224  (
226  const labelList&
227  );
228 
229 
230  // Evaluation functions
231 
232  //- Return the current mapped patch field
233  tmp<Field<Type>> map();
234 
235 
236  //- Write
237  void write(Ostream&) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #ifdef NoRepository
249 #endif
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 #endif
254 
255 // ************************************************************************* //
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:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Patch field mapper which interpolates the values from a set of supplied points in space and time...
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
ClassName("timeVaryingMapped")
Runtime type information.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
word timeName
Definition: getTimeIndex.H:3
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const Time & time() const
Return time.
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.