Compare commits
1 Commits
develop.me
...
feature-fo
| Author | SHA1 | Date | |
|---|---|---|---|
| e2e03fd70d |
@ -1,2 +1,2 @@
|
|||||||
api=2502
|
api=2501
|
||||||
patch=0
|
patch=0
|
||||||
|
|||||||
@ -13,14 +13,7 @@ volVectorField U
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Initialise the velocity internal field to zero
|
// Initialise the velocity internal field to zero
|
||||||
// Note: explicitly bypass evaluation of contraint patch overrides
|
U = dimensionedVector(U.dimensions(), Zero);
|
||||||
// (e.g. swirlFanVelocity might lookup phi,rho)
|
|
||||||
//U = dimensionedVector(U.dimensions(), Zero);
|
|
||||||
{
|
|
||||||
const dimensionedVector dt(U.dimensions(), Zero);
|
|
||||||
U.internalFieldRef() = dt;
|
|
||||||
U.boundaryFieldRef() = dt.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
surfaceScalarField phi
|
surfaceScalarField phi
|
||||||
(
|
(
|
||||||
|
|||||||
@ -36,13 +36,11 @@ 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
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
deltaTFact*runTime.deltaTValue(),
|
deltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
|
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
||||||
|
|
||||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,18 +54,9 @@ if (adjustTimeStep)
|
|||||||
|
|
||||||
runTime.setDeltaT
|
runTime.setDeltaT
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
dt0
|
dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2),
|
||||||
* Foam::min
|
|
||||||
(
|
|
||||||
Foam::min
|
|
||||||
(
|
|
||||||
TFactorFluid,
|
|
||||||
Foam::min(TFactorFilm, TFactorSolid)
|
|
||||||
),
|
|
||||||
1.2
|
|
||||||
),
|
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2013-2016 OpenFOAM Foundation
|
Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -57,23 +57,11 @@ License
|
|||||||
// (relative to reference value)
|
// (relative to reference value)
|
||||||
scalar alphaY(pimpleDict.getOrDefault<scalar>("alphaY", 1.0));
|
scalar alphaY(pimpleDict.getOrDefault<scalar>("alphaY", 1.0));
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
Info<< "Time scales min/max:" << endl;
|
||||||
|
|
||||||
|
// Cache old reciprocal time scale field
|
||||||
|
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||||
|
|
||||||
// Flow time scale
|
// Flow time scale
|
||||||
{
|
{
|
||||||
rDeltaT.ref() =
|
rDeltaT.ref() =
|
||||||
@ -82,14 +70,12 @@ License
|
|||||||
/((2*maxCo)*mesh.V()*rho())
|
/((2*maxCo)*mesh.V()*rho())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Limit the largest time scale (=> smallest reciprocal time)
|
// Limit the largest time scale
|
||||||
rDeltaT.clamp_min(1/maxDeltaT);
|
rDeltaT.max(1/maxDeltaT);
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Flow = "
|
Info<< " Flow = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< 1/gMax(rDeltaT.primitiveField()) << ", "
|
||||||
|
<< 1/gMin(rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heat release rate time scale
|
// Heat release rate time scale
|
||||||
@ -100,13 +86,11 @@ License
|
|||||||
mag(Qdot)/(alphaTemp*rho*thermo.Cp()*T)
|
mag(Qdot)/(alphaTemp*rho*thermo.Cp()*T)
|
||||||
);
|
);
|
||||||
|
|
||||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaTT.field());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Temperature = "
|
Info<< " Temperature = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< 1/(gMax(rDeltaTT.field()) + VSMALL) << ", "
|
||||||
|
<< 1/(gMin(rDeltaTT.field()) + VSMALL) << endl;
|
||||||
|
|
||||||
|
rDeltaT.ref() = max(rDeltaT(), rDeltaTT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reaction rate time scale
|
// Reaction rate time scale
|
||||||
@ -154,13 +138,11 @@ License
|
|||||||
|
|
||||||
if (foundY)
|
if (foundY)
|
||||||
{
|
{
|
||||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
|
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaTY.field());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Composition = "
|
Info<< " Composition = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< 1/(gMax(rDeltaTY.field()) + VSMALL) << ", "
|
||||||
|
<< 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
|
||||||
|
|
||||||
|
rDeltaT.ref() = max(rDeltaT(), rDeltaTY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -179,22 +161,28 @@ License
|
|||||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
// Limit rate of change of time scale
|
||||||
// - reduce as much as required
|
// - reduce as much as required
|
||||||
// - only increase at a fraction of old time scale
|
// - only increase at a fraction of old time scale
|
||||||
if (rDeltaT0_damped)
|
if
|
||||||
|
(
|
||||||
|
rDeltaTDampingCoeff < 1
|
||||||
|
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||||
|
)
|
||||||
{
|
{
|
||||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
rDeltaT = max
|
||||||
|
(
|
||||||
|
rDeltaT,
|
||||||
|
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< 1/gMax(rDeltaT.primitiveField())
|
||||||
|
<< ", " << 1/gMin(rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -106,7 +106,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
|||||||
if (!this->readValueEntry(dict))
|
if (!this->readValueEntry(dict))
|
||||||
{
|
{
|
||||||
// Fallback: set to the internal field
|
// Fallback: set to the internal field
|
||||||
this->extrapolateInternal();
|
fvPatchField<scalar>::patchInternalField(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
refValue() = *this;
|
refValue() = *this;
|
||||||
|
|||||||
@ -23,11 +23,7 @@
|
|||||||
|
|
||||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||||
|
|
||||||
{
|
Info<< "Flow time scale min/max = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
Info<< "Flow time scale min/max = "
|
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,26 +52,18 @@
|
|||||||
// 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 = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
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 = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
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
|
||||||
@ -86,10 +78,8 @@
|
|||||||
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 = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
scalar CoNum = -GREAT;
|
scalar CoNum = -GREAT;
|
||||||
forAll(fluidRegions, regionI)
|
forAll(fluidRegions, regionI)
|
||||||
{
|
{
|
||||||
CoNum = Foam::max
|
CoNum = max
|
||||||
(
|
(
|
||||||
compressibleCourantNo
|
compressibleCourantNo
|
||||||
(
|
(
|
||||||
|
|||||||
@ -78,8 +78,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
|
rho = max(rho, rhoMin[i]);
|
||||||
rho.clamp_range(rhoMin[i], rhoMax[i]);
|
rho = min(rho, rhoMax[i]);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
|
|
||||||
Info<< "Min/max rho:" << min(rho).value() << ' '
|
Info<< "Min/max rho:" << min(rho).value() << ' '
|
||||||
|
|||||||
@ -387,18 +387,15 @@ updateCoeffs()
|
|||||||
{
|
{
|
||||||
scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
|
scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad());
|
||||||
|
|
||||||
auto limits = gMinMax(Tp);
|
Info<< "T solid : " << nl << endl;
|
||||||
auto avg = gAverage(Tp);
|
|
||||||
|
|
||||||
Info<< "T solid : " << nl << endl;
|
Info
|
||||||
|
<< " heat transfer rate from solid:" << Q
|
||||||
Info
|
<< " walltemperature "
|
||||||
<< " heat transfer rate from solid:" << Q
|
<< " min:" << gMin(Tp)
|
||||||
<< " walltemperature "
|
<< " max:" << gMax(Tp)
|
||||||
<< " min:" << limits.min()
|
<< " avg:" << gAverage(Tp) << nl
|
||||||
<< " max:" << limits.max()
|
<< endl;
|
||||||
<< " avg:" << avg << nl
|
|
||||||
<< endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (regionType_ == fluid)
|
else if (regionType_ == fluid)
|
||||||
@ -448,16 +445,10 @@ 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: " << infoLiq.min() << " - " << infoLiq.max() << nl
|
Info<< " qLiq: " << gMin(qLiq) << " - " << gMax(qLiq) << endl;
|
||||||
<< " qVap: " << infoVap.min() << " - " << infoVap.max() << nl;
|
Info<< " qVap: " << gMin(qVap) << " - " << gMax(qVap) << endl;
|
||||||
|
|
||||||
scalar QLiq = gSum(qLiq*patch().magSf());
|
scalar QLiq = gSum(qLiq*patch().magSf());
|
||||||
scalar QVap = gSum(qVap*patch().magSf());
|
scalar QVap = gSum(qVap*patch().magSf());
|
||||||
@ -466,9 +457,9 @@ updateCoeffs()
|
|||||||
Info<< " Heat transfer to Vap: " << QVap << endl;
|
Info<< " Heat transfer to Vap: " << QVap << endl;
|
||||||
|
|
||||||
Info<< " walltemperature "
|
Info<< " walltemperature "
|
||||||
<< " min:" << infoT.min()
|
<< " min:" << gMin(Tp)
|
||||||
<< " max:" << infoT.max()
|
<< " max:" << gMax(Tp)
|
||||||
<< " avg:" << avgT
|
<< " avg:" << gAverage(Tp)
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
scalar regionCoNum =
|
CoNum =
|
||||||
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 = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
|
CoNum = max(UrCoNum, CoNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
forAll(fluidRegions, regioni)
|
forAll(fluidRegions, regioni)
|
||||||
{
|
{
|
||||||
CoNum = Foam::max
|
CoNum = max
|
||||||
(
|
(
|
||||||
compressibleCourantNo
|
compressibleCourantNo
|
||||||
(
|
(
|
||||||
@ -17,7 +17,7 @@
|
|||||||
/*
|
/*
|
||||||
forAll(porousFluidRegions, porousi)
|
forAll(porousFluidRegions, porousi)
|
||||||
{
|
{
|
||||||
CoNum = Foam::max
|
CoNum = max
|
||||||
(
|
(
|
||||||
compressibleCourantNo
|
compressibleCourantNo
|
||||||
(
|
(
|
||||||
|
|||||||
@ -47,10 +47,10 @@ if (adjustTimeStep)
|
|||||||
|
|
||||||
runTime.setDeltaT
|
runTime.setDeltaT
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
Foam::min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||||
Foam::min(runTime.deltaTValue(), maxDeltaT)
|
min(runTime.deltaTValue(), maxDeltaT)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
|
|||||||
@ -48,14 +48,18 @@ if (adjustTimeStep)
|
|||||||
scalar maxDeltaTFluid = maxCo/(CoNum + SMALL);
|
scalar maxDeltaTFluid = maxCo/(CoNum + SMALL);
|
||||||
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
|
scalar maxDeltaTSolid = maxDi/(DiNum + SMALL);
|
||||||
|
|
||||||
const scalar deltaTFluid =
|
scalar deltaTFluid =
|
||||||
Foam::min(Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid), 1.2);
|
min
|
||||||
|
(
|
||||||
|
min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
|
||||||
|
1.2
|
||||||
|
);
|
||||||
|
|
||||||
runTime.setDeltaT
|
runTime.setDeltaT
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
Foam::min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -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 = Foam::max
|
DiNum = max
|
||||||
(
|
(
|
||||||
solidRegionDiffNo
|
solidRegionDiffNo
|
||||||
(
|
(
|
||||||
|
|||||||
@ -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 = Foam::max
|
DiNum = max
|
||||||
(
|
(
|
||||||
solidRegionDiffNo
|
solidRegionDiffNo
|
||||||
(
|
(
|
||||||
|
|||||||
@ -60,10 +60,13 @@ template<class Type>
|
|||||||
void zeroCells
|
void zeroCells
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvPatchField, volMesh>& vf,
|
GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
const labelUList& cells
|
const labelList& cells
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UIndirectList<Type>(vf.primitiveField(), cells) = Zero;
|
forAll(cells, i)
|
||||||
|
{
|
||||||
|
vf[cells[i]] = Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -103,8 +103,8 @@ dimensionedScalar alphaMax
|
|||||||
laminarTransport
|
laminarTransport
|
||||||
);
|
);
|
||||||
|
|
||||||
const labelUList& inletCells = mesh.boundary()["inlet"].faceCells();
|
const labelList& inletCells = mesh.boundary()["inlet"].faceCells();
|
||||||
//const labelUList& outletCells = mesh.boundary()["outlet"].faceCells();
|
//const labelList& outletCells = mesh.boundary()["outlet"].faceCells();
|
||||||
|
|
||||||
volScalarField alpha
|
volScalarField alpha
|
||||||
(
|
(
|
||||||
|
|||||||
@ -55,7 +55,7 @@ if (mesh.changing())
|
|||||||
dimensionedScalar rAUf("rAUf", dimTime, 1.0);
|
dimensionedScalar rAUf("rAUf", dimTime, 1.0);
|
||||||
|
|
||||||
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||||
const labelUList& cellTypes = overlap.cellTypes();
|
const labelList& cellTypes = overlap.cellTypes();
|
||||||
const labelIOList& zoneIDs = overlap.zoneID();
|
const labelIOList& zoneIDs = overlap.zoneID();
|
||||||
|
|
||||||
while (pimple.correctNonOrthogonal())
|
while (pimple.correctNonOrthogonal())
|
||||||
|
|||||||
@ -36,26 +36,18 @@
|
|||||||
// 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 = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
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 = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
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
|
||||||
@ -70,10 +62,8 @@
|
|||||||
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 = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -54,22 +54,11 @@ License
|
|||||||
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
Info<< "Time scales min/max:" << endl;
|
||||||
|
|
||||||
|
// Cache old reciprocal time scale field
|
||||||
|
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||||
|
|
||||||
// Flow time scale
|
// Flow time scale
|
||||||
{
|
{
|
||||||
rDeltaT.ref() =
|
rDeltaT.ref() =
|
||||||
@ -78,14 +67,12 @@ License
|
|||||||
/((2*maxCo)*mesh.V()*rho())
|
/((2*maxCo)*mesh.V()*rho())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Limit the largest time scale (=> smallest reciprocal time)
|
// Limit the largest time scale
|
||||||
rDeltaT.clamp_min(1/maxDeltaT);
|
rDeltaT.max(1/maxDeltaT);
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Flow = "
|
Info<< " Flow = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField()) << ", "
|
||||||
|
<< gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reaction source time scale
|
// Reaction source time scale
|
||||||
@ -106,13 +93,15 @@ License
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaTT.field());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Temperature = "
|
Info<< " Temperature = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
|
||||||
|
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
|
||||||
|
|
||||||
|
rDeltaT.ref() = max
|
||||||
|
(
|
||||||
|
rDeltaT(),
|
||||||
|
rDeltaTT
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update tho boundary values of the reciprocal time-step
|
// Update tho boundary values of the reciprocal time-step
|
||||||
@ -124,19 +113,25 @@ License
|
|||||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
// Limit rate of change of time scale
|
||||||
// - reduce as much as required
|
// - reduce as much as required
|
||||||
// - only increase at a fraction of old time scale
|
// - only increase at a fraction of old time scale
|
||||||
if (rDeltaT0_damped)
|
if
|
||||||
|
(
|
||||||
|
rDeltaTDampingCoeff < 1.0
|
||||||
|
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||||
|
)
|
||||||
{
|
{
|
||||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
rDeltaT = max
|
||||||
|
(
|
||||||
|
rDeltaT,
|
||||||
|
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Overall = "
|
Info<< " Overall = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -36,18 +36,13 @@ Description
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
const scalar maxDeltaTFact =
|
const scalar maxDeltaTFact =
|
||||||
Foam::min
|
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
|
||||||
(
|
|
||||||
maxCo/(CoNum + SMALL),
|
|
||||||
maxCo/(surfaceFilm.CourantNumber() + SMALL)
|
|
||||||
);
|
|
||||||
|
|
||||||
const scalar deltaTFact =
|
const scalar deltaTFact =
|
||||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
min(min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||||
|
|
||||||
runTime.setDeltaT
|
runTime.setDeltaT
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
deltaTFact*runTime.deltaTValue(),
|
deltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020,2025 OpenCFD Ltd.
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -54,22 +54,11 @@ License
|
|||||||
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
scalar alphaTemp(pimpleDict.getOrDefault("alphaTemp", 0.05));
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
Info<< "Time scales min/max:" << endl;
|
||||||
|
|
||||||
|
// Cache old reciprocal time scale field
|
||||||
|
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||||
|
|
||||||
// Flow time scale
|
// Flow time scale
|
||||||
{
|
{
|
||||||
rDeltaT.ref() =
|
rDeltaT.ref() =
|
||||||
@ -78,14 +67,12 @@ License
|
|||||||
/((2*maxCo)*mesh.V()*rho())
|
/((2*maxCo)*mesh.V()*rho())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Limit the largest time scale (=> smallest reciprocal time)
|
// Limit the largest time scale
|
||||||
rDeltaT.clamp_min(1/maxDeltaT);
|
rDeltaT.max(1/maxDeltaT);
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Flow = "
|
Info<< " Flow = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField()) << ", "
|
||||||
|
<< gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reaction source time scale
|
// Reaction source time scale
|
||||||
@ -105,13 +92,15 @@ License
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTT);
|
|
||||||
|
|
||||||
auto limits = gMinMax(rDeltaTT.field());
|
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
|
||||||
|
|
||||||
Info<< " Temperature = "
|
Info<< " Temperature = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
|
||||||
|
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
|
||||||
|
|
||||||
|
rDeltaT.ref() = max
|
||||||
|
(
|
||||||
|
rDeltaT(),
|
||||||
|
rDeltaTT
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the boundary values of the reciprocal time-step
|
// Update the boundary values of the reciprocal time-step
|
||||||
@ -123,22 +112,25 @@ License
|
|||||||
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
// Limit rate of change of time scale
|
||||||
// - reduce as much as required
|
// - reduce as much as required
|
||||||
// - only increase at a fraction of old time scale
|
// - only increase at a fraction of old time scale
|
||||||
if (rDeltaT0_damped)
|
if
|
||||||
|
(
|
||||||
|
rDeltaTDampingCoeff < 1.0
|
||||||
|
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||||
|
)
|
||||||
{
|
{
|
||||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
rDeltaT = max
|
||||||
|
(
|
||||||
|
rDeltaT,
|
||||||
|
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 = "
|
Info<< " Overall = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,8 @@ U.correctBoundaryConditions();
|
|||||||
fvOptions.correct(U);
|
fvOptions.correct(U);
|
||||||
|
|
||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
|
|
||||||
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
||||||
|
|||||||
@ -49,7 +49,8 @@
|
|||||||
fvOptions.correct(U);
|
fvOptions.correct(U);
|
||||||
|
|
||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
|
|
||||||
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
|
|
||||||
volScalarField rAU(1.0/UEqn.A());
|
volScalarField rAU(1.0/UEqn.A());
|
||||||
@ -93,7 +94,8 @@ p.relax();
|
|||||||
|
|
||||||
// Recalculate density from the relaxed pressure
|
// Recalculate density from the relaxed pressure
|
||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
|
|
||||||
volScalarField rAU(1.0/UEqn.A());
|
volScalarField rAU(1.0/UEqn.A());
|
||||||
@ -93,7 +94,8 @@ p.relax();
|
|||||||
|
|
||||||
// Recalculate density from the relaxed pressure
|
// Recalculate density from the relaxed pressure
|
||||||
rho = thermo.rho();
|
rho = thermo.rho();
|
||||||
rho.clamp_range(rhoMin, rhoMax);
|
rho = max(rho, rhoMin);
|
||||||
|
rho = min(rho, rhoMax);
|
||||||
rho.relax();
|
rho.relax();
|
||||||
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;
|
||||||
|
|
||||||
|
|||||||
@ -36,14 +36,13 @@ Description
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
scalar maxDeltaTFact =
|
scalar maxDeltaTFact =
|
||||||
Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
|
min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
|
||||||
|
|
||||||
const scalar deltaTFact =
|
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
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
deltaTFact*runTime.deltaTValue(),
|
deltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
|
|||||||
@ -53,21 +53,6 @@
|
|||||||
pimpleDict.getOrDefault<scalar>("maxDeltaT", GREAT)
|
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);
|
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
|
||||||
|
|
||||||
// Set the reciprocal time-step from the local Courant number
|
// Set the reciprocal time-step from the local Courant number
|
||||||
@ -98,13 +83,10 @@
|
|||||||
// 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 = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
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);
|
||||||
@ -128,25 +110,27 @@
|
|||||||
fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
|
fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
Info<< "Smoothed flow time scale min/max = "
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
|
|
||||||
Info<< "Smoothed flow time scale min/max = "
|
// Limit rate of change of time scale
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Limit rate of change of time scale (=> smallest reciprocal time)
|
|
||||||
// - reduce as much as required
|
// - reduce as much as required
|
||||||
// - only increase at a fraction of old time scale
|
// - only increase at a fraction of old time scale
|
||||||
if (rDeltaT0_damped)
|
if
|
||||||
|
(
|
||||||
|
rDeltaTDampingCoeff < 1.0
|
||||||
|
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
|
||||||
|
)
|
||||||
{
|
{
|
||||||
rDeltaT.clamp_min(rDeltaT0_damped());
|
rDeltaT = max
|
||||||
|
(
|
||||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
rDeltaT,
|
||||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
|
||||||
|
);
|
||||||
|
|
||||||
Info<< "Damped flow time scale min/max = "
|
Info<< "Damped flow time scale min/max = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,14 +36,13 @@ Description
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
scalar maxDeltaTFact =
|
scalar maxDeltaTFact =
|
||||||
Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
|
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
|
||||||
|
|
||||||
const scalar deltaTFact =
|
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
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
deltaTFact*runTime.deltaTValue(),
|
deltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
|
|||||||
@ -37,15 +37,11 @@ if (adjustTimeStep)
|
|||||||
if (CoNum > SMALL)
|
if (CoNum > SMALL)
|
||||||
{
|
{
|
||||||
scalar maxDeltaTFact =
|
scalar maxDeltaTFact =
|
||||||
Foam::min
|
min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
|
||||||
(
|
|
||||||
maxCo/(CoNum + SMALL),
|
|
||||||
maxAcousticCo/(acousticCoNum + SMALL)
|
|
||||||
);
|
|
||||||
|
|
||||||
runTime.setDeltaT
|
runTime.setDeltaT
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
maxDeltaTFact*runTime.deltaTValue(),
|
maxDeltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
|
|||||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
|||||||
{
|
{
|
||||||
if (dgdt[celli] > 0.0)
|
if (dgdt[celli] > 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
else if (dgdt[celli] < 0.0)
|
else if (dgdt[celli] < 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -210,7 +210,7 @@ void VoFPatchTransfer::correct
|
|||||||
film().toRegion(patchi, Vp);
|
film().toRegion(patchi, Vp);
|
||||||
|
|
||||||
const polyPatch& pp = pbm[patchi];
|
const polyPatch& pp = pbm[patchi];
|
||||||
const labelUList& faceCells = pp.faceCells();
|
const labelList& faceCells = pp.faceCells();
|
||||||
|
|
||||||
// Accumulate the total mass removed from patch
|
// Accumulate the total mass removed from patch
|
||||||
scalar dMassPatch = 0;
|
scalar dMassPatch = 0;
|
||||||
|
|||||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
|||||||
{
|
{
|
||||||
if (dgdt[celli] > 0.0)
|
if (dgdt[celli] > 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
else if (dgdt[celli] < 0.0)
|
else if (dgdt[celli] < 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,12 +26,12 @@ forAll(dgdt, celli)
|
|||||||
{
|
{
|
||||||
if (dgdt[celli] > 0.0)
|
if (dgdt[celli] > 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Sp[celli] -= dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
Su[celli] += dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
|
Su[celli] += dgdt[celli]/max(1.0 - alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
else if (dgdt[celli] < 0.0)
|
else if (dgdt[celli] < 0.0)
|
||||||
{
|
{
|
||||||
Sp[celli] += dgdt[celli]/Foam::max(alpha1[celli], 1e-4);
|
Sp[celli] += dgdt[celli]/max(alpha1[celli], 1e-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,7 +135,7 @@ public:
|
|||||||
virtual volScalarField& he()
|
virtual volScalarField& he()
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return volScalarField::null().constCast();
|
return const_cast<volScalarField&>(volScalarField::null());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Enthalpy/Internal energy [J/kg]
|
//- Enthalpy/Internal energy [J/kg]
|
||||||
|
|||||||
@ -243,7 +243,7 @@ public:
|
|||||||
virtual volScalarField& he()
|
virtual volScalarField& he()
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return volScalarField::null().constCast();
|
return const_cast<volScalarField&>(volScalarField::null());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Enthalpy/Internal energy [J/kg]
|
//- Enthalpy/Internal energy [J/kg]
|
||||||
|
|||||||
@ -36,13 +36,13 @@ Description
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
scalar maxDeltaTFact =
|
scalar maxDeltaTFact =
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
maxCo/(CoNum + SMALL),
|
maxCo/(CoNum + SMALL),
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
maxAlphaCo/(alphaCoNum + SMALL),
|
maxAlphaCo/(alphaCoNum + SMALL),
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
maxAlphaDdt/(ddtAlphaNum + SMALL),
|
maxAlphaDdt/(ddtAlphaNum + SMALL),
|
||||||
maxDi/(DiNum + SMALL)
|
maxDi/(DiNum + SMALL)
|
||||||
@ -50,18 +50,16 @@ if (adjustTimeStep)
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalar deltaTFact =
|
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
|
||||||
(
|
(
|
||||||
Foam::min
|
min
|
||||||
(
|
(
|
||||||
deltaTFact*runTime.deltaTValue(),
|
deltaTFact*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public:
|
|||||||
virtual volScalarField& he()
|
virtual volScalarField& he()
|
||||||
{
|
{
|
||||||
NotImplemented;
|
NotImplemented;
|
||||||
return volScalarField::null().constCast();
|
return const_cast<volScalarField&>(volScalarField::null());
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return access to the internal energy field [J/Kg]
|
//- Return access to the internal energy field [J/Kg]
|
||||||
|
|||||||
@ -65,7 +65,7 @@
|
|||||||
dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
|
dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
|
||||||
|
|
||||||
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
const cellCellStencilObject& overlap = Stencil::New(mesh);
|
||||||
const labelUList& cellTypes = overlap.cellTypes();
|
const labelList& cellTypes = overlap.cellTypes();
|
||||||
const labelIOList& zoneIDs = overlap.zoneID();
|
const labelIOList& zoneIDs = overlap.zoneID();
|
||||||
|
|
||||||
while (pimple.correctNonOrthogonal())
|
while (pimple.correctNonOrthogonal())
|
||||||
|
|||||||
@ -38,9 +38,7 @@
|
|||||||
|
|
||||||
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 = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,5 +8,5 @@
|
|||||||
|
|
||||||
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
||||||
|
|
||||||
CoNum = Foam::max(CoNum, UrCoNum);
|
CoNum = max(CoNum, UrCoNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,9 +31,7 @@
|
|||||||
|
|
||||||
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 = "
|
||||||
<< limits.min() << ", " << limits.max() << endl;
|
<< gMin(1/rDeltaT.primitiveField())
|
||||||
|
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,5 +8,5 @@
|
|||||||
|
|
||||||
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
Info<< "Max Ur Courant Number = " << UrCoNum << endl;
|
||||||
|
|
||||||
CoNum = Foam::max(CoNum, UrCoNum);
|
CoNum = max(CoNum, UrCoNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-CircularBuffer.cxx
|
Test-CircularBuffer.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-CircularBuffer
|
EXE = $(FOAM_USER_APPBIN)/Test-CircularBuffer
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-DynamicList.cxx
|
Test-DynamicList.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList
|
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-DynamicList2.cxx
|
Test-DynamicList2.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList2
|
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList2
|
||||||
|
|||||||
@ -52,8 +52,7 @@ void printInfo
|
|||||||
if (showSize)
|
if (showSize)
|
||||||
{
|
{
|
||||||
Info<< " size=\"" << list.size()
|
Info<< " size=\"" << list.size()
|
||||||
<< "\" capacity=\"" << list.capacity() << "\""
|
<< "\" capacity=\"" << list.capacity() << "\"";
|
||||||
<< "\" min=\"" << SizeMin << "\"" ;
|
|
||||||
if (list.cdata())
|
if (list.cdata())
|
||||||
{
|
{
|
||||||
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
||||||
@ -80,8 +79,7 @@ void printInfo
|
|||||||
if (showSize)
|
if (showSize)
|
||||||
{
|
{
|
||||||
Info<< " size=\"" << list.size()
|
Info<< " size=\"" << list.size()
|
||||||
<< "\" capacity=\"" << list.capacity() << "\""
|
<< "\" capacity=\"" << list.capacity() << "\"";
|
||||||
<< "\" min=\"" << SizeMin << "\"" ;
|
|
||||||
if (list.cdata())
|
if (list.cdata())
|
||||||
{
|
{
|
||||||
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
Info<< " ptr=\"" << name(list.cdata()) << "\"";
|
||||||
@ -170,22 +168,6 @@ int main(int argc, char *argv[])
|
|||||||
printInfo("", list2);
|
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";
|
Info<< "\nEnd\n";
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-FixedList.cxx
|
Test-FixedList.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-FixedList
|
EXE = $(FOAM_USER_APPBIN)/Test-FixedList
|
||||||
|
|||||||
@ -41,6 +41,7 @@ See also
|
|||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "IPstream.H"
|
#include "IPstream.H"
|
||||||
#include "OPstream.H"
|
#include "OPstream.H"
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-Hashing2.cxx
|
Test-Hashing2.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
||||||
|
|||||||
@ -274,7 +274,9 @@ int main(int argc, char *argv[])
|
|||||||
Info<< nl << "No " << is.name() << " file found ..." << nl;
|
Info<< nl << "No " << is.name() << " file found ..." << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (token tok; tok.read(is); /*nil*/)
|
token tok;
|
||||||
|
|
||||||
|
while (is.good() && is.read(tok) && tok.good())
|
||||||
{
|
{
|
||||||
const word listType(tok.wordToken());
|
const word listType(tok.wordToken());
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-ICharStream1.cxx
|
Test-ICharStream1.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,10 +83,12 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
Ostream& printView(Ostream& os, std::string_view s)
|
Ostream& printView(Ostream& os, std::string_view s)
|
||||||
{
|
{
|
||||||
return printView(os, s.begin(), s.end());
|
return printView(os, s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||||
@ -136,10 +138,17 @@ void printInfo(const List<char>& buf)
|
|||||||
void printTokens(Istream& is)
|
void printTokens(Istream& is)
|
||||||
{
|
{
|
||||||
label count = 0;
|
label count = 0;
|
||||||
for (token tok; tok.read(is); ++count)
|
token t;
|
||||||
|
while (is.good())
|
||||||
{
|
{
|
||||||
Info<< "token: " << tok << nl;
|
is >> t;
|
||||||
|
if (t.good())
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
Info<<"token: " << t << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< count << " tokens" << endl;
|
Info<< count << " tokens" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017 OpenFOAM Foundation
|
Copyright (C) 2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
Copyright (C) 2019-2022 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -269,7 +269,7 @@ int main(int argc, char *argv[])
|
|||||||
ioOutput.rename(args.executable() + "-labels");
|
ioOutput.rename(args.executable() + "-labels");
|
||||||
Info<< "write " << ioOutput.objectRelPath() << endl;
|
Info<< "write " << ioOutput.objectRelPath() << endl;
|
||||||
{
|
{
|
||||||
IOList<label>::writeContents(ioOutput, ints);
|
IOListRef<label>(ioOutput, ints).write();
|
||||||
}
|
}
|
||||||
|
|
||||||
ioOutput.rename(args.executable() + "-points");
|
ioOutput.rename(args.executable() + "-points");
|
||||||
|
|||||||
@ -73,13 +73,14 @@ Ostream& toString(Ostream& os, const List<char>& list)
|
|||||||
|
|
||||||
void printTokens(Istream& is)
|
void printTokens(Istream& is)
|
||||||
{
|
{
|
||||||
Info<< "stream tokens:" << endl;
|
|
||||||
|
|
||||||
label count = 0;
|
label count = 0;
|
||||||
|
|
||||||
|
Info<< "stream tokens:" << endl;
|
||||||
for (token tok; tok.read(is); ++count)
|
for (token tok; tok.read(is); ++count)
|
||||||
{
|
{
|
||||||
Info<< " : " << tok << nl;
|
Info<< " : " << tok << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< count << " tokens" << endl;
|
Info<< count << " tokens" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-List.cxx
|
Test-List.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-List
|
EXE = $(FOAM_USER_APPBIN)/Test-List
|
||||||
|
|||||||
@ -51,10 +51,10 @@ See also
|
|||||||
#include "IndirectList.H"
|
#include "IndirectList.H"
|
||||||
#include "SubList.H"
|
#include "SubList.H"
|
||||||
#include "SliceList.H"
|
#include "SliceList.H"
|
||||||
#include "SubField.H"
|
|
||||||
#include "ListPolicy.H"
|
#include "ListPolicy.H"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <numeric>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
// see issue #2083
|
// see issue #2083
|
||||||
@ -75,6 +75,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Detail
|
||||||
|
{
|
||||||
namespace ListPolicy
|
namespace ListPolicy
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -82,6 +84,7 @@ namespace ListPolicy
|
|||||||
template<> struct short_length<short> : std::integral_constant<int,20> {};
|
template<> struct short_length<short> : std::integral_constant<int,20> {};
|
||||||
|
|
||||||
} // End namespace ListPolicy
|
} // End namespace ListPolicy
|
||||||
|
} // End namespace Detail
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
@ -116,9 +119,9 @@ Ostream& printListOutputType(const char* what)
|
|||||||
Info<< what
|
Info<< what
|
||||||
<< " (contiguous="
|
<< " (contiguous="
|
||||||
<< is_contiguous_v<T> << " no_linebreak="
|
<< is_contiguous_v<T> << " no_linebreak="
|
||||||
<< ListPolicy::no_linebreak<T>::value
|
<< Detail::ListPolicy::no_linebreak<T>::value
|
||||||
<< " short_length="
|
<< " short_length="
|
||||||
<< ListPolicy::short_length<T>::value << ')';
|
<< Detail::ListPolicy::short_length<T>::value << ')';
|
||||||
|
|
||||||
return Info;
|
return Info;
|
||||||
}
|
}
|
||||||
@ -140,46 +143,8 @@ int main(int argc, char *argv[])
|
|||||||
argList::addBoolOption("ListList", "Test list of list functionality");
|
argList::addBoolOption("ListList", "Test list of list functionality");
|
||||||
argList::addBoolOption("flag");
|
argList::addBoolOption("flag");
|
||||||
|
|
||||||
argList::addBoolOption("reserve", "Test ListPolicy for reserve_size");
|
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#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);
|
List<label> ident(15);
|
||||||
Foam::identity(ident, 0);
|
Foam::identity(ident, 0);
|
||||||
@ -204,6 +169,16 @@ int main(int argc, char *argv[])
|
|||||||
Info<<" " << *iter;
|
Info<<" " << *iter;
|
||||||
}
|
}
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
|
Info<< "data:" << Foam::name(ident.cdata())
|
||||||
|
<< " size:" << ident.size() << nl;
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "resize_unsafe(10)" << nl;
|
||||||
|
ident.resize_unsafe(10);
|
||||||
|
|
||||||
|
Info<< "data:" << Foam::name(ident.cdata())
|
||||||
|
<< " size:" << ident.size() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false)
|
if (false)
|
||||||
@ -272,33 +247,6 @@ int main(int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
Info<< "list4: " << list4 << endl;
|
Info<< "list4: " << list4 << endl;
|
||||||
|
|
||||||
{
|
|
||||||
List<scalar> list4Mag = ListOps::create<scalar>
|
|
||||||
(
|
|
||||||
list4,
|
|
||||||
[](const auto& a){ return a.mag(); }
|
|
||||||
);
|
|
||||||
|
|
||||||
const auto equalMag = [](const auto& a, const auto& b)
|
|
||||||
{
|
|
||||||
return (Foam::mag(a) == Foam::mag(b));
|
|
||||||
};
|
|
||||||
|
|
||||||
Info<< "list4 (mag): " << list4Mag << endl;
|
|
||||||
|
|
||||||
bool same = ListOps::equal(list4, list4Mag, equalMag);
|
|
||||||
Info<< "mag(list4) == list4(mag): " << same << nl;
|
|
||||||
|
|
||||||
SubField<scalar>(list4Mag) *= -1;
|
|
||||||
same = ListOps::equal(list4, list4Mag, equalMag);
|
|
||||||
Info<< "mag(list4) == list4(mag): " << same << nl;
|
|
||||||
|
|
||||||
SubField<scalar>(list4Mag) *= 1.1;
|
|
||||||
same = ListOps::equal(list4, list4Mag, equalMag);
|
|
||||||
Info<< "mag(list4) == list4(mag): " << same << nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
List<vector> list5
|
List<vector> list5
|
||||||
{
|
{
|
||||||
{5, 3, 1},
|
{5, 3, 1},
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-List3.cxx
|
Test-List3.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-List3
|
EXE = $(FOAM_USER_APPBIN)/Test-List3
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-ListRead1.cxx
|
Test-ListRead1.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||||
|
|||||||
@ -50,6 +50,7 @@ Description
|
|||||||
#include "ListPolicy.H"
|
#include "ListPolicy.H"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <numeric>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
@ -85,7 +86,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
|||||||
// constexpr label chunkSize = 128;
|
// constexpr label chunkSize = 128;
|
||||||
typedef std::unique_ptr<List<T>> chunkType;
|
typedef std::unique_ptr<List<T>> chunkType;
|
||||||
|
|
||||||
tok.read(is);
|
is >> tok;
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
|
|
||||||
if (tok.isPunctuation(token::END_LIST))
|
if (tok.isPunctuation(token::END_LIST))
|
||||||
@ -149,7 +150,7 @@ bool readBracketList(List<T>& list, Istream& is)
|
|||||||
"reading entry"
|
"reading entry"
|
||||||
);
|
);
|
||||||
|
|
||||||
tok.read(is);
|
is >> tok;
|
||||||
is.fatalCheck(FUNCTION_NAME);
|
is.fatalCheck(FUNCTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-OCharStream1.cxx
|
Test-OCharStream1.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,10 +83,12 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
Ostream& printView(Ostream& os, std::string_view s)
|
Ostream& printView(Ostream& os, std::string_view s)
|
||||||
{
|
{
|
||||||
return printView(os, s.begin(), s.end());
|
return printView(os, s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||||
@ -127,10 +129,17 @@ void printInfo(const BufType& buf)
|
|||||||
void printTokens(Istream& is)
|
void printTokens(Istream& is)
|
||||||
{
|
{
|
||||||
label count = 0;
|
label count = 0;
|
||||||
for (token tok; tok.read(is); ++count)
|
token t;
|
||||||
|
while (is.good())
|
||||||
{
|
{
|
||||||
Info<< "token: " << tok << nl;
|
is >> t;
|
||||||
|
if (t.good())
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
Info<<"token: " << t << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< count << " tokens" << endl;
|
Info<< count << " tokens" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-PackedList1.cxx
|
Test-PackedList1.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList1
|
EXE = $(FOAM_USER_APPBIN)/Test-PackedList1
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-PackedList2.cxx
|
Test-PackedList2.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList2
|
EXE = $(FOAM_USER_APPBIN)/Test-PackedList2
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-SpanStream1.cxx
|
Test-SpanStream1.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -85,10 +85,12 @@ Ostream& printView(Ostream& os, const char* first, const char* last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
Ostream& printView(Ostream& os, std::string_view s)
|
Ostream& printView(Ostream& os, std::string_view s)
|
||||||
{
|
{
|
||||||
return printView(os, s.begin(), s.end());
|
return printView(os, s.begin(), s.end());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
Ostream& printView(Ostream& os, stdFoam::span<char> s)
|
||||||
@ -143,10 +145,17 @@ void printInfo(const UList<char>& buf)
|
|||||||
void printTokens(Istream& is)
|
void printTokens(Istream& is)
|
||||||
{
|
{
|
||||||
label count = 0;
|
label count = 0;
|
||||||
for (token tok; tok.read(is); ++count)
|
token t;
|
||||||
|
while (is.good())
|
||||||
{
|
{
|
||||||
Info<< "token: " << tok << nl;
|
is >> t;
|
||||||
|
if (t.good())
|
||||||
|
{
|
||||||
|
++count;
|
||||||
|
Info<<"token: " << t << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< count << " tokens" << endl;
|
Info<< count << " tokens" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-SubField.cxx
|
Test-SubField.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-SubField
|
EXE = $(FOAM_USER_APPBIN)/Test-SubField
|
||||||
|
|||||||
@ -38,6 +38,7 @@ Description
|
|||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "labelRange.H"
|
#include "labelRange.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-UIndirectList.cxx
|
Test-UIndirectList.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-UIndirectList
|
EXE = $(FOAM_USER_APPBIN)/Test-UIndirectList
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-bitSet2.cxx
|
Test-bitSet2.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-bitSet2
|
EXE = $(FOAM_USER_APPBIN)/Test-bitSet2
|
||||||
|
|||||||
@ -499,7 +499,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<<"bitSet ";
|
Info<<"bitSet ";
|
||||||
report(list4);
|
report(list4);
|
||||||
|
|
||||||
list4.shrink_to_fit();
|
list4.shrink();
|
||||||
Info<<"shrunk ";
|
Info<<"shrunk ";
|
||||||
report(list4);
|
report(list4);
|
||||||
|
|
||||||
@ -1,3 +1,3 @@
|
|||||||
Test-charList.cxx
|
Test-charList.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-charList
|
EXE = $(FOAM_USER_APPBIN)/Test-charList
|
||||||
|
|||||||
@ -43,6 +43,8 @@ Description
|
|||||||
#include "SubList.H"
|
#include "SubList.H"
|
||||||
#include "FlatOutput.H"
|
#include "FlatOutput.H"
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -50,6 +50,8 @@ Description
|
|||||||
#include "SliceStreamRepo.H"
|
#include "SliceStreamRepo.H"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <numeric>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-contiguous.cxx
|
Test-contiguous.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-contiguous
|
EXE = $(FOAM_USER_APPBIN)/Test-contiguous
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
Test-dictionaryTokens.cxx
|
Test-dictionaryTokens.C
|
||||||
dictionaryTokens.cxx
|
dictionaryTokens.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
|
EXE = $(FOAM_USER_APPBIN)/Test-dictionaryTokens
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-edges.cxx
|
Test-edges.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-edges
|
EXE = $(FOAM_USER_APPBIN)/Test-edges
|
||||||
|
|||||||
@ -142,26 +142,6 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "sorted ";
|
Info<< "sorted ";
|
||||||
printInfo(e4);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,12 +262,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Check constant profile
|
// Check constant profile
|
||||||
{
|
{
|
||||||
auto limits = gMinMax(one);
|
const scalar max = gMax(one);
|
||||||
|
const scalar min = gMin(one);
|
||||||
|
|
||||||
Info<< "Uniform one field min = "
|
Info<< "Uniform one field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform volVectorField not preserved."
|
<< "Uniform volVectorField not preserved."
|
||||||
@ -285,12 +286,13 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const scalarField diff = ccX-mesh.C().component(0);
|
const scalarField diff = ccX-mesh.C().component(0);
|
||||||
|
|
||||||
auto limits = gMinMax(diff);
|
const scalar max = gMax(diff);
|
||||||
|
const scalar min = gMin(diff);
|
||||||
|
|
||||||
Info<< "Linear profile field min = "
|
Info<< "Linear profile field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
|
if (isNotEqual(max, 0) || isNotEqual(min, 0))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Linear profile not preserved."
|
<< "Linear profile not preserved."
|
||||||
@ -307,12 +309,13 @@ int main(int argc, char *argv[])
|
|||||||
// Check face field mapping
|
// Check face field mapping
|
||||||
if (surfaceOne.size())
|
if (surfaceOne.size())
|
||||||
{
|
{
|
||||||
auto limits = gMinMax(surfaceOne.primitiveField());
|
const scalar max = gMax(surfaceOne.primitiveField());
|
||||||
|
const scalar min = gMin(surfaceOne.primitiveField());
|
||||||
|
|
||||||
Info<< "Uniform surface field min = "
|
Info<< "Uniform surface field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform surfaceScalarField not preserved."
|
<< "Uniform surfaceScalarField not preserved."
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-globalMeshData.cxx
|
Test-globalMeshData.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-globalMeshData
|
EXE = $(FOAM_USER_APPBIN)/Test-globalMeshData
|
||||||
|
|||||||
@ -182,11 +182,18 @@ int main(int argc, char *argv[])
|
|||||||
const labelListList& transformedSlaves =
|
const labelListList& transformedSlaves =
|
||||||
globalData.globalPointTransformedBoundaryFaces();
|
globalData.globalPointTransformedBoundaryFaces();
|
||||||
|
|
||||||
|
const label nBnd = mesh.nBoundaryFaces();
|
||||||
|
|
||||||
pointField fc(globalPointBoundaryFacesMap.constructSize());
|
pointField fc(globalPointBoundaryFacesMap.constructSize());
|
||||||
pointField::subList(fc, mesh.nBoundaryFaces()) =
|
SubList<point>(fc, nBnd) =
|
||||||
primitivePatch
|
primitivePatch
|
||||||
(
|
(
|
||||||
mesh.boundaryMesh().faces(),
|
SubList<face>
|
||||||
|
(
|
||||||
|
mesh.faces(),
|
||||||
|
nBnd,
|
||||||
|
mesh.nInternalFaces()
|
||||||
|
),
|
||||||
mesh.points()
|
mesh.points()
|
||||||
).faceCentres();
|
).faceCentres();
|
||||||
|
|
||||||
@ -344,12 +344,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Check constant profile
|
// Check constant profile
|
||||||
{
|
{
|
||||||
auto limits = gMinMax(one);
|
const scalar max = gMax(one);
|
||||||
|
const scalar min = gMin(one);
|
||||||
|
|
||||||
Info<< "Uniform one field min = "
|
Info<< "Uniform one field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
if (isNotEqual(min, 1) || isNotEqual(max, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform volVectorField not preserved."
|
<< "Uniform volVectorField not preserved."
|
||||||
@ -367,12 +368,13 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
const scalarField diff = ccX-mesh.C().component(0);
|
const scalarField diff = ccX-mesh.C().component(0);
|
||||||
|
|
||||||
auto limits = gMinMax(diff);
|
const scalar max = gMax(diff);
|
||||||
|
const scalar min = gMin(diff);
|
||||||
|
|
||||||
Info<< "Linear profile field min = "
|
Info<< "Linear profile field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 0) || isNotEqual(limits.max(), 0))
|
if (isNotEqual(min, 0) || isNotEqual(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
|
||||||
@ -387,12 +389,13 @@ int main(int argc, char *argv[])
|
|||||||
// Check face field mapping
|
// Check face field mapping
|
||||||
if (surfaceOne.size())
|
if (surfaceOne.size())
|
||||||
{
|
{
|
||||||
auto limits = gMinMax(surfaceOne.primitiveField());
|
const scalar max = gMax(surfaceOne.primitiveField());
|
||||||
|
const scalar min = gMin(surfaceOne.primitiveField());
|
||||||
|
|
||||||
Info<< "Uniform surface field min = "
|
Info<< "Uniform surface field min = " << min
|
||||||
<< limits.min() << " max = " << limits.max() << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (isNotEqual(limits.min(), 1) || isNotEqual(limits.max(), 1))
|
if (isNotEqual(min, 1) || isNotEqual(max, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform surfaceScalarField not preserved."
|
<< "Uniform surfaceScalarField not preserved."
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
Test-memoryPool1.cxx
|
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-memoryPool1
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
/* EXE_INC = */
|
|
||||||
/* EXE_LIBS = */
|
|
||||||
@ -1,252 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / 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
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2025 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -175,36 +175,6 @@ int main(int argc, char *argv[])
|
|||||||
<< nl;
|
<< 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;
|
Info<< nl << "\nDone\n" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Test-parallel-broadcast.cxx
|
Test-parallel-broadcast.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-parallel-broadcast
|
EXE = $(FOAM_USER_APPBIN)/Test-parallel-broadcast
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user