BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / finiteVolume / fields / fvPatchFields / derived / timeVaryingMappedFixedValue / timeVaryingMappedFixedValueFvPatchField.H
blobe3ac11215495207ba2572e0a8f978434c7a913f8
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 Class
25     Foam::timeVaryingMappedFixedValueFvPatchField
27 Description
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.
40     @verbatim
41         inlet
42         {
43             type            timeVaryingMappedFixedValue;
45             // Maintain average to that of the supplied values
46             setAverage      false;
48             // Optional: change perturbation (default 1E-5) to avoid any ties
49             // in triangulating regular geometries.
50             //perturb       0.0;
52             // Optional: use name instead of patchname for location of data
53             //fieldTableName samples;
54         }
55     @endverbatim
57     Switch on debug flag to have it dump the triangulation (in transformed
58     space) and transform face centres.
60 SourceFiles
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 namespace Foam
78 /*---------------------------------------------------------------------------*\
79               Class timeVaryingMappedFixedValueFvPatch Declaration
80 \*---------------------------------------------------------------------------*/
82 template<class Type>
83 class timeVaryingMappedFixedValueFvPatchField
85     public fixedValueFvPatchField<Type>
87     // Private data
89         //- Name of the field data table, defaults to the name of the field
90         word fieldTableName_;
92         //- If true adjust the mapped field to maintain average value
93         bool setAverage_;
95         //- Fraction of perturbation (fraction of bounding box) to add
96         scalar perturb_;
98         //- Coordinate system
99         autoPtr<coordinateSystem> referenceCS_;
101         //- Current interpolation addressing to face centres of underlying
102         //  patch
103         List<FixedList<label, 3> > nearestVertex_;
105         //- Current interpolation factors to face centres of underlying
106         //  patch
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
119         Type startAverage_;
121         //- Current end index in sampleTimes
122         label endSampleTime_;
124         //- Interpolated values from endSampleTime
125         Field<Type> endSampledValues_;
127         //- If setAverage: end average value
128         Type endAverage_;
131     // Private Member Functions
133         //- Get names of times
134         static wordList timeNames(const instantList&);
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;
147         //- Read boundary points and determine interpolation weights to patch
148         //  faceCentres
149         void readSamplePoints();
151         //- Do actual interpolation using current weights
152         tmp<Field<Type> > interpolate(const Field<Type>&) const;
155 public:
157     //- Runtime type information
158     TypeName("timeVaryingMappedFixedValue");
161     // Constructors
163         //- Construct from patch and internal field
164         timeVaryingMappedFixedValueFvPatchField
165         (
166             const fvPatch&,
167             const DimensionedField<Type, volMesh>&
168         );
170         //- Construct from patch, internal field and dictionary
171         timeVaryingMappedFixedValueFvPatchField
172         (
173             const fvPatch&,
174             const DimensionedField<Type, volMesh>&,
175             const dictionary&
176         );
178         //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
179         //  onto a new patch
180         timeVaryingMappedFixedValueFvPatchField
181         (
182             const timeVaryingMappedFixedValueFvPatchField<Type>&,
183             const fvPatch&,
184             const DimensionedField<Type, volMesh>&,
185             const fvPatchFieldMapper&
186         );
188         //- Construct as copy
189         timeVaryingMappedFixedValueFvPatchField
190         (
191             const timeVaryingMappedFixedValueFvPatchField<Type>&
192         );
194         //- Construct and return a clone
195         virtual tmp<fvPatchField<Type> > clone() const
196         {
197             return tmp<fvPatchField<Type> >
198             (
199                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this)
200             );
201         }
203         //- Construct as copy setting internal field reference
204         timeVaryingMappedFixedValueFvPatchField
205         (
206             const timeVaryingMappedFixedValueFvPatchField<Type>&,
207             const DimensionedField<Type, volMesh>&
208         );
210         //- Construct and return a clone setting internal field reference
211         virtual tmp<fvPatchField<Type> > clone
212         (
213             const DimensionedField<Type, volMesh>& iF
214         ) const
215         {
216             return tmp<fvPatchField<Type> >
217             (
218                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this, iF)
219             );
220         }
223     // Member functions
225         // Access
227             //- Return the coordinateSystem
228             const coordinateSystem& referenceCS() const
229             {
230                 return referenceCS_;
231             }
233             //- Return startSampledValues
234             const Field<Type> startSampledValues()
235             {
236                  return startSampledValues_;
237             }
240         // Mapping functions
242             //- Map (and resize as needed) from self given a mapping object
243             virtual void autoMap
244             (
245                 const fvPatchFieldMapper&
246             );
248             //- Reverse map the given fvPatchField onto this fvPatchField
249             virtual void rmap
250             (
251                 const fvPatchField<Type>&,
252                 const labelList&
253             );
256         // Utility functions
258             //- Find boundary data inbetween current time and interpolate
259             void checkTable();
262         // Evaluation functions
264             //- Update the coefficients associated with the patch field
265             virtual void updateCoeffs();
268         //- Write
269         virtual void write(Ostream&) const;
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 #ifdef NoRepository
280 #   include "timeVaryingMappedFixedValueFvPatchField.C"
281 #endif
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 #endif
287 // ************************************************************************* //