FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2011 OpenCFD Ltd.
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  Foam::timeVaryingMappedFixedValueFvPatchField
29 
30  Interpolates from a set of supplied points in space and time. Supplied
31  data in constant/boundaryData/<patchname>:
32  - points : pointField with locations
33  - ddd : supplied values at time ddd
34  Points need to be more or less on a plane since get triangulated in 2D.
35 
36  At startup this bc does the triangulation and determines linear
37  interpolation (triangle it is in and weights to the 3 vertices)
38  for every face centre. Interpolates linearly inbetween times.
39 
40  @verbatim
41  inlet
42  {
43  type timeVaryingMappedFixedValue;
44 
45  // Maintain average to that of the supplied values
46  setAverage false;
47 
48  // Optional: change perturbation (default 1E-5) to avoid any ties
49  // in triangulating regular geometries.
50  //perturb 0.0;
51 
52  // Optional: use name instead of patchname for location of data
53  //fieldTableName samples;
54  }
55  @endverbatim
56 
57  Switch on debug flag to have it dump the triangulation (in transformed
58  space) and transform face centres.
59 
60 SourceFiles
61  timeVaryingMappedFixedValueFvPatchField.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef timeVaryingMappedFixedValueFvPatchField_H
66 #define timeVaryingMappedFixedValueFvPatchField_H
67 
70 #include <OpenFOAM/FixedList.H>
71 #include <OpenFOAM/instantList.H>
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class timeVaryingMappedFixedValueFvPatch Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 template<class Type>
84 :
85  public fixedValueFvPatchField<Type>
86 {
87  // Private data
88 
89  //- Name of the field data table, defaults to the name of the field
90  word fieldTableName_;
91 
92  //- If true adjust the mapped field to maintain average value
93  bool setAverage_;
94 
95  //- Fraction of perturbation (fraction of bounding box) to add
96  scalar perturb_;
97 
98  //- Coordinate system
99  autoPtr<coordinateSystem> referenceCS_;
100 
101  //- Current interpolation addressing to face centres of underlying
102  // patch
103  List<FixedList<label, 3> > nearestVertex_;
104 
105  //- Current interpolation factors to face centres of underlying
106  // patch
107  List<FixedList<scalar, 3> > nearestVertexWeight_;
108 
109  //- List of boundaryData time directories
110  instantList sampleTimes_;
111 
112  //- Current starting index in sampleTimes
113  label startSampleTime_;
114 
115  //- Interpolated values from startSampleTime
116  Field<Type> startSampledValues_;
117 
118  //- If setAverage: starting average value
119  Type startAverage_;
120 
121  //- Current end index in sampleTimes
122  label endSampleTime_;
123 
124  //- Interpolated values from endSampleTime
125  Field<Type> endSampledValues_;
126 
127  //- If setAverage: end average value
128  Type endAverage_;
129 
130 
131  // Private Member Functions
132 
133  //- Get names of times
134  static wordList timeNames(const instantList&);
135 
136  //- Find times around current time
137  void findTime
138  (
139  const fileName& instance,
140  const fileName& local,
141  const scalar timeVal,
142  label& lo,
143  label& hi
144  ) const;
145 
146  //- Read boundary points and determine interpolation weights to patch
147  // faceCentres
148  void readSamplePoints();
149 
150 
151  //- Do actual interpolation using current weights
152  tmp<Field<Type> > interpolate(const Field<Type>&) const;
153 
154 
155 public:
156 
157  //- Runtime type information
158  TypeName("timeVaryingMappedFixedValue");
159 
160 
161  // Constructors
162 
163  //- Construct from patch and internal field
165  (
166  const fvPatch&,
168  );
169 
170  //- Construct from patch, internal field and dictionary
172  (
173  const fvPatch&,
175  const dictionary&
176  );
177 
178  //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
179  // onto a new patch
181  (
183  const fvPatch&,
185  const fvPatchFieldMapper&
186  );
187 
188  //- Construct as copy
190  (
192  );
193 
194  //- Construct and return a clone
195  virtual tmp<fvPatchField<Type> > clone() const
196  {
197  return tmp<fvPatchField<Type> >
198  (
200  );
201  }
202 
203  //- Construct as copy setting internal field reference
205  (
208  );
209 
210  //- Construct and return a clone setting internal field reference
211  virtual tmp<fvPatchField<Type> > clone
212  (
214  ) const
215  {
216  return tmp<fvPatchField<Type> >
217  (
219  );
220  }
221 
222 
223  // Member functions
224 
225  //- Find boundary data inbetween current time and interpolate
226  void checkTable();
227 
228  // Access
229 
230  //- Return the coordinateSystem
232  {
233  return referenceCS_;
234  }
235 
236 
238  {
239  return startSampledValues_;
240  }
241 
242  // Mapping functions
243 
244  //- Map (and resize as needed) from self given a mapping object
245  virtual void autoMap
246  (
247  const fvPatchFieldMapper&
248  );
249 
250  //- Reverse map the given fvPatchField onto this fvPatchField
251  virtual void rmap
252  (
253  const fvPatchField<Type>&,
254  const labelList&
255  );
256 
257 
258  // Evaluation functions
259 
260  //- Update the coefficients associated with the patch field
261  virtual void updateCoeffs();
262 
263 
264  //- Write
265  virtual void write(Ostream&) const;
266 };
267 
268 
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270 
271 } // End namespace Foam
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 #ifdef NoRepository
277 #endif
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #endif
282 
283 // ************************ vim: set sw=4 sts=4 et: ************************ //