Compare commits

..

3 Commits

Author SHA1 Message Date
622f476b32 ENH: additional SHA1Digest constructors and methods
- data_bytes(), size_bytes() methods to support broadcasting or
  gather/scatter content. Additional construct from raw bytes
  to support transmitted content.
2023-03-20 11:36:50 +01:00
7389ce15ce STYLE: readOnProc/writeOnProc instead of 'valid' for IO 2023-03-16 11:20:09 +01:00
f801e99f9e STYLE: use readValueEntry in BCs. Assign Zero for refValue/refGrad 2023-03-16 11:20:08 +01:00
10371 changed files with 35317 additions and 61290 deletions

View File

@ -49,7 +49,7 @@
<!-- <!--
Providing details of your set-up can help us identify any issues, e.g. Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v2306|v2212|v2206|v2112|v2106 etc OpenFOAM version : v2212|v2206|v2112|v2106|v2012 etc
Operating system : ubuntu|openSUSE|centos etc Operating system : ubuntu|openSUSE|centos etc
Hardware info : any info that may help? Hardware info : any info that may help?
Compiler : gcc|intel|clang etc Compiler : gcc|intel|clang etc

View File

@ -96,12 +96,10 @@ echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler" echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}" echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo echo
echo " api = $(etc/openfoam -show-api 2>/dev/null)"
# The api/patch information echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
sed -e 's/^/ /; s/=/ = /' ./META-INFO/api-info 2>/dev/null || true echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo echo
echo ======================================== echo ========================================

View File

@ -5,22 +5,17 @@ It is likely incomplete...
## Contributors (alphabetical by surname) ## Contributors (alphabetical by surname)
- Horacio Aguerre
- Yu Ankun
- Tetsuo Aoyagi - Tetsuo Aoyagi
- Akira Azami - Akira Azami
- William Bainbridge - William Bainbridge
- Gabriel Barajas - Gabriel Barajas
- Kutalmis Bercin - Kutalmis Bercin
- Julius Bergmann
- Ivor Clifford - Ivor Clifford
- Greg Collecutt - Greg Collecutt
- Jonathan Cranford - Jonathan Cranford
- Santiago Marquez Damian
- Sergio Ferraris - Sergio Ferraris
- Matej Forman - Matej Forman
- Marian Fuchs - Marian Fuchs
- Gabriel Gerlero
- Pawan Ghildiyal - Pawan Ghildiyal
- Chris Greenshields - Chris Greenshields
- Bernhard Gschaider - Bernhard Gschaider
@ -55,11 +50,8 @@ It is likely incomplete...
- Gavin Tabor - Gavin Tabor
- Zeljko Tukovic - Zeljko Tukovic
- Eugene De Villiers - Eugene De Villiers
- Louis Vittoz
- Vuko Vukcevic
- Yi Wang - Yi Wang
- Norbert Weber - Norbert Weber
- Volker Weissmann
- Henry Weller - Henry Weller
- Niklas Wikstrom - Niklas Wikstrom
- Guanyang Xue - Guanyang Xue

View File

@ -1,2 +1,2 @@
api=2307 api=2301
patch=0 patch=230110

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 If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started. the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2306 version: For example, for the OpenFOAM-v2212 version:
``` ```
source /installation/path/OpenFOAM-v2306/etc/bashrc source /installation/path/OpenFOAM-v2212/etc/bashrc
``` ```
## Compiling OpenFOAM ## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example, to the OpenFOAM directory. For example,
``` ```
/path/parent /path/parent
|-- OpenFOAM-v2306 |-- OpenFOAM-v2212
\-- ThirdParty-v2306 \-- ThirdParty-v2212
``` ```
There are, however, many cases where this simple convention is inadequate: There are, however, many cases where this simple convention is inadequate:
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it) operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary * When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2306, etc.. directory name, e.g. openfoam-sandbox2212, etc..
* When we would like any additional 3rd party software to be located * When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is inside of the OpenFOAM directory to ensure that the installation is
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION 2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach * this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI 3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2306-myCustom`, * allows for an updated value of VERSION, *eg*, `v2212-myCustom`,
without requiring a renamed ThirdParty. The API value would still without requiring a renamed ThirdParty. The API value would still
be `2306` and the original `ThirdParty-v2306/` would be found. be `2212` and the original `ThirdParty-v2212/` would be found.
4. PREFIX/ThirdParty-API 4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value. * same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common 5. PREFIX/ThirdParty-common

View File

@ -18,6 +18,6 @@ dimensionedScalar rho("rho", dimDensity, transportProperties);
scalar MaxCo = scalar MaxCo =
max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value() max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value()
*runTime.deltaTValue(); *runTime.deltaT().value();
Info<< "Max acoustic Courant Number = " << MaxCo << endl; Info<< "Max acoustic Courant Number = " << MaxCo << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2020,2023 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -132,11 +132,6 @@ void PDRkEpsilon::correct()
// Update epsilon and G at the wall // Update epsilon and G at the wall
epsilon_.boundaryFieldRef().updateCoeffs(); epsilon_.boundaryFieldRef().updateCoeffs();
// Push new cell values to
// coupled neighbours. Note that we want to avoid the re-updateCoeffs
// of the wallFunctions so make sure to bypass the evaluate on
// those patches and only do the coupled ones.
epsilon_.boundaryFieldRef().evaluateCoupled<coupledFvPatch>();
// Add the blockage generation term so that it is included consistently // Add the blockage generation term so that it is included consistently
// in both the k and epsilon equations // in both the k and epsilon equations

View File

@ -223,7 +223,7 @@ if (ign.ignited())
volScalarField R(Gstar*XiEqStar/(XiEqStar - scalar(1))); volScalarField R(Gstar*XiEqStar/(XiEqStar - scalar(1)));
volScalarField G(R*(XiEq - scalar(1.001))/XiEq); volScalarField G(R*(XiEq - scalar(1.001))/XiEq);
//R *= (Gstar + 2*mag(devSymm(fvc::grad(U))))/Gstar; //R *= (Gstar + 2*mag(dev(symm(fvc::grad(U)))))/Gstar;
// Solve for the flame wrinkling // Solve for the flame wrinkling
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

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

View File

@ -1,3 +1,3 @@
dtChem = chemistry.solve(runTime.deltaTValue()); dtChem = chemistry.solve(runTime.deltaT().value());
scalar Qdot = chemistry.Qdot()()[0]/rho[0]; scalar Qdot = chemistry.Qdot()()[0]/rho[0];
integratedHeat += Qdot*runTime.deltaTValue(); integratedHeat += Qdot*runTime.deltaT().value();

View File

@ -105,8 +105,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
if (!this->readValueEntry(dict)) if (!this->readValueEntry(dict))
{ {
// Fallback: set to the internal field fvPatchField<scalar>::operator=(patchInternalField());
fvPatchField<scalar>::patchInternalField(*this);
} }
refValue() = *this; refValue() = *this;

View File

@ -17,7 +17,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate
vf, vf,
dir, dir,
"reconstruct(" "reconstruct("
+ (reconFieldName.empty() ? vf.name() : reconFieldName) + (reconFieldName != word::null ? reconFieldName : vf.name())
+ ')' + ')'
) )
); );

View File

@ -29,7 +29,7 @@ if (mesh.changing())
wordList pcorrTypes wordList pcorrTypes
( (
p.boundaryField().size(), p.boundaryField().size(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
// Set BCs of pcorr to fixed-value for patches at which p is fixed // Set BCs of pcorr to fixed-value for patches at which p is fixed

View File

@ -7,7 +7,7 @@
*mag(aMesh.edgeInterpolation::deltaCoeffs()) *mag(aMesh.edgeInterpolation::deltaCoeffs())
/rhol /rhol
) )
).value()*runTime.deltaTValue(); ).value()*runTime.deltaT().value();
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl; Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
} }

View File

@ -87,13 +87,7 @@ int main(int argc, char *argv[])
( (
fam::ddt(h, Us) fam::ddt(h, Us)
+ fam::div(phi2s, Us) + fam::div(phi2s, Us)
+ fam::Sp + fam::Sp(0.0125*frictionFactor*mag(Us), Us)
(
0.0125
*frictionFactor.internalField()
*mag(Us.internalField()),
Us
)
== ==
Gs*h Gs*h
- fam::Sp(Sd, Us) - fam::Sp(Sd, Us)

View File

@ -47,10 +47,10 @@ if (aMesh.nInternalEdges())
); );
CoNum = max(SfUfbyDelta/aMesh.magLe()) CoNum = max(SfUfbyDelta/aMesh.magLe())
.value()*runTime.deltaTValue(); .value()*runTime.deltaT().value();
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe())) meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
.value()*runTime.deltaTValue(); .value()*runTime.deltaT().value();
velMag = max(mag(phis)/aMesh.magLe()).value(); velMag = max(mag(phis)/aMesh.magLe()).value();
} }

View File

@ -47,7 +47,6 @@ forAll(Us, faceI)
Us[faceI].z() = Us[faceI].z() =
Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI])); Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI]));
} }
Us.boundaryFieldRef().evaluateCoupled<coupledFaPatch>();
Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us); Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us);

View File

@ -29,7 +29,7 @@ if (mesh.changing())
wordList pcorrTypes wordList pcorrTypes
( (
p.boundaryField().size(), p.boundaryField().size(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
// Set BCs of pcorr to fixed-value for patches at which p is fixed // Set BCs of pcorr to fixed-value for patches at which p is fixed

View File

@ -108,7 +108,7 @@ forAll(fluidRegions, i)
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
dimensionedScalar(word::null, dimLength, Zero) dimensionedScalar("hRef", dimLength, Zero) // uses name
) )
); );

View File

@ -1,5 +1,5 @@
derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
solid/solidRegionDiffNo.C ../solid/solidRegionDiffNo.C
chtMultiRegionTwoPhaseEulerFoam.C chtMultiRegionTwoPhaseEulerFoam.C
EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam

View File

@ -292,7 +292,8 @@ updateCoeffs()
// Since we're inside initEvaluate/evaluate there might be processor // Since we're inside initEvaluate/evaluate there might be processor
// comms underway. Change the tag we use. // comms underway. Change the tag we use.
const int oldTag = UPstream::incrMsgType(); int oldTag = UPstream::msgType();
UPstream::msgType() = oldTag+1;
// Get the coupling information from the mappedPatchBase // Get the coupling information from the mappedPatchBase
const label patchi = patch().index(); const label patchi = patch().index();
@ -470,9 +471,10 @@ updateCoeffs()
<< regionTypeNames_ << nl << exit(FatalError); << regionTypeNames_ << nl << exit(FatalError);
} }
UPstream::msgType(oldTag); // Restore tag
mixedFvPatchScalarField::updateCoeffs(); mixedFvPatchScalarField::updateCoeffs();
// Restore tag
UPstream::msgType() = oldTag;
} }

View File

@ -221,7 +221,7 @@ forAll(fluidRegions, i)
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
dimensionedScalar(word::null, dimLength, Zero) dimensionedScalar("hRef", dimLength, Zero)
) )
); );

View File

@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
"cumulativeContErr", "cumulativeContErr",
runTime.timeName(), runTime.timeName(),
"uniform", "uniform",
mesh.thisDb(), mesh,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
dimensionedScalar(word::null, dimless, Zero) dimensionedScalar(dimless, Zero)
) )
); );
} }

View File

@ -112,7 +112,7 @@ forAll(fluidRegions, i)
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
dimensionedScalar(word::null, dimLength, Zero) dimensionedScalar("hRef", dimLength, Zero) // uses name
) )
); );

View File

@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
"cumulativeContErr", "cumulativeContErr",
runTime.timeName(), runTime.timeName(),
"uniform", "uniform",
mesh.thisDb(), mesh,
IOobject::READ_IF_PRESENT, IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
dimensionedScalar(word::null, dimless, Zero) dimensionedScalar(dimless, Zero)
) )
); );
} }

View File

@ -49,11 +49,11 @@ if (adjustTimeStep)
( (
min min
( (
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(), min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
min(runTime.deltaTValue(), maxDeltaT) min(runTime.deltaTValue(), maxDeltaT)
) )
); );
Info<< "deltaT = " << runTime.deltaTValue() << endl; Info<< "deltaT = " << runTime.deltaT().value() << endl;
} }
} }

View File

@ -59,12 +59,12 @@ if (adjustTimeStep)
( (
min min
( (
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(), min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
maxDeltaT maxDeltaT
) )
); );
Info<< "deltaT = " << runTime.deltaTValue() << endl; Info<< "deltaT = " << runTime.deltaT().value() << endl;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -57,7 +57,7 @@
), ),
solidRegions[i], solidRegions[i],
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero), dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchSymmTensorField::typeName
) )
); );

View File

@ -34,7 +34,7 @@ if (!thermo.isotropic())
), ),
mesh, mesh,
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero), dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchSymmTensorField::typeName
) )
); );
volSymmTensorField& aniAlpha = *taniAlpha; volSymmTensorField& aniAlpha = *taniAlpha;

View File

@ -24,7 +24,7 @@ if (mesh.changing())
wordList pcorrTypes wordList pcorrTypes
( (
p.boundaryField().size(), p.boundaryField().size(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
// Set BCs of pcorr to fixed-value for patches at which p is fixed // Set BCs of pcorr to fixed-value for patches at which p is fixed

View File

@ -130,7 +130,7 @@ int main(int argc, char *argv[])
), ),
mesh, mesh,
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero), dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchVectorField::typeName
); );
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V(); cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();

View File

@ -111,7 +111,7 @@ int main(int argc, char *argv[])
), ),
mesh, mesh,
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero), dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchVectorField::typeName
); );
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V(); cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();

View File

@ -141,7 +141,7 @@ int main(int argc, char *argv[])
), ),
mesh, mesh,
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero), dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchVectorField::typeName
); );
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V(); cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();

View File

@ -64,7 +64,8 @@ volScalarField mu
mesh, mesh,
IOobject::READ_IF_PRESENT IOobject::READ_IF_PRESENT
), ),
mixture.mu() mixture.mu(),
calculatedFvPatchScalarField::typeName
); );
@ -138,7 +139,7 @@ volScalarField alphac
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
alphac.oldTime(); alphac.oldTime();

View File

@ -1,7 +1,7 @@
wordList pcorrTypes wordList pcorrTypes
( (
p.boundaryField().size(), p.boundaryField().size(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
for (label i=0; i<p.boundaryField().size(); i++) for (label i=0; i<p.boundaryField().size(); i++)

View File

@ -86,7 +86,6 @@ VoFPatchTransfer::VoFPatchTransfer
wordRes patchNames; wordRes patchNames;
if (coeffDict_.readIfPresent("patches", patchNames)) if (coeffDict_.readIfPresent("patches", patchNames))
{ {
// Can also use pbm.indices(), but no warnings...
patchIDs_ = pbm.patchSet(patchNames).sortedToc(); patchIDs_ = pbm.patchSet(patchNames).sortedToc();
Info<< " applying to " << patchIDs_.size() << " patches:" << nl; Info<< " applying to " << patchIDs_.size() << " patches:" << nl;

View File

@ -140,7 +140,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
), ),
mesh, mesh,
dimensionedScalar(dimless, Zero), dimensionedScalar(dimless, Zero),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
), ),
curTimeIndex_(-1) curTimeIndex_(-1)
{ {

View File

@ -1075,7 +1075,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
MULES::limit MULES::limit
( (
1.0/mesh_.time().deltaTValue(), 1.0/mesh_.time().deltaT().value(),
geometricOneField(), geometricOneField(),
alpha, alpha,
phi_, phi_,

View File

@ -105,7 +105,8 @@ incompressibleTwoPhaseInteractingMixture
U_.db() U_.db()
), ),
U_.mesh(), U_.mesh(),
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero) dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero),
calculatedFvPatchScalarField::typeName
) )
{ {
correct(); correct();

View File

@ -48,7 +48,7 @@ Foam::wordList Foam::relativeVelocityModel::UdmPatchFieldTypes() const
wordList UdmTypes wordList UdmTypes
( (
U.boundaryField().size(), U.boundaryField().size(),
fvPatchFieldBase::calculatedType() calculatedFvPatchScalarField::typeName
); );
forAll(U.boundaryField(), i) forAll(U.boundaryField(), i)

View File

@ -699,7 +699,7 @@ void Foam::radiation::laserDTRM::calculate()
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V()); scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
Info << "Total energy absorbed [W]: " << totalQ << endl; Info << "Total energy absorbed [W]: " << totalQ << endl;
if (mesh_.time().writeTime()) if (mesh_.time().outputTime())
{ {
reflectingCellsVol.write(); reflectingCellsVol.write();
nHat.write(); nHat.write();

View File

@ -52,9 +52,7 @@ namespace Foam
const Foam::volScalarField& const Foam::volScalarField&
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
{ {
const volScalarField* ptr = mesh_.cfindObject<volScalarField>(alphaName); if (!mesh_.foundObject<volScalarField>(alphaName))
if (!ptr)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unable to retrieve density field " << alphaName << " from " << "Unable to retrieve density field " << alphaName << " from "
@ -62,7 +60,7 @@ Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
<< exit(FatalError); << exit(FatalError);
} }
return *ptr; return mesh_.lookupObject<volScalarField>(alphaName);
} }

View File

@ -124,7 +124,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
* max(TSat - T, T0) * max(TSat - T, T0)
); );
if (mesh_.time().writeTime()) if (mesh_.time().outputTime())
{ {
mDotC.write(); mDotC.write();
mDotE.write(); mDotE.write();

View File

@ -96,7 +96,7 @@
MULES::limiter MULES::limiter
( (
allLambda, allLambda,
1.0/runTime.deltaTValue(), 1.0/runTime.deltaT().value(),
geometricOneField(), geometricOneField(),
alpha1, alpha1,
alphaPhi1BD, alphaPhi1BD,
@ -164,7 +164,7 @@
MULES::limiter MULES::limiter
( (
allLambda, allLambda,
1.0/runTime.deltaTValue(), 1.0/runTime.deltaT().value(),
geometricOneField(), geometricOneField(),
alpha2, alpha2,
alphaPhi2BD, alphaPhi2BD,

View File

@ -119,7 +119,8 @@ Foam::incompressibleThreePhaseMixture::incompressibleThreePhaseMixture
U.db() U.db()
), ),
U.mesh(), U.mesh(),
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero) dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero),
calculatedFvPatchScalarField::typeName
), ),
nuModel1_ nuModel1_

View File

@ -27,7 +27,7 @@
wordList pcorrTypes wordList pcorrTypes
( (
p_rgh.boundaryField().size(), p_rgh.boundaryField().size(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
for (label i=0; i<p_rgh.boundaryField().size(); i++) for (label i=0; i<p_rgh.boundaryField().size(); i++)

View File

@ -76,7 +76,7 @@
mesh mesh
), ),
fluid.dragCoeff(phase, dragCoeffs())/phase.rho(), fluid.dragCoeff(phase, dragCoeffs())/phase.rho(),
fvPatchFieldBase::zeroGradientType() zeroGradientFvPatchScalarField::typeName
); );
dragCoeffi.correctBoundaryConditions(); dragCoeffi.correctBoundaryConditions();

View File

@ -628,7 +628,7 @@ void Foam::multiphaseMixture::solveAlphas
MULES::limit MULES::limit
( (
1.0/mesh_.time().deltaTValue(), 1.0/mesh_.time().deltaT().value(),
geometricOneField(), geometricOneField(),
alpha, alpha,
phi_, phi_,

View File

@ -20,7 +20,7 @@
IOobject rhoIO IOobject rhoIO
( (
"rho", "rho",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -75,7 +75,7 @@
IOobject EHeader IOobject EHeader
( (
"E", "E",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -127,7 +127,7 @@
IOobject nuIO IOobject nuIO
( (
"nu", "nu",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -51,7 +51,7 @@ if (thermalStress)
IOobject CIO IOobject CIO
( (
"C", "C",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -106,7 +106,7 @@ if (thermalStress)
IOobject rhoKIO IOobject rhoKIO
( (
"k", "k",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -161,7 +161,7 @@ if (thermalStress)
IOobject alphaIO IOobject alphaIO
( (
"alpha", "alpha",
Time::timeName(0), runTime.timeName(0),
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -47,7 +47,7 @@ tractionDisplacementFvPatchVectorField
traction_(p.size(), Zero), traction_(p.size(), Zero),
pressure_(p.size(), Zero) pressure_(p.size(), Zero)
{ {
extrapolateInternal(); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
} }
@ -79,7 +79,7 @@ tractionDisplacementFvPatchVectorField
traction_("traction", dict, p.size()), traction_("traction", dict, p.size()),
pressure_("pressure", dict, p.size()) pressure_("pressure", dict, p.size())
{ {
extrapolateInternal(); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
} }

View File

@ -47,7 +47,7 @@ tractionDisplacementCorrectionFvPatchVectorField
traction_(p.size(), Zero), traction_(p.size(), Zero),
pressure_(p.size(), Zero) pressure_(p.size(), Zero)
{ {
extrapolateInternal(); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
} }
@ -79,7 +79,7 @@ tractionDisplacementCorrectionFvPatchVectorField
traction_("traction", dict, p.size()), traction_("traction", dict, p.size()),
pressure_("pressure", dict, p.size()) pressure_("pressure", dict, p.size())
{ {
extrapolateInternal(); fvPatchVectorField::operator=(patchInternalField());
gradient() = Zero; gradient() = Zero;
} }

View File

@ -27,14 +27,6 @@ License
#include "dummyLib.H" #include "dummyLib.H"
#include <iostream> #include <iostream>
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h> #include <mpi.h>
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //

View File

@ -92,10 +92,7 @@ int main(int argc, char *argv[])
} }
report(buf1); report(buf1);
buf1.push_back(identity(5)); buf1.push_back(identity(5)); report(buf1);
buf1.emplace_front(-1000);
buf1.emplace_back(1000);
report(buf1);
buf1.info(Info); buf1.info(Info);
Info<< buf1 << nl; Info<< buf1 << nl;

View File

@ -55,7 +55,10 @@ public:
i_(i) i_(i)
{} {}
const word& keyword() const noexcept { return keyword_; } const word& keyword() const
{
return keyword_;
}
friend Ostream& operator<<(Ostream& os, const ent& e) friend Ostream& operator<<(Ostream& os, const ent& e)
{ {
@ -71,27 +74,28 @@ class Scalar
public: public:
static bool verbose; Scalar()
:
data_(0)
{}
constexpr Scalar() noexcept : data_(0) {} Scalar(scalar val)
Scalar(scalar val) noexcept : data_(val) {} :
data_(val)
{}
~Scalar() ~Scalar()
{ {
if (verbose) Info<< "delete Scalar: " << data_ << endl; Info<<"delete Scalar: " << data_ << endl;
} }
scalar value() const noexcept { return data_; } friend Ostream& operator<<(Ostream& os, const Scalar& val)
scalar& value() noexcept { return data_; }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{ {
os << item.value(); os << val.data_;
return os; return os;
} }
}; };
bool Scalar::verbose = true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -113,7 +117,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first()); dict.swapDown(dict.first());
forAllConstIters(dict, iter) forAllConstIter(Dictionary<ent>, dict, iter)
{ {
Info<< "element : " << *iter; Info<< "element : " << *iter;
} }
@ -153,9 +157,9 @@ int main(int argc, char *argv[])
} }
Info<< nl << "scalarDict1: " << endl; Info<< nl << "scalarDict1: " << endl;
forAllConstIters(scalarDict, iter) forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
{ {
Info<< " = " << *iter << endl; Info<< " = " << iter() << endl;
} }
PtrDictionary<Scalar> scalarDict2; PtrDictionary<Scalar> scalarDict2;
@ -165,7 +169,7 @@ int main(int argc, char *argv[])
scalarDict2.insert(key, new Scalar(1.3*i)); scalarDict2.insert(key, new Scalar(1.3*i));
} }
Info<< nl << "scalarDict2: " << endl; Info<< nl << "scalarDict2: " << endl;
forAllConstIters(scalarDict2, iter) forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
{ {
std::cout<< "iter: " << typeid(*iter).name() << '\n'; std::cout<< "iter: " << typeid(*iter).name() << '\n';

View File

@ -85,7 +85,7 @@ Description
fileNameList procDirs fileNameList procDirs
( (
DirLister::dirs(".").csorted<fileName>(matchProcs) DirLister::dirs(".").sorted<fileName>(matchProcs)
); );
} }
\endcode \endcode
@ -206,11 +206,11 @@ public:
//- Return a complete list of names, sorted in natural order //- Return a complete list of names, sorted in natural order
template<class StringType=Foam::word> template<class StringType=Foam::word>
List<StringType> csorted() const; List<StringType> sorted() const;
//- Return complete list of names, sorted in natural order //- Return complete list of names, sorted in natural order
template<class StringType=Foam::word, class UnaryPredicate> template<class StringType=Foam::word, class UnaryPredicate>
List<StringType> csorted List<StringType> sorted
( (
const UnaryPredicate& pred, const UnaryPredicate& pred,
const bool prune = false const bool prune = false

View File

@ -70,23 +70,23 @@ Foam::List<StringType> Foam::DirLister::list() const
template<class StringType, class UnaryPredicate> template<class StringType, class UnaryPredicate>
Foam::List<StringType> Foam::DirLister::csorted Foam::List<StringType> Foam::DirLister::sorted
( (
const UnaryPredicate& pred, const UnaryPredicate& pred,
const bool prune const bool prune
) const ) const
{ {
List<StringType> list(list<StringType>(pred, prune)); List<StringType> lst(list<StringType>(pred, prune));
Foam::sort(list, stringOps::natural_sort()); sort(lst, stringOps::natural_sort());
return list; return lst;
} }
template<class StringType> template<class StringType>
Foam::List<StringType> Foam::DirLister::csorted() const Foam::List<StringType> Foam::DirLister::sorted() const
{ {
return csorted<StringType>(predicates::always()); return sorted<StringType>(predicates::always());
} }

View File

@ -162,7 +162,7 @@ int main(int argc, char *argv[])
Info<< "dirList: " Info<< "dirList: "
<< flatOutput << flatOutput
( (
DirLister::dirs(".").csorted<fileName>(relist) DirLister::dirs(".").sorted<fileName>(relist)
) << nl; ) << nl;
} }

View File

@ -112,20 +112,13 @@ int main(int argc, char *argv[])
argList::addBoolOption("iter"); argList::addBoolOption("iter");
argList::addBoolOption("swap"); argList::addBoolOption("swap");
argList::addBoolOption("default", "reinstate default tests"); argList::addBoolOption("default", "reinstate default tests");
argList::addBoolOption("no-wait", "test with skipping request waits");
argList::addNote("runs default tests or specified ones only"); argList::addNote("runs default tests or specified ones only");
#include "setRootCase.H" #include "setRootCase.H"
const bool optNowaiting = args.found("no-wait");
// Run default tests, unless only specific tests are requested // Run default tests, unless only specific tests are requested
const bool defaultTests = const bool defaultTests =
( args.found("default") || args.options().empty();
args.found("default")
|| args.options().empty()
|| (optNowaiting && args.options().size())
);
typedef FixedList<scalar,2> scalar2Type; typedef FixedList<scalar,2> scalar2Type;
@ -202,31 +195,14 @@ int main(int argc, char *argv[])
Info<< "get<3>: " << list1.get<3>() << nl; Info<< "get<3>: " << list1.get<3>() << nl;
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl; // Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
// Test deprecated form label a[4] = {0, 1, 2, 3};
label array2[4] = {0, 1, 2, 3}; FixedList<label, 4> list2(a);
FixedList<label, 4> list2(array2);
Info<< "list2:" << list2 Info<< "list2:" << list2
<< " hash:" << FixedList<label, 4>::hasher()(list2) << nl << " hash:" << FixedList<label, 4>::hasher()(list2) << nl
<< " hash:" << Hash<FixedList<label, 4>>()(list2) << nl; << " hash:" << Hash<FixedList<label, 4>>()(list2) << nl;
// Test deprecated form
SLList<label> sllist3;
{
sllist3.push_back(0);
sllist3.push_back(1);
sllist3.push_back(2);
sllist3.push_back(3);
}
FixedList<label, 4> list3(sllist3);
Info<< "list3:" << list3 << nl;
// Test deprecated forms
list3 = array2;
list2 = sllist3;
// Using FixedList for content too // Using FixedList for content too
{ {
List<FixedList<label, 4>> twolists{list1, list2}; List<FixedList<label, 4>> twolists{list1, list2};
@ -254,8 +230,8 @@ int main(int argc, char *argv[])
Info<< "mem: " Info<< "mem: "
<< name(list1.data()) << " " << name(list2.data()) << nl; << name(list1.data()) << " " << name(list2.data()) << nl;
Foam::Swap(list1, list2); Swap(list1, list2);
Info<< "Foam::Swap() function" << nl; Info<< "The Swap() function" << nl;
Info<< "list1: " << list1 << nl Info<< "list1: " << list1 << nl
<< "list2: " << list2 << nl; << "list2: " << list2 << nl;
@ -331,53 +307,27 @@ int main(int argc, char *argv[])
List<FixedList<label, 2>> list6{{0, 1}, {2, 3}}; List<FixedList<label, 2>> list6{{0, 1}, {2, 3}};
Info<< "list6: " << list6 << nl; Info<< "list6: " << list6 << nl;
if (UPstream::parRun()) if (Pstream::parRun())
{ {
// Fixed buffer would also work, but want to test using UList // Fixed buffer would also work, but want to test using UList
List<labelPair> buffer; List<labelPair> buffer;
DynamicList<UPstream::Request> requests;
const label numProcs = UPstream::nProcs();
const label startOfRequests = UPstream::nRequests(); const label startOfRequests = UPstream::nRequests();
if (Pstream::master())
// NOTE: also test a mix of local and global requests...
UPstream::Request singleRequest;
if (UPstream::master())
{ {
// Use local requests here buffer.resize(UPstream::nProcs());
requests.reserve(numProcs);
buffer.resize(numProcs);
buffer[0] = labelPair(0, UPstream::myProcNo()); buffer[0] = labelPair(0, UPstream::myProcNo());
for (const int proci : UPstream::subProcs()) for (const int proci : Pstream::subProcs())
{ {
UIPstream::read UIPstream::read
( (
requests.emplace_back(), UPstream::commsTypes::nonBlocking,
proci, proci,
buffer.slice(proci, 1) buffer.slice(proci, 1)
); );
} }
if (requests.size() > 1)
{
// Or just wait for as a single request...
singleRequest = requests.back();
requests.pop_back();
}
if (requests.size() > 2)
{
// Peel off a few from local -> global
// the order will not matter (is MPI_Waitall)
UPstream::addRequest(requests.back()); requests.pop_back();
UPstream::addRequest(requests.back()); requests.pop_back();
}
} }
else else
{ {
@ -386,34 +336,16 @@ int main(int argc, char *argv[])
Perr<< "Sending to master: " << buffer << endl; Perr<< "Sending to master: " << buffer << endl;
// Capture the request and transfer to the global list
// (for testing)
UOPstream::write UOPstream::write
( (
singleRequest, UPstream::commsTypes::nonBlocking,
UPstream::masterNo(), UPstream::masterNo(),
buffer.slice(0, 1) // OK buffer.slice(0, 1) // OK
/// buffer // Also OK /// buffer // Also OK
); );
// if (singleRequest.good())
{
UPstream::addRequest(singleRequest);
}
} }
Pout<< "Pending requests [" << numProcs << " procs] global=" UPstream::waitRequests(startOfRequests);
<< (UPstream::nRequests() - startOfRequests)
<< " local=" << requests.size()
<< " single=" << singleRequest.good() << nl;
if (!optNowaiting)
{
UPstream::waitRequests(startOfRequests);
}
UPstream::waitRequests(requests);
UPstream::waitRequest(singleRequest);
Info<< "Gathered: " << buffer << endl; Info<< "Gathered: " << buffer << endl;
} }

View File

@ -68,7 +68,7 @@ void runSwapTest
for (label iLoop = 0; iLoop < nLoops; ++iLoop) for (label iLoop = 0; iLoop < nLoops; ++iLoop)
{ {
Foam::Swap(list1, list2); Swap(list1, list2);
} }
Info<< "output 1: " << list1.first() << nl; Info<< "output 1: " << list1.first() << nl;

View File

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

View File

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

View File

@ -44,28 +44,38 @@ class Scalar
public: public:
static bool verbose; Scalar()
:
data_(0)
{}
constexpr Scalar() noexcept : data_(0) {} Scalar(scalar val)
Scalar(scalar val) noexcept : data_(val) {} :
data_(val)
{}
~Scalar() ~Scalar()
{ {
if (verbose) Info<< "delete Scalar: " << data_ << endl; Info<<"delete Scalar: " << data_ << endl;
} }
const scalar& value() const noexcept { return data_; } const scalar& value() const
scalar& value() noexcept { return data_; }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{ {
os << item.value(); return data_;
}
scalar& value()
{
return data_;
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os; return os;
} }
}; };
bool Scalar::verbose = true;
template<class T> template<class T>
void printTable(const HashPtrTable<T>& table) void printTable(const HashPtrTable<T>& table)
@ -119,9 +129,6 @@ int main()
myTable.set("natlog", new double(2.718282)); myTable.set("natlog", new double(2.718282));
myTable.insert("sqrt2", autoPtr<double>::New(1.414214)); myTable.insert("sqrt2", autoPtr<double>::New(1.414214));
myTable.insert("euler", autoPtr<double>::New(0.577216)); myTable.insert("euler", autoPtr<double>::New(0.577216));
myTable.set("def_0", nullptr);
myTable.emplace_set("def_1", 123);
myTable.emplace_set("def_2", 456);
HashTable<std::unique_ptr<double>> myTable1; HashTable<std::unique_ptr<double>> myTable1;
@ -139,14 +146,6 @@ int main()
Info<< "Initial table" << nl; Info<< "Initial table" << nl;
printTable(myTable); printTable(myTable);
myTable.try_emplace("def_0", 1000); // was nullptr, now value
myTable.try_emplace("def_1", 1001); // no-op
myTable.try_emplace("def_2", 1002); // no-op;
myTable.try_emplace("def_3", 1003); // was non-existent, now value
Info<< "after try_emplace" << nl;
printTable(myTable);
Info<< "print" << nl; Info<< "print" << nl;
Info<< myTable2 << nl; Info<< myTable2 << nl;

View File

@ -75,8 +75,8 @@ int main()
} }
Info<< "\ntable1 csorted() :" << endl; Info<< "\ntable1 sorted() :" << endl;
for (const auto& iter : table1.csorted()) for (const auto& iter : table1.sorted())
{ {
Info<< " " << iter.key() << " => " << iter.val() << nl; Info<< " " << iter.key() << " => " << iter.val() << nl;
} }
@ -100,7 +100,7 @@ int main()
} }
Info<< "\nInplace modified - via sorted() access :" << endl; Info<< "\nInplace modified - via sorted() access :" << endl;
for (const auto& iter : table1.csorted()) for (const auto& iter : table1.sorted())
{ {
Info<< " " << iter.key() << " => " << iter.val() << nl; Info<< " " << iter.key() << " => " << iter.val() << nl;
} }
@ -366,8 +366,8 @@ int main()
Info<< nl << "input values" << nl; Info<< nl << "input values" << nl;
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
Info<<"std::swap function" << nl; Info<<"global Swap function" << nl;
std::swap(table1, table2); Swap(table1, table2);
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl; Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
Info<<"swap method" << nl; Info<<"swap method" << nl;

View File

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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020-2023 OpenCFD Ltd. Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -33,7 +33,6 @@ Description
#include "argList.H" #include "argList.H"
#include "Fstream.H" #include "Fstream.H"
#include "OSspecific.H"
#include "etcFiles.H" #include "etcFiles.H"
using namespace Foam; using namespace Foam;
@ -45,14 +44,11 @@ int main(int argc, char *argv[])
{ {
argList::noBanner(); argList::noBanner();
argList::noParallel(); argList::noParallel();
argList::noParallel();
argList::addOption("ignore", "file", "Test readRaw with ignore");
#include "setRootCase.H" #include "setRootCase.H"
// Test with etc/controlDict (mandatory, from distribution) // Test with etc/controlDict (mandatory, from distribution)
if (!args.found("ignore"))
{ {
const fileName inputFile const fileName inputFile
( (
@ -101,43 +97,6 @@ int main(int argc, char *argv[])
} }
} }
fileName testFile;
if (args.readIfPresent("ignore", testFile))
{
if (testFile.has_ext("gz"))
{
testFile.remove_ext();
Info<< "stripping extraneous .gz ending" << endl;
}
IFstream is(testFile);
auto& stdStream = is.stdStream();
List<char> buffer(1000);
Info<< "Test readRaw with: " << is.name()
<< " compressed:" << int(is.compression())
<< " file-size:" << is.fileSize() << nl;
for (int iter = 0; is.good() && iter < 1000; ++iter)
{
Info<< "iter:" << iter;
if (iter % 2)
{
Info<< " [read] ";
is.readRaw(buffer.data(), buffer.size());
}
else
{
Info<< " [ignore]";
is.readRaw(nullptr, buffer.size() / 2);
}
Info<< " : " << stdStream.gcount() << endl;
}
}
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,46 +27,14 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "SpanStream.H" #include "ListStream.H"
#include "UListStream.H"
#include "wordList.H" #include "wordList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "argList.H" #include "argList.H"
#include <cctype>
#include <cstdio>
using namespace Foam; using namespace Foam;
Ostream& writeList(Ostream& os, const UList<char>& list)
{
char buf[4];
os << list.size() << '(';
for (const char c : list)
{
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& toString(Ostream& os, const UList<char>& list) Ostream& toString(Ostream& os, const UList<char>& list)
{ {
os << '"'; os << '"';
@ -125,7 +93,7 @@ int main(int argc, char *argv[])
// Buffer storage // Buffer storage
DynamicList<char> storage(16); DynamicList<char> storage(16);
OCharStream obuf(std::move(storage)); OListStream obuf(std::move(storage));
obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n"; obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n";
// Move contents to output buffer // Move contents to output buffer
@ -136,9 +104,9 @@ int main(int argc, char *argv[])
Info<< "transfer contents to a List" << endl; Info<< "transfer contents to a List" << endl;
ICharStream ibuf; IListStream ibuf;
// Reclaim data storage from OCharStream -> ICharStream // Reclaim data storage from OListStream -> IListStream
{ {
List<char> data; List<char> data;
obuf.swap(data); obuf.swap(data);
@ -193,43 +161,6 @@ int main(int argc, char *argv[])
Info<<nl << "swapped out:"; Info<<nl << "swapped out:";
printInfo(newvalues); printInfo(newvalues);
{
iliststream is(std::move(newvalues));
char c = 0;
Info<< nl
<< "getting values from iliststream of "
<< is.list() << endl;
// Info<< " (" << is.tellg() << " " << is.remaining() << ")";
// Info<< "get:";
while (is.get(c))
{
Info<< ' ' << c;
// Info<< " (" << is.tellg() << " " << is.remaining() << ")";
}
Info<< " - end" << nl;
// Info<< "remaining: " << is.list() << endl;
// Info<< "remaining: " << is.remaining() << endl;
// Manipulate the list view
{
UList<char> chars(is.list());
Foam::reverse(chars);
}
is.rewind();
Info<< "get:";
while (is.get(c))
{
Info<< ' ' << c;
}
Info<< " - end" << nl;
}
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -290,14 +290,14 @@ int main(int argc, char *argv[])
Info<< "Time: " << runTime.timeName() << nl; Info<< "Time: " << runTime.timeName() << nl;
report(objects); report(objects);
report(objects.csorted()); report(objects.sorted());
report(objects.csorted<volScalarField>()); report(objects.sorted<volScalarField>());
report(objects.csorted<volVectorField>()); report(objects.sorted<volVectorField>());
// Extra checks // Extra checks
report<volScalarField>(objects.csorted<volScalarField>()); report<volScalarField>(objects.sorted<volScalarField>());
report<volScalarField>(objects.csorted<volVectorField>()); report<volScalarField>(objects.sorted<volVectorField>());
findObjectTest(objects); findObjectTest(objects);

View File

@ -46,26 +46,25 @@ class Scalar
{ {
public: public:
// static bool verbose;
scalar data_; scalar data_;
Scalar() : data_(0) {} Scalar()
Scalar(scalar val) : data_(val) {} :
data_(0)
{}
// ~Scalar() {} Scalar(scalar s)
:
data_(s)
{}
scalar value() const noexcept { return data_; } friend Ostream& operator<<(Ostream& os, const Scalar& s)
scalar& value() noexcept { return data_; }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{ {
os << item.value(); os << s.data_;
return os; return os;
} }
};
// bool Scalar::verbose = true; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,7 +27,8 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H" #include "ListStream.H"
#include "UListStream.H"
#include "wordList.H" #include "wordList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "argList.H" #include "argList.H"
@ -154,378 +155,35 @@ void doTest
} }
void printToken(const label index, const token& tok)
{
Info<< " " << index << " " << tok.name();
if (tok.good())
{
Info<< " : " << tok;
}
Info<< nl;
}
template<class BUF>
void testWalk1
(
const std::string& name,
const BUF& input,
const int verbose
)
{
Info<< "tokenized " << name.c_str() << ":" << nl
<< "====" << nl;
toString(Info, input)
<< nl
<< "====" << endl;
ITstream is(input);
Info<< is.size() << " tokens" << endl;
for (is.rewind(); !is.eof(); is.skip())
{
printToken(is.tokenIndex(), is.currentToken());
}
Info<< nl;
Info<< "every other token:" << nl;
for (is.seek(1); is.nRemainingTokens(); is.skip(2))
{
printToken(is.tokenIndex(), is.currentToken());
}
for (int i : { 3, 7, 11, 20 })
{
Info<< "peekToken: ";
printToken(i, is.peekToken(i));
}
labelRange range(is.size()-2, 2);
Info<< nl
<< "remove: " << range << " of 0/" << is.size() << " tokens" << endl;
is.remove(range);
Info<< "Now " << is.size() << " tokens" << endl;
for (is.rewind(); !is.eof(); is.skip())
{
printToken(is.tokenIndex(), is.currentToken());
}
range.reset(10, 3);
Info<< nl
<< "remove: " << range << " of 0/" << is.size() << " tokens" << endl;
is.remove(range);
Info<< "Now " << is.size() << " tokens" << endl;
for (is.rewind(); !is.eof(); is.skip())
{
printToken(is.tokenIndex(), is.currentToken());
}
Info<< nl;
}
void testRewrite(const std::string& input, const int verbose)
{
Info<< "tokens" << nl
<< "====" << nl;
toString(Info, input)
<< nl
<< "====" << endl;
ITstream is(input);
Info<< is.size() << " tokens" << endl;
if (verbose)
{
for (is.rewind(); !is.eof(); is.skip())
{
printToken(is.tokenIndex(), is.currentToken());
}
Info<< nl;
}
else
{
Info<< "==>";
for (const token& tok : is)
{
Info<< ' ' << tok;
}
Info<< nl;
}
Info<< nl
<< "removing sub-dictionary tokens" << nl;
for (is.rewind(); !is.eof(); is.skip())
{
if (is.currentToken().isPunctuation(token::BEGIN_BLOCK))
{
labelRange slice(is.tokenIndex(), 0);
#if 0
// This is a bad way to remove things since we lose the parse
// point!
for (/*nil*/; !is.eof(); is.skip())
{
if (is.currentToken().isPunctuation(token::END_BLOCK))
{
slice.size() = (is.tokenIndex() - slice.start()) + 1;
break;
}
}
#else
for (label toki = is.tokenIndex()+1; toki < is.size(); ++toki)
{
if (is.peekToken(toki).isPunctuation(token::END_BLOCK))
{
slice.size() = (toki - slice.start()) + 1;
break;
}
}
#endif
Info<< "remove range: " << slice
<< " currentIndex: " << is.tokenIndex() << '/' << is.size()
// NB peekToken handles out-of-range
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
const label nRemoved = is.remove(slice);
Info<< "remove " << nRemoved
<< " new current: " << is.tokenIndex() << '/' << is.size()
// NB peekToken handles out-of-range
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
Info<< "==>";
for (const token& tok : is)
{
Info<< ' ' << tok;
}
Info<< nl << nl;
}
}
Info<< nl;
}
void testRemoveDict(const std::string& input, const int verbose)
{
Info<< "tokens" << nl
<< "====" << nl;
toString(Info, input)
<< nl
<< "====" << endl;
ITstream is(input);
Info<< is.size() << " tokens" << endl;
if (verbose)
{
for (is.rewind(); !is.eof(); is.skip())
{
printToken(is.tokenIndex(), is.currentToken());
}
Info<< nl;
}
else
{
Info<< "==>";
for (const token& tok : is)
{
Info<< ' ' << tok;
}
Info<< nl;
}
for (label pos = 0; pos < is.size(); /*nil*/)
{
labelRange slice
(
is.find(token::BEGIN_BLOCK, token::END_BLOCK, pos)
);
if (slice.good())
{
pos = slice.end_value();
tokenList::subList substream(is.slice(slice));
Info<< " dict " << slice << " ==>";
for (const token& tok : substream)
{
Info<< ' ' << tok;
}
Info<< nl;
}
else
{
break;
}
}
Info<< nl
<< "removing sub-dictionary tokens" << nl;
for (is.rewind(); !is.eof(); is.skip())
{
if (is.currentToken().isPunctuation(token::BEGIN_BLOCK))
{
labelRange slice
(
is.find(token::BEGIN_BLOCK, token::END_BLOCK, is.tokenIndex())
);
if (slice.good())
{
ITstream substream(is.extract(slice));
Info<< "got " << slice << " ==>";
for (const token& tok : substream)
{
Info<< ' ' << tok;
}
Info<< nl;
dictionary dict(substream);
Info<< "tokenIndex: " << is.tokenIndex() << nl;
Info<< "sub-dict " << dict << nl;
Info<< "remove range: " << slice
<< " currentIndex: " << is.tokenIndex() << '/' << is.size()
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
const label nRemoved = is.remove(slice);
Info<< "remove " << nRemoved
<< " new current: " << is.tokenIndex() << '/' << is.size()
<< " token: " << is.peekToken(is.tokenIndex()) << nl;
Info<< "==>";
for (const token& tok : is)
{
Info<< ' ' << tok;
}
Info<< nl << nl;
// Reposition the parse point
is.seek(slice.start());
is.skip(-1);
Info<< "continue after " << is.tokenIndex()
<< " : " << is.peekToken(is.tokenIndex()) << nl;
}
}
}
Info<< nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noBanner(); const char* charInput =
argList::noParallel(); "( const char input \"string\" to tokenize )\n"
argList::addVerboseOption("additional verbosity"); "List<label> 5(0 1 2 3 4);";
argList::addBoolOption("basic", "basic tests");
argList::addBoolOption("rewrite", "test rewriting only");
argList::addBoolOption("remove-dict", "test rewriting only");
argList args(argc, argv); string stringInput("( string ; input \"string\" to tokenize )");
if List<char> listInput
( (
!args.found("basic") ListOps::create<char>
&& !args.found("rewrite")
&& !args.found("remove-dict")
)
{
Info<< "No test options specified!" << nl << nl;
}
if (args.found("basic"))
{
const char* charInput =
"( const char input \"string\" to tokenize )\n"
"List<label> 5(0 1 2 3 4);";
string stringInput("( string ; input \"string\" to tokenize )");
List<char> listInput
( (
ListOps::create<char> stringInput.cbegin(),
( stringInput.cend(),
stringInput.cbegin(), Foam::identityOp{}
stringInput.cend(), )
Foam::identityOp{} );
)
);
doTest("empty", "", true, true); doTest("empty", "", true, true);
doTest("char*", charInput, true, true); doTest("char*", charInput, true, true);
doTest("string", stringInput, true); doTest("string", stringInput, true);
doTest("List<char>", listInput, true); doTest("List<char>", listInput, true);
reverse(listInput); reverse(listInput);
doTest("List<char>", listInput, true); doTest("List<char>", listInput, true);
}
if (args.found("rewrite"))
{
testWalk1
(
"std::string",
"( string ; input \"string\" to tokenize )"
"{ other entry; value 100; value2 200; }"
, args.verbose()
);
testRewrite
(
"some entry ( string1 ; )"
"{ sub dict1; value 100; value2 200; }"
"other entry ( string2 ; )"
"{ sub dict2; value 100; value2 200; }"
"{ sub dict3; value 100; value2 200; }"
"trailing entry"
, args.verbose()
);
}
if (args.found("remove-dict"))
{
testRemoveDict
(
"some entry ( string1 ; )"
"{ sub dict1; value 100; value2 200; }"
"other entry ( string2 ; )"
"{ sub dict2; value 100; value2 200; }"
"{ sub dict3; value 100; value2 200; }"
"trailing entry"
, args.verbose()
);
testRemoveDict
(
"some entry no dictionary"
, args.verbose()
);
testRemoveDict
(
"{ leading dict; } last-stuff"
, args.verbose()
);
testRemoveDict
(
"first-stuff { trailing dict; }"
, args.verbose()
);
}
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;

View File

@ -183,7 +183,9 @@ int main(int argc, char *argv[])
Pout<<"recv: " << flatOutput(recv) << endl; Pout<<"recv: " << flatOutput(recv) << endl;
} }
UPstream::barrier(UPstream::worldComm); // MPI barrier
bool barrier = true;
Pstream::broadcast(barrier);
} }

View File

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

View File

@ -1,234 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 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/>.
Application
Test-ListRead1
Description
List reading
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "argList.H"
#include "wordRes.H"
#include "IOstreams.H"
#include "Fstream.H"
#include "StringStream.H"
#include "scalar.H"
#include "vector.H"
#include "labelRange.H"
#include "scalarList.H"
#include "HashOps.H"
#include "ListOps.H"
#include "IndirectList.H"
#include "SubList.H"
#include "SliceList.H"
#include "ListPolicy.H"
#include <list>
#include <numeric>
#include <functional>
using namespace Foam;
label chunkSize = 128;
template<class T>
bool readBracketList(List<T>& list, Istream& is)
{
is.fatalCheck(FUNCTION_NAME);
token tok(is);
is.fatalCheck
(
"List<T>::readBracketList(Istream&) : reading first token"
);
if (!tok.isPunctuation(token::BEGIN_LIST))
{
is.putBack(tok);
return false;
}
{
// "(...)" : read element-wise.
// Uses chunk-wise reading to avoid too many re-allocations
// and avoids relocation of contiguous memory until all of the reading
// is completed. Chunks are wrapped as unique_ptr to ensure proper
// cleanup on failure.
// The choice of chunk-size is somewhat arbitrary...
// constexpr label chunkSize = 128;
typedef std::unique_ptr<List<T>> chunkType;
is >> tok;
is.fatalCheck(FUNCTION_NAME);
if (tok.isPunctuation(token::END_LIST))
{
// Trivial case, an empty list
list.clear();
return true;
}
// Use all storage
//private:// list.resize(list.capacity());
// Start with a few slots, recover current memory where possible
List<chunkType> chunks(16);
if (list.empty())
{
chunks[0] = chunkType(new List<T>(chunkSize));
}
else
{
chunks[0] = chunkType(new List<T>(std::move(list)));
}
label nChunks = 1; // Active number of chunks
label totalCount = 0; // Total number of elements
label localIndex = 0; // Chunk-local index
InfoErr
<< nl << "initial chunk: " << chunks[0]->size() << endl;
while (!tok.isPunctuation(token::END_LIST))
{
is.putBack(tok);
if (chunks[nChunks-1]->size() <= localIndex)
{
// Increase number of slots (doubling)
if (nChunks >= chunks.size())
{
chunks.resize(2*chunks.size());
}
InfoErr<< "new chunk" << endl;
chunks[nChunks] = chunkType(new List<T>(chunkSize));
++nChunks;
localIndex = 0;
}
is >> chunks[nChunks-1]->operator[](localIndex);
++localIndex;
++totalCount;
InfoErr
<< " chunk=" << nChunks
<< " index=" << localIndex
<< " total=" << totalCount << nl;
is.fatalCheck
(
"List<T>::readBracketList(Istream&) : "
"reading entry"
);
is >> tok;
is.fatalCheck(FUNCTION_NAME);
}
// Simple case
if (nChunks == 1)
{
list = std::move(*(chunks[0]));
list.resize(totalCount);
return true;
}
// Destination
//private:// list.setCapacity_nocopy(totalCount);
list.resize_nocopy(totalCount);
auto dest = list.begin();
for (label chunki = 0; chunki < nChunks; ++chunki)
{
List<T> currChunk(std::move(*(chunks[chunki])));
chunks[chunki].reset(nullptr);
const label localLen = min(currChunk.size(), totalCount);
dest = std::move
(
currChunk.begin(),
currChunk.begin(localLen),
dest
);
totalCount -= localLen;
}
}
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noFunctionObjects();
argList::addOption("chunk-size", "value", "change read chunk size");
argList::addArgument("file1 .. fileN");
argList args(argc, argv, false, true);
args.readIfPresent("chunk-size", chunkSize);
Info<< "chunk-size: " << chunkSize << nl;
if (args.size() <= 1)
{
InfoErr<< "Provide a file or files to test" << nl;
}
else
{
for (label argi=1; argi < args.size(); ++argi)
{
const auto input = args.get<fileName>(argi);
IFstream is(input);
while (!is.eof())
{
labelList list;
readBracketList(list, is);
Info<< "read: " << flatOutput(list) << endl;
}
}
}
return 0;
}
// ************************************************************************* //

View File

@ -1,17 +0,0 @@
(
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
)
(
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
<< "via string-stream: " << str.str().size() << " chars" << nl << "via string-stream: " << str.str().size() << " chars" << nl
<< "via ocountstream: " << plain.count() << " chars" << endl; << "via ocountstream: " << plain.size() << " chars" << endl;
fileName outputName; fileName outputName;
args.readIfPresent("write", outputName); args.readIfPresent("write", outputName);

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,46 +27,13 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "SpanStream.H" #include "ListStream.H"
#include "wordList.H" #include "wordList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "argList.H" #include "argList.H"
#include <cctype>
#include <cstdio>
using namespace Foam; using namespace Foam;
Ostream& writeList(Ostream& os, const UList<char>& list)
{
char buf[4];
os << list.size() << '(';
for (const char c : list)
{
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& toString(Ostream& os, const UList<char>& list) Ostream& toString(Ostream& os, const UList<char>& list)
{ {
os << '"'; os << '"';
@ -124,12 +91,12 @@ void outputDict(OS& os)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "setRootCase.H"
// Buffer storage // Buffer storage
DynamicList<char> storage(16); DynamicList<char> storage(16);
OCharStream obuf(std::move(storage)); OListStream obuf(std::move(storage));
obuf.setBlockSize(100);
printInfo(obuf); printInfo(obuf);
@ -173,10 +140,10 @@ int main(int argc, char *argv[])
Info<<"after overwrite" << nl; Info<<"after overwrite" << nl;
printInfo(obuf); printInfo(obuf);
Info<< "transfer contents to a List or ICharStream" << nl; Info<< "transfer contents to a List or IListStream" << nl;
ICharStream ibuf; IListStream ibuf;
// Reclaim data storage from OCharStream -> ICharStream // Reclaim data storage from OListStream -> IListStream
{ {
List<char> data; List<char> data;
obuf.swap(data); obuf.swap(data);
@ -202,7 +169,7 @@ int main(int argc, char *argv[])
Info<<"input:"; Info<<"input:";
toString(Info, list) << endl; toString(Info, list) << endl;
OCharStream buf1(std::move(list)); OListStream buf1(std::move(list));
Info<<"orig:"; Info<<"orig:";
toString(Info, list) << endl; toString(Info, list) << endl;
@ -237,7 +204,7 @@ int main(int argc, char *argv[])
Info<< nl << "Test dictionary" << nl; Info<< nl << "Test dictionary" << nl;
{ {
OCharStream os1; OListStream os1;
outputDict(os1); outputDict(os1);
@ -246,7 +213,7 @@ int main(int argc, char *argv[])
} }
{ {
OCharStream os2; OListStream os2;
os2.indentSize(0); os2.indentSize(0);
outputDict(os2); outputDict(os2);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -47,29 +47,43 @@ class Scalar
public: public:
static bool verbose; Scalar()
:
data_(0)
{}
constexpr Scalar() noexcept : data_(0) {} Scalar(scalar val)
Scalar(scalar val) noexcept : data_(val) {} :
data_(val)
{}
~Scalar() ~Scalar()
{ {
if (verbose) Info<< "delete Scalar: " << data_ << endl; Info<< "delete Scalar: " << data_ << endl;
} }
scalar value() const noexcept { return data_; } const scalar& value() const
scalar& value() noexcept { return data_; }
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{ {
os << item.value(); return data_;
}
scalar& value()
{
return data_;
}
autoPtr<Scalar> clone() const
{
return autoPtr<Scalar>::New(data_);
}
friend Ostream& operator<<(Ostream& os, const Scalar& val)
{
os << val.data_;
return os; return os;
} }
}; };
bool Scalar::verbose = true;
// As per // As per
@ -254,22 +268,6 @@ Ostream& report
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if 1
{
DLPtrList<Scalar> llist1;
Info<< "emplace_front: " << llist1.emplace_front(100) << nl;
Info<< "emplace_front: " << llist1.emplace_front(200) << nl;
Info<< "emplace_front: " << llist1.emplace_front(300) << nl;
Info<< "emplace_back: " << llist1.emplace_back(500) << nl;
Info<< "DLPtrList: " << llist1 << endl;
Scalar::verbose = false;
llist1.clear();
Scalar::verbose = true;
}
#endif
#if 0 #if 0
{ {
DLPtrList<Scalar> llist1; DLPtrList<Scalar> llist1;
@ -327,22 +325,6 @@ int main(int argc, char *argv[])
{ {
list1.set(i, new Scalar(1.3*i)); list1.set(i, new Scalar(1.3*i));
} }
{
auto ptr = autoPtr<Scalar>::New(10);
Info<< "add: " << Foam::name(ptr.get());
list1.set(0, ptr);
Info<< "ptrlist: " << Foam::name(list1.get(0)) << nl;
Info<< "now: " << Foam::name(ptr.get()) << nl;
ptr = autoPtr<Scalar>::New(20);
list1.append(ptr);
// Delete method: list1.push_back(ptr);
// list1.push_back(std::move(ptr));
}
PtrList<Scalar> list2(15); PtrList<Scalar> list2(15);
Info<< "Emplace set " << list2.size() << " values" << nl; Info<< "Emplace set " << list2.size() << " values" << nl;
@ -351,20 +333,6 @@ int main(int argc, char *argv[])
list2.emplace(i, (10 + 1.3*i)); list2.emplace(i, (10 + 1.3*i));
} }
list2.release(5);
list2.release(10);
{
// Memory error (with fulldebug): const label len = (list2.size()+2);
const label len = list2.size();
Info<< "try_emplace " << len << " values" << nl;
for (label i = 0; i < len; ++i)
{
list2.try_emplace(i, (50 + 1.3*i));
}
}
PtrList<Scalar> listApp; PtrList<Scalar> listApp;
for (label i = 0; i < 5; ++i) for (label i = 0; i < 5; ++i)
{ {
@ -655,7 +623,7 @@ int main(int argc, char *argv[])
dynPlanes.set(6, new plane(vector(2,2,1), vector::one)); dynPlanes.set(6, new plane(vector(2,2,1), vector::one));
dynPlanes.set(10, new plane(vector(4,5,6), vector::one)); dynPlanes.set(10, new plane(vector(4,5,6), vector::one));
Info<< "emplaced[12]: " Info<< "emplaced :"
<< dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl; << dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl;
dynPlanes.emplace_back(Zero, vector::one); dynPlanes.emplace_back(Zero, vector::one);

View File

@ -45,29 +45,28 @@ class Scalar
public: public:
static bool verbose; Scalar()
:
data_(0)
{}
constexpr Scalar() noexcept : data_(0) {} Scalar(scalar val)
Scalar(scalar val) noexcept : data_(val) {} :
data_(val)
{}
~Scalar() ~Scalar()
{ {
if (verbose) Info<< "delete Scalar: " << data_ << endl; Info<<"delete Scalar: " << data_ << endl;
} }
const scalar& value() const noexcept { return data_; } friend Ostream& operator<<(Ostream& os, const Scalar& val)
scalar& value() noexcept { return data_; }
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
friend Ostream& operator<<(Ostream& os, const Scalar& item)
{ {
os << item.value(); os << val.data_;
return os; return os;
} }
}; };
bool Scalar::verbose = true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

@ -1,2 +0,0 @@
/* EXE_INC = */
/* EXE_LIBS = */

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -37,7 +37,6 @@ Description
#include "scalarField.H" #include "scalarField.H"
#include "SubField.H" #include "SubField.H"
#include "labelRange.H" #include "labelRange.H"
#include "ListOps.H"
#include <numeric> #include <numeric>
using namespace Foam; using namespace Foam;
@ -58,26 +57,26 @@ int main(int argc, char *argv[])
argList::noFunctionObjects(); argList::noFunctionObjects();
{ {
List<label> ident(25); List<scalar> ident(25);
std::iota(ident.begin(), ident.end(), 0); std::iota(ident.begin(), ident.end(), 0);
print(ident); print(ident);
SubList<label>(ident, 10) = -10; SubList<scalar>(ident, 10) = -10;
print(ident); print(ident);
SubField<label>(ident, 10) = 10; SubField<scalar>(ident, 10) = 10;
print(ident); print(ident);
SubField<label>(ident, 10) += 10; SubField<scalar>(ident, 10) += 10;
print(ident); print(ident);
SubField<label>{ident, 10, 10} *= 5; SubField<scalar>{ident, 10, 10} *= 5;
print(ident); print(ident);
// NOTE: Need {} instead of () // NOTE: Need {} instead of ()
// SubList<label>(ident) = 100; // SubList<scalar>(ident) = 100;
// GCC // GCC
// error: conflicting declaration 'Foam::SubList<double> ident' // error: conflicting declaration 'Foam::SubList<double> ident'
@ -86,30 +85,7 @@ int main(int argc, char *argv[])
// warning: parentheses were disambiguated as redundant parentheses // warning: parentheses were disambiguated as redundant parentheses
// around declaration of variable named 'ident' [-Wvexing-parse] // around declaration of variable named 'ident' [-Wvexing-parse]
SubList<label>{ident} = 100; SubList<scalar>{ident} = 100;
print(ident);
SubList<label> sub(ident);
sub = 1;
print(sub);
sub.reset(ident, labelRange(4, 5)) = 5;
print(sub);
print(ident);
sub.reset(ident, labelRange(14, 5)) = 15;
print(sub);
print(ident);
// Cryptic, probably not a great idea to write this
sub.reset(ident, {20, 3}) = -1;
print(sub);
print(ident);
// This is also possible since we hold a concrete pointer/size
// and not an intermediate
ListOps::identity(sub.reset(ident, 8, 8));
print(sub);
print(ident); print(ident);
} }

View File

@ -370,7 +370,7 @@ void test_global_funcs(Type)
Type(126) Type(126)
) )
); );
cmp(" Square of Frobenius norm = ", magSqr(sT), scalar(205)); cmp(" Square of Frobenius norm = ", magSqr(sT), Type(205));
} }

View File

@ -325,7 +325,7 @@ void test_global_funcs(Type)
Type(13) Type(13)
) )
); );
cmp(" Square of Frobenius norm = ", magSqr(sT), scalar(17.999999999999996)); cmp(" Square of Frobenius norm = ", magSqr(sT), Type(17.999999999999996));
cmp cmp
( (
" Outer-product of a Vector2D with itself = ", " Outer-product of a Vector2D with itself = ",

View File

@ -51,7 +51,10 @@ public:
i_(i) i_(i)
{} {}
const word& keyword() const noexcept { return keyword_; } const word& keyword() const
{
return keyword_;
}
friend Ostream& operator<<(Ostream& os, const ent& e) friend Ostream& operator<<(Ostream& os, const ent& e)
{ {
@ -80,7 +83,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first()); dict.swapDown(dict.first());
forAllConstIters(dict, iter) forAllConstIter(UDictionary<ent>, dict, iter)
{ {
Info<< "element : " << *iter; Info<< "element : " << *iter;
} }

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,48 +27,16 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "SpanStream.H" #include "UListStream.H"
#include "wordList.H" #include "wordList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "argList.H" #include "argList.H"
#include <cctype>
#include <cstdio>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
using namespace Foam; using namespace Foam;
Ostream& writeList(Ostream& os, const UList<char>& list)
{
char buf[4];
os << list.size() << '(';
for (const char c : list)
{
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& toString(Ostream& os, const UList<char>& list) Ostream& toString(Ostream& os, const UList<char>& list)
{ {
os << '"'; os << '"';
@ -140,7 +108,7 @@ int main(int argc, char *argv[])
// Buffer storage // Buffer storage
DynamicList<char> storage(1000); DynamicList<char> storage(1000);
OSpanStream obuf(storage); UOListStream obuf(storage);
obuf << 1002 << "\n" << "abcd" << "\n" << "def" << "\n" << 3.14159 << ";\n"; obuf << 1002 << "\n" << "abcd" << "\n" << "def" << "\n" << 3.14159 << ";\n";
obuf.print(Info); obuf.print(Info);
@ -152,7 +120,7 @@ int main(int argc, char *argv[])
// Attach input buffer - could also do without previous resize // Attach input buffer - could also do without previous resize
{ {
ISpanStream ibuf(storage); UIListStream ibuf(storage);
printTokens(ibuf); printTokens(ibuf);
@ -167,21 +135,13 @@ int main(int argc, char *argv[])
{ {
Info<< "parse as std::istream\n"; Info<< "parse as std::istream\n";
ispanstream is(storage.cdata(), storage.size()); uiliststream is(storage.cdata(), storage.size());
Info<< "input: ";
writeList(Info, is.list()) << endl;
Info<< "where: " << is.tellg() << endl;
Info<< "capacity: " << is.capacity() << endl;
Info<< "total: " << is.capacity() << endl;
string tok; string tok;
while (std::getline(is, tok)) while (std::getline(is, tok))
{ {
std::cerr << "tok: " << tok << nl; std::cerr << "tok: " << tok << nl;
Info<< "where: " << is.tellg() << endl;
} }
Info<< nl << "Repeat..." << endl; Info<< nl << "Repeat..." << endl;
@ -210,7 +170,7 @@ int main(int argc, char *argv[])
toString(Info, chars); toString(Info, chars);
Info<< "----" << nl; Info<< "----" << nl;
ispanstream is(chars.data(), chars.size()); uiliststream is(chars.data(), chars.size());
string tok; string tok;
std::cerr<< nl << "Parsed..." << nl; std::cerr<< nl << "Parsed..." << nl;
while (std::getline(is, tok)) while (std::getline(is, tok))

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -124,9 +124,6 @@ int main(int argc, char *argv[])
argList::addDryRunOption("Just for testing"); argList::addDryRunOption("Just for testing");
argList::addVerboseOption("Increase verbosity"); argList::addVerboseOption("Increase verbosity");
// Check -verbose before initialisation
UPstream::debug = argList::verbose(argc, argv);
#include "setRootCase.H" #include "setRootCase.H"
Pout<< "command-line (" Pout<< "command-line ("

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