limitedSnGrad.C
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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "fv.H"
30 #include "limitedSnGrad.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 #include "localMax.H"
34 #include "fvcCellReduce.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace fv
44 {
45 
46 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47 
48 template<class Type>
49 tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
51 (
53 ) const
54 {
56  (
57  correctedScheme_().correction(vf)
58  );
59 
61  (
62  min
63  (
64  limitCoeff_
65  *mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "SndGrad"))
66  /(
67  (1 - limitCoeff_)*mag(corr)
68  + dimensionedScalar("small", corr.dimensions(), SMALL)
69  ),
70  dimensionedScalar("one", dimless, 1.0)
71  )
72  );
73 
74  if (fv::debug)
75  {
77  << "limiter min: " << min(limiter.primitiveField())
78  << " max: "<< max(limiter.primitiveField())
79  << " avg: " << average(limiter.primitiveField()) << endl;
80 
81 
82  if (fv::debug & 2)
83  {
84  static scalar oldTime = -1;
85  static label subIter = 0;
86  if (vf.mesh().time().value() != oldTime)
87  {
88  oldTime = vf.mesh().time().value();
89  subIter = 0;
90  }
91  else
92  {
93  ++subIter;
94  }
95  word fieldName("limiter_" + Foam::name(subIter));
96 
98  (
99  IOobject
100  (
101  fieldName,
102  vf.mesh().time().timeName(),
103  vf.mesh(),
106  false
107  ),
108  fvc::cellReduce(limiter, minEqOp<scalar>(), scalar(1.0))
109  );
110  Info<< "Writing limiter field to " << volLimiter.objectPath()
111  << endl;
112  volLimiter.write();
113  }
114  }
115 
116  return limiter*corr;
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace fv
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 } // End namespace Foam
127 
128 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
limitedSnGrad.H
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fv.H
oldTime
Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));if(U.nOldTimes()){ volVectorField *Uold=&U.oldTime();volScalarField *Kold=&K.oldTime();*Kold==0.5 *magSqr(*Uold);while(Uold->nOldTimes()) { Uold=&Uold-> oldTime()
Definition: createK.H:12
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
surfaceFields.H
Foam::surfaceFields.
localMax.H
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::fv::limitedSnGrad::correction
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: limitedSnGrad.C:51
Foam::minEqOp
Definition: ops.H:81
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::fvc::cellReduce
tmp< GeometricField< Type, fvPatchField, volMesh > > cellReduce(const GeometricField< Type, fvsPatchField, surfaceMesh > &, const CombineOp &cop, const Type &nullValue=pTraits< Type >::zero)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fv
labelList fv(nPoints)
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fv::snGradScheme
Abstract base class for runtime selected snGrad surface normal gradient schemes.
Definition: snGradScheme.H:76
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
fvcCellReduce.H
Construct a volume field from a surface field using a combine operator.
Foam::limiter
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition: faNVDscheme.C:37
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189