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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::clippedLinear
26 
27 Description
28  Central-differencing interpolation scheme using clipped-weights to
29  improve stability on meshes with very rapid variations in cell size.
30 
31 SourceFiles
32  clippedLinear.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef clippedLinear_H
37 #define clippedLinear_H
38 
40 #include "volFields.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class clippedLinear Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template<class Type>
52 class clippedLinear
53 :
54  public surfaceInterpolationScheme<Type>
55 {
56  // Private data
57 
58  const scalar cellSizeRatio_;
59  scalar wfLimit_;
60 
61 
62  // Private Member Functions
63 
64  void calcWfLimit()
65  {
66  if (cellSizeRatio_ <= 0 || cellSizeRatio_ > 1)
67  {
69  << "Given cellSizeRatio of " << cellSizeRatio_
70  << " is not between 0 and 1"
71  << exit(FatalError);
72  }
73 
75  }
76 
77 
78  //- Disallow default bitwise assignment
79  void operator=(const clippedLinear&);
80 
81 
82 public:
83 
84  //- Runtime type information
85  TypeName("clippedLinear");
86 
87 
88  // Constructors
89 
90  //- Construct from mesh and cellSizeRatio
91  clippedLinear(const fvMesh& mesh, const scalar cellSizeRatio)
92  :
94  cellSizeRatio_(cellSizeRatio)
95  {
96  calcWfLimit();
97  }
98 
99  //- Construct from Istream
100  clippedLinear(const fvMesh& mesh, Istream& is)
101  :
104  {
105  calcWfLimit();
106  }
107 
108  //- Construct from faceFlux and Istream
110  (
111  const fvMesh& mesh,
112  const surfaceScalarField&,
113  Istream& is
114  )
115  :
118  {
119  calcWfLimit();
120  }
121 
122 
123  // Member Functions
124 
125  //- Return the interpolation weighting factors
127  (
129  ) const
130  {
131  const fvMesh& mesh = this->mesh();
132 
133  tmp<surfaceScalarField> tcdWeights
134  (
135  mesh.surfaceInterpolation::weights()
136  );
137  const surfaceScalarField& cdWeights = tcdWeights();
138 
139  tmp<surfaceScalarField> tclippedLinearWeights
140  (
142  (
143  IOobject
144  (
145  "clippedLinearWeights",
146  mesh.time().timeName(),
147  mesh
148  ),
149  mesh,
150  dimless
151  )
152  );
153  surfaceScalarField& clippedLinearWeights = tclippedLinearWeights();
154 
155  clippedLinearWeights.internalField() =
156  max(min(cdWeights.internalField(), 1 - wfLimit_), wfLimit_);
157 
159  {
160  if (clippedLinearWeights.boundaryField()[patchi].coupled())
161  {
162  clippedLinearWeights.boundaryField()[patchi] =
163  max
164  (
165  min
166  (
167  cdWeights.boundaryField()[patchi],
168  1 - wfLimit_
169  ),
170  wfLimit_
171  );
172  }
173  else
174  {
175  clippedLinearWeights.boundaryField()[patchi] =
176  cdWeights.boundaryField()[patchi];
177  }
178  }
179 
180  return tclippedLinearWeights;
181  }
182 };
183 
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::clippedLinear::cellSizeRatio_
const scalar cellSizeRatio_
Definition: clippedLinear.H:57
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::clippedLinear
Central-differencing interpolation scheme using clipped-weights to improve stability on meshes with v...
Definition: clippedLinear.H:51
Foam::clippedLinear::wfLimit_
scalar wfLimit_
Definition: clippedLinear.H:58
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::clippedLinear::weights
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Definition: clippedLinear.H:126
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
Foam::FatalError
error FatalError
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:550
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::clippedLinear::operator=
void operator=(const clippedLinear &)
Disallow default bitwise assignment.
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
Foam::clippedLinear::clippedLinear
clippedLinear(const fvMesh &mesh, Istream &is)
Construct from Istream.
Definition: clippedLinear.H:99
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::clippedLinear::calcWfLimit
void calcWfLimit()
Definition: clippedLinear.H:63
Foam::surfaceInterpolationScheme
Abstract base class for surface interpolation schemes.
Definition: surfaceInterpolationScheme.H:55
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Foam::surfaceInterpolationScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: surfaceInterpolationScheme.H:142
Foam::clippedLinear::TypeName
TypeName("clippedLinear")
Runtime type information.
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::clippedLinear::clippedLinear
clippedLinear(const fvMesh &mesh, const scalar cellSizeRatio)
Construct from mesh and cellSizeRatio.
Definition: clippedLinear.H:90
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
surfaceInterpolationScheme.H