FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

timeVaryingMappedFixedValueFvPatchField.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2011 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::timeVaryingMappedFixedValueFvPatchField
00026 
00027 Description
00028     Foam::timeVaryingMappedFixedValueFvPatchField
00029 
00030     Interpolates from a set of supplied points in space and time. Supplied
00031     data in constant/boundaryData/<patchname>:
00032         - points : pointField with locations
00033         - ddd    : supplied values at time ddd
00034     Points need to be more or less on a plane since get triangulated in 2D.
00035 
00036     At startup this bc does the triangulation and determines linear
00037     interpolation (triangle it is in and weights to the 3 vertices)
00038     for every face centre. Interpolates linearly inbetween times.
00039 
00040     @verbatim
00041         inlet
00042         {
00043             type            timeVaryingMappedFixedValue;
00044 
00045             // Maintain average to that of the supplied values
00046             setAverage      false;
00047 
00048             // Optional: change perturbation (default 1E-5) to avoid any ties
00049             // in triangulating regular geometries.
00050             //perturb       0.0;
00051 
00052             // Optional: use name instead of patchname for location of data
00053             //fieldTableName samples;
00054         }
00055     @endverbatim
00056 
00057     Switch on debug flag to have it dump the triangulation (in transformed
00058     space) and transform face centres.
00059 
00060 SourceFiles
00061     timeVaryingMappedFixedValueFvPatchField.C
00062 
00063 \*---------------------------------------------------------------------------*/
00064 
00065 #ifndef timeVaryingMappedFixedValueFvPatchField_H
00066 #define timeVaryingMappedFixedValueFvPatchField_H
00067 
00068 #include <finiteVolume/fixedValueFvPatchFields.H>
00069 #include <meshTools/coordinateSystem.H>
00070 #include <OpenFOAM/FixedList.H>
00071 #include <OpenFOAM/instantList.H>
00072 
00073 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00074 
00075 namespace Foam
00076 {
00077 
00078 /*---------------------------------------------------------------------------*\
00079               Class timeVaryingMappedFixedValueFvPatch Declaration
00080 \*---------------------------------------------------------------------------*/
00081 
00082 template<class Type>
00083 class timeVaryingMappedFixedValueFvPatchField
00084 :
00085     public fixedValueFvPatchField<Type>
00086 {
00087     // Private data
00088 
00089         //- Name of the field data table, defaults to the name of the field
00090         word fieldTableName_;
00091 
00092         //- If true adjust the mapped field to maintain average value
00093         bool setAverage_;
00094 
00095         //- Fraction of perturbation (fraction of bounding box) to add
00096         scalar perturb_;
00097 
00098         //- Coordinate system
00099         autoPtr<coordinateSystem> referenceCS_;
00100 
00101         //- Current interpolation addressing to face centres of underlying
00102         //  patch
00103         List<FixedList<label, 3> > nearestVertex_;
00104 
00105         //- Current interpolation factors to face centres of underlying
00106         //  patch
00107         List<FixedList<scalar, 3> > nearestVertexWeight_;
00108 
00109         //- List of boundaryData time directories
00110         instantList sampleTimes_;
00111 
00112         //- Current starting index in sampleTimes
00113         label startSampleTime_;
00114 
00115         //- Interpolated values from startSampleTime
00116         Field<Type> startSampledValues_;
00117 
00118         //- If setAverage: starting average value
00119         Type startAverage_;
00120 
00121         //- Current end index in sampleTimes
00122         label endSampleTime_;
00123 
00124         //- Interpolated values from endSampleTime
00125         Field<Type> endSampledValues_;
00126 
00127         //- If setAverage: end average value
00128         Type endAverage_;
00129 
00130 
00131     // Private Member Functions
00132 
00133         //- Get names of times
00134         static wordList timeNames(const instantList&);
00135 
00136         //- Find times around current time
00137         void findTime
00138         (
00139             const fileName& instance,
00140             const fileName& local,
00141             const scalar timeVal,
00142             label& lo,
00143             label& hi
00144         ) const;
00145 
00146         //- Read boundary points and determine interpolation weights to patch
00147         //  faceCentres
00148         void readSamplePoints();
00149 
00150 
00151         //- Do actual interpolation using current weights
00152         tmp<Field<Type> > interpolate(const Field<Type>&) const;
00153 
00154 
00155 public:
00156 
00157     //- Runtime type information
00158     TypeName("timeVaryingMappedFixedValue");
00159 
00160 
00161     // Constructors
00162 
00163         //- Construct from patch and internal field
00164         timeVaryingMappedFixedValueFvPatchField
00165         (
00166             const fvPatch&,
00167             const DimensionedField<Type, volMesh>&
00168         );
00169 
00170         //- Construct from patch, internal field and dictionary
00171         timeVaryingMappedFixedValueFvPatchField
00172         (
00173             const fvPatch&,
00174             const DimensionedField<Type, volMesh>&,
00175             const dictionary&
00176         );
00177 
00178         //- Construct by mapping given timeVaryingMappedFixedValueFvPatchField
00179         //  onto a new patch
00180         timeVaryingMappedFixedValueFvPatchField
00181         (
00182             const timeVaryingMappedFixedValueFvPatchField<Type>&,
00183             const fvPatch&,
00184             const DimensionedField<Type, volMesh>&,
00185             const fvPatchFieldMapper&
00186         );
00187 
00188         //- Construct as copy
00189         timeVaryingMappedFixedValueFvPatchField
00190         (
00191             const timeVaryingMappedFixedValueFvPatchField<Type>&
00192         );
00193 
00194         //- Construct and return a clone
00195         virtual tmp<fvPatchField<Type> > clone() const
00196         {
00197             return tmp<fvPatchField<Type> >
00198             (
00199                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this)
00200             );
00201         }
00202 
00203         //- Construct as copy setting internal field reference
00204         timeVaryingMappedFixedValueFvPatchField
00205         (
00206             const timeVaryingMappedFixedValueFvPatchField<Type>&,
00207             const DimensionedField<Type, volMesh>&
00208         );
00209 
00210         //- Construct and return a clone setting internal field reference
00211         virtual tmp<fvPatchField<Type> > clone
00212         (
00213             const DimensionedField<Type, volMesh>& iF
00214         ) const
00215         {
00216             return tmp<fvPatchField<Type> >
00217             (
00218                 new timeVaryingMappedFixedValueFvPatchField<Type>(*this, iF)
00219             );
00220         }
00221 
00222 
00223     // Member functions
00224 
00225         //- Find boundary data inbetween current time and interpolate
00226         void checkTable();
00227 
00228         // Access
00229 
00230             //- Return the coordinateSystem
00231             const coordinateSystem& referenceCS() const
00232             {
00233                 return referenceCS_;
00234             }
00235 
00236 
00237             const Field<Type> startSampledValues()
00238             {
00239                 return startSampledValues_;
00240             }
00241 
00242         // Mapping functions
00243 
00244             //- Map (and resize as needed) from self given a mapping object
00245             virtual void autoMap
00246             (
00247                 const fvPatchFieldMapper&
00248             );
00249 
00250             //- Reverse map the given fvPatchField onto this fvPatchField
00251             virtual void rmap
00252             (
00253                 const fvPatchField<Type>&,
00254                 const labelList&
00255             );
00256 
00257 
00258         // Evaluation functions
00259 
00260             //- Update the coefficients associated with the patch field
00261             virtual void updateCoeffs();
00262 
00263 
00264         //- Write
00265         virtual void write(Ostream&) const;
00266 };
00267 
00268 
00269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00270 
00271 } // End namespace Foam
00272 
00273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00274 
00275 #ifdef NoRepository
00276 #   include <finiteVolume/timeVaryingMappedFixedValueFvPatchField.C>
00277 #endif
00278 
00279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00280 
00281 #endif
00282 
00283 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines