Compare commits
1 Commits
develop
...
issue-3348
| Author | SHA1 | Date | |
|---|---|---|---|
| bd41a2abdb |
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,7 +11,6 @@
|
||||
|
||||
# File-browser settings - anywhere
|
||||
.directory
|
||||
.DS_Store # OSX app store
|
||||
|
||||
# Backup/recovery versions - anywhere
|
||||
.#*
|
||||
@ -39,8 +38,6 @@ linux*Gcc*/
|
||||
linux*Icc*/
|
||||
solaris*Gcc*/
|
||||
SunOS*Gcc*/
|
||||
darwin*Clang*/
|
||||
darwin*Gcc*/
|
||||
platforms/
|
||||
|
||||
# Top-level build directories
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
# 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"
|
||||
@ -33,7 +31,7 @@ case "$FOAM_MODULE_PREFIX" in
|
||||
;;
|
||||
(*)
|
||||
# Use wmake -all instead of Allwmake to allow for overrides
|
||||
( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all $* )
|
||||
( cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all )
|
||||
esac
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
# 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"
|
||||
@ -33,7 +31,7 @@ case "$FOAM_MODULE_PREFIX" in
|
||||
;;
|
||||
(*)
|
||||
# Use wmake -all instead of Allwmake to allow for overrides
|
||||
( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all $* )
|
||||
( cd "$WM_PROJECT_DIR/plugins" 2>/dev/null && wmake -all )
|
||||
esac
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
api=2507
|
||||
api=2501
|
||||
patch=0
|
||||
|
||||
12
README.md
12
README.md
@ -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
|
||||
|
||||
@ -13,13 +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 = Zero;
|
||||
{
|
||||
U.internalFieldRef() = Zero;
|
||||
U.boundaryFieldRef() = Zero;
|
||||
}
|
||||
U = dimensionedVector(U.dimensions(), Zero);
|
||||
|
||||
surfaceScalarField phi
|
||||
(
|
||||
|
||||
@ -36,8 +36,7 @@ Description
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
scalar maxDeltaTFact = maxCo/(CoNum + StCoNum + SMALL);
|
||||
|
||||
const scalar deltaTFact =
|
||||
scalar deltaTFact =
|
||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||
|
||||
runTime.setDeltaT
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
runTime.setDeltaT(Foam::min(dtChem, maxDeltaT));
|
||||
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -83,13 +75,13 @@
|
||||
)
|
||||
{
|
||||
rDeltaT =
|
||||
(
|
||||
rDeltaT0
|
||||
*max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff);
|
||||
|
||||
auto limits = gMinMax(rDeltaT.primitiveField());
|
||||
limits.reset(1/(limits.max()+VSMALL), 1/(limits.min()+VSMALL));
|
||||
* Foam::max(rDeltaT/rDeltaT0, scalar(1) - rDeltaTDampingCoeff)
|
||||
);
|
||||
|
||||
Info<< "Damped flow time scale min/max = "
|
||||
<< limits.min() << ", " << limits.max() << endl;
|
||||
<< gMin(1/rDeltaT.primitiveField())
|
||||
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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() << ' '
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
);
|
||||
|
||||
|
||||
scalar regionCoNum =
|
||||
scalar maxPhiCoNum =
|
||||
0.5*gMax
|
||||
(
|
||||
sumPhi/fluidRegions[regioni].V().field()
|
||||
@ -43,7 +43,7 @@
|
||||
/ fluidRegions[regioni].V().field()
|
||||
)*runTime.deltaTValue();
|
||||
|
||||
CoNum = Foam::max(CoNum, Foam::max(regionCoNum, UrCoNum));
|
||||
CoNum = Foam::max(CoNum, Foam::max(maxPhiCoNum, UrCoNum));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,12 @@ 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 =
|
||||
Foam::min
|
||||
(
|
||||
Foam::min(maxDeltaTFluid, 1.0 + 0.1*maxDeltaTFluid),
|
||||
1.2
|
||||
);
|
||||
|
||||
runTime.setDeltaT
|
||||
(
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
+ MRF.DDt(U)
|
||||
+ turbulence->divDevReff(U)
|
||||
==
|
||||
invRhoInf*parcels.SU(U)
|
||||
parcels.SU(U, true)
|
||||
+ fvOptions(U)
|
||||
);
|
||||
|
||||
|
||||
@ -39,11 +39,6 @@ dimensionedScalar rhoInfValue
|
||||
laminarTransport
|
||||
);
|
||||
|
||||
const dimensionedScalar invRhoInf
|
||||
(
|
||||
dimless/dimDensity, scalar(1)/rhoInfValue.value()
|
||||
);
|
||||
|
||||
volScalarField rhoInf
|
||||
(
|
||||
IOobject
|
||||
|
||||
@ -38,10 +38,8 @@ if (adjustTimeStep)
|
||||
const scalar maxDeltaTFact =
|
||||
Foam::min
|
||||
(
|
||||
maxCo/(CoNum + SMALL),
|
||||
maxCo/(surfaceFilm.CourantNumber() + SMALL)
|
||||
maxCo/(CoNum + SMALL), maxCo/(surfaceFilm.CourantNumber() + SMALL)
|
||||
);
|
||||
|
||||
const scalar deltaTFact =
|
||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ if (adjustTimeStep)
|
||||
scalar maxDeltaTFact =
|
||||
Foam::min(maxCo/(CoNum + SMALL), maxAlphaCo/(alphaCoNum + SMALL));
|
||||
|
||||
const scalar deltaTFact =
|
||||
scalar deltaTFact =
|
||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||
|
||||
runTime.setDeltaT
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ if (adjustTimeStep)
|
||||
scalar maxDeltaTFact =
|
||||
Foam::min(maxCo/(CoNum + SMALL), maxAcousticCo/(acousticCoNum + SMALL));
|
||||
|
||||
const scalar deltaTFact =
|
||||
scalar deltaTFact =
|
||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||
|
||||
runTime.setDeltaT
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -135,7 +135,7 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
NotImplemented;
|
||||
return volScalarField::null().constCast();
|
||||
return const_cast<volScalarField&>(volScalarField::null());
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy [J/kg]
|
||||
|
||||
@ -1086,7 +1086,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
|
||||
|
||||
MULES::limitSum(alphaPhiCorrs);
|
||||
|
||||
rhoPhi_ = Zero;
|
||||
rhoPhi_ = dimensionedScalar(dimensionSet(1, 0, -1, 0, 0), Zero);
|
||||
|
||||
volScalarField sumAlpha
|
||||
(
|
||||
|
||||
@ -243,7 +243,7 @@ public:
|
||||
virtual volScalarField& he()
|
||||
{
|
||||
NotImplemented;
|
||||
return volScalarField::null().constCast();
|
||||
return const_cast<volScalarField&>(volScalarField::null());
|
||||
}
|
||||
|
||||
//- Enthalpy/Internal energy [J/kg]
|
||||
|
||||
@ -63,11 +63,23 @@ Foam::DTRMParticle::DTRMParticle
|
||||
{
|
||||
is >> p0_ >> p1_ >> I0_ >> I_ >> dA_ >> transmissiveId_;
|
||||
}
|
||||
else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
|
||||
{
|
||||
// Non-native label or scalar size
|
||||
|
||||
is.beginRawRead();
|
||||
|
||||
readRawScalar(is, p0_.data(), vector::nComponents);
|
||||
readRawScalar(is, p1_.data(), vector::nComponents);
|
||||
readRawScalar(is, &I0_);
|
||||
readRawScalar(is, &I_);
|
||||
readRawScalar(is, &dA_);
|
||||
readRawLabel(is, &transmissiveId_);
|
||||
|
||||
is.endRawRead();
|
||||
}
|
||||
else
|
||||
{
|
||||
// No non-native streaming
|
||||
is.fatalCheckNativeSizes(FUNCTION_NAME);
|
||||
|
||||
is.read(reinterpret_cast<char*>(&p0_), sizeofFields_);
|
||||
}
|
||||
}
|
||||
|
||||
@ -557,7 +557,7 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
|
||||
|
||||
// Reset the field
|
||||
Q_ == Zero;
|
||||
Q_ == dimensionedScalar(Q_.dimensions(), Zero);
|
||||
|
||||
a_ = absorptionEmission_->a();
|
||||
e_ = absorptionEmission_->e();
|
||||
|
||||
@ -50,7 +50,7 @@ if (adjustTimeStep)
|
||||
)
|
||||
);
|
||||
|
||||
const scalar deltaTFact =
|
||||
scalar deltaTFact =
|
||||
Foam::min(Foam::min(maxDeltaTFact, 1.0 + 0.1*maxDeltaTFact), 1.2);
|
||||
|
||||
runTime.setDeltaT
|
||||
@ -61,7 +61,6 @@ if (adjustTimeStep)
|
||||
maxDeltaT
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -232,7 +232,7 @@
|
||||
surfaceScalarField mSfGradp("mSfGradp", pEqnIncomp.flux()/rAUf);
|
||||
|
||||
phasei = 0;
|
||||
phi = Zero;
|
||||
phi = dimensionedScalar("phi", phi.dimensions(), Zero);
|
||||
|
||||
for (phaseModel& phase : fluid.phases())
|
||||
{
|
||||
@ -261,7 +261,7 @@
|
||||
|
||||
mSfGradp = pEqnIncomp.flux()/rAUf;
|
||||
|
||||
U = Zero;
|
||||
U = dimensionedVector("U", dimVelocity, Zero);
|
||||
|
||||
phasei = 0;
|
||||
for (phaseModel& phase : fluid.phases())
|
||||
|
||||
@ -626,7 +626,7 @@ void Foam::multiphaseMixture::solveAlphas
|
||||
|
||||
MULES::limitSum(alphaPhiCorrs);
|
||||
|
||||
rhoPhi_ = Zero;
|
||||
rhoPhi_ = dimensionedScalar(dimMass/dimTime, Zero);
|
||||
|
||||
volScalarField sumAlpha
|
||||
(
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -14,6 +14,6 @@ if (!(runTime.timeIndex() % 5))
|
||||
if (smi < -SMALL)
|
||||
{
|
||||
Info<< "Resetting Dcorr to 0" << endl;
|
||||
Dcorr == Zero;
|
||||
Dcorr == dimensionedVector(Dcorr.dimensions(), Zero);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
set -- -all="${0##*/}" "$@" # Execute this instead of ./Allwmake
|
||||
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/AllwmakeParseArguments
|
||||
. "${WM_PROJECT_DIR:?}"/wmake/scripts/wmakeFunctions # Need wmake functions
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments -no-recursion "$@"
|
||||
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Environment
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-CircularBuffer.cxx
|
||||
Test-CircularBuffer.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-CircularBuffer
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-CompactIOList.cxx
|
||||
Test-CompactIOList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-CompactIOList
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2025 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Application
|
||||
Test-CompactIOList
|
||||
testCompactIOList
|
||||
|
||||
Description
|
||||
Simple demonstration and test application for the CompactIOList container
|
||||
@ -46,20 +46,13 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addBoolOption("ascii", "use ascii format");
|
||||
argList::addOption("count", "number of faces");
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
IOstreamOption streamOpt(IOstreamOption::BINARY);
|
||||
// IOstreamOption streamOpt(IOstreamOption::ASCII);
|
||||
|
||||
if (args.found("ascii"))
|
||||
{
|
||||
streamOpt.format(IOstreamOption::ASCII);
|
||||
}
|
||||
|
||||
const label size = args.getOrDefault<label>("count", 20000000);
|
||||
const label size = 20000000;
|
||||
|
||||
// Old format
|
||||
// ~~~~~~~~~~
|
||||
@ -70,50 +63,39 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-plain",
|
||||
"faces2",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
),
|
||||
size
|
||||
);
|
||||
|
||||
faces2.resize(size, face(identity(4)));
|
||||
const face f(identity(4));
|
||||
|
||||
Info<< "Plain format faceList " << faces2.objectRelPath() << nl;
|
||||
Info<< " constructed in = " << runTime.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
forAll(faces2, i)
|
||||
{
|
||||
faces2[i] = f;
|
||||
}
|
||||
|
||||
Info<< "Constructed faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< " wrote in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read (size only)
|
||||
label count = faceIOList::readContentsSize
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-plain",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " counted " << count << " faces on disk in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< "Written old format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
// Read
|
||||
faceIOList faces2b
|
||||
faceIOList faces3
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-plain",
|
||||
"faces2",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
@ -123,7 +105,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " read " << faces2b.size() << " faces in = "
|
||||
Info<< "Read old format " << faces3.size() << " faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
}
|
||||
|
||||
@ -132,54 +114,44 @@ int main(int argc, char *argv[])
|
||||
// ~~~~~~~~~~
|
||||
|
||||
{
|
||||
// Construct big faceList in compact format
|
||||
// Construct big faceList in new format
|
||||
faceCompactIOList faces2
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-compact",
|
||||
"faces2",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
)
|
||||
),
|
||||
size
|
||||
);
|
||||
|
||||
faces2.resize(size, face(identity(4)));
|
||||
const face f(identity(4));
|
||||
|
||||
Info<< "Compact format faceList" << faces2.objectRelPath() << nl;
|
||||
Info<< " constructed in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
forAll(faces2, i)
|
||||
{
|
||||
faces2[i] = f;
|
||||
}
|
||||
|
||||
Info<< "Constructed new format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
|
||||
faces2.writeObject(streamOpt, true);
|
||||
|
||||
Info<< " wrote in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
|
||||
// Read (size only)
|
||||
label count = faceCompactIOList::readContentsSize
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-compact",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
Info<< " counted " << count << " faces on disk in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< "Written new format faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
|
||||
// Read
|
||||
faceCompactIOList faces2b
|
||||
faceCompactIOList faces3
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces2-compact",
|
||||
"faces2",
|
||||
runTime.constant(),
|
||||
polyMesh::meshSubDir,
|
||||
runTime,
|
||||
@ -189,7 +161,7 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< " read " << faces2b.size() << " faces in = "
|
||||
Info<< "Read new format " << faces3.size() << " faceList in = "
|
||||
<< runTime.cpuTimeIncrement() << " s" << nl << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-DynamicList.cxx
|
||||
Test-DynamicList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-DynamicList2.cxx
|
||||
Test-DynamicList2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-DynamicList2
|
||||
|
||||
@ -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;
|
||||
@ -1,3 +1,3 @@
|
||||
Test-FixedList.cxx
|
||||
Test-FixedList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-FixedList
|
||||
|
||||
@ -41,6 +41,7 @@ See also
|
||||
#include "List.H"
|
||||
#include "IPstream.H"
|
||||
#include "OPstream.H"
|
||||
#include <numeric>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashPtrTable.cxx
|
||||
Test-HashPtrTable.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashPtrTable
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2025 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,55 +42,33 @@ Description
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
bool verbosity = true;
|
||||
|
||||
// Gratuitous class inheritance
|
||||
template<class T>
|
||||
class BoxedType
|
||||
class Scalar
|
||||
{
|
||||
T data_;
|
||||
scalar data_;
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
|
||||
constexpr BoxedType() noexcept : data_(0) {}
|
||||
BoxedType(T val) noexcept : data_(val) {}
|
||||
|
||||
~BoxedType()
|
||||
{
|
||||
if (verbosity) Info<< " [delete BoxedType: " << value() << ']' << nl;
|
||||
}
|
||||
|
||||
T value() const noexcept { return data_; }
|
||||
T& value() noexcept { return data_; }
|
||||
|
||||
auto clone() const { return autoPtr<BoxedType<T>>::New(*this); }
|
||||
};
|
||||
|
||||
template<class T> Ostream& operator<<(Ostream& os, const BoxedType<T>& item)
|
||||
{
|
||||
return (os << " -> " << item.value());
|
||||
}
|
||||
|
||||
|
||||
class Scalar : public BoxedType<scalar>
|
||||
{
|
||||
public:
|
||||
|
||||
using BoxedType<scalar>::BoxedType;
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbosity) Info<< "delete Scalar: " << value() << nl;
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
const scalar& value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
os << item.value();
|
||||
return os;
|
||||
}
|
||||
auto clone() const { return autoPtr<Scalar>::New(*this); }
|
||||
};
|
||||
|
||||
Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
{
|
||||
return (os << item.value());
|
||||
}
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
template<class T>
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashTable2.cxx
|
||||
Test-HashTable2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashTable2
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-HashTable3.cxx
|
||||
Test-HashTable3.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-HashTable3
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-Hashing2.cxx
|
||||
Test-Hashing2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-Hashing2
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ICharStream1.cxx
|
||||
Test-ICharStream1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||
|
||||
@ -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,18 @@ 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)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
@ -130,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;
|
||||
}
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-IOobjectList.cxx
|
||||
Test-IOobjectList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IOobjectList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ISLList.cxx
|
||||
Test-ISLList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ISLList
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-IStringStream.cxx
|
||||
Test-IStringStream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IStringStream
|
||||
|
||||
@ -73,13 +73,14 @@ Ostream& toString(Ostream& os, const List<char>& list)
|
||||
|
||||
void printTokens(Istream& is)
|
||||
{
|
||||
Info<< "stream tokens:" << endl;
|
||||
|
||||
label count = 0;
|
||||
|
||||
Info<< "stream tokens:" << endl;
|
||||
for (token tok; tok.read(is); ++count)
|
||||
{
|
||||
Info<< " : " << tok << nl;
|
||||
Info<< " : " << tok << endl;
|
||||
}
|
||||
|
||||
Info<< count << " tokens" << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-List.cxx
|
||||
Test-List.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-List
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -106,7 +109,7 @@ void printMyString(const UList<string>& lst)
|
||||
{
|
||||
MyStrings slist2(lst);
|
||||
|
||||
Info<< slist2 << nl;
|
||||
Info<<slist2 << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
@ -204,6 +169,16 @@ int main(int argc, char *argv[])
|
||||
Info<<" " << *iter;
|
||||
}
|
||||
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)
|
||||
@ -272,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},
|
||||
@ -360,7 +308,7 @@ int main(int argc, char *argv[])
|
||||
auto shrtList = ListOps::create<short>
|
||||
(
|
||||
longLabelList,
|
||||
[](label val){ return val; }
|
||||
[](const label& val){ return val; }
|
||||
);
|
||||
|
||||
printListOutputType<short>("short") << nl;
|
||||
@ -557,7 +505,7 @@ int main(int argc, char *argv[])
|
||||
auto scalars = ListOps::create<scalar>
|
||||
(
|
||||
labels,
|
||||
[](label val){ return scalar(1.5*val); }
|
||||
[](const label& val){ return scalar(1.5*val); }
|
||||
);
|
||||
Info<< "scalars: " << flatOutput(scalars) << endl;
|
||||
}
|
||||
@ -566,7 +514,7 @@ int main(int argc, char *argv[])
|
||||
auto vectors = ListOps::create<vector>
|
||||
(
|
||||
labels,
|
||||
[](label val){ return vector(1.2*val, -1.2*val, 0); }
|
||||
[](const label& val){ return vector(1.2*val, -1.2*val, 0); }
|
||||
);
|
||||
Info<< "vectors: " << flatOutput(vectors) << endl;
|
||||
}
|
||||
@ -575,7 +523,7 @@ int main(int argc, char *argv[])
|
||||
auto longs = ListOps::create<long>
|
||||
(
|
||||
labels,
|
||||
[](label val){ return val; }
|
||||
[](const label& val){ return val; }
|
||||
);
|
||||
Info<< "longs: " << flatOutput(longs) << endl;
|
||||
}
|
||||
@ -593,7 +541,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
labelRange().cbegin(),
|
||||
labelRange(15).cend(),
|
||||
[](label val){ return scalar(-1.125*val); }
|
||||
[](const label& val){ return scalar(-1.125*val); }
|
||||
);
|
||||
Info<< "scalars: " << flatOutput(scalars) << endl;
|
||||
}
|
||||
@ -1,3 +1,3 @@
|
||||
Test-List3.cxx
|
||||
Test-List3.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-List3
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-ListRead1.cxx
|
||||
Test-ListRead1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OCharStream1.cxx
|
||||
Test-OCharStream1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||
|
||||
@ -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,18 @@ 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)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
@ -121,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;
|
||||
}
|
||||
|
||||
@ -183,25 +198,12 @@ int main(int argc, char *argv[])
|
||||
printInfo(obuf);
|
||||
|
||||
// Overwrite at some position
|
||||
if (auto i = obuf.view().find("item5"); i != std::string::npos)
|
||||
{
|
||||
// obuf.seek(0.60 * obuf.size());
|
||||
obuf.seek(i);
|
||||
obuf << "<OVERWRITE>" << nl;
|
||||
}
|
||||
obuf.stdStream().rdbuf()->pubseekpos(0.60 * obuf.size());
|
||||
obuf << "<" << nl << "OVERWRITE" << nl;
|
||||
|
||||
Info<<"after overwrite" << nl;
|
||||
printInfo(obuf);
|
||||
|
||||
// Truncate
|
||||
{
|
||||
constexpr float fraction = 0.90;
|
||||
Info<<"truncated at " << (100*fraction) << "% ["
|
||||
<< int(fraction*obuf.size()) << " chars]" << nl;
|
||||
obuf.seek(fraction*obuf.size());
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
Info<< "transfer contents to a List or ICharStream" << nl;
|
||||
|
||||
// Reclaim data storage from OCharStream -> ICharStream
|
||||
@ -1,3 +0,0 @@
|
||||
Test-OCharStream2.cxx
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream2
|
||||
@ -1,2 +0,0 @@
|
||||
/* EXE_INC = */
|
||||
/* EXE_LIBS = */
|
||||
@ -1,473 +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/>.
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SpanStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "argList.H"
|
||||
|
||||
#include <charconv>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <limits>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
Ostream& printString(Ostream& os, const char* first, const char* last)
|
||||
{
|
||||
os << '"';
|
||||
for (; first != last; (void)++first)
|
||||
{
|
||||
os << *first;
|
||||
}
|
||||
os << '"';
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const char* first, const char* last)
|
||||
{
|
||||
char buf[4];
|
||||
os << label(last-first) << '(';
|
||||
|
||||
for (; first != last; (void)++first)
|
||||
{
|
||||
const char c = *first;
|
||||
|
||||
if (isprint(c))
|
||||
{
|
||||
os << c;
|
||||
}
|
||||
else if (c == '\t')
|
||||
{
|
||||
os << "\\t";
|
||||
}
|
||||
else if (c == '\n')
|
||||
{
|
||||
os << "\\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
::snprintf(buf, 4, "%02X", c);
|
||||
os << "\\x" << buf;
|
||||
}
|
||||
}
|
||||
os << ')';
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printView(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& printView(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list.begin(), list.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& writeList(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printView(os, list);
|
||||
}
|
||||
|
||||
|
||||
Ostream& toString(Ostream& os, const UList<char>& list)
|
||||
{
|
||||
return printString(os, list.begin(), list.end());
|
||||
}
|
||||
|
||||
|
||||
Ostream& toString(Ostream& os, std::string_view s)
|
||||
{
|
||||
return printString(os, s.begin(), s.end());
|
||||
}
|
||||
|
||||
|
||||
template<class BufType>
|
||||
void printInfo(const BufType& buf)
|
||||
{
|
||||
Info<< nl << "=========================" << endl;
|
||||
buf.print(Info);
|
||||
Info<< "addr: " << Foam::name(buf.view().data()) << nl;
|
||||
toString(Info, buf.view());
|
||||
Info<< nl << "=========================" << endl;
|
||||
}
|
||||
|
||||
|
||||
// Return a left-padded integer as "word"
|
||||
template<class IntType>
|
||||
std::string leftpadded(IntType val, char fillch = ' ')
|
||||
{
|
||||
std::string buf;
|
||||
buf.resize((std::numeric_limits<IntType>::digits10+1), fillch);
|
||||
|
||||
auto first = (buf.data());
|
||||
auto last = (buf.data() + buf.size());
|
||||
|
||||
auto result = std::to_chars(first, last, val);
|
||||
|
||||
if (result.ec == std::errc{})
|
||||
{
|
||||
auto* iter = result.ptr;
|
||||
int count = std::distance(iter, last);
|
||||
|
||||
std::cout << "did not fill: " << count << " chars\n";
|
||||
|
||||
// With two spaces before comments
|
||||
if (count > 0) { *iter++ = ' '; --count; }
|
||||
if (count > 0) { *iter++ = ' '; --count; }
|
||||
for (char c = (count >= 2 ? '/' : ' '); count > 0; --count)
|
||||
{
|
||||
*iter++ = c;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
template<class IntType>
|
||||
void leftpad(std::ostream& os, IntType val, char fillch = ' ')
|
||||
{
|
||||
// set fill char and width
|
||||
os.setf(std::ios_base::left, std::ios_base::adjustfield);
|
||||
fillch = os.fill(fillch);
|
||||
os.width(std::numeric_limits<IntType>::digits10+1);
|
||||
os << val;
|
||||
// restore fill char
|
||||
os.fill(fillch);
|
||||
}
|
||||
|
||||
|
||||
template<class IntType>
|
||||
void rightpad(std::ostream& os, IntType val, char fillch = ' ')
|
||||
{
|
||||
// set fill char and width
|
||||
os.setf(std::ios_base::right, std::ios_base::adjustfield);
|
||||
fillch = os.fill(fillch);
|
||||
os.width(std::numeric_limits<IntType>::digits10+1);
|
||||
os << val;
|
||||
// restore fill char
|
||||
os.fill(fillch);
|
||||
}
|
||||
|
||||
|
||||
// Left-padded value with trailing comment slashes
|
||||
template<class IntType>
|
||||
void leftpad(ocharstream& os, IntType val)
|
||||
{
|
||||
const auto beg = os.tellp();
|
||||
os << val;
|
||||
int count = (std::numeric_limits<IntType>::digits10+1) - (os.tellp() - beg);
|
||||
|
||||
// With two spaces before comments
|
||||
if (count > 0) { os << ' '; --count; }
|
||||
if (count > 0) { os << ' '; --count; }
|
||||
for (const char c = (count >= 2 ? '/' : ' '); count > 0; --count)
|
||||
{
|
||||
os << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::addBoolOption("fake-zerosize", "Fake overwriting with zero data");
|
||||
argList::addBoolOption("dict-format", "Format as dictionary entry");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optFakeZerosize = args.found("fake-zerosize");
|
||||
const bool isDictFormat = args.found("dict-format");
|
||||
|
||||
// const constexpr int width = (std::numeric_limits<label>::digits10+1);
|
||||
|
||||
// experiment with to_chars instead of streaming
|
||||
{
|
||||
// Some value
|
||||
label val(1234);
|
||||
|
||||
auto fixed = leftpadded(val);
|
||||
Info<< "leftpadded " << val << " : " << fixed << nl;
|
||||
}
|
||||
|
||||
ocharstream labelbuf;
|
||||
labelbuf.reserve_exact(32);
|
||||
|
||||
// Some value
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, label(10));
|
||||
|
||||
printInfo(labelbuf);
|
||||
|
||||
OCharStream obuf;
|
||||
obuf.reserve_exact(48);
|
||||
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.push_back('>');
|
||||
obuf.append(" string_view ");
|
||||
obuf.push_back('<');
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(8);
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(100);
|
||||
printInfo(obuf);
|
||||
|
||||
|
||||
// Fill with some content
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
obuf<< char('A' + i);
|
||||
}
|
||||
|
||||
// Change letter 'O' to '_'
|
||||
if (auto i = obuf.view().find('O'); i != std::string::npos)
|
||||
{
|
||||
obuf.overwrite(i, '_');
|
||||
}
|
||||
|
||||
// append and push_back some content
|
||||
obuf.append(5, '<');
|
||||
obuf.push_back('#');
|
||||
obuf.append(5, '>');
|
||||
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.pop_back(8);
|
||||
printInfo(obuf);
|
||||
|
||||
// Slightly silly test
|
||||
{
|
||||
const auto list = obuf.list();
|
||||
Info<< "list content:" << list << nl;
|
||||
Info<< "view content:" << nl << list.view() << nl;
|
||||
}
|
||||
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
printInfo(obuf);
|
||||
|
||||
obuf.overwrite(20, "####");
|
||||
printInfo(obuf);
|
||||
|
||||
Info<< "operation Ignored..." << nl;
|
||||
obuf.overwrite(45, "????");
|
||||
printInfo(obuf);
|
||||
|
||||
// Update with new value
|
||||
{
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, label(200), '.');
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
// With yet another value (non-fixed width)
|
||||
{
|
||||
labelbuf.rewind();
|
||||
labelbuf << label(15);
|
||||
obuf.overwrite(4, labelbuf.view());
|
||||
|
||||
printInfo(obuf);
|
||||
}
|
||||
|
||||
// Slightly harder test
|
||||
{
|
||||
std::string chars(26, '?');
|
||||
|
||||
for (int i = 0; i < 26; ++i)
|
||||
{
|
||||
chars[i] = char('A' + i);
|
||||
}
|
||||
|
||||
auto& os = obuf;
|
||||
os.rewind();
|
||||
|
||||
const word procName("processor0");
|
||||
|
||||
// Write as primitiveEntry or commented content
|
||||
// // constexpr bool isDictFormat = true;
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
// Like writeKeyword() with compoundToken
|
||||
os << nl << procName << ' ' << word("List<char>") << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Human-readable comments
|
||||
os << nl << "// " << procName << nl;
|
||||
}
|
||||
|
||||
// This is the code we want to have, but assume we don't know
|
||||
// the size or data beforehand.
|
||||
//
|
||||
// if (str && len > 0)
|
||||
// {
|
||||
// // Special treatment for char data (binary I/O only)
|
||||
// const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
//
|
||||
// os << label(len) << nl;
|
||||
// os.write(str, len);
|
||||
// os << nl;
|
||||
//
|
||||
// os.format(oldFmt);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// os << label(0) << nl;
|
||||
// }
|
||||
|
||||
// Position before writing the label
|
||||
const auto labelBegin = os.tellp();
|
||||
|
||||
// Replace: os << label(len) << nl;
|
||||
// with a fixed-length version
|
||||
{
|
||||
labelbuf.rewind();
|
||||
rightpad(labelbuf, 0);
|
||||
|
||||
os.append(labelbuf.view());
|
||||
os << nl;
|
||||
}
|
||||
|
||||
constexpr bool testUnknown = true;
|
||||
|
||||
label dataCount = 0;
|
||||
|
||||
if constexpr (testUnknown)
|
||||
{
|
||||
// Pretend we don't know the number of characters a priori
|
||||
|
||||
const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
|
||||
const auto lineNumber = os.lineNumber();
|
||||
|
||||
// count is unknown but irrelevant for serial
|
||||
os.beginRawWrite(0);
|
||||
|
||||
// Position before raw binary data
|
||||
const auto dataBegin = os.tellp();
|
||||
|
||||
// Some type of output, streaming etc
|
||||
os.writeRaw(chars.data(), chars.size());
|
||||
|
||||
// How many chars of binary data written?
|
||||
dataCount = (os.tellp() - dataBegin);
|
||||
|
||||
os.endRawWrite();
|
||||
os.lineNumber() = lineNumber;
|
||||
os << nl;
|
||||
|
||||
os.format(oldFmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we had all data collected a priori
|
||||
|
||||
dataCount = chars.size();
|
||||
|
||||
const auto oldFmt = os.format(IOstreamOption::BINARY);
|
||||
|
||||
if (dataCount > 0)
|
||||
{
|
||||
os.write(chars.data(), chars.size());
|
||||
os << nl;
|
||||
}
|
||||
os.format(oldFmt);
|
||||
}
|
||||
|
||||
if (optFakeZerosize)
|
||||
{
|
||||
dataCount = 0; // fake zero-size
|
||||
}
|
||||
|
||||
printInfo(os);
|
||||
|
||||
// Update the data count with the correct value
|
||||
|
||||
if (dataCount > 0)
|
||||
{
|
||||
labelbuf.rewind();
|
||||
leftpad(labelbuf, label(dataCount));
|
||||
|
||||
os.overwrite(labelBegin, labelbuf.view());
|
||||
}
|
||||
else
|
||||
{
|
||||
os.seek(int64_t(labelBegin)-1);
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
os << ' ' << label(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
os << nl << label(0) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// if constexpr (isDictFormat)
|
||||
if (isDictFormat)
|
||||
{
|
||||
os.endEntry();
|
||||
}
|
||||
|
||||
printInfo(os);
|
||||
|
||||
Info<< "view: " << os.view(4, 8) << nl;
|
||||
Info<< "view: " << os.view(32) << nl;
|
||||
// Ignores out-of-range
|
||||
Info<< "view: " << os.view(1000) << nl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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.
|
||||
@ -65,6 +65,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
OCountStream cnt;
|
||||
OCharStream cstr;
|
||||
OStringStream sstr;
|
||||
ocountstream plain;
|
||||
|
||||
generateOutput(cstr);
|
||||
@ -76,6 +77,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
|
||||
<< "via char-stream: " << label(cstr.view().size()) << " chars" << nl
|
||||
<< "via string-stream: " << label(sstr.count()) << " chars" << nl
|
||||
<< "via ocountstream: " << plain.count() << " chars" << endl;
|
||||
|
||||
fileName outputName;
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-OStringStream.cxx
|
||||
Test-OStringStream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OStringStream
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -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 | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
Test-PackedList.cxx
|
||||
Test-PackedList.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-PackedList
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user