Compare commits

..

1 Commits

Author SHA1 Message Date
256dafeea5 ENH: fvMatrix: adding setValues for patch
Speedup in offloading
2025-03-05 09:11:47 +00:00
10784 changed files with 22190 additions and 33560 deletions

View File

@ -49,7 +49,7 @@
<!--
Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v2506|v2412|v2406|v2312|v2306 etc
OpenFOAM version : v2412|v2406|v2312|v2306|v2212 etc
Operating system : ubuntu|openSUSE|RedHat etc
Hardware info : any info that may help?
Compiler : gcc|clang etc

View File

@ -1,15 +1,13 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -no-recursion "$@" # Parse arguments only
# Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" || \
echo "Argument parse error"
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"

View File

@ -1,15 +1,13 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -no-recursion "$@" # Parse arguments only
# Run from OPENFOAM top-level directory only
cd "${0%/*}" || exit
wmake -check-dir "$WM_PROJECT_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_PROJECT_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments -no-recursion "$@" || \
echo "Argument parse error"
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"

View File

@ -1,2 +1,2 @@
api=2506
api=2412
patch=0

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2506 version:
For example, for the OpenFOAM-v2412 version:
```
source /installation/path/OpenFOAM-v2506/etc/bashrc
source /installation/path/OpenFOAM-v2412/etc/bashrc
```
## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2506
\-- ThirdParty-v2506
|-- OpenFOAM-v2412
\-- ThirdParty-v2412
```
There are, however, many cases where this simple convention is inadequate:
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2506-myCustom`,
* allows for an updated value of VERSION, *eg*, `v2412-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2412` and the original `ThirdParty-v2506/` would be found.
be `2412` and the original `ThirdParty-v2412/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common

View File

@ -13,14 +13,7 @@ volVectorField U
);
// Initialise the velocity internal field to zero
// Note: explicitly bypass evaluation of contraint patch overrides
// (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();
}
U = dimensionedVector(U.dimensions(), Zero);
surfaceScalarField phi
(

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2020,2025 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,23 +57,11 @@ License
// (relative to reference value)
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;
// Cache old reciprocal time scale field
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Flow time scale
{
rDeltaT.ref() =
@ -82,14 +70,12 @@ License
/((2*maxCo)*mesh.V()*rho())
);
// 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));
// Limit the largest time scale
rDeltaT.max(1/maxDeltaT);
Info<< " Flow = "
<< limits.min() << ", " << limits.max() << endl;
<< 1/gMax(rDeltaT.primitiveField()) << ", "
<< 1/gMin(rDeltaT.primitiveField()) << endl;
}
// Heat release rate time scale
@ -100,13 +86,11 @@ License
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 = "
<< 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
@ -154,13 +138,11 @@ License
if (foundY)
{
rDeltaT.primitiveFieldRef().clamp_min(rDeltaTY);
auto limits = gMinMax(rDeltaTY.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Composition = "
<< limits.min() << ", " << limits.max() << endl;
<< 1/(gMax(rDeltaTY.field()) + VSMALL) << ", "
<< 1/(gMin(rDeltaTY.field()) + VSMALL) << endl;
rDeltaT.ref() = max(rDeltaT(), rDeltaTY);
}
else
{
@ -179,22 +161,28 @@ License
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
// - 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
rDeltaT.correctBoundaryConditions();
auto limits = gMinMax(rDeltaT.field());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< " Overall = "
<< limits.min() << ", " << limits.max() << endl;
<< 1/gMax(rDeltaT.primitiveField())
<< ", " << 1/gMin(rDeltaT.primitiveField()) << endl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020,2025 OpenCFD Ltd.
Copyright (C) 2020 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
this->extrapolateInternal();
fvPatchField<scalar>::patchInternalField(*this);
}
refValue() = *this;

View File

@ -23,11 +23,7 @@
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 = "
<< limits.min() << ", " << limits.max() << endl;
}
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}

View File

@ -52,26 +52,18 @@
// 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<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
}
{
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;
}
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
// Limit rate of change of time scale
// - reduce as much as required
@ -86,10 +78,8 @@
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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
}

View File

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

View File

@ -78,8 +78,8 @@
}
rho = thermo.rho();
rho.clamp_range(rhoMin[i], rhoMax[i]);
rho = max(rho, rhoMin[i]);
rho = min(rho, rhoMax[i]);
rho.relax();
Info<< "Min/max rho:" << min(rho).value() << ' '

View File

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

View File

@ -31,7 +31,7 @@
);
scalar regionCoNum =
CoNum =
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 = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
CoNum = max(UrCoNum, CoNum);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -60,10 +60,13 @@ template<class Type>
void zeroCells
(
GeometricField<Type, fvPatchField, volMesh>& vf,
const labelUList& cells
const labelList& cells
)
{
UIndirectList<Type>(vf.primitiveField(), cells) = Zero;
forAll(cells, i)
{
vf[cells[i]] = Zero;
}
}

View File

@ -103,8 +103,8 @@ dimensionedScalar alphaMax
laminarTransport
);
const labelUList& inletCells = mesh.boundary()["inlet"].faceCells();
//const labelUList& outletCells = mesh.boundary()["outlet"].faceCells();
const labelList& inletCells = mesh.boundary()["inlet"].faceCells();
//const labelList& outletCells = mesh.boundary()["outlet"].faceCells();
volScalarField alpha
(

View File

@ -55,7 +55,7 @@ if (mesh.changing())
dimensionedScalar rAUf("rAUf", dimTime, 1.0);
const cellCellStencilObject& overlap = Stencil::New(mesh);
const labelUList& cellTypes = overlap.cellTypes();
const labelList& cellTypes = overlap.cellTypes();
const labelIOList& zoneIDs = overlap.zoneID();
while (pimple.correctNonOrthogonal())

View File

@ -36,26 +36,18 @@
// 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<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
}
{
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;
}
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
// Limit rate of change of time scale
// - reduce as much as required
@ -70,10 +62,8 @@
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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020,2025 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,22 +54,11 @@ License
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;
// Cache old reciprocal time scale field
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Flow time scale
{
rDeltaT.ref() =
@ -78,14 +67,12 @@ License
/((2*maxCo)*mesh.V()*rho())
);
// 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));
// Limit the largest time scale
rDeltaT.max(1/maxDeltaT);
Info<< " Flow = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField()) << ", "
<< gMax(1/rDeltaT.primitiveField()) << endl;
}
// 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 = "
<< 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
@ -124,19 +113,25 @@ License
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
// - 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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}

View File

@ -36,18 +36,13 @@ Description
if (adjustTimeStep)
{
const scalar maxDeltaTFact =
Foam::min
(
maxCo/(CoNum + SMALL),
maxCo/(surfaceFilm.CourantNumber() + SMALL)
);
min(maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL));
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
(
Foam::min
min
(
deltaTFact*runTime.deltaTValue(),
maxDeltaT

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020,2025 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,22 +54,11 @@ License
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;
// Cache old reciprocal time scale field
volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Flow time scale
{
rDeltaT.ref() =
@ -78,14 +67,12 @@ License
/((2*maxCo)*mesh.V()*rho())
);
// 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));
// Limit the largest time scale
rDeltaT.max(1/maxDeltaT);
Info<< " Flow = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField()) << ", "
<< gMax(1/rDeltaT.primitiveField()) << endl;
}
// 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 = "
<< 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
@ -123,22 +112,25 @@ License
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
// - 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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}

View File

@ -48,7 +48,8 @@ U.correctBoundaryConditions();
fvOptions.correct(U);
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;

View File

@ -49,7 +49,8 @@
fvOptions.correct(U);
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
Info<< "p min/max = " << min(p).value() << ", " << max(p).value() << endl;

View File

@ -1,5 +1,6 @@
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn.A());
@ -93,7 +94,8 @@ p.relax();
// Recalculate density from the relaxed pressure
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;

View File

@ -1,5 +1,6 @@
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
volScalarField rAU(1.0/UEqn.A());
@ -93,7 +94,8 @@ p.relax();
// Recalculate density from the relaxed pressure
rho = thermo.rho();
rho.clamp_range(rhoMin, rhoMax);
rho = max(rho, rhoMin);
rho = min(rho, rhoMax);
rho.relax();
Info<< "rho min/max : " << min(rho).value() << " " << max(rho).value() << endl;

View File

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

View File

@ -53,21 +53,6 @@
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
@ -98,13 +83,10 @@
// Update tho 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<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
Info<< "Flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
if (rDeltaTSmoothingCoeff < 1.0)
{
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
@ -128,25 +110,27 @@
fvc::sweep(rDeltaT, alpha1, nAlphaSweepIter, alphaSpreadDiff);
}
{
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
Info<< "Smoothed flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
Info<< "Smoothed flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
}
// Limit rate of change of time scale (=> smallest reciprocal time)
// Limit rate of change of time scale
// - reduce as much as required
// - 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());
auto limits = gMinMax(rDeltaT.primitiveField());
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
rDeltaT = max
(
rDeltaT,
(scalar(1) - rDeltaTDampingCoeff)*rDeltaT0
);
Info<< "Damped flow time scale min/max = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}
}

View File

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

View File

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

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[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]/max(1.0 - alpha1[celli], 1e-4);
}
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);
}
}

View File

@ -210,7 +210,7 @@ void VoFPatchTransfer::correct
film().toRegion(patchi, Vp);
const polyPatch& pp = pbm[patchi];
const labelUList& faceCells = pp.faceCells();
const labelList& faceCells = pp.faceCells();
// Accumulate the total mass removed from patch
scalar dMassPatch = 0;

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[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]/max(1.0 - alpha1[celli], 1e-4);
}
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);
}
}

View File

@ -26,12 +26,12 @@ forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]/Foam::max(1.0 - alpha1[celli], 1e-4);
Su[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]/max(1.0 - alpha1[celli], 1e-4);
}
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);
}
}

View File

@ -135,7 +135,7 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return volScalarField::null().constCast();
return const_cast<volScalarField&>(volScalarField::null());
}
//- Enthalpy/Internal energy [J/kg]

View File

@ -243,7 +243,7 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return volScalarField::null().constCast();
return const_cast<volScalarField&>(volScalarField::null());
}
//- Enthalpy/Internal energy [J/kg]

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -679,7 +679,7 @@ void Foam::radiation::laserDTRM::calculate()
}
}
scalar totalQ = gWeightedSum(mesh_.V(), Q_.primitiveField());
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
Info << "Total energy absorbed [W]: " << totalQ << endl;
if (mesh_.time().writeTime())

View File

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

View File

@ -86,7 +86,7 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return volScalarField::null().constCast();
return const_cast<volScalarField&>(volScalarField::null());
}
//- Return access to the internal energy field [J/Kg]

View File

@ -65,7 +65,7 @@
dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0);
const cellCellStencilObject& overlap = Stencil::New(mesh);
const labelUList& cellTypes = overlap.cellTypes();
const labelList& cellTypes = overlap.cellTypes();
const labelIOList& zoneIDs = overlap.zoneID();
while (pimple.correctNonOrthogonal())

View File

@ -38,9 +38,7 @@
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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}

View File

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

View File

@ -31,9 +31,7 @@
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 = "
<< limits.min() << ", " << limits.max() << endl;
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
}

View File

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

View File

@ -1,7 +1,6 @@
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
set -- -no-recursion "$@" # Parse arguments only
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@"
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
#------------------------------------------------------------------------------

View File

@ -51,20 +51,17 @@ Description
//- Mapping of some fundamental and aggregate types to MPI data types
enum class dataTypes : int
{
// Fundamental Types [10]:
Basic_begin,
type_byte = Basic_begin,
type_int16,
// Builtin Types [8]:
DataTypes_begin, //!< Begin builtin types (internal use)
type_byte = DataTypes_begin, // also for char, unsigned char
type_int32,
type_int64,
type_uint16,
type_uint32,
type_uint64,
type_float,
type_double,
type_long_double,
invalid,
Basic_end = invalid
invalid
};
@ -72,19 +69,20 @@ enum class dataTypes : int
// Partial copy from UPstreamTraits.H
//- UPstream data type corresponding to an intrinsic (MPI) type
//- A supported UPstream data type (intrinsic or user-defined)
template<class T>
struct UPstream_mpi_dataType : std::false_type
struct UPstream_base_dataType : std::false_type
{
static constexpr auto datatype_id = dataTypes::invalid;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Specializations of the above,
// each to match the elements of UPstream::dataTypes
// Specializations to match elements of UPstream::dataTypes
#undef defineUPstreamDataTraits
#define defineUPstreamDataTraits(TypeId, Type) \
template<> struct UPstream_mpi_dataType<Type> : std::true_type \
template<> struct UPstream_base_dataType<Type> : std::true_type \
{ \
static constexpr auto datatype_id = dataTypes::TypeId; \
};
@ -92,10 +90,8 @@ struct UPstream_mpi_dataType : std::false_type
defineUPstreamDataTraits(type_byte, char);
defineUPstreamDataTraits(type_byte, unsigned char);
defineUPstreamDataTraits(type_int16, int16_t);
defineUPstreamDataTraits(type_int32, int32_t);
defineUPstreamDataTraits(type_int64, int64_t);
defineUPstreamDataTraits(type_uint16, uint16_t);
defineUPstreamDataTraits(type_uint32, uint32_t);
defineUPstreamDataTraits(type_uint64, uint64_t);
defineUPstreamDataTraits(type_float, float);
@ -113,8 +109,8 @@ struct UPstream_alias_dataType
:
std::bool_constant
<
// Basic MPI type
UPstream_mpi_dataType<std::remove_cv_t<T>>::value ||
// Base type (no alias needed)
UPstream_base_dataType<std::remove_cv_t<T>>::value ||
(
// Or some int 32/64 type to re-map
std::is_integral_v<T>
@ -122,11 +118,15 @@ struct UPstream_alias_dataType
)
>
{
// Is it using the base type? (no alias needed)
static constexpr bool is_base =
UPstream_base_dataType<std::remove_cv_t<T>>::value;
using base = std::conditional_t
<
UPstream_mpi_dataType<std::remove_cv_t<T>>::value,
std::remove_cv_t<T>, // <- using mpi type (no alias)
std::conditional_t // <- using alias
UPstream_base_dataType<std::remove_cv_t<T>>::value, // is_base
std::remove_cv_t<T>,
std::conditional_t
<
(
std::is_integral_v<T>
@ -138,32 +138,12 @@ struct UPstream_alias_dataType
std::conditional_t<std::is_signed_v<T>, int32_t, uint32_t>,
std::conditional_t<std::is_signed_v<T>, int64_t, uint64_t>
>,
char // Fallback is a byte (eg, arbitrary contiguous data)
char // Fallback value (assuming it is contiguous)
>
>;
static constexpr auto datatype_id =
UPstream_mpi_dataType<base>::datatype_id;
};
// Handle int8_t/uint8_t as aliases since 'signed char' etc may be
// ambiguous
//- Map \c int8_t to UPstream::dataTypes::type_byte
template<>
struct UPstream_alias_dataType<int8_t> : std::true_type
{
using base = char;
static constexpr auto datatype_id = dataTypes::type_byte;
};
//- Map \c uint8_t to UPstream::dataTypes::type_byte
template<>
struct UPstream_alias_dataType<uint8_t> : std::true_type
{
using base = unsigned char;
static constexpr auto datatype_id = dataTypes::type_byte;
UPstream_base_dataType<base>::datatype_id;
};
@ -192,31 +172,26 @@ void print(const char* name, bool showLimits = true)
}
// A declared or deduced MPI type, or aliased
if constexpr (UPstream_mpi_dataType<T>::value)
{
std::cout
<< " is_mpi=("
<< int(UPstream_mpi_dataType<T>::datatype_id) << ')';
}
else
{
std::cout << " is_mpi=(null)";
}
std::cout
<< " is_mpi=" << UPstream_base_dataType<T>::value
<< " (" << int(UPstream_base_dataType<T>::datatype_id) << ")";
// Any aliases?
if constexpr (UPstream_alias_dataType<T>::value)
if (UPstream_alias_dataType<T>::value)
{
if constexpr (UPstream_mpi_dataType<T>::value)
if (UPstream_alias_dataType<T>::is_base)
{
std::cout << " alias=base";
std::cout<< " is_base";
}
else
{
std::cout
<< " alias=("
<< int(UPstream_alias_dataType<T>::datatype_id) << ')';
std::cout<< " is_alias ("
<< int(UPstream_alias_dataType<T>::datatype_id) << ")";
}
}
else
{
std::cout<< " no_alias";
}
std::cout<< '\n';
}
@ -242,7 +217,6 @@ int main(int argc, char *argv[])
std::cout << '\n';
print<char>("char");
print<signed char>("signed char");
print<unsigned char>("unsigned char");
print<short>("short");
print<int>("int");

View File

@ -1,3 +1,3 @@
Test-CircularBuffer.cxx
Test-CircularBuffer.C
EXE = $(FOAM_USER_APPBIN)/Test-CircularBuffer

View File

@ -1,3 +1,3 @@
Test-DynamicList.cxx
Test-DynamicList.C
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList

View File

@ -1,3 +1,3 @@
Test-DynamicList2.cxx
Test-DynamicList2.C
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList2

View File

@ -52,8 +52,7 @@ void printInfo
if (showSize)
{
Info<< " size=\"" << list.size()
<< "\" capacity=\"" << list.capacity() << "\""
<< "\" min=\"" << SizeMin << "\"" ;
<< "\" capacity=\"" << list.capacity() << "\"";
if (list.cdata())
{
Info<< " ptr=\"" << name(list.cdata()) << "\"";
@ -80,8 +79,7 @@ void printInfo
if (showSize)
{
Info<< " size=\"" << list.size()
<< "\" capacity=\"" << list.capacity() << "\""
<< "\" min=\"" << SizeMin << "\"" ;
<< "\" capacity=\"" << list.capacity() << "\"";
if (list.cdata())
{
Info<< " ptr=\"" << name(list.cdata()) << "\"";
@ -170,22 +168,6 @@ 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;

View File

@ -1,3 +1,3 @@
Test-FixedList.cxx
Test-FixedList.C
EXE = $(FOAM_USER_APPBIN)/Test-FixedList

View File

@ -41,6 +41,7 @@ See also
#include "List.H"
#include "IPstream.H"
#include "OPstream.H"
#include <numeric>
using namespace Foam;

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-HashTable1.cxx
Test-HashTable1.C
EXE = $(FOAM_USER_APPBIN)/Test-HashTable1

View File

@ -1,3 +1,3 @@
Test-Hashing2.cxx
Test-Hashing2.C
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2

View File

@ -274,7 +274,9 @@ int main(int argc, char *argv[])
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());

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-ICharStream1.cxx
Test-ICharStream1.C
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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)
{
return printView(os, s.begin(), s.end());
}
#endif
Ostream& printView(Ostream& os, stdFoam::span<char> s)
@ -136,10 +138,17 @@ void printInfo(const List<char>& buf)
void printTokens(Istream& is)
{
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;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2025 OpenCFD Ltd.
Copyright (C) 2019-2022 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;
{
IOList<label>::writeContents(ioOutput, ints);
IOListRef<label>(ioOutput, ints).write();
}
ioOutput.rename(args.executable() + "-points");

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -73,13 +73,18 @@ Ostream& toString(Ostream& os, const List<char>& list)
void printTokens(Istream& is)
{
Info<< "stream tokens:" << endl;
label count = 0;
for (token tok; tok.read(is); ++count)
token t;
while (is.good())
{
Info<< " : " << tok << nl;
is >> t;
if (t.good())
{
++count;
Info<< "token: " << t << endl;
}
}
Info<< count << " tokens" << endl;
}
@ -450,12 +455,6 @@ int main(int argc, char *argv[])
"( const char input \"string\" to tokenize )\n"
"List<label> 5(0 1 2 3 4);";
// printTokens
{
ISpanStream is(charInput);
printTokens(is);
}
string stringInput("( string ; input \"string\" to tokenize )");
List<char> listInput

View File

@ -1,3 +1,3 @@
Test-IjkField.cxx
Test-IjkField.C
EXE = $(FOAM_USER_APPBIN)/Test-IjkField

View File

@ -1,3 +1,3 @@
Test-List.cxx
Test-List.C
EXE = $(FOAM_USER_APPBIN)/Test-List

View File

@ -51,10 +51,10 @@ See also
#include "IndirectList.H"
#include "SubList.H"
#include "SliceList.H"
#include "SubField.H"
#include "ListPolicy.H"
#include <list>
#include <numeric>
#include <functional>
// see issue #2083
@ -75,6 +75,8 @@ public:
namespace Detail
{
namespace ListPolicy
{
@ -82,6 +84,7 @@ namespace ListPolicy
template<> struct short_length<short> : std::integral_constant<int,20> {};
} // End namespace ListPolicy
} // End namespace Detail
} // End namespace Foam
@ -116,9 +119,9 @@ Ostream& printListOutputType(const char* what)
Info<< what
<< " (contiguous="
<< is_contiguous_v<T> << " no_linebreak="
<< ListPolicy::no_linebreak<T>::value
<< Detail::ListPolicy::no_linebreak<T>::value
<< " short_length="
<< ListPolicy::short_length<T>::value << ')';
<< Detail::ListPolicy::short_length<T>::value << ')';
return Info;
}
@ -140,46 +143,8 @@ 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);
@ -282,33 +247,6 @@ int main(int argc, char *argv[])
};
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
{
{5, 3, 1},

View File

@ -1,3 +1,3 @@
Test-List2.cxx
Test-List2.C
EXE = $(FOAM_USER_APPBIN)/Test-List2

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +35,6 @@ Description
#include "FixedList.H"
#include "labelList.H"
#include "vectorList.H"
#include "SubList.H"
#include "ListOps.H"
#include "IFstream.H"
#include "OFstream.H"
@ -201,7 +200,6 @@ int main(int argc, char *argv[])
argList::addBoolOption("order");
argList::addBoolOption("labelList");
argList::addBoolOption("vectorList");
argList::addBoolOption("ulist");
argList args(argc, argv);
@ -263,37 +261,6 @@ int main(int argc, char *argv[])
}
if (args.found("ulist"))
{
using span_type = stdFoam::span<vector>;
using ulist_type = UList<vector>;
ulist_type view1, view2;
span_type span1, span2;
List<vector> list(10, vector::one);
Info<< "List: " << Foam::name(list.data()) << nl;
Info<< "view: " << Foam::name(view1.data()) << nl;
Info<< "span: " << Foam::name(span1.data()) << nl;
view1 = list.slice(4);
span1 = span_type(list.begin(4), list.size()-4);
Info<< "view [4]:" << Foam::name(view1.data()) << nl;
Info<< "span [4]:" << Foam::name(span1.data()) << nl;
view2 = std::move(view1);
span2 = std::move(span1);
Info<< "view old:" << Foam::name(view1.data()) << nl;
Info<< "span old:" << Foam::name(span1.data()) << nl;
Info<< "view [4]:" << Foam::name(view2.data()) << nl;
Info<< "span [4]:" << Foam::name(span2.data()) << nl;
view1 = list.slice(7);
Info<< "view [7]:" << Foam::name(view1.data()) << nl;
}
Info<< nl << "Done" << nl << endl;
return 0;
}

View File

@ -1,3 +1,3 @@
Test-List3.cxx
Test-List3.C
EXE = $(FOAM_USER_APPBIN)/Test-List3

View File

@ -1,3 +1,3 @@
Test-ListRead1.cxx
Test-ListRead1.C
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1

View File

@ -50,6 +50,7 @@ Description
#include "ListPolicy.H"
#include <list>
#include <numeric>
#include <functional>
using namespace Foam;
@ -85,7 +86,7 @@ bool readBracketList(List<T>& list, Istream& is)
// constexpr label chunkSize = 128;
typedef std::unique_ptr<List<T>> chunkType;
tok.read(is);
is >> tok;
is.fatalCheck(FUNCTION_NAME);
if (tok.isPunctuation(token::END_LIST))
@ -149,7 +150,7 @@ bool readBracketList(List<T>& list, Istream& is)
"reading entry"
);
tok.read(is);
is >> tok;
is.fatalCheck(FUNCTION_NAME);
}

View File

@ -1,3 +1,3 @@
Test-OCharStream1.cxx
Test-OCharStream1.C
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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)
{
return printView(os, s.begin(), s.end());
}
#endif
Ostream& printView(Ostream& os, stdFoam::span<char> s)
@ -127,10 +129,17 @@ void printInfo(const BufType& buf)
void printTokens(Istream& is)
{
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;
}

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-PackedList1.cxx
Test-PackedList1.C
EXE = $(FOAM_USER_APPBIN)/Test-PackedList1

View File

@ -1,3 +1,3 @@
Test-PackedList2.cxx
Test-PackedList2.C
EXE = $(FOAM_USER_APPBIN)/Test-PackedList2

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2506 |
| \\ / O peration | Version: v2412 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

View File

@ -1,3 +1,3 @@
Test-SpanStream1.cxx
Test-SpanStream1.C
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2025 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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)
{
return printView(os, s.begin(), s.end());
}
#endif
Ostream& printView(Ostream& os, stdFoam::span<char> s)
@ -143,10 +145,17 @@ void printInfo(const UList<char>& buf)
void printTokens(Istream& is)
{
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;
}

View File

@ -1,3 +1,3 @@
Test-SubField.cxx
Test-SubField.C
EXE = $(FOAM_USER_APPBIN)/Test-SubField

View File

@ -38,6 +38,7 @@ Description
#include "SubField.H"
#include "labelRange.H"
#include "ListOps.H"
#include <numeric>
using namespace Foam;

View File

@ -1,3 +1,3 @@
Test-UIndirectList.cxx
Test-UIndirectList.C
EXE = $(FOAM_USER_APPBIN)/Test-UIndirectList

View File

@ -37,40 +37,35 @@ Description
#include "vector.H"
#include "tensor.H"
#include "uLabel.H"
#include "MinMax.H"
#include "Switch.H"
#include "IOstreams.H"
#include "UPstream.H"
#include <functional>
#include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
namespace Foam
{
// Add in some extras from functional
//- Map std::plus to \c UPstream::opCodes::op_sum
template<>
struct UPstream_opType<std::plus<void>> : std::true_type
{
static constexpr auto opcode_id = UPstream::opCodes::op_sum;
};
//- Map 'signed char' to UPstream::dataTypes::type_byte
// Caution with: may be identical to int8_t mapping!!
#if 0
template<>
struct UPstream_alias_dataType<signed char> : std::true_type
{
using base = char;
static constexpr auto datatype_id = UPstream::dataTypes::type_byte;
};
#endif
// Just for debugging
const List<std::string> dataType_names
({
"byte",
"int32",
"int64",
"uint32",
"uint64",
"float",
"double",
"long_double",
"float(2)",
"double(2)",
"float(3)",
"double(3)",
"float(6)",
"double(6)",
"float(9)",
"double(9)"
});
//- Test for pTraits typeName member : default is false
template<class T, class = void>
@ -87,93 +82,24 @@ struct check_has_typeName
std::true_type
{};
} // End namespace Foam
// Possible future change...
// //- A supported UPstream data type (intrinsic or user-defined)
// template<>
// struct UPstream_base_dataType<complex> : std::true_type
// {
// static constexpr auto datatype_id = []()
// {
// if constexpr (sizeof(complex) == 2*sizeof(float))
// return UPstream::dataTypes::type_2float;
// else
// return UPstream::dataTypes::type_2double;
// }();
// };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Just for debugging
static const Foam::List<std::string> dataType_names
({
"byte",
"int16",
"int32",
"int64",
"uint16",
"uint32",
"uint64",
"float",
"double",
"long_double",
"float[3]",
"double[3]",
"float[6]",
"double[6]",
"float[9]",
"double[9]"
});
// Just for debugging
static const Foam::List<std::string> opType_names
({
"op_min",
"op_max",
"op_sum",
"op_prod",
"op_bool_and",
"op_bool_or",
"op_bool_xor",
"op_bit_and",
"op_bit_or",
"op_bit_xor",
"op_replace",
"op_no_op"
});
using namespace Foam;
void printDataTypeId(UPstream::dataTypes datatype_id)
{
if (datatype_id != UPstream::dataTypes::invalid)
{
const int index = int(datatype_id);
if (index < dataType_names.size())
{
Info<< dataType_names[index];
}
else
{
Info<< '(' << index << ')';
}
}
}
void printOpCodeId(UPstream::opCodes opcode_id)
{
if (opcode_id != UPstream::opCodes::invalid)
{
const int index = int(opcode_id);
if (index < opType_names.size())
{
Info<< ':' << opType_names[index].c_str();
}
else
{
Info<< '(' << index << ')';
}
}
else
{
Info<< "(null)";
}
}
template<class T, bool showSize = false>
void printTypeName()
template<class T>
void printTypeName(const bool showSize = false)
{
// Both float and double have pTraits typeName = "scalar"!
if constexpr (std::is_same_v<float, std::remove_cv_t<T>>)
@ -192,13 +118,12 @@ void printTypeName()
{
Info<< typeid(T).name();
}
if constexpr (showSize)
if (showSize)
{
Info<< " (" << sizeof(T) << " bytes)";
}
}
template<class Type, bool UseTypeName = true>
void printPstreamTraits(const std::string_view name = std::string_view())
{
@ -208,111 +133,55 @@ void printPstreamTraits(const std::string_view name = std::string_view())
{
Info<< name << ' ';
}
if constexpr (UseTypeName)
{
printTypeName<Type, true>();
printTypeName<Type>(true);
}
else
{
Info<< typeid(Type).name() << " (" << sizeof(Type) << " bytes)";
}
{
using cmpt = typename Foam::pTraits_cmptType<Type>::type;
if constexpr (!std::is_same_v<Type, cmpt>)
{
Info<< ", cmpt:";
if constexpr (UseTypeName)
{
printTypeName<cmpt, true>();
}
else
{
Info<< typeid(cmpt).name() << " (" << sizeof(cmpt) << " bytes)";
}
}
Info<< typeid(Type).name();
Info<< " (" << sizeof(Type) << " bytes)";
}
Info<< ", cmpt:";
printTypeName<typename Foam::pTraits_cmptType<Type>::type>(true);
Info<< nl
<< " is_contiguous:"
<< is_contiguous<Type>::value;
<< is_contiguous<Type>::value
<< ", is base:"
<< UPstream_base_dataType<Type>::value
<< ", is cmpt:"
<< UPstream_dataType<Type>::value << nl;
if constexpr (UPstream_mpi_dataType<Type>::value)
{
Info<< ", is_mpi=("
<< int(UPstream_mpi_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_mpi=(null)";
}
if constexpr (UPstream_user_dataType<Type>::value)
{
Info<< ", is_user=("
<< int(UPstream_user_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_user=(null)";
}
if constexpr (UPstream_any_dataType<Type>::value)
{
Info<< ", is_any=("
<< int(UPstream_any_dataType<Type>::datatype_id) << ')';
}
else
{
std::cout << ", is_any=(null)";
}
Info<< "is base:"
<< UPstream_base_dataType<Type>::value
<< " (type:" << int(UPstream_base_dataType<Type>::datatype_id)
<< ") is alias:" << UPstream_alias_dataType<Type>::value
<< " (type:" << int(UPstream_alias_dataType<Type>::datatype_id)
<< ")" << nl;
// Any aliases?
if constexpr
(
UPstream_alias_dataType<Type>::value
&& !UPstream_mpi_dataType<Type>::value
)
{
Info<< ", alias=("
<< int(UPstream_alias_dataType<Type>::datatype_id) << ')';
}
Info<< " base-type:" << int(UPstream_basic_dataType<Type>::datatype_id)
<< " data-type:" << int(UPstream_dataType<Type>::datatype_id)
<< nl;
{
int index = int(UPstream_base_dataType<Type>::datatype_id);
Info<< "datatype: " << index;
if constexpr (UPstream_basic_dataType<Type>::value)
{
Info<< " base-type=";
printDataTypeId(UPstream_basic_dataType<Type>::datatype_id);
}
else if constexpr (UPstream_dataType<Type>::value)
{
Info<< " data-type=";
printDataTypeId(UPstream_dataType<Type>::datatype_id);
if (index < dataType_names.size())
{
Info<< ' ' << dataType_names[index];
}
Info<< nl;
}
{
// Use element or component type (or byte-wise) for data type
using base = typename UPstream_dataType<Type>::base;
constexpr auto datatype = UPstream_dataType<Type>::datatype_id;
Info<< " : ";
if constexpr (UseTypeName)
{
printTypeName<base, true>();
}
else
{
Info<< typeid(base).name() << " (" << sizeof(base) << " bytes)";
}
Info<< " cmpt-type=";
printDataTypeId(UPstream_dataType<Type>::datatype_id);
Info<< " count=" << UPstream_dataType<Type>::size(1);
Info<< nl;
Info<< "datatype => ";
printTypeName<base>();
Info<< " (" << sizeof(Type)/sizeof(base) << " elems)" << nl
<< "datatype: " << static_cast<int>(datatype) << nl;
}
}
@ -321,44 +190,15 @@ template<class BinaryOp>
void printOpCodeTraits(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_opType<BinaryOp>::opcode_id);
Info<< nl;
}
template<class DataType, class BinaryOp>
void printOpCodeTraits(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_opType<BinaryOp>::opcode_id);
if constexpr (!std::is_void_v<DataType>)
if constexpr (UPstream_opType<BinaryOp>::value)
{
if constexpr (UPstream_basic_dataType<DataType>::value)
{
Info<< " [supported type]";
}
else
{
Info<< " [disabled]";
}
Info<< "supported";
}
Info<< nl;
}
template<class DataType, class BinaryOp>
void print_data_opType(BinaryOp bop, std::string_view name)
{
Info<< "op: " << name << ' ';
printOpCodeId(UPstream_data_opType<BinaryOp, DataType>::opcode_id);
const bool ok = UPstream_data_opType<BinaryOp, DataType>::value;
Info<< " okay=" << ok << nl;
else
{
Info<< "unknown";
}
Info<< ": " << int(UPstream_opType<BinaryOp>::opcode_id) << nl;
}
@ -370,16 +210,6 @@ int main()
printPstreamTraits<bool>();
printPstreamTraits<label>();
printPstreamTraits<char, false>("<char>");
printPstreamTraits<signed char, false>("<signed char>");
printPstreamTraits<unsigned char, false>("<unsigned char>");
printPstreamTraits<int8_t, false>("<int8_t>");
printPstreamTraits<uint8_t, false>("<uint8_t>");
printPstreamTraits<int16_t, false>("<int16_t>");
printPstreamTraits<uint16_t, false>("<uint16_t>");
printPstreamTraits<int>("<int>");
printPstreamTraits<long>("<long>");
printPstreamTraits<unsigned>("<unsigned>");
@ -428,35 +258,6 @@ int main()
printOpCodeTraits(bitAndOp<unsigned>{}, "bitAnd<unsigned>");
printOpCodeTraits(bitOrOp<unsigned>{}, "bitOr<unsigned>");
printOpCodeTraits<vector>(sumOp<vector>{}, "sum");
printOpCodeTraits(sumOp<scalarMinMax>{}, "sum");
printOpCodeTraits(std::plus<>{}, "sum");
printOpCodeTraits<bool>(std::plus<>{}, "sum");
printOpCodeTraits<vector>(std::plus<>{}, "sum");
// Expect success
Info<< nl << "expect success" << nl;
print_data_opType<vector>(maxOp<scalar>(), "maxOp(scalar)");
print_data_opType<unsigned>(bitOrOp<unsigned>(), "bitOrOp(unsigned)");
print_data_opType<uint8_t>(bitOrOp<uint8_t>(), "bitOrOp(uint8_t)");
print_data_opType<uint16_t>(bitOrOp<uint16_t>(), "bitOrOp(uint16_t)");
// Even allow signed integrals
print_data_opType<int>(bitOrOp<int>(), "bitOrOp(int)");
print_data_opType<int8_t>(bitOrOp<int8_t>(), "bitOrOp(int8_t)");
// Failure - supported op, unsupported data type.
Info<< nl << "expect failure" << nl;
print_data_opType<bool>(maxOp<scalar>(), "maxOp(scalar, bool)");
print_data_opType<bool>(bitOrOp<unsigned>(), "bitOrOp(unsigned, bool)");
// False positives. Failure - supported op, unsupported data type.
Info<< nl << "false positives" << nl;
print_data_opType<void>(maxOp<bool>(), "maxOp(bool, void)");
print_data_opType<float>(bitOrOp<unsigned>(), "bitOrOp(unsigned, float)");
Info<< nl << "End\n" << endl;
return 0;

Some files were not shown because too many files have changed in this diff Show More