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

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