Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / finiteVolume / fields / fvPatchFields / derived / timeVaryingMappedFixedValue / timeVaryingMappedFixedValueFvPatchField.H
blob896f17de78ec134ae88d45206118afeffa7d5d5a
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::timeVaryingMappedFixedValueFvPatchField
27 Description
28     Foam::timeVaryingMappedFixedValueFvPatchField
30 SourceFiles
31     timeVaryingMappedFixedValueFvPatchField.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef timeVaryingMappedFixedValueFvPatchField_H
36 #define timeVaryingMappedFixedValueFvPatchField_H
38 #include "fixedValueFvPatchFields.H"
39 #include "coordinateSystem.H"
40 #include "FixedList.H"
41 #include "instantList.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49               Class timeVaryingMappedFixedValueFvPatch Declaration
50 \*---------------------------------------------------------------------------*/
52 template<class Type>
53 class timeVaryingMappedFixedValueFvPatchField
55     public fixedValueFvPatchField<Type>
57     // Private data
59         //- Name of the field data table, defaults to the name of the field
60         word fieldTableName_;
62         //- If true adjust the mapped field to maintain average value
63         bool setAverage_;
65         //- Coordinate system
66         autoPtr<coordinateSystem> referenceCS_;
68         //- Current interpolation addressing to face centres of underlying
69         //  patch
70         List<FixedList<label, 3> > nearestVertex_;
72         //- Current interpolation factors to face centres of underlying
73         //  patch
74         List<FixedList<scalar, 3> > nearestVertexWeight_;
76         //- List of boundaryData time directories
77         instantList sampleTimes_;
79         //- Current starting index in sampleTimes
80         label startSampleTime_;
82         //- Interpolated values from startSampleTime
83         Field<Type> startSampledValues_;
85         //- If setAverage: starting average value
86         Type startAverage_;
88         //- Current end index in sampleTimes
89         label endSampleTime_;
91         //- Interpolated values from endSampleTime
92         Field<Type> endSampledValues_;
94         //- If setAverage: end average value
95         Type endAverage_;
98     // Private Member Functions
100         //- Get names of times
101         static wordList timeNames(const instantList&);
103         //- Find times around current time
104         void findTime
105         (
106             const fileName& instance,
107             const fileName& local,
108             const scalar timeVal,
109             label& lo,
110             label& hi
111         ) const;
113         //- Read boundary points and determine interpolation weights to patch
114         //  faceCentres
115         void readSamplePoints();
117         //- Find boundary data inbetween current time and interpolate
118         void checkTable();
120         //- Do actual interpolation using current weights
121         tmp<Field<Type> > interpolate(const Field<Type>&) const;
124 public:
126     //- Runtime type information
127     TypeName("timeVaryingMappedFixedValue");
130     // Constructors
132         //- Construct from patch and internal field
133         timeVaryingMappedFixedValueFvPatchField
134         (
135             const fvPatch&,
136             const DimensionedField<Type, volMesh>&
137         );
139         //- Construct from patch, internal field and dictionary
140         timeVaryingMappedFixedValueFvPatchField
141         (
142             const fvPatch&,
143             const DimensionedField<Type, volMesh>&,
144             const dictionary&
145         );
147         //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
148         //  onto a new patch
149         timeVaryingMappedFixedValueFvPatchField
150         (
151             const timeVaryingMappedFixedValueFvPatchField<Type>&,
152             const fvPatch&,
153             const DimensionedField<Type, volMesh>&,
154             const fvPatchFieldMapper&
155         );
157         //- Construct as copy
158         timeVaryingMappedFixedValueFvPatchField
159         (
160             const timeVaryingMappedFixedValueFvPatchField<Type>&
161         );
163         //- Construct and return a clone
164         virtual tmp<fvPatchField<Type> > clone() const
165         {
166             return tmp<fvPatchField<Type> >
167             (
168                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this)
169             );
170         }
172         //- Construct as copy setting internal field reference
173         timeVaryingMappedFixedValueFvPatchField
174         (
175             const timeVaryingMappedFixedValueFvPatchField<Type>&,
176             const DimensionedField<Type, volMesh>&
177         );
179         //- Construct and return a clone setting internal field reference
180         virtual tmp<fvPatchField<Type> > clone
181         (
182             const DimensionedField<Type, volMesh>& iF
183         ) const
184         {
185             return tmp<fvPatchField<Type> >
186             (
187                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this, iF)
188             );
189         }
192     // Member functions
194         // Access
196             //- Return the coordinateSystem
197             const coordinateSystem& referenceCS() const
198             {
199                 return referenceCS_;
200             }
203         // Mapping functions
205             //- Map (and resize as needed) from self given a mapping object
206             virtual void autoMap
207             (
208                 const fvPatchFieldMapper&
209             );
211             //- Reverse map the given fvPatchField onto this fvPatchField
212             virtual void rmap
213             (
214                 const fvPatchField<Type>&,
215                 const labelList&
216             );
219         // Evaluation functions
221             //- Update the coefficients associated with the patch field
222             virtual void updateCoeffs();
225         //- Write
226         virtual void write(Ostream&) const;
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 } // End namespace Foam
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 #ifdef NoRepository
237 #   include "timeVaryingMappedFixedValueFvPatchField.C"
238 #endif
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 #endif
244 // ************************************************************************* //