Compare commits
10 Commits
feature-st
...
wip-update
| Author | SHA1 | Date | |
|---|---|---|---|
| c3aecfab81 | |||
| e655231e24 | |||
| 7cf553ca00 | |||
| 64d1bd7488 | |||
| ce602d340b | |||
| 64e5b7f626 | |||
| b36c9897b2 | |||
| e505abfb30 | |||
| 2ec8a44fad | |||
| 2ea26ffadf |
@ -49,7 +49,7 @@
|
||||
|
||||
<!--
|
||||
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
|
||||
Hardware info : any info that may help?
|
||||
Compiler : gcc|intel|clang etc
|
||||
|
||||
10
Allwmake
10
Allwmake
@ -96,12 +96,10 @@ echo " ${WM_PROJECT_DIR##*/}"
|
||||
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
|
||||
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
|
||||
echo
|
||||
|
||||
# The api/patch information
|
||||
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 " api = $(etc/openfoam -show-api 2>/dev/null)"
|
||||
echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
|
||||
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
|
||||
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
|
||||
echo
|
||||
echo ========================================
|
||||
|
||||
|
||||
@ -5,22 +5,17 @@ It is likely incomplete...
|
||||
|
||||
## Contributors (alphabetical by surname)
|
||||
|
||||
- Horacio Aguerre
|
||||
- Yu Ankun
|
||||
- Tetsuo Aoyagi
|
||||
- Akira Azami
|
||||
- William Bainbridge
|
||||
- Gabriel Barajas
|
||||
- Kutalmis Bercin
|
||||
- Julius Bergmann
|
||||
- Ivor Clifford
|
||||
- Greg Collecutt
|
||||
- Jonathan Cranford
|
||||
- Santiago Marquez Damian
|
||||
- Sergio Ferraris
|
||||
- Matej Forman
|
||||
- Marian Fuchs
|
||||
- Gabriel Gerlero
|
||||
- Pawan Ghildiyal
|
||||
- Chris Greenshields
|
||||
- Bernhard Gschaider
|
||||
@ -55,11 +50,8 @@ It is likely incomplete...
|
||||
- Gavin Tabor
|
||||
- Zeljko Tukovic
|
||||
- Eugene De Villiers
|
||||
- Louis Vittoz
|
||||
- Vuko Vukcevic
|
||||
- Yi Wang
|
||||
- Norbert Weber
|
||||
- Volker Weissmann
|
||||
- Henry Weller
|
||||
- Niklas Wikstrom
|
||||
- Guanyang Xue
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
api=2307
|
||||
patch=0
|
||||
api=2301
|
||||
patch=230110
|
||||
|
||||
14
README.md
14
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-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
|
||||
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
|
||||
to the OpenFOAM directory. For example,
|
||||
```
|
||||
/path/parent
|
||||
|-- OpenFOAM-v2306
|
||||
\-- ThirdParty-v2306
|
||||
|-- OpenFOAM-v2212
|
||||
\-- ThirdParty-v2212
|
||||
```
|
||||
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)
|
||||
|
||||
* 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
|
||||
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
|
||||
* this corresponds to the traditional approach
|
||||
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
|
||||
be `2306` and the original `ThirdParty-v2306/` would be found.
|
||||
be `2212` and the original `ThirdParty-v2212/` would be found.
|
||||
4. PREFIX/ThirdParty-API
|
||||
* same as the previous example, but using an unadorned API value.
|
||||
5. PREFIX/ThirdParty-common
|
||||
|
||||
@ -18,6 +18,6 @@ dimensionedScalar rho("rho", dimDensity, transportProperties);
|
||||
|
||||
scalar MaxCo =
|
||||
max(mesh.surfaceInterpolation::deltaCoeffs()*c0).value()
|
||||
*runTime.deltaTValue();
|
||||
*runTime.deltaT().value();
|
||||
|
||||
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020,2023 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -132,11 +132,6 @@ void PDRkEpsilon::correct()
|
||||
|
||||
// Update epsilon and G at the wall
|
||||
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
|
||||
// in both the k and epsilon equations
|
||||
|
||||
@ -109,7 +109,7 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(Nv.dimensions(), Zero)
|
||||
|
||||
@ -223,7 +223,7 @@ if (ign.ignited())
|
||||
volScalarField R(Gstar*XiEqStar/(XiEqStar - scalar(1)));
|
||||
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
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -12,7 +12,7 @@ Info<< "Creating base fields for time " << runTime.timeName() << endl;
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("Ydefault", dimless, 1)
|
||||
@ -29,7 +29,7 @@ Info<< "Creating base fields for time " << runTime.timeName() << endl;
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("p", dimPressure, p0)
|
||||
@ -46,7 +46,7 @@ Info<< "Creating base fields for time " << runTime.timeName() << endl;
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("T", dimTemperature, T0)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
if (adjustTimeStep)
|
||||
{
|
||||
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
dtChem = chemistry.solve(runTime.deltaTValue());
|
||||
dtChem = chemistry.solve(runTime.deltaT().value());
|
||||
scalar Qdot = chemistry.Qdot()()[0]/rho[0];
|
||||
integratedHeat += Qdot*runTime.deltaTValue();
|
||||
integratedHeat += Qdot*runTime.deltaT().value();
|
||||
|
||||
@ -105,8 +105,7 @@ Foam::smoluchowskiJumpTFvPatchScalarField::smoluchowskiJumpTFvPatchScalarField
|
||||
|
||||
if (!this->readValueEntry(dict))
|
||||
{
|
||||
// Fallback: set to the internal field
|
||||
fvPatchField<scalar>::patchInternalField(*this);
|
||||
fvPatchField<scalar>::operator=(patchInternalField());
|
||||
}
|
||||
|
||||
refValue() = *this;
|
||||
|
||||
@ -17,7 +17,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate
|
||||
vf,
|
||||
dir,
|
||||
"reconstruct("
|
||||
+ (reconFieldName.empty() ? vf.name() : reconFieldName)
|
||||
+ (reconFieldName != word::null ? reconFieldName : vf.name())
|
||||
+ ')'
|
||||
)
|
||||
);
|
||||
|
||||
@ -29,7 +29,7 @@ if (mesh.changing())
|
||||
wordList pcorrTypes
|
||||
(
|
||||
p.boundaryField().size(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
*mag(aMesh.edgeInterpolation::deltaCoeffs())
|
||||
/rhol
|
||||
)
|
||||
).value()*runTime.deltaTValue();
|
||||
).value()*runTime.deltaT().value();
|
||||
|
||||
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
|
||||
}
|
||||
|
||||
@ -87,13 +87,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
fam::ddt(h, Us)
|
||||
+ fam::div(phi2s, Us)
|
||||
+ fam::Sp
|
||||
(
|
||||
0.0125
|
||||
*frictionFactor.internalField()
|
||||
*mag(Us.internalField()),
|
||||
Us
|
||||
)
|
||||
+ fam::Sp(0.0125*frictionFactor*mag(Us), Us)
|
||||
==
|
||||
Gs*h
|
||||
- fam::Sp(Sd, Us)
|
||||
|
||||
@ -47,10 +47,10 @@ if (aMesh.nInternalEdges())
|
||||
);
|
||||
|
||||
CoNum = max(SfUfbyDelta/aMesh.magLe())
|
||||
.value()*runTime.deltaTValue();
|
||||
.value()*runTime.deltaT().value();
|
||||
|
||||
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
|
||||
.value()*runTime.deltaTValue();
|
||||
.value()*runTime.deltaT().value();
|
||||
|
||||
velMag = max(mag(phis)/aMesh.magLe()).value();
|
||||
}
|
||||
|
||||
@ -47,7 +47,6 @@ forAll(Us, faceI)
|
||||
Us[faceI].z() =
|
||||
Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI]));
|
||||
}
|
||||
Us.boundaryFieldRef().evaluateCoupled<coupledFaPatch>();
|
||||
|
||||
Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us);
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ if (mesh.changing())
|
||||
wordList pcorrTypes
|
||||
(
|
||||
p.boundaryField().size(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||
|
||||
@ -108,7 +108,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C
|
||||
solid/solidRegionDiffNo.C
|
||||
../solid/solidRegionDiffNo.C
|
||||
chtMultiRegionTwoPhaseEulerFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam
|
||||
|
||||
@ -292,7 +292,8 @@ updateCoeffs()
|
||||
|
||||
// Since we're inside initEvaluate/evaluate there might be processor
|
||||
// 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
|
||||
const label patchi = patch().index();
|
||||
@ -470,9 +471,10 @@ updateCoeffs()
|
||||
<< regionTypeNames_ << nl << exit(FatalError);
|
||||
}
|
||||
|
||||
UPstream::msgType(oldTag); // Restore tag
|
||||
|
||||
mixedFvPatchScalarField::updateCoeffs();
|
||||
|
||||
// Restore tag
|
||||
UPstream::msgType() = oldTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
dimensionedScalar("hRef", dimLength, Zero)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
||||
"cumulativeContErr",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
mesh.thisDb(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
dimensionedScalar(word::null, dimless, Zero)
|
||||
dimensionedScalar(dimless, Zero)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
../../solid/solidRegionDiffNo.C
|
||||
@ -112,7 +112,7 @@ forAll(fluidRegions, i)
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
dimensionedScalar(word::null, dimLength, Zero)
|
||||
dimensionedScalar("hRef", dimLength, Zero) // uses name
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ forAll(cumulativeContErrIO, i)
|
||||
"cumulativeContErr",
|
||||
runTime.timeName(),
|
||||
"uniform",
|
||||
mesh.thisDb(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
dimensionedScalar(word::null, dimless, Zero)
|
||||
dimensionedScalar(dimless, Zero)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -49,11 +49,11 @@ if (adjustTimeStep)
|
||||
(
|
||||
min
|
||||
(
|
||||
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
|
||||
min(runTime.deltaTValue(), maxDeltaT)
|
||||
)
|
||||
);
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -59,12 +59,12 @@ if (adjustTimeStep)
|
||||
(
|
||||
min
|
||||
(
|
||||
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
|
||||
maxDeltaT
|
||||
)
|
||||
);
|
||||
|
||||
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -57,7 +57,7 @@
|
||||
),
|
||||
solidRegions[i],
|
||||
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchSymmTensorField::typeName
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ if (!thermo.isotropic())
|
||||
),
|
||||
mesh,
|
||||
dimensionedSymmTensor(tkappaByCp().dimensions(), Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchSymmTensorField::typeName
|
||||
)
|
||||
);
|
||||
volSymmTensorField& aniAlpha = *taniAlpha;
|
||||
|
||||
@ -44,7 +44,7 @@ IOobject turbulencePropertiesHeader
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
);
|
||||
|
||||
if (turbulencePropertiesHeader.typeHeaderOk<IOdictionary>(false))
|
||||
|
||||
@ -24,7 +24,7 @@ if (mesh.changing())
|
||||
wordList pcorrTypes
|
||||
(
|
||||
p.boundaryField().size(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
// Set BCs of pcorr to fixed-value for patches at which p is fixed
|
||||
|
||||
@ -130,7 +130,7 @@ int main(int argc, char *argv[])
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchVectorField::typeName
|
||||
);
|
||||
|
||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||
|
||||
@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchVectorField::typeName
|
||||
);
|
||||
|
||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||
|
||||
@ -9,7 +9,7 @@ IOobject io
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
);
|
||||
|
||||
if (io.typeHeaderOk<IOdictionary>())
|
||||
@ -32,4 +32,4 @@ if (io.typeHeaderOk<IOdictionary>())
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector(cloudSU.dimensions()/dimVolume, Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchVectorField::typeName
|
||||
);
|
||||
|
||||
cloudVolSUSu.primitiveFieldRef() = -cloudSU.source()/mesh.V();
|
||||
|
||||
@ -64,7 +64,8 @@ volScalarField mu
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT
|
||||
),
|
||||
mixture.mu()
|
||||
mixture.mu(),
|
||||
calculatedFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
|
||||
@ -138,7 +139,7 @@ volScalarField alphac
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
alphac.oldTime();
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
wordList pcorrTypes
|
||||
(
|
||||
p.boundaryField().size(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
for (label i=0; i<p.boundaryField().size(); i++)
|
||||
|
||||
@ -86,7 +86,6 @@ VoFPatchTransfer::VoFPatchTransfer
|
||||
wordRes patchNames;
|
||||
if (coeffDict_.readIfPresent("patches", patchNames))
|
||||
{
|
||||
// Can also use pbm.indices(), but no warnings...
|
||||
patchIDs_ = pbm.patchSet(patchNames).sortedToc();
|
||||
|
||||
Info<< " applying to " << patchIDs_.size() << " patches:" << nl;
|
||||
|
||||
@ -140,7 +140,7 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(dimless, Zero),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
),
|
||||
curTimeIndex_(-1)
|
||||
{
|
||||
|
||||
@ -84,7 +84,7 @@ Foam::surfaceTensionModels::liquidProperties::sigma() const
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimSigma
|
||||
|
||||
@ -1075,7 +1075,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
|
||||
|
||||
MULES::limit
|
||||
(
|
||||
1.0/mesh_.time().deltaTValue(),
|
||||
1.0/mesh_.time().deltaT().value(),
|
||||
geometricOneField(),
|
||||
alpha,
|
||||
phi_,
|
||||
|
||||
@ -105,7 +105,8 @@ incompressibleTwoPhaseInteractingMixture
|
||||
U_.db()
|
||||
),
|
||||
U_.mesh(),
|
||||
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero)
|
||||
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), Zero),
|
||||
calculatedFvPatchScalarField::typeName
|
||||
)
|
||||
{
|
||||
correct();
|
||||
|
||||
@ -48,7 +48,7 @@ Foam::wordList Foam::relativeVelocityModel::UdmPatchFieldTypes() const
|
||||
wordList UdmTypes
|
||||
(
|
||||
U.boundaryField().size(),
|
||||
fvPatchFieldBase::calculatedType()
|
||||
calculatedFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
forAll(U.boundaryField(), i)
|
||||
|
||||
@ -699,7 +699,7 @@ void Foam::radiation::laserDTRM::calculate()
|
||||
scalar totalQ = gSum(Q_.primitiveFieldRef()*mesh_.V());
|
||||
Info << "Total energy absorbed [W]: " << totalQ << endl;
|
||||
|
||||
if (mesh_.time().writeTime())
|
||||
if (mesh_.time().outputTime())
|
||||
{
|
||||
reflectingCellsVol.write();
|
||||
nHat.write();
|
||||
@ -724,7 +724,7 @@ Foam::tmp<Foam::volScalarField> Foam::radiation::laserDTRM::Rp() const
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimPower/dimVolume/pow4(dimTemperature), Zero)
|
||||
|
||||
@ -52,9 +52,7 @@ namespace Foam
|
||||
const Foam::volScalarField&
|
||||
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
||||
{
|
||||
const volScalarField* ptr = mesh_.cfindObject<volScalarField>(alphaName);
|
||||
|
||||
if (!ptr)
|
||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to retrieve density field " << alphaName << " from "
|
||||
@ -62,7 +60,7 @@ Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return *ptr;
|
||||
return mesh_.lookupObject<volScalarField>(alphaName);
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +97,7 @@ Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(inv(dimLength), Zero)
|
||||
@ -132,7 +130,7 @@ Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(inv(dimLength), Zero)
|
||||
@ -165,7 +163,7 @@ Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
|
||||
|
||||
@ -124,7 +124,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
||||
* max(TSat - T, T0)
|
||||
);
|
||||
|
||||
if (mesh_.time().writeTime())
|
||||
if (mesh_.time().outputTime())
|
||||
{
|
||||
mDotC.write();
|
||||
mDotE.write();
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixture::New
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // Do not register
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimless,
|
||||
@ -96,7 +96,7 @@
|
||||
MULES::limiter
|
||||
(
|
||||
allLambda,
|
||||
1.0/runTime.deltaTValue(),
|
||||
1.0/runTime.deltaT().value(),
|
||||
geometricOneField(),
|
||||
alpha1,
|
||||
alphaPhi1BD,
|
||||
@ -164,7 +164,7 @@
|
||||
MULES::limiter
|
||||
(
|
||||
allLambda,
|
||||
1.0/runTime.deltaTValue(),
|
||||
1.0/runTime.deltaT().value(),
|
||||
geometricOneField(),
|
||||
alpha2,
|
||||
alphaPhi2BD,
|
||||
|
||||
@ -119,7 +119,8 @@ Foam::incompressibleThreePhaseMixture::incompressibleThreePhaseMixture
|
||||
U.db()
|
||||
),
|
||||
U.mesh(),
|
||||
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero)
|
||||
dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), Zero),
|
||||
calculatedFvPatchScalarField::typeName
|
||||
),
|
||||
|
||||
nuModel1_
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
wordList pcorrTypes
|
||||
(
|
||||
p_rgh.boundaryField().size(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
for (label i=0; i<p_rgh.boundaryField().size(); i++)
|
||||
|
||||
@ -48,7 +48,7 @@ Foam::phaseChangeTwoPhaseMixture::New
|
||||
U.db(),
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false // Do not register
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@
|
||||
mesh
|
||||
),
|
||||
fluid.dragCoeff(phase, dragCoeffs())/phase.rho(),
|
||||
fvPatchFieldBase::zeroGradientType()
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
dragCoeffi.correctBoundaryConditions();
|
||||
|
||||
|
||||
@ -628,7 +628,7 @@ void Foam::multiphaseMixture::solveAlphas
|
||||
|
||||
MULES::limit
|
||||
(
|
||||
1.0/mesh_.time().deltaTValue(),
|
||||
1.0/mesh_.time().deltaT().value(),
|
||||
geometricOneField(),
|
||||
alpha,
|
||||
phi_,
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
IOobject rhoIO
|
||||
(
|
||||
"rho",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
@ -75,7 +75,7 @@
|
||||
IOobject EHeader
|
||||
(
|
||||
"E",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
@ -127,7 +127,7 @@
|
||||
IOobject nuIO
|
||||
(
|
||||
"nu",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
|
||||
@ -51,7 +51,7 @@ if (thermalStress)
|
||||
IOobject CIO
|
||||
(
|
||||
"C",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
@ -106,7 +106,7 @@ if (thermalStress)
|
||||
IOobject rhoKIO
|
||||
(
|
||||
"k",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
@ -161,7 +161,7 @@ if (thermalStress)
|
||||
IOobject alphaIO
|
||||
(
|
||||
"alpha",
|
||||
Time::timeName(0),
|
||||
runTime.timeName(0),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
|
||||
@ -47,7 +47,7 @@ tractionDisplacementFvPatchVectorField
|
||||
traction_(p.size(), Zero),
|
||||
pressure_(p.size(), Zero)
|
||||
{
|
||||
extrapolateInternal();
|
||||
fvPatchVectorField::operator=(patchInternalField());
|
||||
gradient() = Zero;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ tractionDisplacementFvPatchVectorField
|
||||
traction_("traction", dict, p.size()),
|
||||
pressure_("pressure", dict, p.size())
|
||||
{
|
||||
extrapolateInternal();
|
||||
fvPatchVectorField::operator=(patchInternalField());
|
||||
gradient() = Zero;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ tractionDisplacementCorrectionFvPatchVectorField
|
||||
traction_(p.size(), Zero),
|
||||
pressure_(p.size(), Zero)
|
||||
{
|
||||
extrapolateInternal();
|
||||
fvPatchVectorField::operator=(patchInternalField());
|
||||
gradient() = Zero;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ tractionDisplacementCorrectionFvPatchVectorField
|
||||
traction_("traction", dict, p.size()),
|
||||
pressure_("pressure", dict, p.size())
|
||||
{
|
||||
extrapolateInternal();
|
||||
fvPatchVectorField::operator=(patchInternalField());
|
||||
gradient() = Zero;
|
||||
}
|
||||
|
||||
|
||||
@ -27,14 +27,6 @@ License
|
||||
|
||||
#include "dummyLib.H"
|
||||
#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>
|
||||
|
||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||
|
||||
@ -92,10 +92,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
report(buf1);
|
||||
|
||||
buf1.push_back(identity(5));
|
||||
buf1.emplace_front(-1000);
|
||||
buf1.emplace_back(1000);
|
||||
report(buf1);
|
||||
buf1.push_back(identity(5)); report(buf1);
|
||||
|
||||
buf1.info(Info);
|
||||
Info<< buf1 << nl;
|
||||
|
||||
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
size
|
||||
);
|
||||
@ -101,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
runTime,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
),
|
||||
size
|
||||
);
|
||||
@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -55,7 +55,10 @@ public:
|
||||
i_(i)
|
||||
{}
|
||||
|
||||
const word& keyword() const noexcept { return keyword_; }
|
||||
const word& keyword() const
|
||||
{
|
||||
return keyword_;
|
||||
}
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const ent& e)
|
||||
{
|
||||
@ -71,27 +74,28 @@ class Scalar
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
Scalar()
|
||||
:
|
||||
data_(0)
|
||||
{}
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
Scalar(scalar val)
|
||||
:
|
||||
data_(val)
|
||||
{}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
Info<<"delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
scalar value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
||||
{
|
||||
os << item.value();
|
||||
os << val.data_;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -113,7 +117,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
dict.swapDown(dict.first());
|
||||
|
||||
forAllConstIters(dict, iter)
|
||||
forAllConstIter(Dictionary<ent>, dict, iter)
|
||||
{
|
||||
Info<< "element : " << *iter;
|
||||
}
|
||||
@ -153,9 +157,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
Info<< nl << "scalarDict1: " << endl;
|
||||
forAllConstIters(scalarDict, iter)
|
||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
|
||||
{
|
||||
Info<< " = " << *iter << endl;
|
||||
Info<< " = " << iter() << endl;
|
||||
}
|
||||
|
||||
PtrDictionary<Scalar> scalarDict2;
|
||||
@ -165,7 +169,7 @@ int main(int argc, char *argv[])
|
||||
scalarDict2.insert(key, new Scalar(1.3*i));
|
||||
}
|
||||
Info<< nl << "scalarDict2: " << endl;
|
||||
forAllConstIters(scalarDict2, iter)
|
||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
|
||||
{
|
||||
std::cout<< "iter: " << typeid(*iter).name() << '\n';
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ Description
|
||||
|
||||
fileNameList procDirs
|
||||
(
|
||||
DirLister::dirs(".").csorted<fileName>(matchProcs)
|
||||
DirLister::dirs(".").sorted<fileName>(matchProcs)
|
||||
);
|
||||
}
|
||||
\endcode
|
||||
@ -206,11 +206,11 @@ public:
|
||||
|
||||
//- Return a complete list of names, sorted in natural order
|
||||
template<class StringType=Foam::word>
|
||||
List<StringType> csorted() const;
|
||||
List<StringType> sorted() const;
|
||||
|
||||
//- Return complete list of names, sorted in natural order
|
||||
template<class StringType=Foam::word, class UnaryPredicate>
|
||||
List<StringType> csorted
|
||||
List<StringType> sorted
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool prune = false
|
||||
|
||||
@ -70,23 +70,23 @@ Foam::List<StringType> Foam::DirLister::list() const
|
||||
|
||||
|
||||
template<class StringType, class UnaryPredicate>
|
||||
Foam::List<StringType> Foam::DirLister::csorted
|
||||
Foam::List<StringType> Foam::DirLister::sorted
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool prune
|
||||
) const
|
||||
{
|
||||
List<StringType> list(list<StringType>(pred, prune));
|
||||
Foam::sort(list, stringOps::natural_sort());
|
||||
List<StringType> lst(list<StringType>(pred, prune));
|
||||
sort(lst, stringOps::natural_sort());
|
||||
|
||||
return list;
|
||||
return lst;
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "dirList: "
|
||||
<< flatOutput
|
||||
(
|
||||
DirLister::dirs(".").csorted<fileName>(relist)
|
||||
DirLister::dirs(".").sorted<fileName>(relist)
|
||||
) << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -112,20 +112,13 @@ int main(int argc, char *argv[])
|
||||
argList::addBoolOption("iter");
|
||||
argList::addBoolOption("swap");
|
||||
argList::addBoolOption("default", "reinstate default tests");
|
||||
argList::addBoolOption("no-wait", "test with skipping request waits");
|
||||
argList::addNote("runs default tests or specified ones only");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
const bool optNowaiting = args.found("no-wait");
|
||||
|
||||
// Run default tests, unless only specific tests are requested
|
||||
const bool defaultTests =
|
||||
(
|
||||
args.found("default")
|
||||
|| args.options().empty()
|
||||
|| (optNowaiting && args.options().size())
|
||||
);
|
||||
args.found("default") || args.options().empty();
|
||||
|
||||
|
||||
typedef FixedList<scalar,2> scalar2Type;
|
||||
@ -202,31 +195,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "get<3>: " << list1.get<3>() << nl;
|
||||
// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl;
|
||||
|
||||
// Test deprecated form
|
||||
label array2[4] = {0, 1, 2, 3};
|
||||
FixedList<label, 4> list2(array2);
|
||||
label a[4] = {0, 1, 2, 3};
|
||||
FixedList<label, 4> list2(a);
|
||||
|
||||
Info<< "list2:" << list2
|
||||
<< " hash:" << FixedList<label, 4>::hasher()(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
|
||||
{
|
||||
List<FixedList<label, 4>> twolists{list1, list2};
|
||||
@ -254,8 +230,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "mem: "
|
||||
<< name(list1.data()) << " " << name(list2.data()) << nl;
|
||||
|
||||
Foam::Swap(list1, list2);
|
||||
Info<< "Foam::Swap() function" << nl;
|
||||
Swap(list1, list2);
|
||||
Info<< "The Swap() function" << nl;
|
||||
Info<< "list1: " << list1 << nl
|
||||
<< "list2: " << list2 << nl;
|
||||
|
||||
@ -331,53 +307,27 @@ int main(int argc, char *argv[])
|
||||
List<FixedList<label, 2>> list6{{0, 1}, {2, 3}};
|
||||
Info<< "list6: " << list6 << nl;
|
||||
|
||||
if (UPstream::parRun())
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Fixed buffer would also work, but want to test using UList
|
||||
List<labelPair> buffer;
|
||||
|
||||
DynamicList<UPstream::Request> requests;
|
||||
|
||||
const label numProcs = UPstream::nProcs();
|
||||
const label startOfRequests = UPstream::nRequests();
|
||||
|
||||
|
||||
// NOTE: also test a mix of local and global requests...
|
||||
UPstream::Request singleRequest;
|
||||
|
||||
if (UPstream::master())
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Use local requests here
|
||||
requests.reserve(numProcs);
|
||||
|
||||
buffer.resize(numProcs);
|
||||
buffer.resize(UPstream::nProcs());
|
||||
buffer[0] = labelPair(0, UPstream::myProcNo());
|
||||
|
||||
for (const int proci : UPstream::subProcs())
|
||||
for (const int proci : Pstream::subProcs())
|
||||
{
|
||||
UIPstream::read
|
||||
(
|
||||
requests.emplace_back(),
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
proci,
|
||||
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
|
||||
{
|
||||
@ -386,34 +336,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
Perr<< "Sending to master: " << buffer << endl;
|
||||
|
||||
// Capture the request and transfer to the global list
|
||||
// (for testing)
|
||||
|
||||
UOPstream::write
|
||||
(
|
||||
singleRequest,
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
UPstream::masterNo(),
|
||||
buffer.slice(0, 1) // OK
|
||||
/// buffer // Also OK
|
||||
);
|
||||
|
||||
// if (singleRequest.good())
|
||||
{
|
||||
UPstream::addRequest(singleRequest);
|
||||
}
|
||||
}
|
||||
|
||||
Pout<< "Pending requests [" << numProcs << " procs] global="
|
||||
<< (UPstream::nRequests() - startOfRequests)
|
||||
<< " local=" << requests.size()
|
||||
<< " single=" << singleRequest.good() << nl;
|
||||
|
||||
if (!optNowaiting)
|
||||
{
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
}
|
||||
UPstream::waitRequests(requests);
|
||||
UPstream::waitRequest(singleRequest);
|
||||
UPstream::waitRequests(startOfRequests);
|
||||
|
||||
Info<< "Gathered: " << buffer << endl;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void runSwapTest
|
||||
|
||||
for (label iLoop = 0; iLoop < nLoops; ++iLoop)
|
||||
{
|
||||
Foam::Swap(list1, list2);
|
||||
Swap(list1, list2);
|
||||
}
|
||||
|
||||
Info<< "output 1: " << list1.first() << nl;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -44,28 +44,38 @@ class Scalar
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
Scalar()
|
||||
:
|
||||
data_(0)
|
||||
{}
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
Scalar(scalar val)
|
||||
:
|
||||
data_(val)
|
||||
{}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
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)
|
||||
const scalar& value() const
|
||||
{
|
||||
os << item.value();
|
||||
return data_;
|
||||
}
|
||||
|
||||
scalar& value()
|
||||
{
|
||||
return data_;
|
||||
}
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
||||
{
|
||||
os << val.data_;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
template<class T>
|
||||
void printTable(const HashPtrTable<T>& table)
|
||||
@ -119,9 +129,6 @@ int main()
|
||||
myTable.set("natlog", new double(2.718282));
|
||||
myTable.insert("sqrt2", autoPtr<double>::New(1.414214));
|
||||
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;
|
||||
|
||||
@ -139,14 +146,6 @@ int main()
|
||||
Info<< "Initial table" << nl;
|
||||
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<< myTable2 << nl;
|
||||
|
||||
|
||||
@ -75,8 +75,8 @@ int main()
|
||||
}
|
||||
|
||||
|
||||
Info<< "\ntable1 csorted() :" << endl;
|
||||
for (const auto& iter : table1.csorted())
|
||||
Info<< "\ntable1 sorted() :" << endl;
|
||||
for (const auto& iter : table1.sorted())
|
||||
{
|
||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||
}
|
||||
@ -100,7 +100,7 @@ int main()
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -366,8 +366,8 @@ int main()
|
||||
Info<< nl << "input values" << nl;
|
||||
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
||||
|
||||
Info<<"std::swap function" << nl;
|
||||
std::swap(table1, table2);
|
||||
Info<<"global Swap function" << nl;
|
||||
Swap(table1, table2);
|
||||
Info<<"table1 = " << table1 << nl <<"table2 = " << table2 << nl;
|
||||
|
||||
Info<<"swap method" << nl;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-ICharStream1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +33,6 @@ Description
|
||||
|
||||
#include "argList.H"
|
||||
#include "Fstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "etcFiles.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -45,14 +44,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::noParallel();
|
||||
argList::addOption("ignore", "file", "Test readRaw with ignore");
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
// Test with etc/controlDict (mandatory, from distribution)
|
||||
|
||||
if (!args.found("ignore"))
|
||||
{
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
3
applications/test/IListStream/Make/files
Normal file
3
applications/test/IListStream/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-IListStream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-IListStream
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,46 +27,14 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SpanStream.H"
|
||||
#include "ListStream.H"
|
||||
#include "UListStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "argList.H"
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
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)
|
||||
{
|
||||
os << '"';
|
||||
@ -125,7 +93,7 @@ int main(int argc, char *argv[])
|
||||
// Buffer storage
|
||||
DynamicList<char> storage(16);
|
||||
|
||||
OCharStream obuf(std::move(storage));
|
||||
OListStream obuf(std::move(storage));
|
||||
obuf << 1002 << " " << "abcd" << " " << "def" << " " << 3.14159 << ";\n";
|
||||
|
||||
// Move contents to output buffer
|
||||
@ -136,9 +104,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
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;
|
||||
obuf.swap(data);
|
||||
@ -193,43 +161,6 @@ int main(int argc, char *argv[])
|
||||
Info<<nl << "swapped out:";
|
||||
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;
|
||||
|
||||
return 0;
|
||||
@ -46,39 +46,35 @@ using namespace Foam;
|
||||
template<class Type>
|
||||
void doWrite(const IOobject& io, const label sz)
|
||||
{
|
||||
const bool writeOnProc = (sz > 0);
|
||||
|
||||
IOField<Type> fld(io, sz);
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = i + 1000.25 + (0.25 * i);
|
||||
}
|
||||
Pout<< "writing:" << fld << endl;
|
||||
fld.write(writeOnProc);
|
||||
fld.write(sz > 0);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void doWrite<bool>(const IOobject& io, const label sz)
|
||||
{
|
||||
const bool writeOnProc = (sz > 0);
|
||||
|
||||
IOField<bool> fld(io, sz);
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = i % 2;
|
||||
}
|
||||
Pout<< "writing:" << fld << endl;
|
||||
fld.write(writeOnProc);
|
||||
fld.write(sz > 0);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void doRead(const IOobject& io, const label sz)
|
||||
{
|
||||
const bool readOnProc = (sz > 0);
|
||||
Pout<< " readOnProc:" << readOnProc << endl;
|
||||
IOField<Type> fld(io, readOnProc);
|
||||
bool valid = (sz > 0);
|
||||
Pout<< " valid:" << valid << endl;
|
||||
IOField<Type> fld(io, valid);
|
||||
Pout<< " wanted:" << sz << " actually read:" << fld.size() << endl;
|
||||
|
||||
if (fld.size() != sz)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -290,14 +290,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "Time: " << runTime.timeName() << nl;
|
||||
|
||||
report(objects);
|
||||
report(objects.csorted());
|
||||
report(objects.sorted());
|
||||
|
||||
report(objects.csorted<volScalarField>());
|
||||
report(objects.csorted<volVectorField>());
|
||||
report(objects.sorted<volScalarField>());
|
||||
report(objects.sorted<volVectorField>());
|
||||
|
||||
// Extra checks
|
||||
report<volScalarField>(objects.csorted<volScalarField>());
|
||||
report<volScalarField>(objects.csorted<volVectorField>());
|
||||
report<volScalarField>(objects.sorted<volScalarField>());
|
||||
report<volScalarField>(objects.sorted<volVectorField>());
|
||||
|
||||
|
||||
findObjectTest(objects);
|
||||
|
||||
@ -46,26 +46,25 @@ class Scalar
|
||||
{
|
||||
public:
|
||||
|
||||
// static bool verbose;
|
||||
|
||||
scalar data_;
|
||||
|
||||
Scalar() : data_(0) {}
|
||||
Scalar(scalar val) : data_(val) {}
|
||||
Scalar()
|
||||
:
|
||||
data_(0)
|
||||
{}
|
||||
|
||||
// ~Scalar() {}
|
||||
Scalar(scalar s)
|
||||
:
|
||||
data_(s)
|
||||
{}
|
||||
|
||||
scalar value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& s)
|
||||
{
|
||||
os << item.value();
|
||||
os << s.data_;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
// bool Scalar::verbose = true;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,7 +27,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "ListStream.H"
|
||||
#include "UListStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.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:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noBanner();
|
||||
argList::noParallel();
|
||||
argList::addVerboseOption("additional verbosity");
|
||||
argList::addBoolOption("basic", "basic tests");
|
||||
argList::addBoolOption("rewrite", "test rewriting only");
|
||||
argList::addBoolOption("remove-dict", "test rewriting only");
|
||||
const char* charInput =
|
||||
"( const char input \"string\" to tokenize )\n"
|
||||
"List<label> 5(0 1 2 3 4);";
|
||||
|
||||
argList args(argc, argv);
|
||||
string stringInput("( string ; input \"string\" to tokenize )");
|
||||
|
||||
if
|
||||
List<char> listInput
|
||||
(
|
||||
!args.found("basic")
|
||||
&& !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>
|
||||
(
|
||||
ListOps::create<char>
|
||||
(
|
||||
stringInput.cbegin(),
|
||||
stringInput.cend(),
|
||||
Foam::identityOp{}
|
||||
)
|
||||
);
|
||||
stringInput.cbegin(),
|
||||
stringInput.cend(),
|
||||
Foam::identityOp{}
|
||||
)
|
||||
);
|
||||
|
||||
doTest("empty", "", true, true);
|
||||
doTest("empty", "", true, true);
|
||||
|
||||
doTest("char*", charInput, true, true);
|
||||
doTest("string", stringInput, true);
|
||||
doTest("List<char>", listInput, true);
|
||||
doTest("char*", charInput, true, true);
|
||||
doTest("string", stringInput, true);
|
||||
doTest("List<char>", listInput, true);
|
||||
|
||||
reverse(listInput);
|
||||
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()
|
||||
);
|
||||
}
|
||||
reverse(listInput);
|
||||
doTest("List<char>", listInput, true);
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
|
||||
@ -183,7 +183,9 @@ int main(int argc, char *argv[])
|
||||
Pout<<"recv: " << flatOutput(recv) << endl;
|
||||
}
|
||||
|
||||
UPstream::barrier(UPstream::worldComm);
|
||||
// MPI barrier
|
||||
bool barrier = true;
|
||||
Pstream::broadcast(barrier);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
Test-ListRead1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||
@ -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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -1,3 +0,0 @@
|
||||
Test-OCharStream1.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
|
||||
<< "via string-stream: " << str.str().size() << " chars" << nl
|
||||
<< "via ocountstream: " << plain.count() << " chars" << endl;
|
||||
<< "via ocountstream: " << plain.size() << " chars" << endl;
|
||||
|
||||
fileName outputName;
|
||||
args.readIfPresent("write", outputName);
|
||||
|
||||
3
applications/test/OListStream/Make/files
Normal file
3
applications/test/OListStream/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-OListStream.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OListStream
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,46 +27,13 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SpanStream.H"
|
||||
#include "ListStream.H"
|
||||
#include "wordList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "argList.H"
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
|
||||
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)
|
||||
{
|
||||
os << '"';
|
||||
@ -124,12 +91,12 @@ void outputDict(OS& os)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include "setRootCase.H"
|
||||
|
||||
// Buffer storage
|
||||
DynamicList<char> storage(16);
|
||||
|
||||
OCharStream obuf(std::move(storage));
|
||||
OListStream obuf(std::move(storage));
|
||||
|
||||
obuf.setBlockSize(100);
|
||||
|
||||
printInfo(obuf);
|
||||
|
||||
@ -173,10 +140,10 @@ int main(int argc, char *argv[])
|
||||
Info<<"after overwrite" << nl;
|
||||
printInfo(obuf);
|
||||
|
||||
Info<< "transfer contents to a List or ICharStream" << nl;
|
||||
Info<< "transfer contents to a List or IListStream" << nl;
|
||||
|
||||
ICharStream ibuf;
|
||||
// Reclaim data storage from OCharStream -> ICharStream
|
||||
IListStream ibuf;
|
||||
// Reclaim data storage from OListStream -> IListStream
|
||||
{
|
||||
List<char> data;
|
||||
obuf.swap(data);
|
||||
@ -202,7 +169,7 @@ int main(int argc, char *argv[])
|
||||
Info<<"input:";
|
||||
toString(Info, list) << endl;
|
||||
|
||||
OCharStream buf1(std::move(list));
|
||||
OListStream buf1(std::move(list));
|
||||
|
||||
Info<<"orig:";
|
||||
toString(Info, list) << endl;
|
||||
@ -237,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< nl << "Test dictionary" << nl;
|
||||
{
|
||||
OCharStream os1;
|
||||
OListStream os1;
|
||||
|
||||
outputDict(os1);
|
||||
|
||||
@ -246,7 +213,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
OCharStream os2;
|
||||
OListStream os2;
|
||||
os2.indentSize(0);
|
||||
|
||||
outputDict(os2);
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -92,8 +92,8 @@ int main(int argc, char *argv[])
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::NO_REGISTER
|
||||
IOobject::AUTO_WRITE,
|
||||
false
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector(Zero)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2306 |
|
||||
| \\ / O peration | Version: v2212 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -47,29 +47,43 @@ class Scalar
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
Scalar()
|
||||
:
|
||||
data_(0)
|
||||
{}
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
Scalar(scalar val)
|
||||
:
|
||||
data_(val)
|
||||
{}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
Info<< "delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
scalar value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
const scalar& value() const
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
// As per
|
||||
@ -254,22 +268,6 @@ Ostream& report
|
||||
|
||||
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
|
||||
{
|
||||
DLPtrList<Scalar> llist1;
|
||||
@ -327,22 +325,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
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);
|
||||
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.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;
|
||||
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(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_back(Zero, vector::one);
|
||||
|
||||
@ -45,29 +45,28 @@ class Scalar
|
||||
|
||||
public:
|
||||
|
||||
static bool verbose;
|
||||
Scalar()
|
||||
:
|
||||
data_(0)
|
||||
{}
|
||||
|
||||
constexpr Scalar() noexcept : data_(0) {}
|
||||
Scalar(scalar val) noexcept : data_(val) {}
|
||||
Scalar(scalar val)
|
||||
:
|
||||
data_(val)
|
||||
{}
|
||||
|
||||
~Scalar()
|
||||
{
|
||||
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||
Info<<"delete Scalar: " << data_ << endl;
|
||||
}
|
||||
|
||||
const scalar& value() const noexcept { return data_; }
|
||||
scalar& value() noexcept { return data_; }
|
||||
|
||||
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
||||
{
|
||||
os << item.value();
|
||||
os << val.data_;
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
bool Scalar::verbose = true;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user