Loading...
Searching...
No Matches
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:
59 public surfaceInterpolationScheme<Type>
60{
61 // Private Data
62
63 scalar wfLimit_;
64
65
66 // Private Member Functions
67
68 static scalar calcWfLimit(scalar cellSizeRatio)
69 {
70 if (cellSizeRatio <= 0 || cellSizeRatio > 1)
71 {
73 << "Given cellSizeRatio of " << cellSizeRatio
74 << " is not between 0 and 1"
75 << exit(FatalError);
76 }
77
78 return cellSizeRatio/(1.0 + cellSizeRatio);
79 }
80
81
82 //- No copy assignment
83 void operator=(const clippedLinear&) = delete;
84
85
86public:
87
88 //- Runtime type information
89 TypeName("clippedLinear");
90
91
92 // Constructors
93
94 //- Construct from mesh and cellSizeRatio
95 clippedLinear(const fvMesh& mesh, const scalar cellSizeRatio)
96 :
97 surfaceInterpolationScheme<Type>(mesh),
98 wfLimit_(calcWfLimit(cellSizeRatio))
99 {}
100
101 //- Construct from Istream
102 clippedLinear(const fvMesh& mesh, Istream& is)
103 :
105 wfLimit_(calcWfLimit(readScalar(is)))
106 {}
107
108 //- Construct from faceFlux and Istream
110 (
111 const fvMesh& mesh,
112 const surfaceScalarField&,
113 Istream& is
115 :
116 surfaceInterpolationScheme<Type>(mesh),
117 wfLimit_(calcWfLimit(readScalar(is)))
118 {}
119
120
121 // Member Functions
122
123 //- Return the interpolation weighting factors
125 (
127 ) const
128 {
129 const fvMesh& mesh = this->mesh();
130
132 (
133 mesh.surfaceInterpolation::weights()
134 );
135 const surfaceScalarField& cdWeights = tcdWeights();
136
137 const scalarMinMax bounds(wfLimit_, 1 - wfLimit_);
138
139 tmp<surfaceScalarField> tclippedLinearWeights
140 (
142 (
144 (
145 "clippedLinearWeights",
146 mesh.time().timeName(),
147 mesh
148 ),
149 mesh,
150 dimless
151 )
152 );
153 surfaceScalarField& clippedLinearWeights =
154 tclippedLinearWeights.ref();
155
156 clippedLinearWeights.primitiveFieldRef() =
157 clamp(cdWeights.primitiveField(), bounds);
158
160 clippedLinearWeights.boundaryFieldRef();
161
162 forAll(mesh.boundary(), patchi)
163 {
164 if (clwbf[patchi].coupled())
165 {
166 clwbf[patchi] =
167 clamp(cdWeights.boundaryField()[patchi], bounds);
168 }
169 else
170 {
171 clwbf[patchi] = cdWeights.boundaryField()[patchi];
172 }
173 }
174
175 return tclippedLinearWeights;
176 }
177};
178
179
180// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181
182} // End namespace Foam
183
184// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185
186#endif
187
188// ************************************************************************* //
Generic GeometricField class.
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
GeometricBoundaryField< scalar, fvsPatchField, surfaceMesh > Boundary
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
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.
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:85
Abstract base class for surface interpolation schemes.
const fvMesh & mesh() const
Return mesh reference.
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
bool coupled
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for bounding specifications. At the moment, mostly for tables.
Namespace for OpenFOAM.
const dimensionSet dimless
Dimensionless.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
MinMax< scalar > scalarMinMax
A scalar min/max range.
Definition MinMax.H:97
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68