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 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::clippedLinear
28 
29 Group
30  grpFvSurfaceInterpolationSchemes
31 
32 Description
33  Central-differencing interpolation scheme using clipped-weights to
34  improve stability on meshes with very rapid variations in cell size.
35 
36 SourceFiles
37  clippedLinear.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef clippedLinear_H
42 #define clippedLinear_H
43 
45 #include "volFields.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class clippedLinear Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 template<class Type>
57 class 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 
86 public:
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  :
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
114  )
115  :
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 
131  tmp<surfaceScalarField> tcdWeights
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  (
143  IOobject
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 // ************************************************************************* //
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const dimensionSet dimless
Dimensionless.
const fvMesh & mesh() const
Return mesh reference.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:360
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
TypeName("clippedLinear")
Runtime type information.
clippedLinear(const fvMesh &mesh, const scalar cellSizeRatio)
Construct from mesh and cellSizeRatio.
Definition: clippedLinear.H:96
Central-differencing interpolation scheme using clipped-weights to improve stability on meshes with v...
Definition: clippedLinear.H:52
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
Definition: Time.C:714
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef()
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
A class for managing temporary objects.
Definition: HashPtrTable.H:50
bool coupled
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Abstract base class for surface interpolation schemes.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
Definition: dimensionSet.C:271