1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
29 Central-differencing interpolation scheme using clipped-weights to
30 improve stability on meshes with very rapid variations in cell size.
35 \*---------------------------------------------------------------------------*/
37 #ifndef clippedLinear_H
38 #define clippedLinear_H
40 #include "surfaceInterpolationScheme.H"
41 #include "volFields.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 /*---------------------------------------------------------------------------*\
49 Class clippedLinear Declaration
50 \*---------------------------------------------------------------------------*/
55 public surfaceInterpolationScheme<Type>
59 const scalar cellSizeRatio_;
63 // Private Member Functions
67 if (cellSizeRatio_ <= 0 || cellSizeRatio_ > 1)
69 FatalErrorIn("clippedLinear::calcWfLimit()")
70 << "Given cellSizeRatio of " << cellSizeRatio_
71 << " is not between 0 and 1"
75 wfLimit_ = cellSizeRatio_/(1.0 + cellSizeRatio_);
79 //- Disallow default bitwise assignment
80 void operator=(const clippedLinear&);
85 //- Runtime type information
86 TypeName("clippedLinear");
91 //- Construct from mesh and cellSizeRatio
92 clippedLinear(const fvMesh& mesh, const scalar cellSizeRatio)
94 surfaceInterpolationScheme<Type>(mesh),
95 cellSizeRatio_(cellSizeRatio)
100 //- Construct from Istream
101 clippedLinear(const fvMesh& mesh, Istream& is)
103 surfaceInterpolationScheme<Type>(mesh),
104 cellSizeRatio_(readScalar(is))
109 //- Construct from faceFlux and Istream
113 const surfaceScalarField&,
117 surfaceInterpolationScheme<Type>(mesh),
118 cellSizeRatio_(readScalar(is))
126 //- Return the interpolation weighting factors
127 tmp<surfaceScalarField> weights
129 const GeometricField<Type, fvPatchField, volMesh>&
132 const fvMesh& mesh = this->mesh();
134 tmp<surfaceScalarField> tcdWeights
136 mesh.surfaceInterpolation::weights()
138 const surfaceScalarField& cdWeights = tcdWeights();
140 tmp<surfaceScalarField> tclippedLinearWeights
142 new surfaceScalarField
146 "clippedLinearWeights",
147 mesh.time().timeName(),
154 surfaceScalarField& clippedLinearWeights = tclippedLinearWeights();
156 clippedLinearWeights.internalField() =
157 max(min(cdWeights.internalField(), 1 - wfLimit_), wfLimit_);
159 forAll (mesh.boundary(), patchi)
161 if (mesh.boundary()[patchi].coupled())
163 clippedLinearWeights.boundaryField()[patchi] =
168 cdWeights.boundaryField()[patchi],
176 clippedLinearWeights.boundaryField()[patchi] =
177 cdWeights.boundaryField()[patchi];
181 return tclippedLinearWeights;
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 } // End namespace Foam
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 // ************************************************************************* //