/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description Abstract base class for surface interpolation schemes. \*---------------------------------------------------------------------------*/ #include "surfaceInterpolationScheme.H" #include "volFields.H" #include "surfaceFields.H" #include "coupledFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // // Return weighting factors for scheme given by name in dictionary template tmp > surfaceInterpolationScheme::New ( const fvMesh& mesh, Istream& schemeData ) { if (schemeData.eof()) { FatalIOErrorIn ( "surfaceInterpolationScheme::New(const fvMesh&, Istream&)", schemeData ) << "Discretisation scheme not specified" << endl << endl << "Valid schemes are :" << endl << MeshConstructorTablePtr_->sortedToc() << exit(FatalIOError); } word schemeName(schemeData); if (surfaceInterpolation::debug || surfaceInterpolationScheme::debug) { Info<< "surfaceInterpolationScheme::New" "(const fvMesh&, Istream&)" " : discretisation scheme = " << schemeName << endl; } typename MeshConstructorTable::iterator constructorIter = MeshConstructorTablePtr_->find(schemeName); if (constructorIter == MeshConstructorTablePtr_->end()) { FatalIOErrorIn ( "surfaceInterpolationScheme::New(const fvMesh&, Istream&)", schemeData ) << "Unknown discretisation scheme " << schemeName << endl << endl << "Valid schemes are :" << endl << MeshConstructorTablePtr_->sortedToc() << exit(FatalIOError); } return constructorIter()(mesh, schemeData); } // Return weighting factors for scheme given by name in dictionary template tmp > surfaceInterpolationScheme::New ( const fvMesh& mesh, const surfaceScalarField& faceFlux, Istream& schemeData ) { if (schemeData.eof()) { FatalIOErrorIn ( "surfaceInterpolationScheme::New" "(const fvMesh&, const surfaceScalarField&, Istream&)", schemeData ) << "Discretisation scheme not specified" << endl << endl << "Valid schemes are :" << endl << MeshConstructorTablePtr_->sortedToc() << exit(FatalIOError); } word schemeName(schemeData); if (surfaceInterpolation::debug || surfaceInterpolationScheme::debug) { Info<< "surfaceInterpolationScheme::New" "(const fvMesh&, const surfaceScalarField&, Istream&)" " : discretisation scheme = " << schemeName << endl; } typename MeshFluxConstructorTable::iterator constructorIter = MeshFluxConstructorTablePtr_->find(schemeName); if (constructorIter == MeshFluxConstructorTablePtr_->end()) { FatalIOErrorIn ( "surfaceInterpolationScheme::New" "(const fvMesh&, const surfaceScalarField&, Istream&)", schemeData ) << "Unknown discretisation scheme " << schemeName << endl << endl << "Valid schemes are :" << endl << MeshFluxConstructorTablePtr_->sortedToc() << exit(FatalIOError); } return constructorIter()(mesh, faceFlux, schemeData); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template surfaceInterpolationScheme::~surfaceInterpolationScheme() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // //- Return the face-interpolate of the given cell field // with the given owner and neighbour weighting factors template tmp > surfaceInterpolationScheme::interpolate ( const GeometricField& vf, const tmp& tlambdas, const tmp& tys ) { if (surfaceInterpolation::debug) { Info<< "surfaceInterpolationScheme::uncorrectedInterpolate" "(const GeometricField&, " "const tmp&, " "const tmp&) : " "interpolating volTypeField from cells to faces " "without explicit correction" << endl; } const surfaceScalarField& lambdas = tlambdas(); const surfaceScalarField& ys = tys(); const Field& vfi = vf.internalField(); const scalarField& lambda = lambdas.internalField(); const scalarField& y = ys.internalField(); const fvMesh& mesh = vf.mesh(); const unallocLabelList& P = mesh.owner(); const unallocLabelList& N = mesh.neighbour(); tmp > tsf ( new GeometricField ( IOobject ( "interpolate("+vf.name()+')', vf.instance(), vf.db() ), mesh, vf.dimensions() ) ); GeometricField& sf = tsf(); Field& sfi = sf.internalField(); for (register label fi=0; fi tmp > surfaceInterpolationScheme::interpolate ( const GeometricField& vf, const tmp& tlambdas ) { if (surfaceInterpolation::debug) { Info<< "surfaceInterpolationScheme::interpolate" "(const GeometricField&, " "const tmp&) : " "interpolating volTypeField from cells to faces " "without explicit correction" << endl; } const surfaceScalarField& lambdas = tlambdas(); const Field& vfi = vf.internalField(); const scalarField& lambda = lambdas.internalField(); const fvMesh& mesh = vf.mesh(); const unallocLabelList& P = mesh.owner(); const unallocLabelList& N = mesh.neighbour(); tmp > tsf ( new GeometricField ( IOobject ( "interpolate("+vf.name()+')', vf.instance(), vf.db() ), mesh, vf.dimensions() ) ); GeometricField& sf = tsf(); Field& sfi = sf.internalField(); for (register label fi=0; fi tmp > surfaceInterpolationScheme::interpolate ( const GeometricField& vf ) const { if (surfaceInterpolation::debug) { Info<< "surfaceInterpolationScheme::interpolate" "(const GeometricField&) : " << "interpolating volTypeField from cells to faces" << endl; } tmp > tsf = interpolate(vf, weights(vf)); if (corrected()) { tsf() += correction(vf); } return tsf; } //- Return the face-interpolate of the given cell field // with explicit correction template tmp > surfaceInterpolationScheme::interpolate ( const tmp >& tvf ) const { tmp > tinterpVf = interpolate(tvf()); tvf.clear(); return tinterpVf; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // ************************************************************************* //