52 const scalar& maxDelta,
53 const scalar& minDelta,
54 const scalar& extrapolate
57 if (extrapolate > maxDelta + VSMALL)
61 else if (extrapolate < minDelta - VSMALL)
74 const Type& extrapolate
77 for (
direction cmpt = 0; cmpt < Type::nComponents; ++cmpt)
82 maxDelta.component(cmpt),
83 minDelta.component(cmpt),
84 extrapolate.component(cmpt)
99 const faMesh&
mesh = vsf.mesh();
101 tmp<areaVectorField> tGrad = basicGradScheme_().calcGrad(vsf,
name);
121 const label own = owner[facei];
122 const label nei = neighbour[facei];
124 const scalar vsfOwn = vsf[own];
125 const scalar vsfNei = vsf[nei];
127 maxVsf[own] =
max(maxVsf[own], vsfNei);
128 minVsf[own] =
min(minVsf[own], vsfNei);
130 maxVsf[nei] =
max(maxVsf[nei], vsfOwn);
131 minVsf[nei] =
min(minVsf[nei], vsfOwn);
136 auto updateLimiter = [&](
const label patchi,
const scalarField&
fld) ->
void
142 const label own = pOwner[facei];
143 const scalar vsf =
fld[facei];
145 maxVsf[own] =
max(maxVsf[own], vsf);
146 minVsf[own] =
min(minVsf[own], vsf);
157 updateLimiter(patchi, psf.patchNeighbourField());
161 updateLimiter(patchi, psf);
170 const scalarField maxMinVsf((1.0/k_ - 1.0)*(maxVsf - minVsf));
181 const label own = owner[facei];
182 const label nei = neighbour[facei];
190 (Cf[facei] -
C[own]) &
g[own]
199 (Cf[facei] -
C[nei]) &
g[nei]
206 const vectorField& pCf = Cf.boundaryField()[patchi];
210 const label own = pOwner[pFacei];
217 (pCf[pFacei] -
C[own]) &
g[own]
227 Info<<
"gradient limiter for: " << vsf.name()
228 <<
" min = " <<
limits.min()
229 <<
" max = " <<
limits.max()
230 <<
" average: " << avg <<
endl;
234 g.correctBoundaryConditions();
248 const faMesh&
mesh = vsf.mesh();
250 tmp<areaTensorField> tGrad = basicGradScheme_().grad(vsf,
name);
270 const label own = owner[facei];
271 const label nei = neighbour[facei];
273 const vector& vsfOwn = vsf[own];
274 const vector& vsfNei = vsf[nei];
276 maxVsf[own] =
max(maxVsf[own], vsfNei);
277 minVsf[own] =
min(minVsf[own], vsfNei);
279 maxVsf[nei] =
max(maxVsf[nei], vsfOwn);
280 minVsf[nei] =
min(minVsf[nei], vsfOwn);
285 auto updateLimiter = [&](
const label patchi,
const vectorField&
fld) ->
void
291 const label own = pOwner[facei];
294 maxVsf[own] =
max(maxVsf[own], vsf);
295 minVsf[own] =
min(minVsf[own], vsf);
306 updateLimiter(patchi, psf.patchNeighbourField());
310 updateLimiter(patchi, psf);
319 const vectorField maxMinVsf((1.0/k_ - 1.0)*(maxVsf - minVsf));
333 const label own = owner[facei];
334 const label nei = neighbour[facei];
342 (Cf[facei] -
C[own]) &
g[own]
351 (Cf[facei] -
C[nei]) &
g[nei]
358 const vectorField& pCf = Cf.boundaryField()[patchi];
362 const label own = pOwner[pFacei];
369 ((pCf[pFacei] -
C[own]) &
g[own])
379 Info<<
"gradient limiter for: " << vsf.name()
380 <<
" min = " <<
limits.min()
381 <<
" max = " <<
limits.max()
382 <<
" average: " << avg <<
endl;
397 g.correctBoundaryConditions();
static const Foam::dimensionedScalar C("", Foam::dimTemperature, 234.5)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
const uniformDimensionedVectorField & g
GeometricBoundaryField< scalar, faPatchField, areaMesh > Boundary
static void limitEdge(Type &limiter, const Type &maxDelta, const Type &minDelta, const Type &extrapolate)
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > calcGrad(const GeometricField< Type, faPatchField, areaMesh > &vsf, const word &name) const
Return the gradient of the given field to the gradScheme::grad for optional caching.
static void correctBoundaryConditions(const GeometricField< Type, faPatchField, areaMesh > &, GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > &)
Correct the boundary values of the gradient using the patchField.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define makeFaGradScheme(SS)
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< vector, faePatchField, edgeMesh > edgeVectorField
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< tensor, faPatchField, areaMesh > areaTensorField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
faPatchField< vector > faPatchVectorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Field< vector > vectorField
Specialisation of Field<T> for vector.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
UList< label > labelUList
A UList of labels.
faPatchField< scalar > faPatchScalarField
tmp< areaScalarField > limiter(const areaScalarField &phi)
#define forAll(list, i)
Loop across all elements in list.