1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "limitedSurfaceInterpolationScheme.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "coupledFvPatchField.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
40 tmp<limitedSurfaceInterpolationScheme<Type> >
41 limitedSurfaceInterpolationScheme<Type>::New
47 if (surfaceInterpolation::debug)
49 Info<< "limitedSurfaceInterpolationScheme<Type>::"
50 "New(const fvMesh&, Istream&)"
51 " : constructing limitedSurfaceInterpolationScheme<Type>"
59 "limitedSurfaceInterpolationScheme<Type>::"
60 "New(const fvMesh&, Istream&)",
62 ) << "Discretisation scheme not specified"
64 << "Valid schemes are :" << endl
65 << MeshConstructorTablePtr_->toc()
66 << exit(FatalIOError);
69 word schemeName(schemeData);
71 typename MeshConstructorTable::iterator constructorIter =
72 MeshConstructorTablePtr_->find(schemeName);
74 if (constructorIter == MeshConstructorTablePtr_->end())
78 "limitedSurfaceInterpolationScheme<Type>::"
79 "New(const fvMesh&, Istream&)",
81 ) << "Unknown discretisation scheme " << schemeName
83 << "Valid schemes are :" << endl
84 << MeshConstructorTablePtr_->toc()
85 << exit(FatalIOError);
88 return constructorIter()(mesh, schemeData);
92 // Return weighting factors for scheme given by name in dictionary
94 tmp<limitedSurfaceInterpolationScheme<Type> >
95 limitedSurfaceInterpolationScheme<Type>::New
98 const surfaceScalarField& faceFlux,
102 if (surfaceInterpolation::debug)
104 Info<< "limitedSurfaceInterpolationScheme<Type>::New"
105 "(const fvMesh&, const surfaceScalarField&, Istream&) : "
106 "constructing limitedSurfaceInterpolationScheme<Type>"
110 if (schemeData.eof())
114 "limitedSurfaceInterpolationScheme<Type>::New"
115 "(const fvMesh&, const surfaceScalarField&, Istream&)",
117 ) << "Discretisation scheme not specified"
119 << "Valid schemes are :" << endl
120 << MeshConstructorTablePtr_->toc()
121 << exit(FatalIOError);
124 word schemeName(schemeData);
126 typename MeshFluxConstructorTable::iterator constructorIter =
127 MeshFluxConstructorTablePtr_->find(schemeName);
129 if (constructorIter == MeshFluxConstructorTablePtr_->end())
133 "limitedSurfaceInterpolationScheme<Type>::New"
134 "(const fvMesh&, const surfaceScalarField&, Istream&)",
136 ) << "Unknown discretisation scheme " << schemeName
138 << "Valid schemes are :" << endl
139 << MeshFluxConstructorTablePtr_->toc()
140 << exit(FatalIOError);
143 return constructorIter()(mesh, faceFlux, schemeData);
147 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 limitedSurfaceInterpolationScheme<Type>::~limitedSurfaceInterpolationScheme()
154 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
157 tmp<surfaceScalarField> limitedSurfaceInterpolationScheme<Type>::weights
159 const GeometricField<Type, fvPatchField, volMesh>& phi,
160 const surfaceScalarField& CDweights,
161 tmp<surfaceScalarField> tLimiter
164 // Note that here the weights field is initialised as the limiter
165 // from which the weight is calculated using the limiter value
166 surfaceScalarField& Weights = tLimiter();
168 scalarField& pWeights = Weights.internalField();
170 forAll(pWeights, face)
173 pWeights[face]*CDweights[face]
174 + (1.0 - pWeights[face])*pos(faceFlux_[face]);
177 surfaceScalarField::GeometricBoundaryField& bWeights =
178 Weights.boundaryField();
180 forAll(bWeights, patchI)
182 scalarField& pWeights = bWeights[patchI];
184 const scalarField& pCDweights = CDweights.boundaryField()[patchI];
185 const scalarField& pFaceFlux = faceFlux_.boundaryField()[patchI];
187 forAll(pWeights, face)
190 pWeights[face]*pCDweights[face]
191 + (1.0 - pWeights[face])*pos(pFaceFlux[face]);
199 tmp<surfaceScalarField> limitedSurfaceInterpolationScheme<Type>::weights
201 const GeometricField<Type, fvPatchField, volMesh>& phi
207 this->mesh().surfaceInterpolation::weights(),
213 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
214 limitedSurfaceInterpolationScheme<Type>::flux
216 const GeometricField<Type, fvPatchField, volMesh>& phi
219 return faceFlux_*interpolate(phi);
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 } // End namespace Foam
227 // ************************************************************************* //