Compare commits
39 Commits
issue-3348
...
feature-me
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b7229fc13 | |||
| 6ca0c59519 | |||
| 72ce3eb4ef | |||
| a9b59ad27e | |||
| 4668d0e886 | |||
| c78f25035d | |||
| 82e0d76748 | |||
| 4e513cec18 | |||
| ae3adc1007 | |||
| a0bba74950 | |||
| a3f74d832a | |||
| a92143400d | |||
| c6220c162e | |||
| e5f147a211 | |||
| ebbeef27b4 | |||
| 5bb030480d | |||
| 4334aa43a0 | |||
| 34143b433a | |||
| c5ceec3c73 | |||
| 91e7870ee8 | |||
| 1d62b6274e | |||
| 5ee8f19bdd | |||
| 2d77f7ae26 | |||
| 5c44f360fe | |||
| 735b701006 | |||
| fd41930377 | |||
| 59f3c55871 | |||
| 0be19b7fae | |||
| 01727c84f1 | |||
| 80d7fe97f0 | |||
| a7e8a43f4a | |||
| 6c20df2808 | |||
| b8a0706e72 | |||
| 7f062a8f5e | |||
| f13a05375c | |||
| eb56c75c4b | |||
| cb6d11d39b | |||
| ad037ac744 | |||
| e3c93a9c85 |
@ -36,11 +36,13 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
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
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
deltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
||||
runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
|
||||
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
}
|
||||
|
||||
@ -54,9 +54,18 @@ if (adjustTimeStep)
|
||||
|
||||
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
|
||||
)
|
||||
);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -57,10 +57,22 @@ License
|
||||
// (relative to reference value)
|
||||
scalar alphaY(pimpleDict.getOrDefault<scalar>("alphaY", 1.0));
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
|
||||
// Cache old reciprocal time scale field
|
||||
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||
// The old reciprocal time scale field, with any damping factor
|
||||
tmp<volScalarField> rDeltaT0_damped;
|
||||
|
||||
// Calculate damped value before applying any other changes
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
{
|
||||
rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
|
||||
}
|
||||
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
|
||||
// Flow time scale
|
||||
{
|
||||
@ -70,12 +82,14 @@ License
|
||||
/((2*maxCo)*mesh.V()*rho())
|
||||
);
|
||||
|
||||
// Limit the largest time scale
|
||||
rDeltaT.max(1/maxDeltaT);
|
||||
// Limit the largest time scale (=> smallest reciprocal time)
|
||||
rDeltaT.clamp_min(1/maxDeltaT);
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Flow = "
|
||||
<< 1/gMax(rDeltaT.primitiveField()) << ", "
|
||||
<< 1/gMin(rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Heat release rate time scale
|
||||
@ -86,11 +100,13 @@ License
|
||||
mag(Qdot)/(alphaTemp*rho*thermo.Cp()*T)
|
||||
);
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< 1/(gMax(rDeltaTT.field()) + VSMALL) << ", "
|
||||
<< 1/(gMin(rDeltaTT.field()) + VSMALL) << endl;
|
||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
||||
|
||||
rDeltaT.ref() = max(rDeltaT(), rDeltaTT);
|
||||
auto limits = gMinMax(rDeltaTT.field());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Reaction rate time scale
|
||||
@ -138,11 +154,13 @@ License
|
||||
|
||||
if (foundY)
|
||||
{
|
||||
Info<< " Composition = "
|
||||
<< 1/(gMax(rDeltaTY.field()) + VSMALL) << ", "
|
||||
<< 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
|
||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
|
||||
|
||||
rDeltaT.ref() = max(rDeltaT(), rDeltaTY);
|
||||
auto limits = gMinMax(rDeltaTY.field());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Composition = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -161,28 +179,22 @@ License
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
}
|
||||
|
||||
// Limit rate of change of time scale
|
||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
||||
// - reduce as much as required
|
||||
// - only increase at a fraction of old time scale
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
if (rDeltaT0_damped)
|
||||
{
|
||||
rDeltaT = max
|
||||
(
|
||||
rDeltaT,
|
||||
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||
);
|
||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
||||
}
|
||||
|
||||
// Update tho boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
auto limits = gMinMax(rDeltaT.field());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Overall = "
|
||||
<< 1/gMax(rDeltaT.primitiveField())
|
||||
<< ", " << 1/gMin(rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,7 +106,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
if (!this->readValueEntry(dict))
|
||||
{
|
||||
// Fallback: set to the internal field
|
||||
fvPatchField<scalar>::patchInternalField(*this);
|
||||
this->extrapolateInternal();
|
||||
}
|
||||
|
||||
refValue() = *this;
|
||||
|
||||
@ -23,7 +23,11 @@
|
||||
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
|
||||
Info<< "Flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< "Flow time scale min/max = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,18 +52,26 @@
|
||||
// Update the boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
Info<< "Flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
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)
|
||||
{
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
}
|
||||
|
||||
Info<< "Smoothed flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
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
|
||||
// - reduce as much as required
|
||||
@ -78,8 +86,10 @@
|
||||
rDeltaT0
|
||||
*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 = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
scalar CoNum = -GREAT;
|
||||
forAll(fluidRegions, regionI)
|
||||
{
|
||||
CoNum = max
|
||||
CoNum = Foam::max
|
||||
(
|
||||
compressibleCourantNo
|
||||
(
|
||||
|
||||
@ -78,8 +78,8 @@
|
||||
}
|
||||
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin[i]);
|
||||
rho = min(rho, rhoMax[i]);
|
||||
|
||||
rho.clamp_range(rhoMin[i], rhoMax[i]);
|
||||
rho.relax();
|
||||
|
||||
Info<< "Min/max rho:" << min(rho).value() << ' '
|
||||
|
||||
@ -387,15 +387,18 @@ updateCoeffs()
|
||||
{
|
||||
scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
|
||||
|
||||
Info<< "T solid : " << nl << endl;
|
||||
auto limits = gMinMax(Tp);
|
||||
auto avg = gAverage(Tp);
|
||||
|
||||
Info
|
||||
<< " heat transfer rate from solid:" << Q
|
||||
<< " walltemperature "
|
||||
<< " min:" << gMin(Tp)
|
||||
<< " max:" << gMax(Tp)
|
||||
<< " avg:" << gAverage(Tp) << nl
|
||||
<< endl;
|
||||
Info<< "T solid : " << nl << endl;
|
||||
|
||||
Info
|
||||
<< " heat transfer rate from solid:" << Q
|
||||
<< " walltemperature "
|
||||
<< " min:" << limits.min()
|
||||
<< " max:" << limits.max()
|
||||
<< " avg:" << avg << nl
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
else if (regionType_ == fluid)
|
||||
@ -445,10 +448,16 @@ updateCoeffs()
|
||||
scalarField qLiq((Tp - Tc)*KdeltaLiq);
|
||||
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<< " qLiq: " << gMin(qLiq) << " - " << gMax(qLiq) << endl;
|
||||
Info<< " qVap: " << gMin(qVap) << " - " << gMax(qVap) << endl;
|
||||
Info<< " qLiq: " << infoLiq.min() << " - " << infoLiq.max() << nl
|
||||
<< " qVap: " << infoVap.min() << " - " << infoVap.max() << nl;
|
||||
|
||||
scalar QLiq = gSum(qLiq*patch().magSf());
|
||||
scalar QVap = gSum(qVap*patch().magSf());
|
||||
@ -457,9 +466,9 @@ updateCoeffs()
|
||||
Info<< " Heat transfer to Vap: " << QVap << endl;
|
||||
|
||||
Info<< " walltemperature "
|
||||
<< " min:" << gMin(Tp)
|
||||
<< " max:" << gMax(Tp)
|
||||
<< " avg:" << gAverage(Tp)
|
||||
<< " min:" << infoT.min()
|
||||
<< " max:" << infoT.max()
|
||||
<< " avg:" << avgT
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
);
|
||||
|
||||
|
||||
CoNum =
|
||||
scalar regionCoNum =
|
||||
0.5*gMax
|
||||
(
|
||||
sumPhi/fluidRegions[regioni].V().field()
|
||||
@ -41,9 +41,9 @@
|
||||
(
|
||||
fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()
|
||||
/ fluidRegions[regioni].V().field()
|
||||
)*runTime.deltaTValue(),
|
||||
)*runTime.deltaTValue();
|
||||
|
||||
CoNum = max(UrCoNum, CoNum);
|
||||
CoNum = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
forAll(fluidRegions, regioni)
|
||||
{
|
||||
CoNum = max
|
||||
CoNum = Foam::max
|
||||
(
|
||||
compressibleCourantNo
|
||||
(
|
||||
@ -17,7 +17,7 @@
|
||||
/*
|
||||
forAll(porousFluidRegions, porousi)
|
||||
{
|
||||
CoNum = max
|
||||
CoNum = Foam::max
|
||||
(
|
||||
compressibleCourantNo
|
||||
(
|
||||
|
||||
@ -47,10 +47,10 @@ if (adjustTimeStep)
|
||||
|
||||
runTime.setDeltaT
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||
min(runTime.deltaTValue(), maxDeltaT)
|
||||
Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||
Foam::min(runTime.deltaTValue(), maxDeltaT)
|
||||
)
|
||||
);
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
|
||||
@ -48,18 +48,14 @@ if (adjustTimeStep)
|
||||
scalar maxDeltaTFluid = maxCo/(CoNum + SMALL);
|
||||
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
|
||||
|
||||
scalar deltaTFluid =
|
||||
min
|
||||
(
|
||||
min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
|
||||
1.2
|
||||
);
|
||||
const scalar deltaTFluid =
|
||||
Foam::min(Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid), 1.2);
|
||||
|
||||
runTime.setDeltaT
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||
Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
)
|
||||
);
|
||||
|
||||
@ -22,7 +22,7 @@ forAll(solidRegions, i)
|
||||
tmp<volScalarField> trho = thermo.rho();
|
||||
const volScalarField& rho = trho();
|
||||
|
||||
DiNum = max
|
||||
DiNum = Foam::max
|
||||
(
|
||||
solidRegionDiffNo
|
||||
(
|
||||
|
||||
@ -17,7 +17,7 @@ scalar DiNum = -GREAT;
|
||||
tmp<volScalarField> trho = thermo.rho();
|
||||
const volScalarField& rho = trho();
|
||||
|
||||
DiNum = max
|
||||
DiNum = Foam::max
|
||||
(
|
||||
solidRegionDiffNo
|
||||
(
|
||||
|
||||
@ -60,13 +60,10 @@ template<class Type>
|
||||
void zeroCells
|
||||
(
|
||||
GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||
const labelList& cells
|
||||
const labelUList& cells
|
||||
)
|
||||
{
|
||||
forAll(cells, i)
|
||||
{
|
||||
vf[cells[i]] = Zero;
|
||||
}
|
||||
UIndirectList<Type>(vf.primitiveField(), cells) = Zero;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -103,8 +103,8 @@ dimensionedScalar alphaMax
|
||||
laminarTransport
|
||||
);
|
||||
|
||||
const labelList& inletCells = mesh.boundary()["inlet"].faceCells();
|
||||
//const labelList& outletCells = mesh.boundary()["outlet"].faceCells();
|
||||
const labelUList& inletCells = mesh.boundary()["inlet"].faceCells();
|
||||
//const labelUList& outletCells = mesh.boundary()["outlet"].faceCells();
|
||||
|
||||
volScalarField alpha
|
||||
(
|
||||
|
||||
@ -55,7 +55,7 @@ if (mesh.changing())
|
||||
dimensionedScalar rAUf("rAUf", dimTime, 1.0);
|
||||
|
||||
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||
const labelList& cellTypes = overlap.cellTypes();
|
||||
const labelUList& cellTypes = overlap.cellTypes();
|
||||
const labelIOList& zoneIDs = overlap.zoneID();
|
||||
|
||||
while (pimple.correctNonOrthogonal())
|
||||
|
||||
@ -36,18 +36,26 @@
|
||||
// Update the boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
Info<< "Flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
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)
|
||||
{
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
}
|
||||
|
||||
Info<< "Smoothed flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
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
|
||||
// - reduce as much as required
|
||||
@ -62,8 +70,10 @@
|
||||
rDeltaT0
|
||||
*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 = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,10 +54,21 @@ License
|
||||
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
||||
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
// The old reciprocal time scale field, with any damping factor
|
||||
tmp<volScalarField> rDeltaT0_damped;
|
||||
|
||||
// Cache old reciprocal time scale field
|
||||
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||
// Calculate damped value before applying any other changes
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
{
|
||||
rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
|
||||
}
|
||||
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
|
||||
// Flow time scale
|
||||
{
|
||||
@ -67,12 +78,14 @@ License
|
||||
/((2*maxCo)*mesh.V()*rho())
|
||||
);
|
||||
|
||||
// Limit the largest time scale
|
||||
rDeltaT.max(1/maxDeltaT);
|
||||
// Limit the largest time scale (=> smallest reciprocal time)
|
||||
rDeltaT.clamp_min(1/maxDeltaT);
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Flow = "
|
||||
<< gMin(1/rDeltaT.primitiveField()) << ", "
|
||||
<< gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Reaction source time scale
|
||||
@ -93,15 +106,13 @@ License
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
|
||||
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
|
||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
||||
|
||||
rDeltaT.ref() = max
|
||||
(
|
||||
rDeltaT(),
|
||||
rDeltaTT
|
||||
);
|
||||
auto limits = gMinMax(rDeltaTT.field());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Update tho boundary values of the reciprocal time-step
|
||||
@ -113,25 +124,19 @@ License
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
}
|
||||
|
||||
// Limit rate of change of time scale
|
||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
||||
// - reduce as much as required
|
||||
// - only increase at a fraction of old time scale
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1.0
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
if (rDeltaT0_damped)
|
||||
{
|
||||
rDeltaT = max
|
||||
(
|
||||
rDeltaT,
|
||||
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||
);
|
||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
||||
}
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Overall = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,13 +36,18 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
const scalar maxDeltaTFact =
|
||||
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
|
||||
Foam::min
|
||||
(
|
||||
maxCo/(CoNum + SMALL),
|
||||
maxCo/(surfaceFilm.CourantNumber() + SMALL)
|
||||
);
|
||||
|
||||
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
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
deltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,10 +54,21 @@ License
|
||||
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
||||
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
// The old reciprocal time scale field, with any damping factor
|
||||
tmp<volScalarField> rDeltaT0_damped;
|
||||
|
||||
// Cache old reciprocal time scale field
|
||||
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||
// Calculate damped value before applying any other changes
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
{
|
||||
rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
|
||||
}
|
||||
|
||||
|
||||
Info<< "Time scales min/max:" << endl;
|
||||
|
||||
// Flow time scale
|
||||
{
|
||||
@ -67,12 +78,14 @@ License
|
||||
/((2*maxCo)*mesh.V()*rho())
|
||||
);
|
||||
|
||||
// Limit the largest time scale
|
||||
rDeltaT.max(1/maxDeltaT);
|
||||
// Limit the largest time scale (=> smallest reciprocal time)
|
||||
rDeltaT.clamp_min(1/maxDeltaT);
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Flow = "
|
||||
<< gMin(1/rDeltaT.primitiveField()) << ", "
|
||||
<< gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Reaction source time scale
|
||||
@ -92,15 +105,13 @@ License
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
|
||||
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
|
||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
||||
|
||||
rDeltaT.ref() = max
|
||||
(
|
||||
rDeltaT(),
|
||||
rDeltaTT
|
||||
);
|
||||
auto limits = gMinMax(rDeltaTT.field());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Temperature = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Update the boundary values of the reciprocal time-step
|
||||
@ -112,25 +123,22 @@ License
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
}
|
||||
|
||||
// Limit rate of change of time scale
|
||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
||||
// - reduce as much as required
|
||||
// - only increase at a fraction of old time scale
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1.0
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
if (rDeltaT0_damped)
|
||||
{
|
||||
rDeltaT = max
|
||||
(
|
||||
rDeltaT,
|
||||
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||
);
|
||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
||||
}
|
||||
|
||||
// Update the boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
Info<< " Overall = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -48,8 +48,7 @@ U.correctBoundaryConditions();
|
||||
fvOptions.correct(U);
|
||||
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
|
||||
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
||||
|
||||
@ -49,8 +49,7 @@
|
||||
fvOptions.correct(U);
|
||||
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
|
||||
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
|
||||
volScalarField rAU(1.0/UEqn.A());
|
||||
@ -94,8 +93,7 @@ p.relax();
|
||||
|
||||
// Recalculate density from the relaxed pressure
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
|
||||
volScalarField rAU(1.0/UEqn.A());
|
||||
@ -94,8 +93,7 @@ p.relax();
|
||||
|
||||
// Recalculate density from the relaxed pressure
|
||||
rho = thermo.rho();
|
||||
rho = max(rho, rhoMin);
|
||||
rho = min(rho, rhoMax);
|
||||
rho.clamp_range(rhoMin, rhoMax);
|
||||
rho.relax();
|
||||
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
||||
|
||||
|
||||
@ -36,13 +36,14 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
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
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
deltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
|
||||
@ -53,6 +53,21 @@
|
||||
pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
|
||||
);
|
||||
|
||||
|
||||
// The old reciprocal time scale field, with any damping factor
|
||||
tmp<volScalarField> rDeltaT0_damped;
|
||||
|
||||
// Calculate damped value before applying any other changes
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
{
|
||||
rDeltaT0_damped = (scalar(1) - rDeltaTDampingCoeff)*(rDeltaT);
|
||||
}
|
||||
|
||||
|
||||
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||
|
||||
// Set the reciprocal time-step from the local Courant number
|
||||
@ -83,10 +98,13 @@
|
||||
// Update tho boundary values of the reciprocal time-step
|
||||
rDeltaT.correctBoundaryConditions();
|
||||
|
||||
Info<< "Flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
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)
|
||||
{
|
||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||
@ -110,27 +128,25 @@
|
||||
fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
|
||||
}
|
||||
|
||||
Info<< "Smoothed flow time scale min/max = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
{
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
|
||||
// Limit rate of change of time scale
|
||||
Info<< "Smoothed flow time scale min/max = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
||||
// - reduce as much as required
|
||||
// - only increase at a fraction of old time scale
|
||||
if
|
||||
(
|
||||
rDeltaTDampingCoeff < 1.0
|
||||
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||
)
|
||||
if (rDeltaT0_damped)
|
||||
{
|
||||
rDeltaT = max
|
||||
(
|
||||
rDeltaT,
|
||||
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||
);
|
||||
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 = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,13 +36,14 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
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
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
deltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
|
||||
@ -37,11 +37,15 @@ if (adjustTimeStep)
|
||||
if (CoNum > SMALL)
|
||||
{
|
||||
scalar maxDeltaTFact =
|
||||
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
|
||||
Foam::min
|
||||
(
|
||||
maxCo/(CoNum + SMALL),
|
||||
maxAcousticCo/(acousticCoNum + SMALL)
|
||||
);
|
||||
|
||||
runTime.setDeltaT
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
maxDeltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
|
||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
||||
{
|
||||
if (dgdt[celli] > 0.0)
|
||||
{
|
||||
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
}
|
||||
else if (dgdt[celli] < 0.0)
|
||||
{
|
||||
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -210,7 +210,7 @@ void VoFPatchTransfer::correct
|
||||
film().toRegion(patchi, Vp);
|
||||
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
const labelList& faceCells = pp.faceCells();
|
||||
const labelUList& faceCells = pp.faceCells();
|
||||
|
||||
// Accumulate the total mass removed from patch
|
||||
scalar dMassPatch = 0;
|
||||
|
||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
||||
{
|
||||
if (dgdt[celli] > 0.0)
|
||||
{
|
||||
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
}
|
||||
else if (dgdt[celli] < 0.0)
|
||||
{
|
||||
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
||||
{
|
||||
if (dgdt[celli] > 0.0)
|
||||
{
|
||||
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
||||
}
|
||||
else if (dgdt[celli] < 0.0)
|
||||
{
|
||||
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
NotImplemented;
|
||||
return const_cast<volScalarField&>(volScalarField::null());
|
||||
return volScalarField::null().constCast();
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy [J/kg]
|
||||
|
||||
@ -243,7 +243,7 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
NotImplemented;
|
||||
return const_cast<volScalarField&>(volScalarField::null());
|
||||
return volScalarField::null().constCast();
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy [J/kg]
|
||||
|
||||
@ -36,13 +36,13 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
scalar maxDeltaTFact =
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
maxCo/(CoNum + SMALL),
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
maxAlphaCo/(alphaCoNum + SMALL),
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
maxAlphaDdt/(ddtAlphaNum + 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
|
||||
(
|
||||
min
|
||||
Foam::min
|
||||
(
|
||||
deltaTFact*runTime.deltaTValue(),
|
||||
maxDeltaT
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
NotImplemented;
|
||||
return const_cast<volScalarField&>(volScalarField::null());
|
||||
return volScalarField::null().constCast();
|
||||
}
|
||||
|
||||
//- Return access to the internal energy field [J/Kg]
|
||||
|
||||
@ -65,7 +65,7 @@
|
||||
dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
|
||||
|
||||
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||
const labelList& cellTypes = overlap.cellTypes();
|
||||
const labelUList& cellTypes = overlap.cellTypes();
|
||||
const labelIOList& zoneIDs = overlap.zoneID();
|
||||
|
||||
while (pimple.correctNonOrthogonal())
|
||||
|
||||
@ -38,7 +38,9 @@
|
||||
|
||||
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 = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
@ -8,5 +8,5 @@
|
||||
|
||||
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
||||
|
||||
CoNum = max(CoNum, UrCoNum);
|
||||
CoNum = Foam::max(CoNum, UrCoNum);
|
||||
}
|
||||
|
||||
@ -31,7 +31,9 @@
|
||||
|
||||
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 = "
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
}
|
||||
|
||||
@ -8,5 +8,5 @@
|
||||
|
||||
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
||||
|
||||
CoNum = max(CoNum, UrCoNum);
|
||||
CoNum = Foam::max(CoNum, UrCoNum);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-CircularBuffer.C
|
||||
Test-CircularBuffer.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-CircularBuffer
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-DynamicList.C
|
||||
Test-DynamicList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-DynamicList2.C
|
||||
Test-DynamicList2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList2
|
||||
|
||||
@ -52,7 +52,8 @@ void printInfo
|
||||
if (showSize)
|
||||
{
|
||||
Info<< " size=\"" << list.size()
|
||||
<< "\" capacity=\"" << list.capacity() << "\"";
|
||||
<< "\" capacity=\"" << list.capacity() << "\""
|
||||
<< "\" min=\"" << SizeMin << "\"" ;
|
||||
if (list.cdata())
|
||||
{
|
||||
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
||||
@ -79,7 +80,8 @@ void printInfo
|
||||
if (showSize)
|
||||
{
|
||||
Info<< " size=\"" << list.size()
|
||||
<< "\" capacity=\"" << list.capacity() << "\"";
|
||||
<< "\" capacity=\"" << list.capacity() << "\""
|
||||
<< "\" min=\"" << SizeMin << "\"" ;
|
||||
if (list.cdata())
|
||||
{
|
||||
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
||||
@ -168,6 +170,22 @@ int main(int argc, char *argv[])
|
||||
printInfo("", list2);
|
||||
}
|
||||
|
||||
{
|
||||
DynamicList<float, 32> list1(std::pair<label,label>(16,0));
|
||||
list1 = -1;
|
||||
|
||||
Info<< "construct with specified size/capacity" << nl;
|
||||
printInfo("", list1);
|
||||
}
|
||||
|
||||
{
|
||||
DynamicList<float, 32> list1(std::pair<label,label>(8,16));
|
||||
list1 = -1;
|
||||
|
||||
Info<< "construct with specified size/capacity" << nl;
|
||||
printInfo("", list1);
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n";
|
||||
|
||||
return 0;
|
||||
@ -1,3 +1,3 @@
|
||||
Test-FixedList.C
|
||||
Test-FixedList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-FixedList
|
||||
|
||||
@ -41,7 +41,6 @@ See also
|
||||
#include "List.H"
|
||||
#include "IPstream.H"
|
||||
#include "OPstream.H"
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-Hashing2.C
|
||||
Test-Hashing2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
||||
|
||||
@ -274,9 +274,7 @@ int main(int argc, char *argv[])
|
||||
Info<< nl << "No " << is.name() << " file found ..." << nl;
|
||||
}
|
||||
|
||||
token tok;
|
||||
|
||||
while (is.good() && is.read(tok) && tok.good())
|
||||
for (token tok; tok.read(is); /*nil*/)
|
||||
{
|
||||
const word listType(tok.wordToken());
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ICharStream1.C
|
||||
Test-ICharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -138,17 +136,10 @@ void printInfo(const List<char>& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -269,7 +269,7 @@ int main(int argc, char *argv[])
|
||||
ioOutput.rename(args.executable() + "-labels");
|
||||
Info<< "write " << ioOutput.objectRelPath() << endl;
|
||||
{
|
||||
IOListRef<label>(ioOutput, ints).write();
|
||||
IOList<label>::writeContents(ioOutput, ints);
|
||||
}
|
||||
|
||||
ioOutput.rename(args.executable() + "-points");
|
||||
|
||||
@ -73,14 +73,13 @@ Ostream& toString(Ostream& os, const List<char>& list)
|
||||
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
Info<< "stream tokens:" << endl;
|
||||
|
||||
label count = 0;
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
Info<< " : " << tok << endl;
|
||||
Info<< " : " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-List.C
|
||||
Test-List.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-List
|
||||
|
||||
@ -54,7 +54,6 @@ See also
|
||||
#include "ListPolicy.H"
|
||||
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
|
||||
// see issue #2083
|
||||
@ -75,8 +74,6 @@ public:
|
||||
|
||||
|
||||
|
||||
namespace Detail
|
||||
{
|
||||
namespace ListPolicy
|
||||
{
|
||||
|
||||
@ -84,7 +81,6 @@ namespace ListPolicy
|
||||
template<> struct short_length<short> : std::integral_constant<int,20> {};
|
||||
|
||||
} // End namespace ListPolicy
|
||||
} // End namespace Detail
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
@ -119,9 +115,9 @@ Ostream& printListOutputType(const char* what)
|
||||
Info<< what
|
||||
<< " (contiguous="
|
||||
<< is_contiguous_v<T> << " no_linebreak="
|
||||
<< Detail::ListPolicy::no_linebreak<T>::value
|
||||
<< ListPolicy::no_linebreak<T>::value
|
||||
<< " short_length="
|
||||
<< Detail::ListPolicy::short_length<T>::value << ')';
|
||||
<< ListPolicy::short_length<T>::value << ')';
|
||||
|
||||
return Info;
|
||||
}
|
||||
@ -143,8 +139,46 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption("ListList", "Test list of list functionality");
|
||||
argList::addBoolOption("flag");
|
||||
|
||||
argList::addBoolOption("reserve", "Test ListPolicy for reserve_size");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (args.found("reserve"))
|
||||
{
|
||||
using namespace Foam::ListPolicy;
|
||||
|
||||
using control = std::pair<label, label>;
|
||||
|
||||
for
|
||||
(
|
||||
const auto& tup :
|
||||
{
|
||||
control{ 10, 5 },
|
||||
control{ 20, 25 }
|
||||
}
|
||||
)
|
||||
{
|
||||
const auto [len, capacity] = tup;
|
||||
|
||||
Info<< "test " << tup << nl;
|
||||
|
||||
auto size = reserve_size<16,2>(len, capacity);
|
||||
Info<< " => " << size << " (ratio 2)" << nl;
|
||||
|
||||
size = reserve_size<16,3,2>(len, capacity);
|
||||
Info<< " => " << size << " (ratio 3/2)" << nl;
|
||||
|
||||
size = reserve_size<16,13,8>(len, capacity);
|
||||
Info<< " => " << size << " (ratio " << (13.0/8) << ')' << nl;
|
||||
|
||||
size = reserve_size<16,25,16>(len, capacity);
|
||||
Info<< " => " << size << " (ratio " << (25.0/16) << ')' << nl;
|
||||
}
|
||||
|
||||
Info<< nl << "\nEnd" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
{
|
||||
List<label> ident(15);
|
||||
Foam::identity(ident, 0);
|
||||
@ -1,3 +1,3 @@
|
||||
Test-List3.C
|
||||
Test-List3.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-List3
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ListRead1.C
|
||||
Test-ListRead1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||
|
||||
@ -50,7 +50,6 @@ Description
|
||||
#include "ListPolicy.H"
|
||||
|
||||
#include <list>
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
|
||||
using namespace Foam;
|
||||
@ -86,7 +85,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
// constexpr label chunkSize = 128;
|
||||
typedef std::unique_ptr<List<T>> chunkType;
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
|
||||
if (tok.isPunctuation(token::END_LIST))
|
||||
@ -150,7 +149,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
||||
"reading entry"
|
||||
);
|
||||
|
||||
is >> tok;
|
||||
tok.read(is);
|
||||
is.fatalCheck(FUNCTION_NAME);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCharStream1.C
|
||||
Test-OCharStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -83,12 +83,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -129,17 +127,10 @@ void printInfo(const BufType& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PackedList1.C
|
||||
Test-PackedList1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList1
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PackedList2.C
|
||||
Test-PackedList2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList2
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SpanStream1.C
|
||||
Test-SpanStream1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,12 +85,10 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
}
|
||||
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||
@ -145,17 +143,10 @@ void printInfo(const UList<char>& buf)
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
label count = 0;
|
||||
token t;
|
||||
while (is.good())
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
is >> t;
|
||||
if (t.good())
|
||||
{
|
||||
++count;
|
||||
Info<<"token: " << t << endl;
|
||||
}
|
||||
Info<< "token: " << tok << nl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-SubField.C
|
||||
Test-SubField.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-SubField
|
||||
|
||||
@ -38,7 +38,6 @@ Description
|
||||
#include "SubField.H"
|
||||
#include "labelRange.H"
|
||||
#include "ListOps.H"
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-UIndirectList.C
|
||||
Test-UIndirectList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-UIndirectList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-bitSet2.C
|
||||
Test-bitSet2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-bitSet2
|
||||
|
||||
@ -499,7 +499,7 @@ int main(int argc, char *argv[])
|
||||
Info<<"bitSet ";
|
||||
report(list4);
|
||||
|
||||
list4.shrink();
|
||||
list4.shrink_to_fit();
|
||||
Info<<"shrunk ";
|
||||
report(list4);
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-charList.C
|
||||
Test-charList.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-charList
|
||||
|
||||
@ -43,8 +43,6 @@ Description
|
||||
#include "SubList.H"
|
||||
#include "FlatOutput.H"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -50,8 +50,6 @@ Description
|
||||
#include "SliceStreamRepo.H"
|
||||
#endif
|
||||
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-contiguous.C
|
||||
Test-contiguous.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-contiguous
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
Test-dictionaryTokens.C
|
||||
dictionaryTokens.C
|
||||
Test-dictionaryTokens.cxx
|
||||
dictionaryTokens.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-edges.C
|
||||
Test-edges.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-edges
|
||||
|
||||
@ -142,6 +142,26 @@ int main(int argc, char *argv[])
|
||||
Info<< "sorted ";
|
||||
printInfo(e4);
|
||||
|
||||
// Sorted construction
|
||||
{
|
||||
edge edge1(10, 5);
|
||||
|
||||
Info<< "plain ";
|
||||
printInfo(edge1);
|
||||
|
||||
// construct sorted
|
||||
auto edge3(edge::sorted(10, 5));
|
||||
|
||||
Info<< "sorted ";
|
||||
printInfo(edge3);
|
||||
|
||||
// // construct sorted (deprecated)
|
||||
// edge edge2(10, 5, true);
|
||||
//
|
||||
// Info<< "sorted ";
|
||||
// printInfo(edge2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -262,13 +262,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check constant profile
|
||||
{
|
||||
const scalar max = gMax(one);
|
||||
const scalar min = gMin(one);
|
||||
auto limits = gMinMax(one);
|
||||
|
||||
Info<< "Uniform one field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Uniform one field min = "
|
||||
<< limits.min() << " max = " << limits.max() << endl;
|
||||
|
||||
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Uniform volVectorField not preserved."
|
||||
@ -286,13 +285,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const scalarField diff = ccX-mesh.C().component(0);
|
||||
|
||||
const scalar max = gMax(diff);
|
||||
const scalar min = gMin(diff);
|
||||
auto limits = gMinMax(diff);
|
||||
|
||||
Info<< "Linear profile field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Linear profile field min = "
|
||||
<< limits.min() << " max = " << limits.max() << endl;
|
||||
|
||||
if (isNotEqual(max, 0) || isNotEqual(min, 0))
|
||||
if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Linear profile not preserved."
|
||||
@ -309,13 +307,12 @@ int main(int argc, char *argv[])
|
||||
// Check face field mapping
|
||||
if (surfaceOne.size())
|
||||
{
|
||||
const scalar max = gMax(surfaceOne.primitiveField());
|
||||
const scalar min = gMin(surfaceOne.primitiveField());
|
||||
auto limits = gMinMax(surfaceOne.primitiveField());
|
||||
|
||||
Info<< "Uniform surface field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Uniform surface field min = "
|
||||
<< limits.min() << " max = " << limits.max() << endl;
|
||||
|
||||
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Uniform surfaceScalarField not preserved."
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-globalMeshData.C
|
||||
Test-globalMeshData.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-globalMeshData
|
||||
|
||||
@ -182,18 +182,11 @@ int main(int argc, char *argv[])
|
||||
const labelListList& transformedSlaves =
|
||||
globalData.globalPointTransformedBoundaryFaces();
|
||||
|
||||
const label nBnd = mesh.nBoundaryFaces();
|
||||
|
||||
pointField fc(globalPointBoundaryFacesMap.constructSize());
|
||||
SubList<point>(fc, nBnd) =
|
||||
pointField::subList(fc, mesh.nBoundaryFaces()) =
|
||||
primitivePatch
|
||||
(
|
||||
SubList<face>
|
||||
(
|
||||
mesh.faces(),
|
||||
nBnd,
|
||||
mesh.nInternalFaces()
|
||||
),
|
||||
mesh.boundaryMesh().faces(),
|
||||
mesh.points()
|
||||
).faceCentres();
|
||||
|
||||
@ -344,13 +344,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check constant profile
|
||||
{
|
||||
const scalar max = gMax(one);
|
||||
const scalar min = gMin(one);
|
||||
auto limits = gMinMax(one);
|
||||
|
||||
Info<< "Uniform one field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Uniform one field min = "
|
||||
<< limits.min() << " max = " << limits.max() << endl;
|
||||
|
||||
if (isNotEqual(min, 1) || isNotEqual(max, 1))
|
||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Uniform volVectorField not preserved."
|
||||
@ -368,13 +367,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const scalarField diff = ccX-mesh.C().component(0);
|
||||
|
||||
const scalar max = gMax(diff);
|
||||
const scalar min = gMin(diff);
|
||||
auto limits = gMinMax(diff);
|
||||
|
||||
Info<< "Linear profile field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Linear profile field min = "
|
||||
<< 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."
|
||||
<< " Min and max should both be 0.0. min:" << min
|
||||
@ -389,13 +387,12 @@ int main(int argc, char *argv[])
|
||||
// Check face field mapping
|
||||
if (surfaceOne.size())
|
||||
{
|
||||
const scalar max = gMax(surfaceOne.primitiveField());
|
||||
const scalar min = gMin(surfaceOne.primitiveField());
|
||||
auto limits = gMinMax(surfaceOne.primitiveField());
|
||||
|
||||
Info<< "Uniform surface field min = " << min
|
||||
<< " max = " << max << endl;
|
||||
Info<< "Uniform surface field min = "
|
||||
<< limits.min() << " max = " << limits.max() << endl;
|
||||
|
||||
if (isNotEqual(min, 1) || isNotEqual(max, 1))
|
||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Uniform surfaceScalarField not preserved."
|
||||
|
||||
3
applications/test/memoryPool1/Make/files
Normal file
3
applications/test/memoryPool1/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-memoryPool1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-memoryPool1
|
||||
2
applications/test/memoryPool1/Make/options
Normal file
2
applications/test/memoryPool1/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
252
applications/test/memoryPool1/Test-memoryPool1.cxx
Normal file
252
applications/test/memoryPool1/Test-memoryPool1.cxx
Normal file
@ -0,0 +1,252 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// Enable/disable based on header
|
||||
#ifdef Foam_MemoryPool_H
|
||||
#define FOAM_HAS_MEMORY_POOL
|
||||
#else
|
||||
#undef FOAM_HAS_MEMORY_POOL
|
||||
#endif
|
||||
|
||||
// options
|
||||
int min_align_size = 5;
|
||||
int min_pool_size = 10;
|
||||
bool use_aligned_alloc(true);
|
||||
bool use_aligned_dealloc(true);
|
||||
|
||||
//- True if size exceeds the min-size for using memory alignment
|
||||
template<class IntType>
|
||||
inline bool use_alignment(IntType n) noexcept
|
||||
{
|
||||
return (n >= min_align_size);
|
||||
}
|
||||
|
||||
|
||||
//- True if size exceeds the min-size for using the memory pool
|
||||
template<class IntType>
|
||||
inline bool use_memory_pool(IntType n) noexcept
|
||||
{
|
||||
return (n >= IntType(min_pool_size));
|
||||
}
|
||||
|
||||
|
||||
//- Default alignment
|
||||
inline constexpr std::align_val_t default_alignment() noexcept
|
||||
{
|
||||
return std::align_val_t(64);
|
||||
}
|
||||
|
||||
|
||||
//- Allocate from memory pool (if active) or aligned/normal
|
||||
template<class T, class IntType>
|
||||
inline T* my_allocate(IntType n)
|
||||
{
|
||||
std::cerr<< "my_allocate(" << n << ")\n";
|
||||
|
||||
if (use_aligned_alloc && use_alignment(n))
|
||||
{
|
||||
#ifdef FOAM_HAS_MEMORY_POOL
|
||||
if
|
||||
(
|
||||
void *pool_ptr
|
||||
(
|
||||
// Consider memory pool for large amounts of data
|
||||
use_memory_pool(n)
|
||||
? Foam::MemoryPool::try_allocate(sizeof(T)*n)
|
||||
: nullptr
|
||||
);
|
||||
pool_ptr
|
||||
)
|
||||
{
|
||||
// Placement new
|
||||
return new (pool_ptr) T[n];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return new (default_alignment()) T[n];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Plain new
|
||||
return new T[n];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Deallocate from memory pool or normal
|
||||
template<class T>
|
||||
inline void my_deallocate(T* ptr)
|
||||
{
|
||||
std::cerr<< "my_deallocate() : " << Foam::name(ptr) << '\n';
|
||||
|
||||
#ifdef FOAM_HAS_MEMORY_POOL
|
||||
if
|
||||
(
|
||||
ptr && !Foam::MemoryPool::try_deallocate(ptr)
|
||||
)
|
||||
#endif
|
||||
{
|
||||
// Plain new
|
||||
delete[] ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Deallocate from memory pool or aligned/normal
|
||||
template<class T, class IntType>
|
||||
inline void my_deallocate(T* ptr, IntType n)
|
||||
{
|
||||
std::cerr<< "my_deallocate(" << n << ") : " << Foam::name(ptr) << '\n';
|
||||
|
||||
if (use_aligned_dealloc && use_alignment(n))
|
||||
{
|
||||
if
|
||||
(
|
||||
#ifdef FOAM_HAS_MEMORY_POOL
|
||||
ptr && !Foam::MemoryPool::try_deallocate(ptr)
|
||||
#else
|
||||
ptr
|
||||
#endif
|
||||
)
|
||||
{
|
||||
::operator delete[](ptr, default_alignment());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Plain new
|
||||
delete[] ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noCheckProcessorDirectories();
|
||||
argList::addOption
|
||||
(
|
||||
"min-align",
|
||||
"INT",
|
||||
"Min number of elements for memory alignment (default: 5)"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"min-pool",
|
||||
"INT",
|
||||
"Min number of elements for using memory pool (default: 10)"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"count",
|
||||
"INT",
|
||||
"Number of elements to test (default: 10)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-align",
|
||||
"Disable aligned alloc/dealloc"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-align-alloc",
|
||||
"Disable aligned alloc (default: false)"
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"no-align-dealloc",
|
||||
"Disable aligned dealloc (default: false)"
|
||||
);
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
label count(10);
|
||||
|
||||
args.readIfPresent("count", count);
|
||||
args.readIfPresent("min-align", min_align_size);
|
||||
args.readIfPresent("min-pool", min_pool_size);
|
||||
|
||||
if (min_pool_size < min_align_size)
|
||||
{
|
||||
min_pool_size = min_align_size;
|
||||
}
|
||||
|
||||
if (args.found("no-align"))
|
||||
{
|
||||
use_aligned_alloc = false;
|
||||
use_aligned_dealloc = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
use_aligned_alloc = !args.found("no-align-alloc");
|
||||
use_aligned_dealloc = !args.found("no-align-dealloc");
|
||||
}
|
||||
|
||||
|
||||
Info<< "Testing with " << count << " elements" << nl
|
||||
<< "min-align: " << int(min_align_size) << " elements" << nl
|
||||
#ifdef FOAM_HAS_MEMORY_POOL
|
||||
<< "min-pool: " << int(min_pool_size)
|
||||
<< " elements, active:" << MemoryPool::active() << nl
|
||||
#endif
|
||||
<< "alignment: " << int(default_alignment()) << " bytes" << nl
|
||||
<< nl;
|
||||
|
||||
{
|
||||
using T = double;
|
||||
label len = count;
|
||||
|
||||
UList<T> list(my_allocate<T>(len), len);
|
||||
|
||||
Info<< "List ptr: " << Foam::name(list.data()) << nl;
|
||||
|
||||
list = 1.234;
|
||||
|
||||
Info<< "List: " << list << nl;
|
||||
|
||||
my_deallocate(list.data(), len);
|
||||
|
||||
list = UList<T>();
|
||||
|
||||
my_deallocate(list.data());
|
||||
my_deallocate(list.data(), len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -175,6 +175,36 @@ int main(int argc, char *argv[])
|
||||
<< nl;
|
||||
}
|
||||
|
||||
{
|
||||
scalarField field1(10);
|
||||
scalarField field2(10);
|
||||
scalarField work;
|
||||
|
||||
Random rnd(4567);
|
||||
for (scalar& val : field1)
|
||||
{
|
||||
val = rnd.position(scalar(-0.2), scalar(1.2));
|
||||
}
|
||||
for (scalar& val : field2)
|
||||
{
|
||||
val = rnd.position(scalar(-0.1), scalar(1.1));
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
<< "field1: " << flatOutput(field1) << nl
|
||||
<< "field2: " << flatOutput(field2) << nl;
|
||||
|
||||
work = field1;
|
||||
work.clamp_min(field2);
|
||||
|
||||
Info<< "clamp_min: " << flatOutput(work) << nl;
|
||||
|
||||
work = field1;
|
||||
work.clamp_max(field2);
|
||||
|
||||
Info<< "clamp_max: " << flatOutput(work) << nl;
|
||||
}
|
||||
|
||||
Info<< nl << "\nDone\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-parallel-comm2.C
|
||||
Test-parallel-comm2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-parallel-comm2
|
||||
|
||||
@ -69,6 +69,7 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption("info", "information");
|
||||
argList::addBoolOption("print-tree", "Report tree(s) as graph");
|
||||
argList::addBoolOption("no-test", "Disable general tests");
|
||||
argList::addBoolOption("split", "Test Pstream split-comm");
|
||||
argList::addBoolOption("host-comm", "Test Pstream host-comm");
|
||||
argList::addBoolOption("host-broadcast", "Test host-base broadcasts");
|
||||
|
||||
@ -85,8 +86,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (UPstream::parRun() && optPrintTree)
|
||||
{
|
||||
Info<< "comms: "
|
||||
<< UPstream::whichCommunication(UPstream::worldComm) << nl;
|
||||
// Info<< "comms: "
|
||||
// << UPstream::whichCommunication(UPstream::worldComm) << nl;
|
||||
UPstream::printCommTree(UPstream::commWorld());
|
||||
}
|
||||
|
||||
@ -102,6 +103,34 @@ int main(int argc, char *argv[])
|
||||
<< flatOutput(UPstream::procID(UPstream::commLocalNode())) << nl;
|
||||
}
|
||||
|
||||
if (UPstream::parRun() && args.found("split"))
|
||||
{
|
||||
Info<< "split: alternative ranks" << nl;
|
||||
|
||||
const auto myRank = UPstream::myProcNo();
|
||||
|
||||
int colour =
|
||||
(
|
||||
(myRank == 5 || myRank == 6) // Exclude these ones
|
||||
? -1
|
||||
: (myRank % 2)
|
||||
);
|
||||
|
||||
UPstream::communicator comm =
|
||||
UPstream::communicator::split(UPstream::commWorld(), colour, true);
|
||||
|
||||
Pout<< "split ranks (colour=" << colour << ") "
|
||||
<< flatOutput(UPstream::procID(comm.comm())) << nl;
|
||||
|
||||
comm.reset();
|
||||
comm =
|
||||
UPstream::communicator::split(UPstream::commWorld(), colour, false);
|
||||
|
||||
Pout<< "Split ranks (colour=" << colour << ") "
|
||||
<< flatOutput(UPstream::procID(comm.comm())) << nl;
|
||||
}
|
||||
|
||||
|
||||
if (args.found("info"))
|
||||
{
|
||||
Info<< nl;
|
||||
@ -135,8 +164,8 @@ int main(int argc, char *argv[])
|
||||
<< endl;
|
||||
|
||||
{
|
||||
Info<< "host-master: "
|
||||
<< UPstream::whichCommunication(commInterNode) << endl;
|
||||
// Info<< "host-master: "
|
||||
// << UPstream::whichCommunication(commInterNode) << endl;
|
||||
|
||||
UPstream::printCommTree(commInterNode);
|
||||
UPstream::printCommTree(commLocalNode);
|
||||
@ -1,3 +1,3 @@
|
||||
Test-string_view1.C
|
||||
Test-string_view1.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-string_view1
|
||||
|
||||
@ -40,11 +40,6 @@ using namespace Foam;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Compiled with C++ " << __cplusplus;
|
||||
#if __cplusplus >= 201703L
|
||||
Info<< " - has std::string_view" << nl << nl;
|
||||
#else
|
||||
Info<< " - NO std::string_view" << nl << nl;
|
||||
#endif
|
||||
|
||||
// basics
|
||||
{
|
||||
@ -63,9 +58,7 @@ int main(int argc, char *argv[])
|
||||
<< "input: <" << cstr << '>'
|
||||
<< " type: " << typeid(cstr).name() << " len:" << len << nl;
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
Info<< " view: " << std::string_view(cstr) << nl;
|
||||
#endif
|
||||
|
||||
Info<< " span: "
|
||||
<< stdFoam::span<const char>(cstr, len) << nl;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user