outletStabilised.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-2017 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::outletStabilised
28 
29 Group
30  grpFvSurfaceInterpolationSchemes
31 
32 Description
33  Outlet-stabilised interpolation scheme which applies upwind differencing
34  to the faces of the cells adjacent to outlets.
35 
36  This is particularly useful to stabilise the velocity at entrainment
37  boundaries for LES cases using linear or other centred differencing
38  schemes.
39 
40 SourceFiles
41  outletStabilised.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef outletStabilised_H
46 #define outletStabilised_H
47 
49 #include "skewCorrectionVectors.H"
50 #include "linear.H"
51 #include "gaussGrad.H"
53 #include "mixedFvPatchField.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class outletStabilised Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class Type>
66 class outletStabilised
67 :
68  public surfaceInterpolationScheme<Type>
69 {
70  // Private member data
71 
72  const surfaceScalarField& faceFlux_;
74 
75 
76  // Private Member Functions
77 
78  //- No copy construct
79  outletStabilised(const outletStabilised&) = delete;
80 
81  //- No copy assignment
82  void operator=(const outletStabilised&) = delete;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("outletStabilised");
89 
90 
91  // Constructors
92 
93  //- Construct from mesh and Istream
95  (
96  const fvMesh& mesh,
97  Istream& is
98  )
99  :
101  faceFlux_
102  (
103  mesh.lookupObject<surfaceScalarField>
104  (
105  word(is)
106  )
107  ),
108  tScheme_
109  (
110  surfaceInterpolationScheme<Type>::New(mesh, faceFlux_, is)
111  )
112  {}
113 
114 
115  //- Construct from mesh, faceFlux and Istream
117  (
118  const fvMesh& mesh,
119  const surfaceScalarField& faceFlux,
120  Istream& is
121  )
122  :
124  faceFlux_(faceFlux),
125  tScheme_
126  (
127  surfaceInterpolationScheme<Type>::New(mesh, faceFlux, is)
128  )
129  {}
130 
131 
132  // Member Functions
133 
134  //- Return the interpolation weighting factors
136  (
138  ) const
139  {
140  tmp<surfaceScalarField> tw = tScheme_().weights(vf);
141  surfaceScalarField& w = tw.ref();
142 
143  const fvMesh& mesh_ = this->mesh();
144  const cellList& cells = mesh_.cells();
145 
146  forAll(vf.boundaryField(), patchi)
147  {
148  if
149  (
151  (vf.boundaryField()[patchi])
152  || isA<mixedFvPatchField<Type>>(vf.boundaryField()[patchi])
154  (vf.boundaryField()[patchi])
155  )
156  {
157  for
158  (
159  const label celli
160  : mesh_.boundary()[patchi].faceCells()
161  )
162  {
163  for (const label facei : cells[celli])
164  {
165  if (mesh_.isInternalFace(facei))
166  {
167  // Apply upwind differencing
168  w[facei] = pos0(faceFlux_[facei]);
169  }
170  }
171  }
172  }
173  }
174 
175  return tw;
176  }
177 
178  //- Return true if this scheme uses an explicit correction
179  virtual bool corrected() const
180  {
181  return tScheme_().corrected();
182  }
183 
184  //- Return the explicit correction to the face-interpolate
185  // set to zero on the near-boundary faces where upwind is applied
186  virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
187  correction
188  (
190  ) const
191  {
192  if (tScheme_().corrected())
193  {
195  tScheme_().correction(vf);
196 
198  tcorr.ref();
199 
200  const fvMesh& mesh_ = this->mesh();
201  const cellList& cells = mesh_.cells();
202 
203  forAll(vf.boundaryField(), patchi)
204  {
205  if
206  (
208  (vf.boundaryField()[patchi])
210  (vf.boundaryField()[patchi])
211  )
212  {
213  for
214  (
215  const label celli
216  : mesh_.boundary()[patchi].faceCells()
217  )
218  {
219  for (const label facei : cells[celli])
220  {
221  if (mesh_.isInternalFace(facei))
222  {
223  // Remove correction
224  corr[facei] = Zero;
225  }
226  }
227  }
228  }
229  }
230 
231  return tcorr;
232  }
233  else
234  {
235  return nullptr;
236  }
237  }
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
const cellList & cells() const
const fvMesh & mesh() const
Return mesh reference.
TypeName("outletStabilised")
Runtime type information.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:286
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
Base class for direction-mixed boundary conditions.
Outlet-stabilised interpolation scheme which applies upwind differencing to the faces of the cells ad...
const cellShapeList & cells
A class for handling words, derived from Foam::string.
Definition: word.H:63
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
dimensionedScalar pos0(const dimensionedScalar &ds)
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition: typeInfo.H:87
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Abstract base class for surface interpolation schemes.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127