clippedLinear.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::clippedLinear
28
29Group
30 grpFvSurfaceInterpolationSchemes
31
32Description
33 Central-differencing interpolation scheme using clipped-weights to
34 improve stability on meshes with very rapid variations in cell size.
35
36SourceFiles
37 clippedLinear.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef clippedLinear_H
42#define clippedLinear_H
43
45#include "volFields.H"
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
50{
51
52/*---------------------------------------------------------------------------*\
53 Class clippedLinear Declaration
54\*---------------------------------------------------------------------------*/
55
56template<class Type>
57class clippedLinear
58:
60{
61 // Private data
62
63 const scalar cellSizeRatio_;
64 scalar wfLimit_;
65
66
67 // Private Member Functions
68
69 void calcWfLimit()
70 {
71 if (cellSizeRatio_ <= 0 || cellSizeRatio_ > 1)
72 {
74 << "Given cellSizeRatio of " << cellSizeRatio_
75 << " is not between 0 and 1"
76 << exit(FatalError);
77 }
78
79 wfLimit_ = cellSizeRatio_/(1.0 + cellSizeRatio_);
80 }
81
82
83 //- No copy assignment
84 void operator=(const clippedLinear&) = delete;
85
86
87public:
88
89 //- Runtime type information
90 TypeName("clippedLinear");
91
92
93 // Constructors
94
95 //- Construct from mesh and cellSizeRatio
96 clippedLinear(const fvMesh& mesh, const scalar cellSizeRatio)
97 :
99 cellSizeRatio_(cellSizeRatio)
100 {
101 calcWfLimit();
102 }
103
104 //- Construct from Istream
105 clippedLinear(const fvMesh& mesh, Istream& is)
106 :
108 cellSizeRatio_(readScalar(is))
109 {
110 calcWfLimit();
111 }
112
113 //- Construct from faceFlux and Istream
115 (
116 const fvMesh& mesh,
117 const surfaceScalarField&,
118 Istream& is
119 )
120 :
122 cellSizeRatio_(readScalar(is))
123 {
124 calcWfLimit();
125 }
126
127
128 // Member Functions
129
130 //- Return the interpolation weighting factors
132 (
134 ) const
135 {
136 const fvMesh& mesh = this->mesh();
137
138 tmp<surfaceScalarField> tcdWeights
139 (
140 mesh.surfaceInterpolation::weights()
141 );
142 const surfaceScalarField& cdWeights = tcdWeights();
143
144 tmp<surfaceScalarField> tclippedLinearWeights
145 (
147 (
149 (
150 "clippedLinearWeights",
151 mesh.time().timeName(),
152 mesh
153 ),
154 mesh,
155 dimless
156 )
157 );
158 surfaceScalarField& clippedLinearWeights =
159 tclippedLinearWeights.ref();
160
161 clippedLinearWeights.primitiveFieldRef() =
162 max(min(cdWeights.primitiveField(), 1 - wfLimit_), wfLimit_);
163
165 clippedLinearWeights.boundaryFieldRef();
166
167 forAll(mesh.boundary(), patchi)
168 {
169 if (clwbf[patchi].coupled())
170 {
171 clwbf[patchi] =
172 max
173 (
174 min
175 (
176 cdWeights.boundaryField()[patchi],
177 1 - wfLimit_
178 ),
179 wfLimit_
180 );
181 }
182 else
183 {
184 clwbf[patchi] = cdWeights.boundaryField()[patchi];
185 }
186 }
187
188 return tclippedLinearWeights;
189 }
190};
191
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195} // End namespace Foam
196
197// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198
199#endif
200
201// ************************************************************************* //
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Central-differencing interpolation scheme using clipped-weights to improve stability on meshes with v...
Definition: clippedLinear.H:59
clippedLinear(const fvMesh &mesh, Istream &is)
Construct from Istream.
clippedLinear(const fvMesh &mesh, const surfaceScalarField &, Istream &is)
Construct from faceFlux and Istream.
TypeName("clippedLinear")
Runtime type information.
clippedLinear(const fvMesh &mesh, const scalar cellSizeRatio)
Construct from mesh and cellSizeRatio.
Definition: clippedLinear.H:95
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Abstract base class for surface interpolation schemes.
const fvMesh & mesh() const
Return mesh reference.
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
const dimensionSet dimless
Dimensionless.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73