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

limitedSurfaceInterpolationScheme.C

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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "limitedSurfaceInterpolationScheme.H"
00028 #include "volFields.H"
00029 #include "surfaceFields.H"
00030 #include "coupledFvPatchField.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
00038 
00039 template<class Type>
00040 tmp<limitedSurfaceInterpolationScheme<Type> >
00041 limitedSurfaceInterpolationScheme<Type>::New
00042 (
00043     const fvMesh& mesh,
00044     Istream& schemeData
00045 )
00046 {
00047     if (surfaceInterpolation::debug)
00048     {
00049         Info<< "limitedSurfaceInterpolationScheme<Type>::"
00050                "New(const fvMesh&, Istream&)"
00051                " : constructing limitedSurfaceInterpolationScheme<Type>"
00052             << endl;
00053     }
00054 
00055     if (schemeData.eof())
00056     {
00057         FatalIOErrorIn
00058         (
00059             "limitedSurfaceInterpolationScheme<Type>::"
00060             "New(const fvMesh&, Istream&)",
00061             schemeData
00062         )   << "Discretisation scheme not specified"
00063             << endl << endl
00064             << "Valid schemes are :" << endl
00065             << MeshConstructorTablePtr_->toc()
00066             << exit(FatalIOError);
00067     }
00068 
00069     word schemeName(schemeData);
00070 
00071     typename MeshConstructorTable::iterator constructorIter =
00072         MeshConstructorTablePtr_->find(schemeName);
00073 
00074     if (constructorIter == MeshConstructorTablePtr_->end())
00075     {
00076         FatalIOErrorIn
00077         (
00078             "limitedSurfaceInterpolationScheme<Type>::"
00079             "New(const fvMesh&, Istream&)",
00080             schemeData
00081         )   << "Unknown discretisation scheme " << schemeName
00082             << endl << endl
00083             << "Valid schemes are :" << endl
00084             << MeshConstructorTablePtr_->toc()
00085             << exit(FatalIOError);
00086     }
00087 
00088     return constructorIter()(mesh, schemeData);
00089 }
00090 
00091 
00092 // Return weighting factors for scheme given by name in dictionary
00093 template<class Type>
00094 tmp<limitedSurfaceInterpolationScheme<Type> >
00095 limitedSurfaceInterpolationScheme<Type>::New
00096 (
00097     const fvMesh& mesh,
00098     const surfaceScalarField& faceFlux,
00099     Istream& schemeData
00100 )
00101 {
00102     if (surfaceInterpolation::debug)
00103     {
00104         Info<< "limitedSurfaceInterpolationScheme<Type>::New"
00105                "(const fvMesh&, const surfaceScalarField&, Istream&) : "
00106                "constructing limitedSurfaceInterpolationScheme<Type>"
00107             << endl;
00108     }
00109 
00110     if (schemeData.eof())
00111     {
00112         FatalIOErrorIn
00113         (
00114             "limitedSurfaceInterpolationScheme<Type>::New"
00115             "(const fvMesh&, const surfaceScalarField&, Istream&)",
00116             schemeData
00117         )   << "Discretisation scheme not specified"
00118             << endl << endl
00119             << "Valid schemes are :" << endl
00120             << MeshConstructorTablePtr_->toc()
00121             << exit(FatalIOError);
00122     }
00123 
00124     word schemeName(schemeData);
00125 
00126     typename MeshFluxConstructorTable::iterator constructorIter =
00127         MeshFluxConstructorTablePtr_->find(schemeName);
00128 
00129     if (constructorIter == MeshFluxConstructorTablePtr_->end())
00130     {
00131         FatalIOErrorIn
00132         (
00133             "limitedSurfaceInterpolationScheme<Type>::New"
00134             "(const fvMesh&, const surfaceScalarField&, Istream&)",
00135             schemeData
00136         )   << "Unknown discretisation scheme " << schemeName
00137             << endl << endl
00138             << "Valid schemes are :" << endl
00139             << MeshFluxConstructorTablePtr_->toc()
00140             << exit(FatalIOError);
00141     }
00142 
00143     return constructorIter()(mesh, faceFlux, schemeData);
00144 }
00145 
00146 
00147 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00148 
00149 template<class Type>
00150 limitedSurfaceInterpolationScheme<Type>::~limitedSurfaceInterpolationScheme()
00151 {}
00152 
00153 
00154 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00155 
00156 template<class Type>
00157 tmp<surfaceScalarField> limitedSurfaceInterpolationScheme<Type>::weights
00158 (
00159     const GeometricField<Type, fvPatchField, volMesh>& phi,
00160     const surfaceScalarField& CDweights,
00161     tmp<surfaceScalarField> tLimiter
00162 ) const
00163 {
00164     // Note that here the weights field is initialised as the limiter
00165     // from which the weight is calculated using the limiter value
00166     surfaceScalarField& Weights = tLimiter();
00167 
00168     scalarField& pWeights = Weights.internalField();
00169 
00170     forAll(pWeights, face)
00171     {
00172         pWeights[face] =
00173             pWeights[face]*CDweights[face]
00174           + (1.0 - pWeights[face])*pos(faceFlux_[face]);
00175     }
00176 
00177     surfaceScalarField::GeometricBoundaryField& bWeights =
00178         Weights.boundaryField();
00179 
00180     forAll(bWeights, patchI)
00181     {
00182         scalarField& pWeights = bWeights[patchI];
00183 
00184         const scalarField& pCDweights = CDweights.boundaryField()[patchI];
00185         const scalarField& pFaceFlux = faceFlux_.boundaryField()[patchI];
00186 
00187         forAll(pWeights, face)
00188         {
00189             pWeights[face] =
00190                 pWeights[face]*pCDweights[face]
00191               + (1.0 - pWeights[face])*pos(pFaceFlux[face]);
00192         }
00193     }
00194 
00195     return tLimiter;
00196 }
00197 
00198 template<class Type>
00199 tmp<surfaceScalarField> limitedSurfaceInterpolationScheme<Type>::weights
00200 (
00201     const GeometricField<Type, fvPatchField, volMesh>& phi
00202 ) const
00203 {
00204     return this->weights
00205     (
00206         phi,
00207         this->mesh().surfaceInterpolation::weights(),
00208         this->limiter(phi)
00209     );
00210 }
00211 
00212 template<class Type>
00213 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00214 limitedSurfaceInterpolationScheme<Type>::flux
00215 (
00216     const GeometricField<Type, fvPatchField, volMesh>& phi
00217 ) const
00218 {
00219     return faceFlux_*interpolate(phi);
00220 }
00221 
00222 
00223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00224 
00225 } // End namespace Foam
00226 
00227 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd