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

fixedBlended.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-2010 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::fixedBlended
00026 
00027 Description
00028     Two-scheme fixed-blending differencing scheme.
00029 
00030     Similar to localBlended but uses a single (global) constant blending
00031     factor. The factor applies to the first scheme and 1-factor to the
00032     second scheme.
00033 
00034 Note
00035     Although a blending factor of 0 and 1 is permitted, it is more efficient
00036     just to use the underlying scheme directly.
00037 
00038 SourceFiles
00039     fixedBlended.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef fixedBlended_H
00044 #define fixedBlended_H
00045 
00046 #include <finiteVolume/surfaceInterpolationScheme.H>
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 /*---------------------------------------------------------------------------*\
00054                         Class fixedBlended Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 template<class Type>
00058 class fixedBlended
00059 :
00060     public surfaceInterpolationScheme<Type>
00061 {
00062     // Private data
00063 
00064         const scalar blendingFactor_;
00065 
00066     // Private Member Functions
00067 
00068         //- Scheme 1
00069         tmp<surfaceInterpolationScheme<Type> > tScheme1_;
00070 
00071         //- Scheme 2
00072         tmp<surfaceInterpolationScheme<Type> > tScheme2_;
00073 
00074 
00075         //- Disallow default bitwise copy construct
00076         fixedBlended(const fixedBlended&);
00077 
00078         //- Disallow default bitwise assignment
00079         void operator=(const fixedBlended&);
00080 
00081 
00082 public:
00083 
00084     //- Runtime type information
00085     TypeName("fixedBlended");
00086 
00087 
00088     // Constructors
00089 
00090         //- Construct from mesh and Istream.
00091         //  The name of the flux field is read from the Istream and looked-up
00092         //  from the mesh objectRegistry
00093         fixedBlended
00094         (
00095             const fvMesh& mesh,
00096             Istream& is
00097         )
00098         :
00099             surfaceInterpolationScheme<Type>(mesh),
00100             blendingFactor_(readScalar(is)),
00101             tScheme1_
00102             (
00103                 surfaceInterpolationScheme<Type>::New(mesh, is)
00104             ),
00105             tScheme2_
00106             (
00107                 surfaceInterpolationScheme<Type>::New(mesh, is)
00108             )
00109         {
00110             if (blendingFactor_ < 0 || blendingFactor_ > 1)
00111             {
00112                 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
00113                     << "coefficient = " << blendingFactor_
00114                     << " should be >= 0 and <= 1"
00115                     << exit(FatalIOError);
00116             }
00117             if (surfaceInterpolationScheme<Type>::debug)
00118             {
00119                 Info<<"fixedBlended: " << blendingFactor_
00120                     << "*" << tScheme1_().type()
00121                     << " + (1-" << blendingFactor_ << ")*"
00122                     << tScheme2_().type()
00123                     <<endl;
00124             }
00125         }
00126 
00127 
00128         //- Construct from mesh, faceFlux and Istream
00129         fixedBlended
00130         (
00131             const fvMesh& mesh,
00132             const surfaceScalarField& faceFlux,
00133             Istream& is
00134         )
00135         :
00136             surfaceInterpolationScheme<Type>(mesh),
00137             blendingFactor_(readScalar(is)),
00138             tScheme1_
00139             (
00140                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
00141             ),
00142             tScheme2_
00143             (
00144                 surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
00145             )
00146         {
00147             if (blendingFactor_ < 0 || blendingFactor_ > 1)
00148             {
00149                 FatalIOErrorIn("fixedBlended(const fvMesh&, Istream&)", is)
00150                     << "coefficient = " << blendingFactor_
00151                     << " should be >= 0 and <= 1"
00152                     << exit(FatalIOError);
00153             }
00154             if (surfaceInterpolationScheme<Type>::debug)
00155             {
00156                 Info<<"fixedBlended: " << blendingFactor_
00157                     << "*" << tScheme1_().type()
00158                     << " + (1-" << blendingFactor_ << ")*"
00159                     << tScheme2_().type()
00160                     <<endl;
00161             }
00162         }
00163 
00164 
00165     // Member Functions
00166 
00167         //- Return the interpolation weighting factors
00168         tmp<surfaceScalarField>
00169         weights
00170         (
00171             const GeometricField<Type, fvPatchField, volMesh>& vf
00172         ) const
00173         {
00174             return
00175                 blendingFactor_*tScheme1_().weights(vf)
00176               + (scalar(1.0) - blendingFactor_)*tScheme2_().weights(vf);
00177         }
00178 
00179 
00180         //- Return the face-interpolate of the given cell field
00181         //  with explicit correction
00182         tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00183         interpolate
00184         (
00185             const GeometricField<Type, fvPatchField, volMesh>& vf
00186         ) const
00187         {
00188             return
00189                 blendingFactor_*tScheme1_().interpolate(vf)
00190               + (scalar(1.0) - blendingFactor_)*tScheme2_().interpolate(vf);
00191         }
00192 
00193 
00194         //- Return true if this scheme uses an explicit correction
00195         virtual bool corrected() const
00196         {
00197             return tScheme1_().corrected() || tScheme2_().corrected();
00198         }
00199 
00200 
00201         //- Return the explicit correction to the face-interpolate
00202         //  for the given field
00203         virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00204         correction
00205         (
00206             const GeometricField<Type, fvPatchField, volMesh>& vf
00207         ) const
00208         {
00209             if (tScheme1_().corrected())
00210             {
00211                 if (tScheme2_().corrected())
00212                 {
00213                     return
00214                     (
00215                         blendingFactor_
00216                       * tScheme1_().correction(vf)
00217                       + (scalar(1.0) - blendingFactor_)
00218                       * tScheme2_().correction(vf)
00219                     );
00220                 }
00221                 else
00222                 {
00223                     return
00224                     (
00225                         blendingFactor_
00226                       * tScheme1_().correction(vf)
00227                     );
00228                 }
00229             }
00230             else if (tScheme2_().corrected())
00231             {
00232                 return
00233                 (
00234                     (scalar(1.0) - blendingFactor_)
00235                   * tScheme2_().correction(vf)
00236                 );
00237             }
00238             else
00239             {
00240                 return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00241                 (
00242                     NULL
00243                 );
00244             }
00245         }
00246 };
00247 
00248 
00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00250 
00251 } // End namespace Foam
00252 
00253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00254 
00255 #endif
00256 
00257 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines