ENH: use gMinMax() instead of separate gMin(), gMax()

- for reciprocal values, gMinMax() first and then calculate the
  reciprocal, which avoids creating temporaries

STYLE: prefer MinMax to separate min/max accounting

COMP: namespace qualify min/max for deltaT, CourantNo, etc (#3348)
This commit is contained in:
Mark Olesen
2025-04-02 12:01:28 +02:00
parent a7e8a43f4a
commit 01727c84f1
84 changed files with 837 additions and 646 deletions

View File

@ -36,11 +36,13 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL); scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -1,5 +1,6 @@
if (adjustTimeStep) if (adjustTimeStep)
{ {
runTime.setDeltaT(min(dtChem, maxDeltaT)); runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
Info<< "deltaT = " << runTime.deltaTValue() << endl; Info<< "deltaT = " << runTime.deltaTValue() << endl;
} }

View File

@ -54,9 +54,18 @@ if (adjustTimeStep)
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2), dt0
* Foam::min
(
Foam::min
(
TFactorFluid,
Foam::min(TFactorFilm, TFactorSolid)
),
1.2
),
maxDeltaT maxDeltaT
) )
); );

View File

@ -85,9 +85,11 @@ License
// Limit the largest time scale (=> smallest reciprocal time) // Limit the largest time scale (=> smallest reciprocal time)
rDeltaT.clamp_min(1/maxDeltaT); rDeltaT.clamp_min(1/maxDeltaT);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Flow = " Info<< " Flow = "
<< 1/gMax(rDeltaT.primitiveField()) << ", " << limits.min() << ", " << limits.max() << endl;
<< 1/gMin(rDeltaT.primitiveField()) << endl;
} }
// Heat release rate time scale // Heat release rate time scale
@ -100,9 +102,11 @@ License
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT); rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
auto limits = gMinMax(rDeltaTT.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Temperature = " Info<< " Temperature = "
<< 1/(gMax(rDeltaTT.field()) + VSMALL) << ", " << limits.min() << ", " << limits.max() << endl;
<< 1/(gMin(rDeltaTT.field()) + VSMALL) << endl;
} }
// Reaction rate time scale // Reaction rate time scale
@ -152,9 +156,11 @@ License
{ {
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY); rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
auto limits = gMinMax(rDeltaTY.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Composition = " Info<< " Composition = "
<< 1/(gMax(rDeltaTY.field()) + VSMALL) << ", " << limits.min() << ", " << limits.max() << endl;
<< 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
} }
else else
{ {
@ -184,9 +190,11 @@ License
// Update tho boundary values of the reciprocal time-step // Update tho boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions(); rDeltaT.correctBoundaryConditions();
auto limits = gMinMax(rDeltaT.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Overall = " Info<< " Overall = "
<< 1/gMax(rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << 1/gMin(rDeltaT.primitiveField()) << endl;
} }

View File

@ -23,7 +23,11 @@
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
Info<< "Flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
} }

View File

@ -52,18 +52,26 @@
// Update the boundary values of the reciprocal time-step // Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions(); rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
if (rDeltaTSmoothingCoeff < 1.0) if (rDeltaTSmoothingCoeff < 1.0)
{ {
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
} }
Info<< "Smoothed flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Smoothed flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
// Limit rate of change of time scale // Limit rate of change of time scale
// - reduce as much as required // - reduce as much as required
@ -78,8 +86,10 @@
rDeltaT0 rDeltaT0
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff); *max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Damped flow time scale min/max = " Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }
} }

View File

@ -1,7 +1,7 @@
scalar CoNum = -GREAT; scalar CoNum = -GREAT;
forAll(fluidRegions, regionI) forAll(fluidRegions, regionI)
{ {
CoNum = max CoNum = Foam::max
( (
compressibleCourantNo compressibleCourantNo
( (

View File

@ -387,15 +387,18 @@ updateCoeffs()
{ {
scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad()); scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
Info<< "T solid : " << nl << endl; auto limits = gMinMax(Tp);
auto avg = gAverage(Tp);
Info Info<< "T solid : " << nl << endl;
<< " heat transfer rate from solid:" << Q
<< " walltemperature " Info
<< " min:" << gMin(Tp) << " heat transfer rate from solid:" << Q
<< " max:" << gMax(Tp) << " walltemperature "
<< " avg:" << gAverage(Tp) << nl << " min:" << limits.min()
<< endl; << " max:" << limits.max()
<< " avg:" << avg << nl
<< endl;
} }
} }
else if (regionType_ == fluid) else if (regionType_ == fluid)
@ -445,10 +448,16 @@ updateCoeffs()
scalarField qLiq((Tp - Tc)*KdeltaLiq); scalarField qLiq((Tp - Tc)*KdeltaLiq);
scalarField qVap((Tp - Tv.patchInternalField())*KdeltaVap); scalarField qVap((Tp - Tv.patchInternalField())*KdeltaVap);
auto infoT = gMinMax(Tp);
auto avgT = gAverage(Tp);
auto infoLiq = gMinMax(qLiq);
auto infoVap = gMinMax(qVap);
Info<< "T flow : " << nl << endl; Info<< "T flow : " << nl << endl;
Info<< " qLiq: " << gMin(qLiq) << " - " << gMax(qLiq) << endl; Info<< " qLiq: " << infoLiq.min() << " - " << infoLiq.max() << nl
Info<< " qVap: " << gMin(qVap) << " - " << gMax(qVap) << endl; << " qVap: " << infoVap.min() << " - " << infoVap.max() << nl;
scalar QLiq = gSum(qLiq*patch().magSf()); scalar QLiq = gSum(qLiq*patch().magSf());
scalar QVap = gSum(qVap*patch().magSf()); scalar QVap = gSum(qVap*patch().magSf());
@ -457,9 +466,9 @@ updateCoeffs()
Info<< " Heat transfer to Vap: " << QVap << endl; Info<< " Heat transfer to Vap: " << QVap << endl;
Info<< " walltemperature " Info<< " walltemperature "
<< " min:" << gMin(Tp) << " min:" << infoT.min()
<< " max:" << gMax(Tp) << " max:" << infoT.max()
<< " avg:" << gAverage(Tp) << " avg:" << avgT
<< endl; << endl;
} }
} }

View File

@ -31,7 +31,7 @@
); );
CoNum = scalar regionCoNum =
0.5*gMax 0.5*gMax
( (
sumPhi/fluidRegions[regioni].V().field() sumPhi/fluidRegions[regioni].V().field()
@ -41,9 +41,9 @@
( (
fvc::surfaceSum(mag(phi1 - phi2))().primitiveField() fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()
/ fluidRegions[regioni].V().field() / fluidRegions[regioni].V().field()
)*runTime.deltaTValue(), )*runTime.deltaTValue();
CoNum = max(UrCoNum, CoNum); CoNum = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
} }
} }

View File

@ -2,7 +2,7 @@
forAll(fluidRegions, regioni) forAll(fluidRegions, regioni)
{ {
CoNum = max CoNum = Foam::max
( (
compressibleCourantNo compressibleCourantNo
( (
@ -17,7 +17,7 @@
/* /*
forAll(porousFluidRegions, porousi) forAll(porousFluidRegions, porousi)
{ {
CoNum = max CoNum = Foam::max
( (
compressibleCourantNo compressibleCourantNo
( (

View File

@ -47,10 +47,10 @@ if (adjustTimeStep)
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(), Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
min(runTime.deltaTValue(), maxDeltaT) Foam::min(runTime.deltaTValue(), maxDeltaT)
) )
); );
Info<< "deltaT = " << runTime.deltaTValue() << endl; Info<< "deltaT = " << runTime.deltaTValue() << endl;

View File

@ -48,18 +48,14 @@ if (adjustTimeStep)
scalar maxDeltaTFluid = maxCo/(CoNum + SMALL); scalar maxDeltaTFluid = maxCo/(CoNum + SMALL);
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL); scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
scalar deltaTFluid = const scalar deltaTFluid =
min Foam::min(Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid), 1.2);
(
min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
1.2
);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(), Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
maxDeltaT maxDeltaT
) )
); );

View File

@ -22,7 +22,7 @@ forAll(solidRegions, i)
tmp<volScalarField> trho = thermo.rho(); tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho(); const volScalarField& rho = trho();
DiNum = max DiNum = Foam::max
( (
solidRegionDiffNo solidRegionDiffNo
( (

View File

@ -17,7 +17,7 @@ scalar DiNum = -GREAT;
tmp<volScalarField> trho = thermo.rho(); tmp<volScalarField> trho = thermo.rho();
const volScalarField& rho = trho(); const volScalarField& rho = trho();
DiNum = max DiNum = Foam::max
( (
solidRegionDiffNo solidRegionDiffNo
( (

View File

@ -36,18 +36,26 @@
// Update the boundary values of the reciprocal time-step // Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions(); rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
if (rDeltaTSmoothingCoeff < 1.0) if (rDeltaTSmoothingCoeff < 1.0)
{ {
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
} }
Info<< "Smoothed flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Smoothed flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
// Limit rate of change of time scale // Limit rate of change of time scale
// - reduce as much as required // - reduce as much as required
@ -62,8 +70,10 @@
rDeltaT0 rDeltaT0
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff); *max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Damped flow time scale min/max = " Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }
} }

View File

@ -81,9 +81,11 @@ License
// Limit the largest time scale (=> smallest reciprocal time) // Limit the largest time scale (=> smallest reciprocal time)
rDeltaT.clamp_min(1/maxDeltaT); rDeltaT.clamp_min(1/maxDeltaT);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Flow = " Info<< " Flow = "
<< gMin(1/rDeltaT.primitiveField()) << ", " << limits.min() << ", " << limits.max() << endl;
<< gMax(1/rDeltaT.primitiveField()) << endl;
} }
// Reaction source time scale // Reaction source time scale
@ -106,9 +108,11 @@ License
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT); rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
auto limits = gMinMax(rDeltaTT.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Temperature = " Info<< " Temperature = "
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", " << limits.min() << ", " << limits.max() << endl;
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
} }
// Update tho boundary values of the reciprocal time-step // Update tho boundary values of the reciprocal time-step
@ -128,9 +132,11 @@ License
rDeltaT.clamp_min(rDeltaT0_damped()); rDeltaT.clamp_min(rDeltaT0_damped());
} }
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Overall = " Info<< " Overall = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }

View File

@ -36,13 +36,18 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
const scalar maxDeltaTFact = const scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL)); Foam::min
(
maxCo/(CoNum + SMALL),
maxCo/(surfaceFilm.CourantNumber() + SMALL)
);
const scalar deltaTFact = const scalar deltaTFact =
min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -81,9 +81,11 @@ License
// Limit the largest time scale (=> smallest reciprocal time) // Limit the largest time scale (=> smallest reciprocal time)
rDeltaT.clamp_min(1/maxDeltaT); rDeltaT.clamp_min(1/maxDeltaT);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Flow = " Info<< " Flow = "
<< gMin(1/rDeltaT.primitiveField()) << ", " << limits.min() << ", " << limits.max() << endl;
<< gMax(1/rDeltaT.primitiveField()) << endl;
} }
// Reaction source time scale // Reaction source time scale
@ -105,9 +107,11 @@ License
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT); rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
auto limits = gMinMax(rDeltaTT.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Temperature = " Info<< " Temperature = "
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", " << limits.min() << ", " << limits.max() << endl;
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
} }
// Update the boundary values of the reciprocal time-step // Update the boundary values of the reciprocal time-step
@ -130,9 +134,11 @@ License
// Update the boundary values of the reciprocal time-step // Update the boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions(); rDeltaT.correctBoundaryConditions();
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Overall = " Info<< " Overall = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }

View File

@ -36,13 +36,14 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
scalar maxDeltaTFact = scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL)); Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -98,10 +98,13 @@
// Update tho boundary values of the reciprocal time-step // Update tho boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions(); rDeltaT.correctBoundaryConditions();
Info<< "Flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
if (rDeltaTSmoothingCoeff < 1.0) if (rDeltaTSmoothingCoeff < 1.0)
{ {
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
@ -125,9 +128,13 @@
fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff); fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
} }
Info<< "Smoothed flow time scale min/max = " {
<< gMin(1/rDeltaT.primitiveField()) auto limits = gMinMax(rDeltaT.primitiveField());
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl; limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Smoothed flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
// Limit rate of change of time scale (=> smallest reciprocal time) // Limit rate of change of time scale (=> smallest reciprocal time)
// - reduce as much as required // - reduce as much as required
@ -136,8 +143,10 @@
{ {
rDeltaT.clamp_min(rDeltaT0_damped()); rDeltaT.clamp_min(rDeltaT0_damped());
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Damped flow time scale min/max = " Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }
} }

View File

@ -36,13 +36,14 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
scalar maxDeltaTFact = scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -37,11 +37,15 @@ if (adjustTimeStep)
if (CoNum > SMALL) if (CoNum > SMALL)
{ {
scalar maxDeltaTFact = scalar maxDeltaTFact =
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL)); Foam::min
(
maxCo/(CoNum + SMALL),
maxAcousticCo/(acousticCoNum + SMALL)
);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
maxDeltaTFact*runTime.deltaTValue(), maxDeltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -36,13 +36,13 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
scalar maxDeltaTFact = scalar maxDeltaTFact =
min Foam::min
( (
maxCo/(CoNum + SMALL), maxCo/(CoNum + SMALL),
min Foam::min
( (
maxAlphaCo/(alphaCoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL),
min Foam::min
( (
maxAlphaDdt/(ddtAlphaNum + SMALL), maxAlphaDdt/(ddtAlphaNum + SMALL),
maxDi/(DiNum + SMALL) maxDi/(DiNum + SMALL)
@ -50,16 +50,18 @@ if (adjustTimeStep)
) )
); );
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2); const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT
) )
); );
Info<< "deltaT = " << runTime.deltaTValue() << endl; Info<< "deltaT = " << runTime.deltaTValue() << endl;
} }

View File

@ -38,7 +38,9 @@
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = " Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl; Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = max(CoNum, UrCoNum); CoNum = Foam::max(CoNum, UrCoNum);
} }

View File

@ -31,7 +31,9 @@
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Flow time scale min/max = " Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
} }

View File

@ -8,5 +8,5 @@
Info<< "Max Ur Courant Number = " << UrCoNum << endl; Info<< "Max Ur Courant Number = " << UrCoNum << endl;
CoNum = max(CoNum, UrCoNum); CoNum = Foam::max(CoNum, UrCoNum);
} }

View File

@ -262,13 +262,12 @@ int main(int argc, char *argv[])
// Check constant profile // Check constant profile
{ {
const scalar max = gMax(one); auto limits = gMinMax(one);
const scalar min = gMin(one);
Info<< "Uniform one field min = " << min Info<< "Uniform one field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(max, 1) || isNotEqual(min, 1)) if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Uniform volVectorField not preserved." << "Uniform volVectorField not preserved."
@ -286,13 +285,12 @@ int main(int argc, char *argv[])
{ {
const scalarField diff = ccX-mesh.C().component(0); const scalarField diff = ccX-mesh.C().component(0);
const scalar max = gMax(diff); auto limits = gMinMax(diff);
const scalar min = gMin(diff);
Info<< "Linear profile field min = " << min Info<< "Linear profile field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(max, 0) || isNotEqual(min, 0)) if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Linear profile not preserved." << "Linear profile not preserved."
@ -309,13 +307,12 @@ int main(int argc, char *argv[])
// Check face field mapping // Check face field mapping
if (surfaceOne.size()) if (surfaceOne.size())
{ {
const scalar max = gMax(surfaceOne.primitiveField()); auto limits = gMinMax(surfaceOne.primitiveField());
const scalar min = gMin(surfaceOne.primitiveField());
Info<< "Uniform surface field min = " << min Info<< "Uniform surface field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(max, 1) || isNotEqual(min, 1)) if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Uniform surfaceScalarField not preserved." << "Uniform surfaceScalarField not preserved."

View File

@ -344,13 +344,12 @@ int main(int argc, char *argv[])
// Check constant profile // Check constant profile
{ {
const scalar max = gMax(one); auto limits = gMinMax(one);
const scalar min = gMin(one);
Info<< "Uniform one field min = " << min Info<< "Uniform one field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(min, 1) || isNotEqual(max, 1)) if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Uniform volVectorField not preserved." << "Uniform volVectorField not preserved."
@ -368,13 +367,12 @@ int main(int argc, char *argv[])
{ {
const scalarField diff = ccX-mesh.C().component(0); const scalarField diff = ccX-mesh.C().component(0);
const scalar max = gMax(diff); auto limits = gMinMax(diff);
const scalar min = gMin(diff);
Info<< "Linear profile field min = " << min Info<< "Linear profile field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(min, 0) || isNotEqual(max, 0)) if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
{ {
Info<< "Linear profile not preserved." Info<< "Linear profile not preserved."
<< " Min and max should both be 0.0. min:" << min << " Min and max should both be 0.0. min:" << min
@ -389,13 +387,12 @@ int main(int argc, char *argv[])
// Check face field mapping // Check face field mapping
if (surfaceOne.size()) if (surfaceOne.size())
{ {
const scalar max = gMax(surfaceOne.primitiveField()); auto limits = gMinMax(surfaceOne.primitiveField());
const scalar min = gMin(surfaceOne.primitiveField());
Info<< "Uniform surface field min = " << min Info<< "Uniform surface field min = "
<< " max = " << max << endl; << limits.min() << " max = " << limits.max() << endl;
if (isNotEqual(min, 1) || isNotEqual(max, 1)) if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Uniform surfaceScalarField not preserved." << "Uniform surfaceScalarField not preserved."

View File

@ -145,17 +145,22 @@ int main(int argc, char *argv[])
hexRef8 meshCutter(mesh); hexRef8 meshCutter(mesh);
// Some stats // Some stats
Info<< "Read mesh:" << nl {
<< " cells:" << mesh.globalData().nTotalCells() << nl auto cellLimits = gMinMax(meshCutter.cellLevel());
<< " faces:" << mesh.globalData().nTotalFaces() << nl auto pointLimits = gMinMax(meshCutter.pointLevel());
<< " points:" << mesh.globalData().nTotalPoints() << nl
<< " cellLevel :" Info<< "Read mesh:" << nl
<< " min:" << gMin(meshCutter.cellLevel()) << " cells:" << mesh.globalData().nTotalCells() << nl
<< " max:" << gMax(meshCutter.cellLevel()) << nl << " faces:" << mesh.globalData().nTotalFaces() << nl
<< " pointLevel :" << " points:" << mesh.globalData().nTotalPoints() << nl
<< " min:" << gMin(meshCutter.pointLevel()) << " cellLevel :"
<< " max:" << gMax(meshCutter.pointLevel()) << nl << " min:" << cellLimits.min()
<< endl; << " max:" << cellLimits.max() << nl
<< " pointLevel :"
<< " min:" << pointLimits.min()
<< " max:" << pointLimits.max() << nl
<< endl;
}
// Maintain 2:1 ratio // Maintain 2:1 ratio

View File

@ -37,7 +37,6 @@ License
const Foam::scalar Foam::edgeStats::edgeTol_ = 1e-3; const Foam::scalar Foam::edgeStats::edgeTol_ = 1e-3;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::direction Foam::edgeStats::getNormalDir Foam::direction Foam::edgeStats::getNormalDir
@ -45,26 +44,25 @@ Foam::direction Foam::edgeStats::getNormalDir
const twoDPointCorrector* correct2DPtr const twoDPointCorrector* correct2DPtr
) const ) const
{ {
direction dir = 3;
if (correct2DPtr) if (correct2DPtr)
{ {
const vector& normal = correct2DPtr->planeNormal(); const vector& normal = correct2DPtr->planeNormal();
if (mag(normal & vector(1, 0, 0)) > 1-edgeTol_) if (mag(normal.x()) > 1-edgeTol_)
{ {
dir = 0; return vector::X;
} }
else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol_) else if (mag(normal.y()) > 1-edgeTol_)
{ {
dir = 1; return vector::Y;
} }
else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol_) else if (mag(normal.z()) > 1-edgeTol_)
{ {
dir = 2; return vector::Z;
} }
} }
return dir;
return direction(3);
} }
@ -95,12 +93,9 @@ Foam::edgeStats::edgeStats(const polyMesh& mesh)
{ {
Info<< "Correcting for 2D motion" << endl << endl; Info<< "Correcting for 2D motion" << endl << endl;
autoPtr<twoDPointCorrector> correct2DPtr twoDPointCorrector correct2D(mesh);
(
new twoDPointCorrector(mesh)
);
normalDir_ = getNormalDir(&correct2DPtr()); normalDir_ = getNormalDir(&correct2D);
} }
} }
} }
@ -122,24 +117,15 @@ Foam::edgeStats::edgeStats
Foam::scalar Foam::edgeStats::minLen(Ostream& os) const Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
{ {
label nX = 0; label nAny(0);
label nY = 0; label nX(0);
label nZ = 0; label nY(0);
label nZ(0);
scalar minX = GREAT; scalarMinMax limitsAny(GREAT, -GREAT);
scalar maxX = -GREAT; scalarMinMax limitsX(limitsAny);
vector x(1, 0, 0); scalarMinMax limitsY(limitsAny);
scalarMinMax limitsZ(limitsAny);
scalar minY = GREAT;
scalar maxY = -GREAT;
vector y(0, 1, 0);
scalar minZ = GREAT;
scalar maxZ = -GREAT;
vector z(0, 0, 1);
scalar minOther = GREAT;
scalar maxOther = -GREAT;
const edgeList& edges = mesh_.edges(); const edgeList& edges = mesh_.edges();
@ -151,58 +137,75 @@ Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
eVec /= eMag; eVec /= eMag;
if (mag(eVec & x) > 1-edgeTol_) if (mag(eVec.x()) > 1-edgeTol_)
{ {
minX = min(minX, eMag); limitsX.add(eMag);
maxX = max(maxX, eMag);
nX++; nX++;
} }
else if (mag(eVec & y) > 1-edgeTol_) else if (mag(eVec.y()) > 1-edgeTol_)
{ {
minY = min(minY, eMag); limitsY.add(eMag);
maxY = max(maxY, eMag);
nY++; nY++;
} }
else if (mag(eVec & z) > 1-edgeTol_) else if (mag(eVec.z()) > 1-edgeTol_)
{ {
minZ = min(minZ, eMag); limitsZ.add(eMag);
maxZ = max(maxZ, eMag);
nZ++; nZ++;
} }
else else
{ {
minOther = min(minOther, eMag); limitsAny.add(eMag);
maxOther = max(maxOther, eMag); nAny++;
} }
} }
os << "Mesh bounding box:" << boundBox(mesh_.points()) << nl << nl os << "Mesh bounding box:" << boundBox(mesh_.points()) << nl << nl
<< "Mesh edge statistics:" << nl << "Mesh edge statistics:" << nl
<< " x aligned : number:" << nX << "\tminLen:" << minX << " x aligned : number:" << nX
<< "\tmaxLen:" << maxX << nl << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
<< " y aligned : number:" << nY << "\tminLen:" << minY << " y aligned : number:" << nY
<< "\tmaxLen:" << maxY << nl << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
<< " z aligned : number:" << nZ << "\tminLen:" << minZ << " z aligned : number:" << nZ
<< "\tmaxLen:" << maxZ << nl << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
<< " other : number:" << mesh_.nEdges() - nX - nY - nZ << " other : number:" << nAny
<< "\tminLen:" << minOther << "\tminLen:" << limitsAny.min()
<< "\tmaxLen:" << maxOther << nl << endl; << "\tmaxLen:" << limitsAny.max() << nl << endl;
if (normalDir_ == 0) if (normalDir_ == vector::X)
{ {
return min(minY, min(minZ, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsY.min(), limitsZ.min())
);
} }
else if (normalDir_ == 1) else if (normalDir_ == vector::Y)
{ {
return min(minX, min(minZ, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsX.min(), limitsZ.min())
);
} }
else if (normalDir_ == 2) else if (normalDir_ == vector::Z)
{ {
return min(minX, min(minY, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsX.min(), limitsY.min())
);
} }
else else
{ {
return min(minX, min(minY, min(minZ, minOther))); return Foam::min
(
limitsAny.min(),
Foam::min
(
limitsX.min(),
Foam::min(limitsY.min(), limitsZ.min())
)
);
} }
} }

View File

@ -81,26 +81,25 @@ void writeSet(const cellSet& cells, const string& msg)
direction getNormalDir(const twoDPointCorrector* correct2DPtr) direction getNormalDir(const twoDPointCorrector* correct2DPtr)
{ {
direction dir = 3;
if (correct2DPtr) if (correct2DPtr)
{ {
const vector& normal = correct2DPtr->planeNormal(); const vector& normal = correct2DPtr->planeNormal();
if (mag(normal & vector(1, 0, 0)) > 1-edgeTol) if (mag(normal.x()) > 1-edgeTol)
{ {
dir = 0; return vector::X;
} }
else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol) else if (mag(normal.y()) > 1-edgeTol)
{ {
dir = 1; return vector::Y;
} }
else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol) else if (mag(normal.z()) > 1-edgeTol)
{ {
dir = 2; return vector::Z;
} }
} }
return dir;
return direction(3);
} }
@ -109,89 +108,95 @@ direction getNormalDir(const twoDPointCorrector* correct2DPtr)
// directions but exclude component (0=x, 1=y, 2=z, other=none) // directions but exclude component (0=x, 1=y, 2=z, other=none)
scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt) scalar getEdgeStats(const primitiveMesh& mesh, const direction excludeCmpt)
{ {
label nX = 0; label nAny(0);
label nY = 0; label nX(0);
label nZ = 0; label nY(0);
label nZ(0);
scalar minX = GREAT; scalarMinMax limitsAny(GREAT, -GREAT);
scalar maxX = -GREAT; scalarMinMax limitsX(limitsAny);
vector x(1, 0, 0); scalarMinMax limitsY(limitsAny);
scalarMinMax limitsZ(limitsAny);
scalar minY = GREAT;
scalar maxY = -GREAT;
vector y(0, 1, 0);
scalar minZ = GREAT;
scalar maxZ = -GREAT;
vector z(0, 0, 1);
scalar minOther = GREAT;
scalar maxOther = -GREAT;
const edgeList& edges = mesh.edges(); const edgeList& edges = mesh.edges();
forAll(edges, edgei) for (const edge& e : edges)
{ {
const edge& e = edges[edgei];
vector eVec(e.vec(mesh.points())); vector eVec(e.vec(mesh.points()));
scalar eMag = mag(eVec); scalar eMag = mag(eVec);
eVec /= eMag; eVec /= eMag;
if (mag(eVec & x) > 1-edgeTol) if (mag(eVec.x()) > 1-edgeTol)
{ {
minX = min(minX, eMag); limitsX.add(eMag);
maxX = max(maxX, eMag);
nX++; nX++;
} }
else if (mag(eVec & y) > 1-edgeTol) else if (mag(eVec.y()) > 1-edgeTol)
{ {
minY = min(minY, eMag); limitsY.add(eMag);
maxY = max(maxY, eMag);
nY++; nY++;
} }
else if (mag(eVec & z) > 1-edgeTol) else if (mag(eVec.z()) > 1-edgeTol)
{ {
minZ = min(minZ, eMag); limitsZ.add(eMag);
maxZ = max(maxZ, eMag);
nZ++; nZ++;
} }
else else
{ {
minOther = min(minOther, eMag); limitsAny.add(eMag);
maxOther = max(maxOther, eMag); nAny++;
} }
} }
Info<< "Mesh bounding box:" << boundBox(mesh.points()) << nl << nl Info<< "Mesh bounding box:" << boundBox(mesh.points()) << nl << nl
<< "Mesh edge statistics:" << nl << "Mesh edge statistics:" << nl
<< " x aligned : number:" << nX << "\tminLen:" << minX << " x aligned : number:" << nX
<< "\tmaxLen:" << maxX << nl << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
<< " y aligned : number:" << nY << "\tminLen:" << minY << " y aligned : number:" << nY
<< "\tmaxLen:" << maxY << nl << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
<< " z aligned : number:" << nZ << "\tminLen:" << minZ << " z aligned : number:" << nZ
<< "\tmaxLen:" << maxZ << nl << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
<< " other : number:" << mesh.nEdges() - nX - nY - nZ << " other : number:" << nAny
<< "\tminLen:" << minOther << "\tminLen:" << limitsAny.min()
<< "\tmaxLen:" << maxOther << nl << endl; << "\tmaxLen:" << limitsAny.max() << nl << endl;
if (excludeCmpt == 0) if (excludeCmpt == vector::X)
{ {
return min(minY, min(minZ, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsY.min(), limitsZ.min())
);
} }
else if (excludeCmpt == 1) else if (excludeCmpt == vector::Y)
{ {
return min(minX, min(minZ, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsX.min(), limitsZ.min())
);
} }
else if (excludeCmpt == 2) else if (excludeCmpt == vector::Z)
{ {
return min(minX, min(minY, minOther)); return Foam::min
(
limitsAny.min(),
Foam::min(limitsX.min(), limitsY.min())
);
} }
else else
{ {
return min(minX, min(minY, min(minZ, minOther))); return Foam::min
(
limitsAny.min(),
Foam::min
(
limitsX.min(),
Foam::min(limitsY.min(), limitsZ.min())
)
);
} }
} }

View File

@ -63,96 +63,72 @@ static const scalar edgeTol = 1e-3;
// Print edge statistics on mesh. // Print edge statistics on mesh.
void printEdgeStats(const polyMesh& mesh) void printEdgeStats(const polyMesh& mesh)
{ {
label nX = 0; label nAny(0);
label nY = 0; label nX(0);
label nZ = 0; label nY(0);
label nZ(0);
scalar minX = GREAT; scalarMinMax limitsAny(GREAT, -GREAT);
scalar maxX = -GREAT; scalarMinMax limitsX(limitsAny);
static const vector x(1, 0, 0); scalarMinMax limitsY(limitsAny);
scalarMinMax limitsZ(limitsAny);
scalar minY = GREAT;
scalar maxY = -GREAT;
static const vector y(0, 1, 0);
scalar minZ = GREAT;
scalar maxZ = -GREAT;
static const vector z(0, 0, 1);
scalar minOther = GREAT;
scalar maxOther = -GREAT;
bitSet isMasterEdge(syncTools::getMasterEdges(mesh)); bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
const edgeList& edges = mesh.edges(); const edgeList& edges = mesh.edges();
forAll(edges, edgeI) for (const label edgei : isMasterEdge)
{ {
if (isMasterEdge.test(edgeI)) const edge& e = edges[edgei];
vector eVec(e.vec(mesh.points()));
scalar eMag = mag(eVec);
eVec /= eMag;
if (mag(eVec.x()) > 1-edgeTol)
{ {
const edge& e = edges[edgeI]; limitsX.add(eMag);
nX++;
vector eVec(e.vec(mesh.points())); }
else if (mag(eVec.y()) > 1-edgeTol)
scalar eMag = mag(eVec); {
limitsY.add(eMag);
eVec /= eMag; nY++;
}
if (mag(eVec & x) > 1-edgeTol) else if (mag(eVec.z()) > 1-edgeTol)
{ {
minX = min(minX, eMag); limitsZ.add(eMag);
maxX = max(maxX, eMag); nZ++;
nX++; }
} else
else if (mag(eVec & y) > 1-edgeTol) {
{ limitsAny.add(eMag);
minY = min(minY, eMag); nAny++;
maxY = max(maxY, eMag);
nY++;
}
else if (mag(eVec & z) > 1-edgeTol)
{
minZ = min(minZ, eMag);
maxZ = max(maxZ, eMag);
nZ++;
}
else
{
minOther = min(minOther, eMag);
maxOther = max(maxOther, eMag);
}
} }
} }
label nEdges = mesh.nEdges();
reduce(nEdges, sumOp<label>());
reduce(nX, sumOp<label>()); reduce(nX, sumOp<label>());
reduce(nY, sumOp<label>()); reduce(nY, sumOp<label>());
reduce(nZ, sumOp<label>()); reduce(nZ, sumOp<label>());
reduce(nAny, sumOp<label>());
reduce(minX, minOp<scalar>()); reduce(limitsX, sumOp<scalarMinMax>());
reduce(maxX, maxOp<scalar>()); reduce(limitsY, sumOp<scalarMinMax>());
reduce(limitsZ, sumOp<scalarMinMax>());
reduce(minY, minOp<scalar>()); reduce(limitsAny, sumOp<scalarMinMax>());
reduce(maxY, maxOp<scalar>());
reduce(minZ, minOp<scalar>());
reduce(maxZ, maxOp<scalar>());
reduce(minOther, minOp<scalar>());
reduce(maxOther, maxOp<scalar>());
Info<< "Mesh edge statistics:" << nl Info<< "Mesh edge statistics:" << nl
<< " x aligned : number:" << nX << "\tminLen:" << minX << " x aligned : number:" << nX
<< "\tmaxLen:" << maxX << nl << "\tminLen:" << limitsX.min() << "\tmaxLen:" << limitsX.max() << nl
<< " y aligned : number:" << nY << "\tminLen:" << minY << " y aligned : number:" << nY
<< "\tmaxLen:" << maxY << nl << "\tminLen:" << limitsY.min() << "\tmaxLen:" << limitsY.max() << nl
<< " z aligned : number:" << nZ << "\tminLen:" << minZ << " z aligned : number:" << nZ
<< "\tmaxLen:" << maxZ << nl << "\tminLen:" << limitsZ.min() << "\tmaxLen:" << limitsZ.max() << nl
<< " other : number:" << nEdges - nX - nY - nZ << " other : number:" << nAny
<< "\tminLen:" << minOther << "\tminLen:" << limitsAny.min()
<< "\tmaxLen:" << maxOther << nl << endl; << "\tmaxLen:" << limitsAny.max() << nl << endl;
} }

View File

@ -167,18 +167,24 @@ int main(int argc, char *argv[])
Info<< "Generating kinetic energy field" << endl; Info<< "Generating kinetic energy field" << endl;
volScalarField k("k", 0.5*magSqr(U)); volScalarField k("k", 0.5*magSqr(U));
k.write(); k.write();
auto limits = gMinMax(k);
auto avg = gAverage(k);
Info<< "min/max/average k = " Info<< "min/max/average k = "
<< gMin(k) << ", " << gMax(k) << ", " << gAverage(k) << limits.min() << ", " << limits.max() << ", " << avg << endl;
<< endl;
} }
{ {
Info<< "Generating div(U) field" << endl; Info<< "Generating div(U) field" << endl;
volScalarField divU(fvc::div(U)); volScalarField divU(fvc::div(U));
divU.write(); divU.write();
auto limits = gMinMax(divU);
auto avg = gAverage(divU);
Info<< "min/max/average div(U) = " Info<< "min/max/average div(U) = "
<< gMin(divU) << ", " << gMax(divU) << ", " << gAverage(divU) << limits.min() << ", " << limits.max() << ", " << avg << endl;
<< endl;
} }
Info<< nl; Info<< nl;

View File

@ -223,11 +223,16 @@ int main(int argc, char *argv[])
Info<< "Writing new alpha field " << alpha1.name() << endl; Info<< "Writing new alpha field " << alpha1.name() << endl;
alpha1.write(); alpha1.write();
const scalarField& alpha = alpha1.internalField(); {
const auto& alpha = alpha1.primitiveField();
Info<< "sum(alpha*V):" << gSum(mesh.V()*alpha) auto limits = gMinMax(alpha);
<< ", 1-max(alpha1): " << 1 - gMax(alpha) auto total = gWeightedSum(mesh.V(), alpha);
<< " min(alpha1): " << gMin(alpha) << endl;
Info<< "sum(alpha*V):" << total
<< ", 1-max(alpha1): " << 1 - limits.max()
<< " min(alpha1): " << limits.min() << endl;
}
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;

View File

@ -180,8 +180,9 @@ void Foam::combustionModels::EDC<ReactionThermo>::correct()
kappa_.correctBoundaryConditions(); kappa_.correctBoundaryConditions();
} }
Info<< "Chemistry time solved max/min : " auto limits = gMinMax(tauStar);
<< gMax(tauStar) << " / " << gMin(tauStar) << endl; Info<< "Chemistry time solved min/max : "
<< limits.min() << ", " << limits.max() << endl;
this->chemistryPtr_->solve(tauStar); this->chemistryPtr_->solve(tauStar);
} }

View File

@ -2022,8 +2022,11 @@ bool Foam::interfaceTrackingFvMesh::update()
const scalarField& K = aMesh().faceCurvatures().internalField(); const scalarField& K = aMesh().faceCurvatures().internalField();
Info<< "Free surface curvature: min = " << gMin(K) auto limits = gMinMax(K);
<< ", max = " << gMax(K) << ", average = " << gAverage(K) << nl;
Info<< "Free surface curvature: min = " << limits.min()
<< ", max = " << limits.max()
<< ", average = " << gAverage(K) << nl;
timeIndex_ = mesh().time().timeIndex(); timeIndex_ = mesh().time().timeIndex();
} }

View File

@ -879,10 +879,13 @@ bool Foam::motionSmootherAlgo::scaleMesh
vector::zero // null value vector::zero // null value
); );
Info<< "Moving mesh using displacement scaling :" {
<< " min:" << gMin(scale_.primitiveField()) auto limits = gMinMax(scale_.primitiveField());
<< " max:" << gMax(scale_.primitiveField()) Info<< "Moving mesh using displacement scaling :"
<< endl; << " min:" << limits.min()
<< " max:" << limits.max()
<< endl;
}
// Get points using current displacement and scale. Optionally 2D corrected. // Get points using current displacement and scale. Optionally 2D corrected.
pointField newPoints(curPoints()); pointField newPoints(curPoints());
@ -1018,9 +1021,11 @@ bool Foam::motionSmootherAlgo::scaleMesh
if (debug) if (debug)
{ {
auto limits = gMinMax(scale_);
Pout<< "scale_ after smoothing :" Pout<< "scale_ after smoothing :"
<< " min:" << Foam::gMin(scale_) << " min:" << limits.min()
<< " max:" << Foam::gMax(scale_) << " max:" << limits.max()
<< endl; << endl;
} }

View File

@ -166,9 +166,7 @@ void Foam::componentDisplacementMotionSolver::updateMesh(const mapPolyMesh& mpm)
); );
// Get extents of points0 and points and determine scale // Get extents of points0 and points and determine scale
const scalar scale = const scalar scale = gMinMax(points0_).span() / gMinMax(points).span();
(gMax(points0_)-gMin(points0_))
/(gMax(points)-gMin(points));
scalarField newPoints0(mpm.pointMap().size()); scalarField newPoints0(mpm.pointMap().size());

View File

@ -138,16 +138,18 @@ void Foam::displacementInterpolationMotionSolver::calcInterpolation()
scalar minCoord = VGREAT; scalar minCoord = VGREAT;
scalar maxCoord = -VGREAT; scalar maxCoord = -VGREAT;
forAll(fz().meshPoints(), localI) scalarMinMax limits;
for (const label pointi : fz().meshPoints())
{ {
label pointi = fz().meshPoints()[localI];
const scalar coord = points0()[pointi][dir]; const scalar coord = points0()[pointi][dir];
minCoord = min(minCoord, coord); limits.add(coord);
maxCoord = max(maxCoord, coord);
} }
zoneCoordinates[2*i] = returnReduce(minCoord, minOp<scalar>()); reduce(limits, sumOp<scalarMinMax>());
zoneCoordinates[2*i+1] = returnReduce(maxCoord, maxOp<scalar>());
zoneCoordinates[2*i] = limits.min();
zoneCoordinates[2*i+1] = limits.max();
if (debug) if (debug)
{ {
@ -167,8 +169,13 @@ void Foam::displacementInterpolationMotionSolver::calcInterpolation()
// Check if we have static min and max mesh bounds // Check if we have static min and max mesh bounds
const scalarField meshCoords(points0().component(dir)); const scalarField meshCoords(points0().component(dir));
scalar minCoord = gMin(meshCoords); scalar minCoord, maxCoord;
scalar maxCoord = gMax(meshCoords); {
auto limits = gMinMax(meshCoords);
minCoord = limits.min();
maxCoord = limits.max();
}
if (debug) if (debug)
{ {

View File

@ -386,15 +386,21 @@ void Foam::displacementLayeredMotionMotionSolver::cellZoneSolve
patchi patchi
); );
DebugInfo if (debug)
<< "For cellZone:" << cellZoneI {
<< " for faceZone:" << fz.name() auto limits = gMinMax(tseed());
<< " nPoints:" << tseed().size() auto avg = gAverage(tseed());
<< " have patchField:"
<< " max:" << gMax(tseed()) Info
<< " min:" << gMin(tseed()) << "For cellZone:" << cellZoneI
<< " avg:" << gAverage(tseed()) << " for faceZone:" << fz.name()
<< endl; << " nPoints:" << tseed().size()
<< " have patchField:"
<< " min:" << limits.min()
<< " max:" << limits.max()
<< " avg:" << avg
<< endl;
}
// Set distance and transported value // Set distance and transported value

View File

@ -175,10 +175,13 @@ tmp<areaVectorField> edgeLimitedGrad<scalar>::calcGrad
if (fa::debug) if (fa::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vsf.name() Info<< "gradient limiter for: " << vsf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
g.primitiveFieldRef() *= limiter; g.primitiveFieldRef() *= limiter;
@ -312,10 +315,13 @@ tmp<areaTensorField> edgeLimitedGrad<vector>::calcGrad
if (fa::debug) if (fa::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vvf.name() Info<< "gradient limiter for: " << vvf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
g.primitiveFieldRef() *= limiter; g.primitiveFieldRef() *= limiter;

View File

@ -221,10 +221,13 @@ tmp<areaVectorField> faceLimitedGrad<scalar>::calcGrad
if (fa::debug) if (fa::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vsf.name() Info<< "gradient limiter for: " << vsf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
g.primitiveFieldRef() *= limiter; g.primitiveFieldRef() *= limiter;
@ -370,10 +373,13 @@ tmp<areaTensorField> faceLimitedGrad<vector>::calcGrad
if (fa::debug) if (fa::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vsf.name() Info<< "gradient limiter for: " << vsf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
tensorField& gIf = g.primitiveFieldRef(); tensorField& gIf = g.primitiveFieldRef();

View File

@ -36,11 +36,13 @@ Description
if (adjustTimeStep) if (adjustTimeStep)
{ {
scalar maxDeltaTFact = maxCo/(CoNum + SMALL); scalar maxDeltaTFact = maxCo/(CoNum + SMALL);
scalar deltaTFact = min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
const scalar deltaTFact =
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
deltaTFact*runTime.deltaTValue(), deltaTFact*runTime.deltaTValue(),
maxDeltaT maxDeltaT

View File

@ -38,10 +38,10 @@ if (adjustTimeStep)
{ {
runTime.setDeltaT runTime.setDeltaT
( (
min Foam::min
( (
maxCo*runTime.deltaTValue()/CoNum, maxCo*runTime.deltaTValue()/CoNum,
min(runTime.deltaTValue(), maxDeltaT) Foam::min(runTime.deltaTValue(), maxDeltaT)
) )
); );
} }

View File

@ -496,16 +496,15 @@ void Foam::electrostaticDepositionFvPatchScalarField::updateCoeffs()
timei_ = db().time().timeIndex(); timei_ = db().time().timeIndex();
{ {
const scalar hMin = gMin(h_); auto limits = gMinMax(h_);
const scalar hMax = gMax(h_); auto avg = gAverage(h_);
const scalar hAvg = gAverage(h_);
if (Pstream::master()) if (UPstream::master())
{ {
Info<< " patch: " << patch().name() Info<< " patch: " << patch().name()
<< ", h: min = " << hMin << ", h: min = " << limits.min()
<< ", max = " << hMax << ", max = " << limits.max()
<< ", average = " << hAvg << nl << ", average = " << avg << nl
<< endl; << endl;
} }
} }

View File

@ -175,11 +175,14 @@ void Foam::mappedFieldFvPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< "operating on field:" << this->internalField().name() Info<< "operating on field:" << this->internalField().name()
<< " patch:" << this->patch().name() << " patch:" << this->patch().name()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< endl; << endl;
} }

View File

@ -173,6 +173,9 @@ void Foam::mappedMixedFieldFvPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< this->patch().boundaryMesh().mesh().name() << ':' Info<< this->patch().boundaryMesh().mesh().name() << ':'
<< this->patch().name() << ':' << this->patch().name() << ':'
<< this->internalField().name() << " <- " << this->internalField().name() << " <- "
@ -180,9 +183,9 @@ void Foam::mappedMixedFieldFvPatchField<Type>::updateCoeffs()
<< this->mapper_.samplePatch() << ':' << this->mapper_.samplePatch() << ':'
<< this->fieldName_ << " :" << this->fieldName_ << " :"
<< " value " << " value "
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< endl; << endl;
} }
} }

View File

@ -122,12 +122,15 @@ void Foam::mappedFixedValueFvPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< "mapped on field:" Info<< "mapped on field:"
<< this->internalField().name() << this->internalField().name()
<< " patch:" << this->patch().name() << " patch:" << this->patch().name()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< endl; << endl;
} }

View File

@ -215,6 +215,9 @@ void Foam::mappedMixedFvPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< this->patch().boundaryMesh().mesh().name() << ':' Info<< this->patch().boundaryMesh().mesh().name() << ':'
<< this->patch().name() << ':' << this->patch().name() << ':'
<< this->internalField().name() << " <- " << this->internalField().name() << " <- "
@ -222,9 +225,9 @@ void Foam::mappedMixedFvPatchField<Type>::updateCoeffs()
<< this->mapper_.samplePatch() << ':' << this->mapper_.samplePatch() << ':'
<< this->fieldName_ << " :" << this->fieldName_ << " :"
<< " value " << " value "
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< endl; << endl;
} }
} }

View File

@ -181,9 +181,12 @@ void Foam::timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this) auto limits = gMinMax(*this);
<< " max:" << gMax(*this) auto avg = gAverage(*this);
<< " avg:" << gAverage(*this) << endl;
Pout<< "updateCoeffs : set fixedValue to min:" << limits.min()
<< " max:" << limits.max()
<< " avg:" << avg << endl;
} }
fixedValueFvPatchField<Type>::updateCoeffs(); fixedValueFvPatchField<Type>::updateCoeffs();

View File

@ -962,6 +962,8 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(*this);
Info<< "Magnitude of bulk velocity: " << UBulk << endl; Info<< "Magnitude of bulk velocity: " << UBulk << endl;
Info<< "Number of eddies: " Info<< "Number of eddies: "
@ -969,7 +971,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::updateCoeffs()
<< endl; << endl;
Info<< "Patch:" << patch().patch().name() Info<< "Patch:" << patch().patch().name()
<< " min/max(U):" << gMin(U) << ", " << gMax(U) << " min/max(U):" << limits.min() << ", " << limits.max()
<< endl; << endl;
if (db().time().writeTime()) if (db().time().writeTime())

View File

@ -210,8 +210,12 @@ void Foam::waveSurfacePressureFvPatchScalarField::updateCoeffs()
} }
Info<< "min/max zetap = " << gMin(zetap & nf()) << ", " {
<< gMax(zetap & nf()) << endl; auto limits = gMinMax(zetap & nf());
Info<< "min/max zetap = "
<< limits.min() << ", " << limits.max() << endl;
}
// Update the surface pressure // Update the surface pressure
const uniformDimensionedVectorField& g = const uniformDimensionedVectorField& g =

View File

@ -186,12 +186,12 @@ tmp<surfaceScalarField> ddtScheme<Type>::fvcDdtPhiCoeff
if (debug > 1) if (debug > 1)
{ {
auto limits = gMinMax(ddtCouplingCoeff.primitiveField());
auto avg = gAverage(ddtCouplingCoeff.primitiveField());
InfoInFunction InfoInFunction
<< "ddtCouplingCoeff mean max min = " << "ddtCouplingCoeff mean max min = "
<< gAverage(ddtCouplingCoeff.primitiveField()) << avg << ' ' << limits.max() << ' ' << limits.min() << endl;
<< " " << gMax(ddtCouplingCoeff.primitiveField())
<< " " << gMin(ddtCouplingCoeff.primitiveField())
<< endl;
} }
return tddtCouplingCoeff; return tddtCouplingCoeff;
@ -267,12 +267,12 @@ tmp<surfaceScalarField> ddtScheme<Type>::fvcDdtPhiCoeffExperimental
if (debug > 1) if (debug > 1)
{ {
auto limits = gMinMax(ddtCouplingCoeff.primitiveField());
auto avg = gAverage(ddtCouplingCoeff.primitiveField());
InfoInFunction InfoInFunction
<< "ddtCouplingCoeff mean max min = " << "ddtCouplingCoeff mean max min = "
<< gAverage(ddtCouplingCoeff.primitiveField()) << avg << ' ' << limits.max() << ' ' << limits.min() << endl;
<< " " << gMax(ddtCouplingCoeff.primitiveField())
<< " " << gMin(ddtCouplingCoeff.primitiveField())
<< endl;
} }
return tddtCouplingCoeff; return tddtCouplingCoeff;

View File

@ -215,10 +215,13 @@ Foam::fv::cellLimitedGrad<Type, Limiter>::calcGrad
if (fv::debug) if (fv::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vsf.name() Info<< "gradient limiter for: " << vsf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
limitGradient(limiter, g); limitGradient(limiter, g);

View File

@ -162,10 +162,13 @@ Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad
if (fv::debug) if (fv::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vsf.name() Info<< "gradient limiter for: " << vsf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
g.primitiveFieldRef() *= limiter; g.primitiveFieldRef() *= limiter;
@ -323,10 +326,13 @@ Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad
if (fv::debug) if (fv::debug)
{ {
auto limits = gMinMax(limiter);
auto avg = gAverage(limiter);
Info<< "gradient limiter for: " << vvf.name() Info<< "gradient limiter for: " << vvf.name()
<< " max = " << gMax(limiter) << " min = " << limits.min()
<< " min = " << gMin(limiter) << " max = " << limits.max()
<< " average: " << gAverage(limiter) << endl; << " average: " << avg << endl;
} }
g.primitiveFieldRef() *= limiter; g.primitiveFieldRef() *= limiter;

View File

@ -814,6 +814,7 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
Foam::acos(faceOrthogonality) Foam::acos(faceOrthogonality)
) )
); );
Pout<< " iter:" << iter Pout<< " iter:" << iter
<< " nClipped:" << nClipped << " nClipped:" << nClipped
<< " average displacement:" << gAverage(magCorrection) << " average displacement:" << gAverage(magCorrection)
@ -845,10 +846,13 @@ void Foam::averageNeighbourFvGeometryScheme::movePoints()
if (debug) if (debug)
{ {
auto limits = gMinMax(cellWeight);
auto avg = gAverage(cellWeight);
Pout<< "averageNeighbourFvGeometryScheme::movePoints() :" Pout<< "averageNeighbourFvGeometryScheme::movePoints() :"
<< " averageNeighbour weight" << " averageNeighbour weight"
<< " max:" << gMax(cellWeight) << " min:" << gMin(cellWeight) << " min:" << limits.min() << " max:" << limits.max()
<< " average:" << gAverage(cellWeight) << endl; << " average:" << avg << endl;
// Dump lines from old to new location // Dump lines from old to new location
const fileName tp(mesh_.time().timePath()); const fileName tp(mesh_.time().timePath());

View File

@ -120,8 +120,11 @@ void Foam::cellAspectRatio::calcAspectRatio()
if (debug) if (debug)
{ {
InfoInFunction << "Calculated cell aspect ratio min:" << gMin(aRatio) auto limits = gMinMax(aRatio);
<< " max:" << gMax(aRatio) << " average:" << gAverage(aRatio) auto avg = gAverage(aRatio);
InfoInFunction << "Calculated cell aspect ratio min:" << limits.min()
<< " max:" << limits.max() << " average:" << avg
<< endl; << endl;
} }
} }

View File

@ -434,10 +434,13 @@ void Foam::highAspectRatioFvGeometryScheme::movePoints()
if (debug) if (debug)
{ {
auto limits = gMinMax(cellWeight);
auto avg = gAverage(cellWeight);
Pout<< "highAspectRatioFvGeometryScheme::movePoints() :" Pout<< "highAspectRatioFvGeometryScheme::movePoints() :"
<< " highAspectRatio weight" << " highAspectRatio weight"
<< " max:" << gMax(cellWeight) << " min:" << gMin(cellWeight) << " min:" << limits.max() << " max:" << limits.max()
<< " average:" << gAverage(cellWeight) << endl; << " average:" << avg << endl;
} }
vectorField faceAreas(mesh_.faceAreas()); vectorField faceAreas(mesh_.faceAreas());

View File

@ -88,52 +88,52 @@ void Foam::functionObjects::AMIWeights::reportPatch
const Switch distributed = pp.AMI().distributed(); const Switch distributed = pp.AMI().distributed();
const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum(); const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum();
const scalar srcMinWeight = gMin(srcWeightsSum); const auto srcWeightLimits = gMinMax(srcWeightsSum);
const scalar srcMaxWeight = gMax(srcWeightsSum); const auto srcWeightAvg = gAverage(srcWeightsSum);
const scalar srcAveWeight = gAverage(srcWeightsSum);
const labelListList& srcAddress = pp.AMI().srcAddress(); const labelListList& srcAddress = pp.AMI().srcAddress();
label srcMinNbr = labelMax;
label srcMaxNbr = labelMin; labelMinMax srcNbrLimits(labelMax, labelMin);
scalar srcAveNbr = 0; scalar srcNbrAvg(0);
for (const labelList& srcFace : srcAddress) for (const labelList& srcFace : srcAddress)
{ {
const label n = srcFace.size(); const label n = srcFace.size();
srcAveNbr += n;
srcMinNbr = min(srcMinNbr, n); srcNbrAvg += n;
srcMaxNbr = max(srcMaxNbr, n); srcNbrLimits.add(n);
} }
reduce(srcMinNbr, minOp<label>()); {
reduce(srcMaxNbr, maxOp<label>()); reduce(srcNbrLimits, sumOp<labelMinMax>());
srcAveNbr = label count = srcAddress.size();
returnReduce(srcAveNbr, sumOp<scalar>()) sumReduce(srcNbrAvg, count);
/(returnReduce(srcAddress.size(), sumOp<scalar>()) + ROOTVSMALL); srcNbrAvg /= (count + ROOTVSMALL);
}
const scalarField& tgtWeightsSum = pp.AMI().tgtWeightsSum(); const scalarField& tgtWeightsSum = pp.AMI().tgtWeightsSum();
const scalar tgtMinWeight = gMin(tgtWeightsSum); const auto tgtWeightLimits = gMinMax(tgtWeightsSum);
const scalar tgtMaxWeight = gMax(tgtWeightsSum); const auto tgtWeightAvg = gAverage(tgtWeightsSum);
const scalar tgtAveWeight = gAverage(tgtWeightsSum);
const labelListList& tgtAddress = pp.AMI().tgtAddress(); const labelListList& tgtAddress = pp.AMI().tgtAddress();
label tgtMinNbr = labelMax;
label tgtMaxNbr = labelMin; labelMinMax tgtNbrLimits(labelMax, labelMin);
scalar tgtAveNbr = 0; scalar tgtNbrAvg(0);
for (const labelList& tgtFace : tgtAddress) for (const labelList& tgtFace : tgtAddress)
{ {
const label n = tgtFace.size(); const label n = tgtFace.size();
tgtAveNbr += n;
tgtMinNbr = min(tgtMinNbr, n); tgtNbrAvg += n;
tgtMaxNbr = max(tgtMaxNbr, n); tgtNbrLimits.add(n);
} }
reduce(tgtMinNbr, minOp<label>()); {
reduce(tgtMaxNbr, maxOp<label>()); reduce(tgtNbrLimits, sumOp<labelMinMax>());
tgtAveNbr = label count = tgtAddress.size();
returnReduce(tgtAveNbr, sumOp<scalar>()) sumReduce(tgtNbrAvg, count);
/(returnReduce(tgtAddress.size(), sumOp<scalar>()) + ROOTVSMALL); tgtNbrAvg /= (count + ROOTVSMALL);
}
file() file()
<< mesh_.time().timeName() << tab << mesh_.time().timeName() << tab
@ -147,18 +147,18 @@ void Foam::functionObjects::AMIWeights::reportPatch
} }
file() file()
<< srcMinWeight << tab << srcWeightLimits.min() << tab
<< srcMaxWeight << tab << srcWeightLimits.max() << tab
<< srcAveWeight << tab << srcWeightAvg << tab
<< srcMinNbr << tab << srcNbrLimits.min() << tab
<< srcMaxNbr << tab << srcNbrLimits.max() << tab
<< srcAveNbr << tab << srcNbrAvg << tab
<< tgtMinWeight << tab << tgtWeightLimits.min() << tab
<< tgtMaxWeight << tab << tgtWeightLimits.max() << tab
<< tgtAveWeight << tab << tgtWeightAvg << tab
<< tgtMinNbr << tab << tgtNbrLimits.min() << tab
<< tgtMaxNbr << tab << tgtNbrLimits.max() << tab
<< tgtAveNbr << tab << tgtNbrAvg
<< endl; << endl;
Log << " Patches: " << nl Log << " Patches: " << nl
@ -176,34 +176,34 @@ void Foam::functionObjects::AMIWeights::reportPatch
Log << " | " << setw(w) << pp.name() Log << " | " << setw(w) << pp.name()
<< " | " << setw(w) << nbrPatchName << " | " << nl << " | " << setw(w) << nbrPatchName << " | " << nl
<< " min(weight) | " << setw(w) << srcMinWeight << " min(weight) | " << setw(w) << srcWeightLimits.min()
<< " | " << setw(w) << tgtMinWeight << " | " << nl << " | " << setw(w) << tgtWeightLimits.min() << " | " << nl
<< " max(weight) | " << setw(w) << srcMaxWeight << " max(weight) | " << setw(w) << srcWeightLimits.max()
<< " | " << setw(w) << tgtMaxWeight << " | " << nl << " | " << setw(w) << tgtWeightLimits.max() << " | " << nl
<< " ave(weight) | " << setw(w) << srcAveWeight << " ave(weight) | " << setw(w) << srcWeightAvg
<< " | " << setw(w) << tgtAveWeight << " | " << nl << " | " << setw(w) << tgtWeightAvg << " | " << nl
<< " min(address) | " << setw(w) << srcMinNbr << " min(address) | " << setw(w) << srcNbrLimits.min()
<< " | " << setw(w) << tgtMinNbr << " | " << nl << " | " << setw(w) << tgtNbrLimits.min() << " | " << nl
<< " max(address) | " << setw(w) << srcMaxNbr << " max(address) | " << setw(w) << srcNbrLimits.max()
<< " | " << setw(w) << tgtMaxNbr << " | " << nl << " | " << setw(w) << tgtNbrLimits.max() << " | " << nl
<< " ave(address) | " << setw(w) << srcAveNbr << " ave(address) | " << setw(w) << srcNbrAvg
<< " | " << setw(w) << tgtAveNbr << " | " << nl << " | " << setw(w) << tgtNbrAvg << " | " << nl
<< endl; << endl;
setResult(pp.name() + ":src", pp.name()); setResult(pp.name() + ":src", pp.name());
setResult(pp.name() + ":tgt", nbrPatchName); setResult(pp.name() + ":tgt", nbrPatchName);
setResult(pp.name() + ":src:min(weight)", srcMinWeight); setResult(pp.name() + ":src:min(weight)", srcWeightLimits.min());
setResult(pp.name() + ":src:max(weight)", srcMaxWeight); setResult(pp.name() + ":src:max(weight)", srcWeightLimits.max());
setResult(pp.name() + ":src:ave(weight)", srcAveWeight); setResult(pp.name() + ":src:ave(weight)", srcWeightAvg);
setResult(pp.name() + ":src:min(address)", srcMinNbr); setResult(pp.name() + ":src:min(address)", srcNbrLimits.min());
setResult(pp.name() + ":src:max(address)", srcMaxNbr); setResult(pp.name() + ":src:max(address)", srcNbrLimits.max());
setResult(pp.name() + ":src:ave(address)", srcAveNbr); setResult(pp.name() + ":src:ave(address)", srcNbrAvg);
setResult(pp.name() + ":tgt:min(weight)", tgtMinWeight); setResult(pp.name() + ":tgt:min(weight)", tgtWeightLimits.min());
setResult(pp.name() + ":tgt:max(weight)", tgtMaxWeight); setResult(pp.name() + ":tgt:max(weight)", tgtWeightLimits.max());
setResult(pp.name() + ":tgt:ave(weight)", tgtAveWeight); setResult(pp.name() + ":tgt:ave(weight)", tgtWeightAvg);
setResult(pp.name() + ":tgt:min(address)", tgtMinNbr); setResult(pp.name() + ":tgt:min(address)", tgtNbrLimits.min());
setResult(pp.name() + ":tgt:max(address)", tgtMaxNbr); setResult(pp.name() + ":tgt:max(address)", tgtNbrLimits.max());
setResult(pp.name() + ":tgt:ave(address)", tgtAveNbr); setResult(pp.name() + ":tgt:ave(address)", tgtNbrAvg);
} }

View File

@ -211,25 +211,24 @@ bool Foam::functionObjects::yPlus::write()
{ {
const scalarField& yPlusp = yPlusBf[patchi]; const scalarField& yPlusp = yPlusBf[patchi];
const scalar minYplus = gMin(yPlusp); auto limits = gMinMax(yPlusp);
const scalar maxYplus = gMax(yPlusp); auto avg = gAverage(yPlusp);
const scalar avgYplus = gAverage(yPlusp);
if (UPstream::master()) if (UPstream::master())
{ {
writeCurrentTime(file()); writeCurrentTime(file());
file() file()
<< token::TAB << patch.name() << token::TAB << patch.name()
<< token::TAB << minYplus << token::TAB << limits.min()
<< token::TAB << maxYplus << token::TAB << limits.max()
<< token::TAB << avgYplus << token::TAB << avg
<< endl; << endl;
} }
Log << " patch " << patch.name() Log << " patch " << patch.name()
<< " y+ : min = " << minYplus << " y+ : min = " << limits.min()
<< ", max = " << maxYplus << ", max = " << limits.max()
<< ", average = " << avgYplus << endl; << ", average = " << avg << endl;
} }
} }

View File

@ -552,9 +552,12 @@ void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs()
if (debug) if (debug)
{ {
Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this) auto limits = gMinMax(*this);
<< " max:" << gMax(*this) auto avg = gAverage(*this);
<< " avg:" << gAverage(*this) << endl;
Pout<< "updateCoeffs : set fixedValue to min:" << limits.min()
<< " max:" << limits.max()
<< " avg:" << avg << endl;
} }
fixedValuePointPatchField<Type>::updateCoeffs(); fixedValuePointPatchField<Type>::updateCoeffs();

View File

@ -195,23 +195,23 @@ Foam::heatExchangerModels::effectivenessTable::energyDensity
secondaryInletT_ += targetQdotRelax_*dT; secondaryInletT_ += targetQdotRelax_*dT;
} }
const scalarField TCells(T, cells); // start with a copy
scalarField deltaTCells(cells.size(), Zero); scalarField deltaTCells(T, cells);
Tref_ = 0; Tref_ = 0;
if (Qt_ > 0) if (Qt_ > 0)
{ {
Tref_ = gMax(TCells); Tref_ = gMax(deltaTCells);
forAll(deltaTCells, i) for (scalar& delta : deltaTCells)
{ {
deltaTCells[i] = max(Tref_ - TCells[i], scalar(0)); delta = Foam::max(Tref_ - delta, scalar(0));
} }
} }
else else
{ {
Tref_ = gMin(TCells); Tref_ = gMin(deltaTCells);
forAll(deltaTCells, i) for (scalar& delta : deltaTCells)
{ {
deltaTCells[i] = max(TCells[i] - Tref_, scalar(0)); delta = Foam::max(delta - Tref_, scalar(0));
} }
} }

View File

@ -950,13 +950,12 @@ void Foam::KinematicCloud<CloudType>::info()
alpha().write(); alpha().write();
} }
const scalar alphaMin = gMin(alpha().primitiveField()); auto limits = gMinMax(alpha().primitiveField());
const scalar alphaMax = gMax(alpha().primitiveField());
Log_<< " Min cell volume fraction = " << alphaMin << nl Log_<< " Min cell volume fraction = " << limits.min() << nl
<< " Max cell volume fraction = " << alphaMax << endl; << " Max cell volume fraction = " << limits.max() << endl;
if (alphaMax < SMALL) if (limits.max() < SMALL)
{ {
return; return;
} }
@ -969,7 +968,7 @@ void Foam::KinematicCloud<CloudType>::info()
if (n > 0) if (n > 0)
{ {
const scalar nPack = n*alphaMax/alpha()[celli]; const scalar nPack = n*limits.max()/alpha()[celli];
if (nPack < nMin) if (nPack < nMin)
{ {

View File

@ -283,13 +283,12 @@ void Foam::MPPICCloud<CloudType>::info()
tmp<volScalarField> alpha = this->theta(); tmp<volScalarField> alpha = this->theta();
const scalar alphaMin = gMin(alpha().primitiveField()); auto limits = gMinMax(alpha().primitiveField());
const scalar alphaMax = gMax(alpha().primitiveField());
Log_ << " Min cell volume fraction = " << alphaMin << nl Log_ << " Min cell volume fraction = " << limits.min() << nl
<< " Max cell volume fraction = " << alphaMax << endl; << " Max cell volume fraction = " << limits.max() << endl;
if (alphaMax < SMALL) if (limits.max() < SMALL)
{ {
return; return;
} }
@ -302,7 +301,7 @@ void Foam::MPPICCloud<CloudType>::info()
if (n > 0) if (n > 0)
{ {
const scalar nPack = n*alphaMax/alpha()[celli]; const scalar nPack = n*limits.max()/alpha()[celli];
if (nPack < nMin) if (nPack < nMin)
{ {

View File

@ -1676,8 +1676,7 @@ void Foam::snappyLayerDriver::calculateLayerThickness
GREAT // null value GREAT // null value
); );
//Info<< "calculateLayerThickness : min:" << gMin(thickness) //Info<< "calculateLayerThickness : " << gMinMax(thickness) << endl;
// << " max:" << gMax(thickness) << endl;
// Print a bit // Print a bit
{ {

View File

@ -2087,10 +2087,12 @@ Foam::vectorField Foam::snappySnapDriver::calcNearestSurface
scalarField magDisp(mag(patchDisp)); scalarField magDisp(mag(patchDisp));
auto limits = gMinMax(magDisp);
Info<< "Wanted displacement : average:" Info<< "Wanted displacement : average:"
<< meshRefinement::gAverage(isPatchMasterPoint, magDisp) << meshRefinement::gAverage(isPatchMasterPoint, magDisp)
<< " min:" << gMin(magDisp) << " min:" << limits.min()
<< " max:" << gMax(magDisp) << endl; << " max:" << limits.max() << endl;
} }
} }

View File

@ -279,37 +279,31 @@ void Foam::AMIInterpolation::normaliseWeights
} }
} }
if (output && comm != -1) if (output && comm != -1 && returnReduceOr(wght.size(), comm))
{ {
// Note: change global communicator since gMin,gAverage etc don't auto limits = gMinMax(wghtSum, comm);
// support user communicator auto avg = gAverage(wghtSum, comm);
const label oldWorldComm(UPstream::worldComm);
UPstream::worldComm = comm;
if (returnReduceOr(wght.size())) label nLow =
returnReduce(nLowWeight, sumOp<label>(), UPstream::msgType(), comm);
Info.masterStream(comm)
<< indent
<< "AMI: Patch " << patchName
<< " sum(weights)"
<< " min:" << limits.min()
<< " max:" << limits.max()
<< " average:" << avg << nl;
if (nLow)
{ {
Info.masterStream(comm) Info.masterStream(comm)
<< indent << indent
<< "AMI: Patch " << patchName << "AMI: Patch " << patchName
<< " sum(weights)" << " identified " << nLow
<< " min:" << gMin(wghtSum) << " faces with weights less than " << lowWeightTol
<< " max:" << gMax(wghtSum) << endl;
<< " average:" << gAverage(wghtSum) << nl;
const label nLow = returnReduce(nLowWeight, sumOp<label>());
if (nLow)
{
Info.masterStream(comm)
<< indent
<< "AMI: Patch " << patchName
<< " identified " << nLow
<< " faces with weights less than " << lowWeightTol
<< endl;
}
} }
UPstream::worldComm = oldWorldComm;
} }
} }

View File

@ -513,18 +513,29 @@ void Foam::cyclicPeriodicAMIPolyPatch::resetAMI() const
tgtWghtSum[faceI] = sum(AMIPtr_->tgtWeights()[faceI]); tgtWghtSum[faceI] = sum(AMIPtr_->tgtWeights()[faceI]);
} }
Info<< indent {
<< "AMI: Patch " << name() auto limits = gMinMax(srcWghtSum);
<< " sum(weights)" auto avg = gAverage(srcWghtSum);
<< " min:" << gMin(srcWghtSum)
<< " max:" << gMax(srcWghtSum) Info<< indent
<< " average:" << gAverage(srcWghtSum) << nl; << "AMI: Patch " << name()
Info<< indent << " sum(weights)"
<< "AMI: Patch " << neighbPatch().name() << " min:" << limits.min()
<< " sum(weights)" << " max:" << limits.max()
<< " min:" << gMin(tgtWghtSum) << " average:" << avg << nl;
<< " max:" << gMax(tgtWghtSum) }
<< " average:" << gAverage(tgtWghtSum) << nl;
{
auto limits = gMinMax(tgtWghtSum);
auto avg = gAverage(tgtWghtSum);
Info<< indent
<< "AMI: Patch " << neighbPatch().name()
<< " sum(weights)"
<< " min:" << limits.min()
<< " max:" << limits.max()
<< " average:" << avg << nl;
}
} }
} }
} }

View File

@ -747,9 +747,13 @@ Foam::PatchFunction1Types::MappedFile<Type>::value
if (debug) if (debug)
{ {
Pout<< "MappedFile<Type>::value : set fixedValue to min:" << gMin(fld) auto limits = gMinMax(fld);
<< " max:" << gMax(fld) auto avg = gAverage(fld);
<< " avg:" << gAverage(fld) << endl;
Pout<< "MappedFile<Type>::value : set fixedValue to min:"
<< limits.min()
<< " max:" << limits.max()
<< " avg:" << avg << endl;
} }
return this->transform(tfld); return this->transform(tfld);

View File

@ -231,7 +231,7 @@ void Foam::Helmholtz::regularise
); );
// Map result back to original field // Map result back to original field
result.rmap(resultSub, cellMap); result.rmap(resultSub, cellMap);
Info<< "min max " << gMin(result) << " " << gMax(result) << endl; Info<< "min max " << gMinMax(result) << endl;
return; return;
} }
} }

View File

@ -430,21 +430,29 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::correctInterfaceThermo()
Tf = (H1*T1 + H2*T2 + iDmdtNew*L)/(H1 + H2); Tf = (H1*T1 + H2*T2 + iDmdtNew*L)/(H1 + H2);
Info<< "Tf." << pair.name() {
<< ": min = " << gMin(Tf.primitiveField()) auto limits = gMinMax(Tf.primitiveField());
<< ", mean = " << gAverage(Tf.primitiveField()) auto avg = gAverage(Tf.primitiveField());
<< ", max = " << gMax(Tf.primitiveField())
<< endl; Info<< "Tf." << pair.name()
<< ": min = " << limits.min()
<< ", mean = " << avg
<< ", max = " << limits.max()
<< endl;
}
scalar iDmdtRelax(this->mesh().fieldRelaxationFactor("iDmdt")); scalar iDmdtRelax(this->mesh().fieldRelaxationFactor("iDmdt"));
iDmdt = (1 - iDmdtRelax)*iDmdt + iDmdtRelax*iDmdtNew; iDmdt = (1 - iDmdtRelax)*iDmdt + iDmdtRelax*iDmdtNew;
if (phaseChange_) if (phaseChange_)
{ {
auto limits = gMinMax(iDmdt.primitiveField());
auto avg = gAverage(iDmdt.primitiveField());
Info<< "iDmdt." << pair.name() Info<< "iDmdt." << pair.name()
<< ": min = " << gMin(iDmdt.primitiveField()) << ": min = " << limits.min()
<< ", mean = " << gAverage(iDmdt.primitiveField()) << ", mean = " << avg
<< ", max = " << gMax(iDmdt.primitiveField()) << ", max = " << limits.max()
<< ", integral = " << fvc::domainIntegrate(iDmdt).value() << ", integral = " << fvc::domainIntegrate(iDmdt).value()
<< endl; << endl;
} }
@ -525,10 +533,13 @@ Foam::ThermalPhaseChangePhaseSystem<BasePhaseSystem>::correctInterfaceThermo()
if (wallBoilingActive) if (wallBoilingActive)
{ {
auto limits = gMinMax(wDmdt.primitiveField());
auto avg = gAverage(wDmdt.primitiveField());
Info<< "wDmdt." << pair.name() Info<< "wDmdt." << pair.name()
<< ": min = " << gMin(wDmdt.primitiveField()) << ": min = " << limits.min()
<< ", mean = " << gAverage(wDmdt.primitiveField()) << ", mean = " << avg
<< ", max = " << gMax(wDmdt.primitiveField()) << ", max = " << limits.max()
<< ", integral = " << fvc::domainIntegrate(wDmdt).value() << ", integral = " << fvc::domainIntegrate(wDmdt).value()
<< endl; << endl;
} }

View File

@ -505,13 +505,12 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
{ {
Info<< "alphat for vapour : " << nl << endl; Info<< "alphat for vapour : " << nl << endl;
Info<< " alphatEffv: " << gMin(vaporw*(*this + alphaw)) Info<< " alphatEffv: " << gMinMax(vaporw*(*this + alphaw))
<< " - " << gMax(vaporw*(*this + alphaw)) << endl; << endl;
const scalarField qEff(vaporw*(*this + alphaw)*hewv.snGrad()); const scalarField qEff(vaporw*(*this + alphaw)*hewv.snGrad());
Info<< " qEffVap: " << gMin(qEff) << " - " Info<< " qEffVap: " << gMinMax(qEff) << endl;
<< gMax(qEff) << endl;
scalar Qeff = gWeightedSum(patch().magSf(), qEff); scalar Qeff = gWeightedSum(patch().magSf(), qEff);
Info<< " Effective heat transfer rate to vapor:" << Qeff Info<< " Effective heat transfer rate to vapor:" << Qeff
@ -1096,24 +1095,16 @@ void alphatWallBoilingWallFunctionFvPatchScalarField::updateCoeffs()
fLiquid*liquidw*(*this + alphaw)*hew.snGrad() fLiquid*liquidw*(*this + alphaw)*hew.snGrad()
); );
Info<< "alphat for liquid: " << nl << endl; Info<< "alphat for liquid: " << nl << nl;
Info<< " qEffLiq: " << gMinMax(qEff) << nl;
Info<< " alphatl: " << gMinMax(*this) << nl;
Info<< " dmdt: " << gMinMax(dmdt_) << nl;
Info<< " alphatlEff: "
<< gMinMax(liquidw*(*this + alphaw)) << nl;
Info<< " qEffLiq: " << gMin(qEff) << " - " Info<< " Effective heat transfer rate to liquid: "
<< gMax(qEff) << endl; << gWeightedSum(patch().magSf(), qEff)
<< nl << endl;
Info<< " alphatl: " << gMin((*this)) << " - "
<< gMax((*this)) << endl;
Info<< " dmdt: " << gMin((dmdt_)) << " - "
<< gMax((dmdt_)) << endl;
Info<< " alphatlEff: " << gMin(liquidw*(*this + alphaw))
<< " - " << gMax(liquidw*(*this + alphaw)) << endl;
scalar Qeff = gWeightedSum(patch().magSf(), qEff);
Info<< " Effective heat transfer rate to liquid: " << Qeff
<< endl << nl;
if (debug == 2) if (debug == 2)
{ {

View File

@ -147,8 +147,11 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
const scalarField q0(T.snGrad()*alpha*kappaEff); const scalarField q0(T.snGrad()*alpha*kappaEff);
Q += q0; Q += q0;
auto limits = gMinMax(q0);
Info<< patch().name() << " " << phase.name() Info<< patch().name() << " " << phase.name()
<< ": Heat flux " << gMin(q0) << " - " << gMax(q0) << endl; << ": Heat flux "
<< limits.min() << " - " << limits.max() << endl;
} }
A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs(); A += T.patchInternalField()*alpha*kappaEff*patch().deltaCoeffs();
@ -157,7 +160,7 @@ void Foam::fixedMultiPhaseHeatFluxFvPatchScalarField::updateCoeffs()
if (debug) if (debug)
{ {
MinMax<scalar> limits = gMinMax(Q); auto limits = gMinMax(Q);
Info<< patch().name() << " " << ": overall heat flux " Info<< patch().name() << " " << ": overall heat flux "
<< limits.min() << " - " << limits.max() << " W/m2, power: " << limits.min() << " - " << limits.max() << " W/m2, power: "

View File

@ -694,11 +694,10 @@ void reactingOneDim::evolveRegion()
solidThermo_->correct(); solidThermo_->correct();
auto limits = gMinMax(solidThermo_->T().primitiveField());
Info<< "pyrolysis min/max(T) = " Info<< "pyrolysis min/max(T) = "
<< gMin(solidThermo_->T().primitiveField()) << limits.min() << ", " << limits.max() << endl;
<< ", "
<< gMax(solidThermo_->T().primitiveField())
<< endl;
} }

View File

@ -697,10 +697,11 @@ void thermoSingleLayer::info()
const scalarField& Tinternal = T_; const scalarField& Tinternal = T_;
auto limits = gMinMax(Tinternal);
auto avg = gAverage(Tinternal);
Info<< indent << "min/mean/max(T) = " Info<< indent << "min/mean/max(T) = "
<< gMin(Tinternal) << ", " << limits.min() << ", " << avg << ", " << limits.max() << nl;
<< gAverage(Tinternal) << ", "
<< gMax(Tinternal) << nl;
phaseChange_->info(Info); phaseChange_->info(Info);
} }

View File

@ -195,14 +195,17 @@ void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs()
} }
} }
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< patch().boundaryMesh().mesh().name() << ':' Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':' << patch().name() << ':'
<< this->internalField().name() << " :" << this->internalField().name() << " :"
<< " heat transfer rate:" << Q << " heat transfer rate:" << Q
<< " wall temperature " << " wall temperature "
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< " Qin [W]:" << Qin << " Qin [W]:" << Qin
<< " Qout [W]:" << Qout << " Qout [W]:" << Qout
<< endl; << endl;

View File

@ -400,6 +400,10 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
if (debug) if (debug)
{ {
scalar Q = gAverage(kappaw*snGrad()); scalar Q = gAverage(kappaw*snGrad());
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< patch().boundaryMesh().mesh().name() << ':' Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':' << patch().name() << ':'
<< this->internalField().name() << " <- " << this->internalField().name() << " <- "
@ -407,9 +411,9 @@ void thermalBaffle1DFvPatchScalarField<solidType>::updateCoeffs()
<< this->internalField().name() << " :" << this->internalField().name() << " :"
<< " heat[W]:" << Q << " heat[W]:" << Q
<< " walltemperature " << " walltemperature "
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< endl; << endl;
} }
} }

View File

@ -385,6 +385,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
{ {
scalar Q = gSum(kappaTp*patch().magSf()*snGrad()); scalar Q = gSum(kappaTp*patch().magSf()*snGrad());
auto limits = gMinMax(*this);
auto avg = gAverage(*this);
Info<< patch().boundaryMesh().mesh().name() << ':' Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':' << patch().name() << ':'
<< this->internalField().name() << " <- " << this->internalField().name() << " <- "
@ -393,9 +396,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
<< this->internalField().name() << " :" << this->internalField().name() << " :"
<< " heat transfer rate:" << Q << " heat transfer rate:" << Q
<< " walltemperature " << " walltemperature "
<< " min:" << gMin(*this) << " min:" << limits.min()
<< " max:" << gMax(*this) << " max:" << limits.max()
<< " avg:" << gAverage(*this) << " avg:" << avg
<< endl; << endl;
} }

View File

@ -234,8 +234,10 @@ patchSource() const
if (debug) if (debug)
{ {
auto limits = gMinMax(dhdt);
Info<< " Patch enthalpy rate min/max [J/m3/sec]: " Info<< " Patch enthalpy rate min/max [J/m3/sec]: "
<< gMin(dhdt) << " - " << gMax(dhdt) << endl; << limits.min() << " - " << limits.max() << endl;
} }
return tmp<scalarField>::New(dhdt); return tmp<scalarField>::New(dhdt);
@ -282,8 +284,10 @@ void Foam::enthalpySorptionFvPatchScalarField::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(dhdt_);
Info<< " Enthalpy change min/max [J/kg]: " Info<< " Enthalpy change min/max [J/kg]: "
<< gMin(dhdt_) << " - " << gMax(dhdt_) << endl; << limits.min() << " - " << limits.max() << endl;
} }
zeroGradientFvPatchScalarField::updateCoeffs(); zeroGradientFvPatchScalarField::updateCoeffs();

View File

@ -321,8 +321,10 @@ patchSource() const
if (debug) if (debug)
{ {
auto limits = gMinMax(dfldp);
Info<< " Patch mass rate min/max [kg/m3/sec]: " Info<< " Patch mass rate min/max [kg/m3/sec]: "
<< gMin(dfldp) << " - " << gMax(dfldp) << endl; << limits.min() << " - " << limits.max() << endl;
} }
return tmp<scalarField>::New(dfldp); return tmp<scalarField>::New(dfldp);
@ -391,8 +393,10 @@ void Foam::speciesSorptionFvPatchScalarField::updateCoeffs()
if (debug) if (debug)
{ {
auto limits = gMinMax(dfldp_);
Info<< " Absorption rate min/max [mol/kg/sec]: " Info<< " Absorption rate min/max [mol/kg/sec]: "
<< gMin(dfldp_) << " - " << gMax(dfldp_) << endl; << limits.min() << " - " << limits.max() << endl;
} }
zeroGradientFvPatchScalarField::updateCoeffs(); zeroGradientFvPatchScalarField::updateCoeffs();

View File

@ -134,7 +134,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
&& fc[facei].x() < -0.003499 && fc[facei].x() < -0.003499
) )
{ {
if ((fa[facei] & vector(1, 0, 0)) < 0) if (fa[facei].x() < 0)
{ {
flipZone1[nZoneFaces1] = true; flipZone1[nZoneFaces1] = true;
} }
@ -152,7 +152,7 @@ void Foam::movingConeTopoFvMesh::addZonesAndModifiers()
{ {
zone2[nZoneFaces2] = facei; zone2[nZoneFaces2] = facei;
if ((fa[facei] & vector(1, 0, 0)) > 0) if (fa[facei].x() > 0)
{ {
flipZone2[nZoneFaces2] = true; flipZone2[nZoneFaces2] = true;
} }

View File

@ -160,11 +160,9 @@ Foam::isoAdvection::isoAdvection
if (porosityPtr_) if (porosityPtr_)
{ {
if auto limits = gMinMax(porosityPtr_->primitiveField());
(
gMin(porosityPtr_->primitiveField()) <= 0 if (limits.min() <= 0 || limits.max() > 1 + SMALL)
|| gMax(porosityPtr_->primitiveField()) > 1 + SMALL
)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Porosity field has values <= 0 or > 1" << "Porosity field has values <= 0 or > 1"

View File

@ -121,9 +121,11 @@ void Foam::isoAdvection::limitFluxes
addProfilingInFunction(geometricVoF); addProfilingInFunction(geometricVoF);
DebugInFunction << endl; DebugInFunction << endl;
auto alpha1Limits = gMinMax(alpha1_);
const scalar aTol = 100*SMALL; // Note: tolerances const scalar aTol = 100*SMALL; // Note: tolerances
scalar maxAlphaMinus1 = gMax(alpha1_) - 1; // max(alphaNew - 1); scalar maxAlphaMinus1 = alpha1Limits.max() - 1; // max(alphaNew - 1);
scalar minAlpha = gMin(alpha1_); // min(alphaNew); scalar minAlpha = alpha1Limits.min(); // min(alphaNew);
const label nOvershoots = 20; // sum(pos0(alphaNew - 1 - aTol)); const label nOvershoots = 20; // sum(pos0(alphaNew - 1 - aTol));
const labelList& owner = mesh_.faceOwner(); const labelList& owner = mesh_.faceOwner();
@ -232,8 +234,10 @@ void Foam::isoAdvection::limitFluxes
break; break;
} }
maxAlphaMinus1 = gMax(alpha1_) - 1; // max(alphaNew - 1); alpha1Limits = gMinMax(alpha1_);
minAlpha = gMin(alpha1_); // min(alphaNew);
maxAlphaMinus1 = alpha1Limits.max() - 1; // max(alphaNew - 1);
minAlpha = alpha1Limits.min(); // min(alphaNew);
if (debug) if (debug)
{ {
@ -486,11 +490,13 @@ void Foam::isoAdvection::advect(const SpType& Sp, const SuType& Su)
// Adjust dVf for unbounded cells // Adjust dVf for unbounded cells
limitFluxes(Sp, Su); limitFluxes(Sp, Su);
scalar maxAlphaMinus1 = gMax(alpha1In_) - 1; {
scalar minAlpha = gMin(alpha1In_); auto limits = gMinMax(alpha1In_);
Info<< "isoAdvection: After conservative bounding: min(alpha) = " Info<< "isoAdvection: After conservative bounding:"
<< minAlpha << ", max(alpha) = 1 + " << maxAlphaMinus1 << endl; << " min(alpha) = " << limits.min()
<< ", max(alpha) = 1 + " << (limits.max()-1) << endl;
}
// Apply non-conservative bounding mechanisms (clipping and snapping) // Apply non-conservative bounding mechanisms (clipping and snapping)
// Note: We should be able to write out alpha before this is done! // Note: We should be able to write out alpha before this is done!