1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
25 Foam::timeVaryingMappedFixedValueFvPatchField
28 Foam::timeVaryingMappedFixedValueFvPatchField
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.
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.
43 type timeVaryingMappedFixedValue;
45 // Maintain average to that of the supplied values
48 // Optional: change perturbation (default 1E-5) to avoid any ties
49 // in triangulating regular geometries.
52 // Optional: use name instead of patchname for location of data
53 //fieldTableName samples;
57 Switch on debug flag to have it dump the triangulation (in transformed
58 space) and transform face centres.
61 timeVaryingMappedFixedValueFvPatchField.C
63 \*---------------------------------------------------------------------------*/
65 #ifndef timeVaryingMappedFixedValueFvPatchField_H
66 #define timeVaryingMappedFixedValueFvPatchField_H
68 #include "fixedValueFvPatchFields.H"
69 #include "coordinateSystem.H"
70 #include "FixedList.H"
71 #include "instantList.H"
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 /*---------------------------------------------------------------------------*\
79 Class timeVaryingMappedFixedValueFvPatch Declaration
80 \*---------------------------------------------------------------------------*/
83 class timeVaryingMappedFixedValueFvPatchField
85 public fixedValueFvPatchField<Type>
89 //- Name of the field data table, defaults to the name of the field
92 //- If true adjust the mapped field to maintain average value
95 //- Fraction of perturbation (fraction of bounding box) to add
99 autoPtr<coordinateSystem> referenceCS_;
101 //- Current interpolation addressing to face centres of underlying
103 List<FixedList<label, 3> > nearestVertex_;
105 //- Current interpolation factors to face centres of underlying
107 List<FixedList<scalar, 3> > nearestVertexWeight_;
109 //- List of boundaryData time directories
110 instantList sampleTimes_;
112 //- Current starting index in sampleTimes
113 label startSampleTime_;
115 //- Interpolated values from startSampleTime
116 Field<Type> startSampledValues_;
118 //- If setAverage: starting average value
121 //- Current end index in sampleTimes
122 label endSampleTime_;
124 //- Interpolated values from endSampleTime
125 Field<Type> endSampledValues_;
127 //- If setAverage: end average value
131 // Private Member Functions
133 //- Get names of times
134 static wordList timeNames(const instantList&);
136 //- Find times around current time
139 const fileName& instance,
140 const fileName& local,
141 const scalar timeVal,
147 //- Read boundary points and determine interpolation weights to patch
149 void readSamplePoints();
151 //- Do actual interpolation using current weights
152 tmp<Field<Type> > interpolate(const Field<Type>&) const;
157 //- Runtime type information
158 TypeName("timeVaryingMappedFixedValue");
163 //- Construct from patch and internal field
164 timeVaryingMappedFixedValueFvPatchField
167 const DimensionedField<Type, volMesh>&
170 //- Construct from patch, internal field and dictionary
171 timeVaryingMappedFixedValueFvPatchField
174 const DimensionedField<Type, volMesh>&,
178 //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
180 timeVaryingMappedFixedValueFvPatchField
182 const timeVaryingMappedFixedValueFvPatchField<Type>&,
184 const DimensionedField<Type, volMesh>&,
185 const fvPatchFieldMapper&
188 //- Construct as copy
189 timeVaryingMappedFixedValueFvPatchField
191 const timeVaryingMappedFixedValueFvPatchField<Type>&
194 //- Construct and return a clone
195 virtual tmp<fvPatchField<Type> > clone() const
197 return tmp<fvPatchField<Type> >
199 new timeVaryingMappedFixedValueFvPatchField<Type>(*this)
203 //- Construct as copy setting internal field reference
204 timeVaryingMappedFixedValueFvPatchField
206 const timeVaryingMappedFixedValueFvPatchField<Type>&,
207 const DimensionedField<Type, volMesh>&
210 //- Construct and return a clone setting internal field reference
211 virtual tmp<fvPatchField<Type> > clone
213 const DimensionedField<Type, volMesh>& iF
216 return tmp<fvPatchField<Type> >
218 new timeVaryingMappedFixedValueFvPatchField<Type>(*this, iF)
227 //- Return the coordinateSystem
228 const coordinateSystem& referenceCS() const
233 //- Return startSampledValues
234 const Field<Type> startSampledValues()
236 return startSampledValues_;
242 //- Map (and resize as needed) from self given a mapping object
245 const fvPatchFieldMapper&
248 //- Reverse map the given fvPatchField onto this fvPatchField
251 const fvPatchField<Type>&,
258 //- Find boundary data inbetween current time and interpolate
262 // Evaluation functions
264 //- Update the coefficients associated with the patch field
265 virtual void updateCoeffs();
269 virtual void write(Ostream&) const;
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 # include "timeVaryingMappedFixedValueFvPatchField.C"
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 // ************************************************************************* //