OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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