Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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::outletStabilised
28
29Group
30 grpFvSurfaceInterpolationSchemes
31
32Description
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
40SourceFiles
41 outletStabilised.C
42
43\*---------------------------------------------------------------------------*/
44
45#ifndef outletStabilised_H
46#define outletStabilised_H
47
50#include "linear.H"
51#include "gaussGrad.H"
53#include "mixedFvPatchField.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61/*---------------------------------------------------------------------------*\
62 Class outletStabilised Declaration
63\*---------------------------------------------------------------------------*/
64
65template<class Type>
66class 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
85public:
86
87 //- Runtime type information
88 TypeName("outletStabilised");
90
91 // Constructors
92
93 //- Construct from mesh and Istream
94 outletStabilised
95 (
96 const fvMesh& mesh,
98 )
99 :
100 surfaceInterpolationScheme<Type>(mesh),
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
122 :
123 surfaceInterpolationScheme<Type>(mesh),
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();
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])
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>>
190 ) const
191 {
192 if (tScheme_().corrected())
193 {
195 tScheme_().correction(vf);
196
198 tcorr.ref();
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// ************************************************************************* //
Generic GeometricField class.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Base class for direction-mixed boundary conditions.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Outlet-stabilised interpolation scheme which applies upwind differencing to the faces of the cells ad...
outletStabilised(const fvMesh &mesh, Istream &is)
Construct from mesh and Istream.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
TypeName("outletStabilised")
Runtime type information.
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the interpolation weighting factors.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
outletStabilised(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &is)
Construct from mesh, faceFlux and Istream.
const fvMesh & mesh() const
Return mesh reference.
static tmp< surfaceInterpolationScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
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
A class for handling words, derived from Foam::string.
Definition word.H:66
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
dynamicFvMesh & mesh
const cellShapeList & cells
Namespace for OpenFOAM.
dimensionedScalar pos0(const dimensionedScalar &ds)
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
List< cell > cellList
List of cell.
Definition cellListFwd.H:41
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
#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