Compare commits
108 Commits
temp-probe
...
feature-st
| Author | SHA1 | Date | |
|---|---|---|---|
| 775d0b277b | |||
| f7dfb02d12 | |||
| a252677618 | |||
| 99f5d9a7db | |||
| 133149a1dd | |||
| 6396256522 | |||
| 5d98eec6af | |||
| 2d76514b5b | |||
| 2e3f0811a0 | |||
| ff2abdf1f0 | |||
| f49403969e | |||
| 2e8e259217 | |||
| 0250a1b0bb | |||
| aa1b6d9cbd | |||
| df6de6ed33 | |||
| f800ccc3d9 | |||
| 459aaad0f9 | |||
| a341d09afc | |||
| 6d7e67408e | |||
| d8f5714d1b | |||
| 69169c5abe | |||
| 539d538d5a | |||
| c09acbb781 | |||
| b931772369 | |||
| 750d9084d4 | |||
| 6defeddbff | |||
| 9d291ab4cc | |||
| 0e11f47f74 | |||
| 698e05eeb3 | |||
| 2395e493d1 | |||
| 12916cd7a3 | |||
| b66369fb37 | |||
| b236e1493c | |||
| a6744d0814 | |||
| 1e2858e8cb | |||
| 09d86dc02b | |||
| 36f8542e01 | |||
| 886ba89ddb | |||
| 778796853d | |||
| 224c3199aa | |||
| e4f2efec18 | |||
| 3630333526 | |||
| 97668eab26 | |||
| b620152191 | |||
| 03ca52b036 | |||
| 11a1f78338 | |||
| 268de43afc | |||
| 43f8b477b7 | |||
| bbbab8a9c2 | |||
| 2422e6f061 | |||
| eeb9d144e3 | |||
| fabd3f4e0c | |||
| 7828067ef6 | |||
| 53b3fff7d5 | |||
| 066a5a997a | |||
| 4daaf6dd2a | |||
| 944840f8d6 | |||
| 1340bc50bd | |||
| 97a42df7ba | |||
| 5eacd8257b | |||
| aad4c2222e | |||
| 14f7d44ca0 | |||
| db39f196cc | |||
| 2fc2d1f95f | |||
| db16d80840 | |||
| d65e2d89b5 | |||
| dc95242cd2 | |||
| ed314b2740 | |||
| 5397c9ac04 | |||
| 129b738136 | |||
| 0eb4354ee0 | |||
| f18a29a742 | |||
| 36161e682a | |||
| a3ec19c344 | |||
| 4dfafc3c36 | |||
| 945e3e41b1 | |||
| 76efcba4c7 | |||
| 7cae3b9660 | |||
| 8117cde596 | |||
| 63258d0b33 | |||
| 5e334c0686 | |||
| 32903d337e | |||
| f717f79833 | |||
| 3430ab3aa8 | |||
| 779c3fe11e | |||
| 8562f4d7a4 | |||
| 65cddb6120 | |||
| 95b820368c | |||
| ab0d4d95ff | |||
| a8df552998 | |||
| edb455ca97 | |||
| ae6de092d5 | |||
| 69dae2e008 | |||
| 63753605a0 | |||
| 7a29eb9b3b | |||
| 4db98e5de4 | |||
| 115bbd2699 | |||
| 8ee4b52560 | |||
| f398d7b313 | |||
| a1e34bb251 | |||
| 0d456a4c66 | |||
| 728527a345 | |||
| 5635e14f81 | |||
| fc2760ab9c | |||
| f8987e64ed | |||
| a215f94ec4 | |||
| d5a0eaeeee | |||
| 7a857b318a |
@ -1,2 +1,2 @@
|
|||||||
api=2306
|
api=2307
|
||||||
patch=0
|
patch=0
|
||||||
|
|||||||
@ -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.deltaT().value();
|
*runTime.deltaTValue();
|
||||||
|
|
||||||
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
Info<< "Max acoustic Courant Number = " << MaxCo << endl;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
if (adjustTimeStep)
|
if (adjustTimeStep)
|
||||||
{
|
{
|
||||||
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
runTime.setDeltaT(min(dtChem, maxDeltaT));
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
dtChem = chemistry.solve(runTime.deltaT().value());
|
dtChem = chemistry.solve(runTime.deltaTValue());
|
||||||
scalar Qdot = chemistry.Qdot()()[0]/rho[0];
|
scalar Qdot = chemistry.Qdot()()[0]/rho[0];
|
||||||
integratedHeat += Qdot*runTime.deltaT().value();
|
integratedHeat += Qdot*runTime.deltaTValue();
|
||||||
|
|||||||
@ -17,7 +17,7 @@ tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> interpolate
|
|||||||
vf,
|
vf,
|
||||||
dir,
|
dir,
|
||||||
"reconstruct("
|
"reconstruct("
|
||||||
+ (reconFieldName != word::null ? reconFieldName : vf.name())
|
+ (reconFieldName.empty() ? vf.name() : reconFieldName)
|
||||||
+ ')'
|
+ ')'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
*mag(aMesh.edgeInterpolation::deltaCoeffs())
|
*mag(aMesh.edgeInterpolation::deltaCoeffs())
|
||||||
/rhol
|
/rhol
|
||||||
)
|
)
|
||||||
).value()*runTime.deltaT().value();
|
).value()*runTime.deltaTValue();
|
||||||
|
|
||||||
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
|
Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,10 +47,10 @@ if (aMesh.nInternalEdges())
|
|||||||
);
|
);
|
||||||
|
|
||||||
CoNum = max(SfUfbyDelta/aMesh.magLe())
|
CoNum = max(SfUfbyDelta/aMesh.magLe())
|
||||||
.value()*runTime.deltaT().value();
|
.value()*runTime.deltaTValue();
|
||||||
|
|
||||||
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
|
meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe()))
|
||||||
.value()*runTime.deltaT().value();
|
.value()*runTime.deltaTValue();
|
||||||
|
|
||||||
velMag = max(mag(phis)/aMesh.magLe()).value();
|
velMag = max(mag(phis)/aMesh.magLe()).value();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,8 +292,7 @@ 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.
|
||||||
int oldTag = UPstream::msgType();
|
const int oldTag = UPstream::incrMsgType();
|
||||||
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();
|
||||||
@ -471,10 +470,9 @@ updateCoeffs()
|
|||||||
<< regionTypeNames_ << nl << exit(FatalError);
|
<< regionTypeNames_ << nl << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
mixedFvPatchScalarField::updateCoeffs();
|
UPstream::msgType(oldTag); // Restore tag
|
||||||
|
|
||||||
// Restore tag
|
mixedFvPatchScalarField::updateCoeffs();
|
||||||
UPstream::msgType() = oldTag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,11 +49,11 @@ if (adjustTimeStep)
|
|||||||
(
|
(
|
||||||
min
|
min
|
||||||
(
|
(
|
||||||
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaT().value(),
|
min(maxCo/CoNum, maxDi/DiNum)*runTime.deltaTValue(),
|
||||||
min(runTime.deltaTValue(), maxDeltaT)
|
min(runTime.deltaTValue(), maxDeltaT)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,12 +59,12 @@ if (adjustTimeStep)
|
|||||||
(
|
(
|
||||||
min
|
min
|
||||||
(
|
(
|
||||||
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaT().value(),
|
min(deltaTFluid, maxDeltaTSolid)*runTime.deltaTValue(),
|
||||||
maxDeltaT
|
maxDeltaT
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< "deltaT = " << runTime.deltaT().value() << endl;
|
Info<< "deltaT = " << runTime.deltaTValue() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -86,6 +86,7 @@ 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;
|
||||||
|
|||||||
@ -1075,7 +1075,7 @@ void Foam::multiphaseMixtureThermo::solveAlphas
|
|||||||
|
|
||||||
MULES::limit
|
MULES::limit
|
||||||
(
|
(
|
||||||
1.0/mesh_.time().deltaT().value(),
|
1.0/mesh_.time().deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha,
|
alpha,
|
||||||
phi_,
|
phi_,
|
||||||
|
|||||||
@ -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().outputTime())
|
if (mesh_.time().writeTime())
|
||||||
{
|
{
|
||||||
reflectingCellsVol.write();
|
reflectingCellsVol.write();
|
||||||
nHat.write();
|
nHat.write();
|
||||||
|
|||||||
@ -52,7 +52,9 @@ namespace Foam
|
|||||||
const Foam::volScalarField&
|
const Foam::volScalarField&
|
||||||
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
||||||
{
|
{
|
||||||
if (!mesh_.foundObject<volScalarField>(alphaName))
|
const volScalarField* ptr = mesh_.cfindObject<volScalarField>(alphaName);
|
||||||
|
|
||||||
|
if (!ptr)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Unable to retrieve density field " << alphaName << " from "
|
<< "Unable to retrieve density field " << alphaName << " from "
|
||||||
@ -60,7 +62,7 @@ Foam::radiation::localDensityAbsorptionEmission::alpha(word alphaName) const
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mesh_.lookupObject<volScalarField>(alphaName);
|
return *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -124,7 +124,7 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
|||||||
* max(TSat - T, T0)
|
* max(TSat - T, T0)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mesh_.time().outputTime())
|
if (mesh_.time().writeTime())
|
||||||
{
|
{
|
||||||
mDotC.write();
|
mDotC.write();
|
||||||
mDotE.write();
|
mDotE.write();
|
||||||
|
|||||||
@ -96,7 +96,7 @@
|
|||||||
MULES::limiter
|
MULES::limiter
|
||||||
(
|
(
|
||||||
allLambda,
|
allLambda,
|
||||||
1.0/runTime.deltaT().value(),
|
1.0/runTime.deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha1,
|
alpha1,
|
||||||
alphaPhi1BD,
|
alphaPhi1BD,
|
||||||
@ -164,7 +164,7 @@
|
|||||||
MULES::limiter
|
MULES::limiter
|
||||||
(
|
(
|
||||||
allLambda,
|
allLambda,
|
||||||
1.0/runTime.deltaT().value(),
|
1.0/runTime.deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha2,
|
alpha2,
|
||||||
alphaPhi2BD,
|
alphaPhi2BD,
|
||||||
|
|||||||
@ -628,7 +628,7 @@ void Foam::multiphaseMixture::solveAlphas
|
|||||||
|
|
||||||
MULES::limit
|
MULES::limit
|
||||||
(
|
(
|
||||||
1.0/mesh_.time().deltaT().value(),
|
1.0/mesh_.time().deltaTValue(),
|
||||||
geometricOneField(),
|
geometricOneField(),
|
||||||
alpha,
|
alpha,
|
||||||
phi_,
|
phi_,
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
IOobject rhoIO
|
IOobject rhoIO
|
||||||
(
|
(
|
||||||
"rho",
|
"rho",
|
||||||
runTime.timeName(0),
|
Time::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",
|
||||||
runTime.timeName(0),
|
Time::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",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
|
|||||||
@ -51,7 +51,7 @@ if (thermalStress)
|
|||||||
IOobject CIO
|
IOobject CIO
|
||||||
(
|
(
|
||||||
"C",
|
"C",
|
||||||
runTime.timeName(0),
|
Time::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",
|
||||||
runTime.timeName(0),
|
Time::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",
|
||||||
runTime.timeName(0),
|
Time::timeName(0),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ,
|
IOobject::NO_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
|
|||||||
@ -92,7 +92,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
report(buf1);
|
report(buf1);
|
||||||
|
|
||||||
buf1.push_back(identity(5)); report(buf1);
|
buf1.push_back(identity(5));
|
||||||
|
buf1.emplace_front(-1000);
|
||||||
|
buf1.emplace_back(1000);
|
||||||
|
report(buf1);
|
||||||
|
|
||||||
buf1.info(Info);
|
buf1.info(Info);
|
||||||
Info<< buf1 << nl;
|
Info<< buf1 << nl;
|
||||||
|
|||||||
@ -55,10 +55,7 @@ public:
|
|||||||
i_(i)
|
i_(i)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const word& keyword() const
|
const word& keyword() const noexcept { return keyword_; }
|
||||||
{
|
|
||||||
return keyword_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const ent& e)
|
friend Ostream& operator<<(Ostream& os, const ent& e)
|
||||||
{
|
{
|
||||||
@ -74,28 +71,27 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
scalar value() const noexcept { return data_; }
|
||||||
|
scalar& value() noexcept { return data_; }
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
os << val.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -117,7 +113,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
dict.swapDown(dict.first());
|
dict.swapDown(dict.first());
|
||||||
|
|
||||||
forAllConstIter(Dictionary<ent>, dict, iter)
|
forAllConstIters(dict, iter)
|
||||||
{
|
{
|
||||||
Info<< "element : " << *iter;
|
Info<< "element : " << *iter;
|
||||||
}
|
}
|
||||||
@ -157,9 +153,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "scalarDict1: " << endl;
|
Info<< nl << "scalarDict1: " << endl;
|
||||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
|
forAllConstIters(scalarDict, iter)
|
||||||
{
|
{
|
||||||
Info<< " = " << iter() << endl;
|
Info<< " = " << *iter << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
PtrDictionary<Scalar> scalarDict2;
|
PtrDictionary<Scalar> scalarDict2;
|
||||||
@ -169,7 +165,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;
|
||||||
forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
|
forAllConstIters(scalarDict2, iter)
|
||||||
{
|
{
|
||||||
std::cout<< "iter: " << typeid(*iter).name() << '\n';
|
std::cout<< "iter: " << typeid(*iter).name() << '\n';
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,7 @@ Description
|
|||||||
|
|
||||||
fileNameList procDirs
|
fileNameList procDirs
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(matchProcs)
|
DirLister::dirs(".").csorted<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> sorted() const;
|
List<StringType> csorted() 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> sorted
|
List<StringType> csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune = false
|
const bool prune = false
|
||||||
|
|||||||
@ -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::sorted
|
Foam::List<StringType> Foam::DirLister::csorted
|
||||||
(
|
(
|
||||||
const UnaryPredicate& pred,
|
const UnaryPredicate& pred,
|
||||||
const bool prune
|
const bool prune
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
List<StringType> lst(list<StringType>(pred, prune));
|
List<StringType> list(list<StringType>(pred, prune));
|
||||||
sort(lst, stringOps::natural_sort());
|
Foam::sort(list, stringOps::natural_sort());
|
||||||
|
|
||||||
return lst;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
Foam::List<StringType> Foam::DirLister::sorted() const
|
Foam::List<StringType> Foam::DirLister::csorted() const
|
||||||
{
|
{
|
||||||
return sorted<StringType>(predicates::always());
|
return csorted<StringType>(predicates::always());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "dirList: "
|
Info<< "dirList: "
|
||||||
<< flatOutput
|
<< flatOutput
|
||||||
(
|
(
|
||||||
DirLister::dirs(".").sorted<fileName>(relist)
|
DirLister::dirs(".").csorted<fileName>(relist)
|
||||||
) << nl;
|
) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -202,14 +202,31 @@ 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;
|
||||||
|
|
||||||
label a[4] = {0, 1, 2, 3};
|
// Test deprecated form
|
||||||
FixedList<label, 4> list2(a);
|
label array2[4] = {0, 1, 2, 3};
|
||||||
|
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};
|
||||||
@ -237,8 +254,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;
|
||||||
|
|
||||||
Swap(list1, list2);
|
Foam::Swap(list1, list2);
|
||||||
Info<< "The Swap() function" << nl;
|
Info<< "Foam::Swap() function" << nl;
|
||||||
Info<< "list1: " << list1 << nl
|
Info<< "list1: " << list1 << nl
|
||||||
<< "list2: " << list2 << nl;
|
<< "list2: " << list2 << nl;
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ void runSwapTest
|
|||||||
|
|
||||||
for (label iLoop = 0; iLoop < nLoops; ++iLoop)
|
for (label iLoop = 0; iLoop < nLoops; ++iLoop)
|
||||||
{
|
{
|
||||||
Swap(list1, list2);
|
Foam::Swap(list1, list2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "output 1: " << list1.first() << nl;
|
Info<< "output 1: " << list1.first() << nl;
|
||||||
|
|||||||
@ -44,38 +44,28 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar& value() const
|
const scalar& value() const noexcept { return data_; }
|
||||||
{
|
scalar& value() noexcept { return data_; }
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar& value()
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
return data_;
|
os << item.value();
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
@ -129,6 +119,9 @@ 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;
|
||||||
|
|
||||||
@ -146,6 +139,14 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@ -75,8 +75,8 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Info<< "\ntable1 sorted() :" << endl;
|
Info<< "\ntable1 csorted() :" << endl;
|
||||||
for (const auto& iter : table1.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
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.sorted())
|
for (const auto& iter : table1.csorted())
|
||||||
{
|
{
|
||||||
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<<"global Swap function" << nl;
|
Info<<"std::swap function" << nl;
|
||||||
Swap(table1, table2);
|
std::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;
|
||||||
|
|||||||
3
applications/test/ICharStream1/Make/files
Normal file
3
applications/test/ICharStream1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-ICharStream1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-ICharStream1
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,14 +27,46 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ListStream.H"
|
#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>
|
||||||
|
|
||||||
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 << '"';
|
||||||
@ -93,7 +125,7 @@ int main(int argc, char *argv[])
|
|||||||
// Buffer storage
|
// Buffer storage
|
||||||
DynamicList<char> storage(16);
|
DynamicList<char> storage(16);
|
||||||
|
|
||||||
OListStream obuf(std::move(storage));
|
OCharStream 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
|
||||||
@ -104,9 +136,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "transfer contents to a List" << endl;
|
Info<< "transfer contents to a List" << endl;
|
||||||
|
|
||||||
IListStream ibuf;
|
ICharStream ibuf;
|
||||||
|
|
||||||
// Reclaim data storage from OListStream -> IListStream
|
// Reclaim data storage from OCharStream -> ICharStream
|
||||||
{
|
{
|
||||||
List<char> data;
|
List<char> data;
|
||||||
obuf.swap(data);
|
obuf.swap(data);
|
||||||
@ -161,6 +193,43 @@ 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;
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,6 +33,7 @@ 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;
|
||||||
@ -44,11 +45,14 @@ 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
|
||||||
(
|
(
|
||||||
@ -97,6 +101,43 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
Test-IListStream.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-IListStream
|
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 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.sorted());
|
report(objects.csorted());
|
||||||
|
|
||||||
report(objects.sorted<volScalarField>());
|
report(objects.csorted<volScalarField>());
|
||||||
report(objects.sorted<volVectorField>());
|
report(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
// Extra checks
|
// Extra checks
|
||||||
report<volScalarField>(objects.sorted<volScalarField>());
|
report<volScalarField>(objects.csorted<volScalarField>());
|
||||||
report<volScalarField>(objects.sorted<volVectorField>());
|
report<volScalarField>(objects.csorted<volVectorField>());
|
||||||
|
|
||||||
|
|
||||||
findObjectTest(objects);
|
findObjectTest(objects);
|
||||||
|
|||||||
@ -46,26 +46,27 @@ class Scalar
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// static bool verbose;
|
||||||
|
|
||||||
scalar data_;
|
scalar data_;
|
||||||
|
|
||||||
Scalar()
|
Scalar() : data_(0) {}
|
||||||
:
|
Scalar(scalar val) : data_(val) {}
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar s)
|
// ~Scalar() {}
|
||||||
:
|
|
||||||
data_(s)
|
|
||||||
{}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& s)
|
scalar value() const noexcept { return data_; }
|
||||||
|
scalar& value() noexcept { return data_; }
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
os << s.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,8 +27,7 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ListStream.H"
|
#include "argList.H"
|
||||||
#include "UListStream.H"
|
|
||||||
#include "wordList.H"
|
#include "wordList.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
@ -155,35 +154,378 @@ 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[])
|
||||||
{
|
{
|
||||||
const char* charInput =
|
argList::noBanner();
|
||||||
"( const char input \"string\" to tokenize )\n"
|
argList::noParallel();
|
||||||
"List<label> 5(0 1 2 3 4);";
|
argList::addVerboseOption("additional verbosity");
|
||||||
|
argList::addBoolOption("basic", "basic tests");
|
||||||
|
argList::addBoolOption("rewrite", "test rewriting only");
|
||||||
|
argList::addBoolOption("remove-dict", "test rewriting only");
|
||||||
|
|
||||||
string stringInput("( string ; input \"string\" to tokenize )");
|
argList args(argc, argv);
|
||||||
|
|
||||||
List<char> listInput
|
if
|
||||||
(
|
(
|
||||||
ListOps::create<char>
|
!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
|
||||||
(
|
(
|
||||||
stringInput.cbegin(),
|
ListOps::create<char>
|
||||||
stringInput.cend(),
|
(
|
||||||
Foam::identityOp{}
|
stringInput.cbegin(),
|
||||||
)
|
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;
|
||||||
|
|
||||||
|
|||||||
@ -183,9 +183,7 @@ int main(int argc, char *argv[])
|
|||||||
Pout<<"recv: " << flatOutput(recv) << endl;
|
Pout<<"recv: " << flatOutput(recv) << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MPI barrier
|
UPstream::barrier(UPstream::worldComm);
|
||||||
bool barrier = true;
|
|
||||||
Pstream::broadcast(barrier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
3
applications/test/ListRead1/Make/files
Normal file
3
applications/test/ListRead1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-ListRead1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-ListRead1
|
||||||
234
applications/test/ListRead1/Test-ListRead1.C
Normal file
234
applications/test/ListRead1/Test-ListRead1.C
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
17
applications/test/ListRead1/testLists1
Normal file
17
applications/test/ListRead1/testLists1
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
(
|
||||||
|
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
|
||||||
|
)
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
3
applications/test/OCharStream1/Make/files
Normal file
3
applications/test/OCharStream1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-OCharStream1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-OCharStream1
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,13 +27,46 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ListStream.H"
|
#include "SpanStream.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 << '"';
|
||||||
@ -91,12 +124,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);
|
||||||
|
|
||||||
OListStream obuf(std::move(storage));
|
OCharStream obuf(std::move(storage));
|
||||||
|
|
||||||
obuf.setBlockSize(100);
|
|
||||||
|
|
||||||
printInfo(obuf);
|
printInfo(obuf);
|
||||||
|
|
||||||
@ -140,10 +173,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 IListStream" << nl;
|
Info<< "transfer contents to a List or ICharStream" << nl;
|
||||||
|
|
||||||
IListStream ibuf;
|
ICharStream ibuf;
|
||||||
// Reclaim data storage from OListStream -> IListStream
|
// Reclaim data storage from OCharStream -> ICharStream
|
||||||
{
|
{
|
||||||
List<char> data;
|
List<char> data;
|
||||||
obuf.swap(data);
|
obuf.swap(data);
|
||||||
@ -169,7 +202,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<<"input:";
|
Info<<"input:";
|
||||||
toString(Info, list) << endl;
|
toString(Info, list) << endl;
|
||||||
|
|
||||||
OListStream buf1(std::move(list));
|
OCharStream buf1(std::move(list));
|
||||||
|
|
||||||
Info<<"orig:";
|
Info<<"orig:";
|
||||||
toString(Info, list) << endl;
|
toString(Info, list) << endl;
|
||||||
@ -204,7 +237,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< nl << "Test dictionary" << nl;
|
Info<< nl << "Test dictionary" << nl;
|
||||||
{
|
{
|
||||||
OListStream os1;
|
OCharStream os1;
|
||||||
|
|
||||||
outputDict(os1);
|
outputDict(os1);
|
||||||
|
|
||||||
@ -213,7 +246,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
OListStream os2;
|
OCharStream os2;
|
||||||
os2.indentSize(0);
|
os2.indentSize(0);
|
||||||
|
|
||||||
outputDict(os2);
|
outputDict(os2);
|
||||||
@ -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.size() << " chars" << endl;
|
<< "via ocountstream: " << plain.count() << " chars" << endl;
|
||||||
|
|
||||||
fileName outputName;
|
fileName outputName;
|
||||||
args.readIfPresent("write", outputName);
|
args.readIfPresent("write", outputName);
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
Test-OListStream.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-OListStream
|
|
||||||
@ -47,43 +47,29 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<< "delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalar& value() const
|
scalar value() const noexcept { return data_; }
|
||||||
{
|
scalar& value() noexcept { return data_; }
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
scalar& value()
|
autoPtr<Scalar> clone() const { return autoPtr<Scalar>::New(data_); }
|
||||||
{
|
|
||||||
return data_;
|
|
||||||
}
|
|
||||||
|
|
||||||
autoPtr<Scalar> clone() const
|
friend Ostream& operator<<(Ostream& os, const Scalar& item)
|
||||||
{
|
{
|
||||||
return autoPtr<Scalar>::New(data_);
|
os << item.value();
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
|
||||||
{
|
|
||||||
os << val.data_;
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// As per
|
// As per
|
||||||
@ -268,6 +254,22 @@ 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;
|
||||||
@ -349,6 +351,20 @@ 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)
|
||||||
{
|
{
|
||||||
@ -639,7 +655,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 :"
|
Info<< "emplaced[12]: "
|
||||||
<< 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);
|
||||||
|
|||||||
@ -45,28 +45,29 @@ class Scalar
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Scalar()
|
static bool verbose;
|
||||||
:
|
|
||||||
data_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Scalar(scalar val)
|
constexpr Scalar() noexcept : data_(0) {}
|
||||||
:
|
Scalar(scalar val) noexcept : data_(val) {}
|
||||||
data_(val)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~Scalar()
|
~Scalar()
|
||||||
{
|
{
|
||||||
Info<<"delete Scalar: " << data_ << endl;
|
if (verbose) Info<< "delete Scalar: " << data_ << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const Scalar& val)
|
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)
|
||||||
{
|
{
|
||||||
os << val.data_;
|
os << item.value();
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool Scalar::verbose = true;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
3
applications/test/SpanStream1/Make/files
Normal file
3
applications/test/SpanStream1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-SpanStream1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-SpanStream1
|
||||||
2
applications/test/SpanStream1/Make/options
Normal file
2
applications/test/SpanStream1/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2018 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,16 +27,48 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "UListStream.H"
|
#include "SpanStream.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 << '"';
|
||||||
@ -108,7 +140,7 @@ int main(int argc, char *argv[])
|
|||||||
// Buffer storage
|
// Buffer storage
|
||||||
DynamicList<char> storage(1000);
|
DynamicList<char> storage(1000);
|
||||||
|
|
||||||
UOListStream obuf(storage);
|
OSpanStream 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);
|
||||||
@ -120,7 +152,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
|
||||||
{
|
{
|
||||||
UIListStream ibuf(storage);
|
ISpanStream ibuf(storage);
|
||||||
|
|
||||||
printTokens(ibuf);
|
printTokens(ibuf);
|
||||||
|
|
||||||
@ -135,13 +167,21 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<< "parse as std::istream\n";
|
Info<< "parse as std::istream\n";
|
||||||
|
|
||||||
uiliststream is(storage.cdata(), storage.size());
|
ispanstream 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;
|
||||||
@ -170,7 +210,7 @@ int main(int argc, char *argv[])
|
|||||||
toString(Info, chars);
|
toString(Info, chars);
|
||||||
Info<< "----" << nl;
|
Info<< "----" << nl;
|
||||||
|
|
||||||
uiliststream is(chars.data(), chars.size());
|
ispanstream 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))
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,6 +37,7 @@ 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;
|
||||||
@ -57,26 +58,26 @@ int main(int argc, char *argv[])
|
|||||||
argList::noFunctionObjects();
|
argList::noFunctionObjects();
|
||||||
|
|
||||||
{
|
{
|
||||||
List<scalar> ident(25);
|
List<label> ident(25);
|
||||||
std::iota(ident.begin(), ident.end(), 0);
|
std::iota(ident.begin(), ident.end(), 0);
|
||||||
|
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubList<scalar>(ident, 10) = -10;
|
SubList<label>(ident, 10) = -10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>(ident, 10) = 10;
|
SubField<label>(ident, 10) = 10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>(ident, 10) += 10;
|
SubField<label>(ident, 10) += 10;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
SubField<scalar>{ident, 10, 10} *= 5;
|
SubField<label>{ident, 10, 10} *= 5;
|
||||||
print(ident);
|
print(ident);
|
||||||
|
|
||||||
|
|
||||||
// NOTE: Need {} instead of ()
|
// NOTE: Need {} instead of ()
|
||||||
// SubList<scalar>(ident) = 100;
|
// SubList<label>(ident) = 100;
|
||||||
|
|
||||||
// GCC
|
// GCC
|
||||||
// error: conflicting declaration 'Foam::SubList<double> ident'
|
// error: conflicting declaration 'Foam::SubList<double> ident'
|
||||||
@ -85,7 +86,30 @@ 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<scalar>{ident} = 100;
|
SubList<label>{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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,7 @@ public:
|
|||||||
i_(i)
|
i_(i)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
const word& keyword() const
|
const word& keyword() const noexcept { return keyword_; }
|
||||||
{
|
|
||||||
return keyword_;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend Ostream& operator<<(Ostream& os, const ent& e)
|
friend Ostream& operator<<(Ostream& os, const ent& e)
|
||||||
{
|
{
|
||||||
@ -83,7 +80,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
dict.swapDown(dict.first());
|
dict.swapDown(dict.first());
|
||||||
|
|
||||||
forAllConstIter(UDictionary<ent>, dict, iter)
|
forAllConstIters(dict, iter)
|
||||||
{
|
{
|
||||||
Info<< "element : " << *iter;
|
Info<< "element : " << *iter;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
Test-UIListStream.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/Test-UIListStream
|
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -84,6 +84,20 @@ struct DerivedList : public List<T>
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void printInfo(const autoPtr<T>& item, const bool verbose = false)
|
||||||
|
{
|
||||||
|
Info<< "autoPtr good:" << Switch::name(item.good())
|
||||||
|
<< " addr: " << Foam::name(item.get());
|
||||||
|
|
||||||
|
if (verbose && item)
|
||||||
|
{
|
||||||
|
Info<< " content: " << item();
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -112,6 +126,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<<"move unique to autoPtr: " << *list3 << nl;
|
Info<<"move unique to autoPtr: " << *list3 << nl;
|
||||||
Info<<"old is " << Switch(bool(list2)) << nl;
|
Info<<"old is " << Switch(bool(list2)) << nl;
|
||||||
|
|
||||||
|
Info<< "before emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
|
|
||||||
|
list.emplace(4, label(-2));
|
||||||
|
Info<< "after emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
|
|
||||||
|
list.emplace(2, label(-4));
|
||||||
|
Info<< "after emplace: ";
|
||||||
|
printInfo(list, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirm that forwarding with move construct actually works as expected
|
// Confirm that forwarding with move construct actually works as expected
|
||||||
|
|||||||
@ -58,8 +58,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
Info<< "Known compound tokens: "
|
// Info<< "Known compound tokens: "
|
||||||
<< token::compound::IstreamConstructorTablePtr_->sortedToc() << nl;
|
// << token::compound::emptyConstructorTablePtr_->sortedToc() << nl;
|
||||||
|
|
||||||
OStringStream ostr;
|
OStringStream ostr;
|
||||||
|
|
||||||
@ -79,6 +79,13 @@ int main(int argc, char *argv[])
|
|||||||
List<char> alphabet(istr);
|
List<char> alphabet(istr);
|
||||||
|
|
||||||
Info<< "re-read: " << alphabet << nl;
|
Info<< "re-read: " << alphabet << nl;
|
||||||
|
|
||||||
|
// Can assign zero?
|
||||||
|
//Fails: alphabet = char(Zero);
|
||||||
|
alphabet = Foam::zero{};
|
||||||
|
|
||||||
|
// alphabet = '@';
|
||||||
|
Info<< "blanked: " << alphabet << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
3
applications/test/compoundToken1/Make/files
Normal file
3
applications/test/compoundToken1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-compoundToken1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-compoundToken1
|
||||||
1
applications/test/compoundToken1/Make/options
Normal file
1
applications/test/compoundToken1/Make/options
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
307
applications/test/compoundToken1/Test-compoundToken1.C
Normal file
307
applications/test/compoundToken1/Test-compoundToken1.C
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test token construct assign etc.
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "IOobject.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "IFstream.H"
|
||||||
|
#include "StringStream.H"
|
||||||
|
#include "cpuTime.H"
|
||||||
|
#include "labelList.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class OS>
|
||||||
|
OS& printTypeCode(OS& os, char typeCode)
|
||||||
|
{
|
||||||
|
os << int(static_cast<unsigned char>(typeCode));
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class IFstream Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
bool test_pending = false;
|
||||||
|
|
||||||
|
class IFstreamDelayed
|
||||||
|
:
|
||||||
|
public IFstream
|
||||||
|
{
|
||||||
|
virtual bool readCompoundToken(token& tok, const word& type)
|
||||||
|
{
|
||||||
|
auto& is = *this;
|
||||||
|
|
||||||
|
bool delay = true;
|
||||||
|
|
||||||
|
// Low-level: get next valid character (after comments)
|
||||||
|
// and branch based on it being a '{' or not
|
||||||
|
|
||||||
|
char c = 0;
|
||||||
|
if (is.read(c))
|
||||||
|
{
|
||||||
|
// Delay further reading?
|
||||||
|
delay = (c == token::BEGIN_BLOCK);
|
||||||
|
is.putback(c);
|
||||||
|
|
||||||
|
if (c)
|
||||||
|
{
|
||||||
|
cerr<< "nextChar:" << c << " : delay read: " << delay << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Caller already checked token::compound::isCompound(...)
|
||||||
|
// but use readCompoundToken anyhow for convenience
|
||||||
|
|
||||||
|
if (tok.readCompoundToken(type, is, !delay))
|
||||||
|
{
|
||||||
|
cerr<< "readCompound(" << type << ")\n";
|
||||||
|
cerr<< "typeCode: ";
|
||||||
|
printTypeCode(cerr, tok.compoundToken().typeCode()) << nl;
|
||||||
|
|
||||||
|
if (test_pending && delay)
|
||||||
|
{
|
||||||
|
InfoErr<< "pending read "
|
||||||
|
<< tok.compoundToken().type() << endl;
|
||||||
|
|
||||||
|
tok.refCompoundToken().pending(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
using IFstream::IFstream;
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~IFstreamDelayed() = default;
|
||||||
|
|
||||||
|
// Testing deprecation warnings
|
||||||
|
FOAM_DEPRECATED_STRICT(2023-08, "direct calling")
|
||||||
|
Istream& operator()() const
|
||||||
|
{
|
||||||
|
return const_cast<IFstreamDelayed&>(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
void populateCompound(token::compound& ct, const dictionary& dict)
|
||||||
|
{
|
||||||
|
Info<< "populateCompound: " << nl;
|
||||||
|
|
||||||
|
// This is where runTime dispatch, eg based on transport type
|
||||||
|
// could be used...
|
||||||
|
|
||||||
|
switch (ct.typeCode())
|
||||||
|
{
|
||||||
|
#undef fillComponents
|
||||||
|
#define fillComponents(Type, Variable, Value) \
|
||||||
|
{ \
|
||||||
|
ct.pending(false); \
|
||||||
|
ct.resize(10); \
|
||||||
|
UList<Type> Variable \
|
||||||
|
( \
|
||||||
|
reinterpret_cast<Type*>(ct.data_bytes()), \
|
||||||
|
label(ct.size_bytes() / sizeof(Type)) \
|
||||||
|
); \
|
||||||
|
Variable = Value; \
|
||||||
|
}
|
||||||
|
|
||||||
|
case token::tokenType::PUNCTUATION :
|
||||||
|
{
|
||||||
|
fillComponents(char, cmpts, '@');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::BOOL :
|
||||||
|
{
|
||||||
|
fillComponents(bool, cmpts, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::LABEL :
|
||||||
|
{
|
||||||
|
fillComponents(label, cmpts, 123);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::FLOAT :
|
||||||
|
{
|
||||||
|
fillComponents(float, cmpts, 2.7);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::DOUBLE :
|
||||||
|
{
|
||||||
|
fillComponents(double, cmpts, 3.1415);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
#undef fillComponents
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ct.pending())
|
||||||
|
{
|
||||||
|
Info<< "assigned values:" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rewriteCompounds(ITstream& is)
|
||||||
|
{
|
||||||
|
Info<< "rewrite: " << flatOutput(is) << endl;
|
||||||
|
|
||||||
|
for (label toki = 0; toki < is.size(); ++toki)
|
||||||
|
{
|
||||||
|
if (is[toki].isCompound() && is[toki].compoundToken().pending())
|
||||||
|
{
|
||||||
|
Info<< "replace : " << is[toki].info() << endl;
|
||||||
|
|
||||||
|
if (is.peekToken(toki+1).isPunctuation(token::BEGIN_BLOCK))
|
||||||
|
{
|
||||||
|
labelRange slice
|
||||||
|
(
|
||||||
|
is.find(token::BEGIN_BLOCK, token::END_BLOCK, toki+1)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (slice.good() && (slice.start() == toki+1))
|
||||||
|
{
|
||||||
|
Info<< "Compound at:" << toki
|
||||||
|
<< " dict:" << slice << endl;
|
||||||
|
|
||||||
|
ITstream substream(is.extract(slice));
|
||||||
|
|
||||||
|
dictionary dict(substream);
|
||||||
|
|
||||||
|
populateCompound(is[toki].refCompoundToken(), dict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void rewriteDict(dictionary& dict)
|
||||||
|
{
|
||||||
|
for (entry& e : dict)
|
||||||
|
{
|
||||||
|
if (e.isDict())
|
||||||
|
{
|
||||||
|
rewriteDict(e.dict());
|
||||||
|
}
|
||||||
|
else if (e.isStream())
|
||||||
|
{
|
||||||
|
rewriteCompounds(e.stream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noParallel();
|
||||||
|
argList::addBoolOption("std", "standard reading (no delayed compounds)");
|
||||||
|
argList::addBoolOption("pending", "read with pending");
|
||||||
|
|
||||||
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
|
Info<< "typeCodes:" << nl;
|
||||||
|
Info<< " bool=";
|
||||||
|
printTypeCode(Info, token::tokenType::BOOL) << nl;
|
||||||
|
Info<< " label=";
|
||||||
|
printTypeCode(Info, token::tokenType::LABEL) << nl;
|
||||||
|
Info<< " float=";
|
||||||
|
printTypeCode(Info, token::tokenType::FLOAT) << nl;
|
||||||
|
Info<< " double=";
|
||||||
|
printTypeCode(Info, token::tokenType::DOUBLE) << nl;
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
if (args.found("pending"))
|
||||||
|
{
|
||||||
|
test_pending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.found("std"))
|
||||||
|
{
|
||||||
|
for (label argi = 1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
Info<< "Read: " << args[argi] << endl;
|
||||||
|
IFstream is(args[argi]);
|
||||||
|
|
||||||
|
dictionary dict(is);
|
||||||
|
|
||||||
|
Info<< "read: " << dict << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (label argi = 1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
Info<< "Read delay: " << args[argi] << endl;
|
||||||
|
|
||||||
|
IFstreamDelayed is(args[argi]);
|
||||||
|
|
||||||
|
// Trigger strict warning?
|
||||||
|
Info<< "stream: " << is().name() << nl;
|
||||||
|
|
||||||
|
dictionary dict(is);
|
||||||
|
Info<< "read: " << dict << nl;
|
||||||
|
|
||||||
|
rewriteDict(dict);
|
||||||
|
|
||||||
|
Info<< "modified: " << dict << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
24
applications/test/compoundToken1/testDict1
Normal file
24
applications/test/compoundToken1/testDict1
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2312 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dictionary;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
internalField uniform 1;
|
||||||
|
|
||||||
|
temperature List<scalar> 10(270 271 272 273 274 275 276 277 278 279);
|
||||||
|
|
||||||
|
pressure 1e5;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
65
applications/test/compoundToken1/testDict2
Normal file
65
applications/test/compoundToken1/testDict2
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2312 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dictionary;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
internalField uniform 1;
|
||||||
|
|
||||||
|
// Regular syntax
|
||||||
|
valuesT List<scalar> (123 456 890);
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
temperature List<scalar>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (270 271 272 273 274 275 276 277 278 279);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
velocity List<vector>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (270 271 272 273 274 275 276 277 278 279);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
isGood List<bool>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (true false true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
master List<label>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values (0 100 35 50);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test some non-standard syntax
|
||||||
|
edges List<edge>
|
||||||
|
{
|
||||||
|
transport adios;
|
||||||
|
length 10;
|
||||||
|
values ((0 1) (2 1));
|
||||||
|
};
|
||||||
|
|
||||||
|
pressure 1e5;
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -61,7 +61,7 @@ void basicTests(const coordinateSystem& cs)
|
|||||||
|
|
||||||
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
|
if (const auto* cartptr = isA<coordSystem::cartesian>(cs))
|
||||||
{
|
{
|
||||||
if (!cartptr->valid())
|
if (!cartptr->good())
|
||||||
{
|
{
|
||||||
Info<< "invalid cartesian = " << (*cartptr)
|
Info<< "invalid cartesian = " << (*cartptr)
|
||||||
<< " with: " << (*cartptr).R() << nl;
|
<< " with: " << (*cartptr).R() << nl;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2021 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -17,8 +17,9 @@ Description
|
|||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "ITstream.H"
|
#include "ITstream.H"
|
||||||
#include "exprTraits.H"
|
|
||||||
#include "uLabel.H"
|
#include "uLabel.H"
|
||||||
|
|
||||||
|
#include "exprTraits.H"
|
||||||
#include "error.H"
|
#include "error.H"
|
||||||
#include "stringList.H"
|
#include "stringList.H"
|
||||||
#include "exprScanToken.H"
|
#include "exprScanToken.H"
|
||||||
@ -27,16 +28,18 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class Type>
|
||||||
void printTraits()
|
void printTraits()
|
||||||
{
|
{
|
||||||
const auto typeCode = exprTypeTraits<T>::value;
|
const auto typeCode = exprTypeTraits<Type>::value;
|
||||||
|
|
||||||
Info<< "type " << pTraits<T>::typeName
|
Info<< "Type '" << pTraits<Type>::typeName
|
||||||
<< " code:" << int(typeCode)
|
<< "' = code:" << int(typeCode)
|
||||||
<< " name:" << exprTypeTraits<T>::name;
|
<< " rank:" << exprTypeTraits<Type>::rank
|
||||||
|
<< " cmpt:" << exprTypeTraits<Type>::nComponents
|
||||||
|
<< " name:" << exprTypeTraits<Type>::name;
|
||||||
|
|
||||||
if (pTraits<T>::typeName != word(exprTypeTraits<T>::name))
|
if (pTraits<Type>::typeName != word(exprTypeTraits<Type>::name))
|
||||||
{
|
{
|
||||||
Info<< " (UNSUPPORTED)";
|
Info<< " (UNSUPPORTED)";
|
||||||
}
|
}
|
||||||
@ -45,6 +48,17 @@ void printTraits()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void print(const expressions::scanToken& tok)
|
||||||
|
{
|
||||||
|
Info<< " type:" << int(tok.type_);
|
||||||
|
if (tok.is_pointer())
|
||||||
|
{
|
||||||
|
Info<< " ptr:" << Foam::name(tok.name_);
|
||||||
|
}
|
||||||
|
Info<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@ -56,6 +70,7 @@ int main()
|
|||||||
printTraits<bool>();
|
printTraits<bool>();
|
||||||
printTraits<label>();
|
printTraits<label>();
|
||||||
printTraits<scalar>();
|
printTraits<scalar>();
|
||||||
|
printTraits<complex>();
|
||||||
printTraits<vector>();
|
printTraits<vector>();
|
||||||
printTraits<tensor>();
|
printTraits<tensor>();
|
||||||
printTraits<symmTensor>();
|
printTraits<symmTensor>();
|
||||||
@ -71,33 +86,27 @@ int main()
|
|||||||
Info<< "Name of typeCode: "
|
Info<< "Name of typeCode: "
|
||||||
<< getName(expressions::valueTypeCode::type_bool) << nl;
|
<< getName(expressions::valueTypeCode::type_bool) << nl;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
expressions::scanToken tok;
|
expressions::scanToken tok(expressions::scanToken::null());
|
||||||
expressions::scanToken tok2;
|
expressions::scanToken tok2(expressions::scanToken::null());
|
||||||
|
|
||||||
Info<< nl << "sizeof(scanToken): "
|
Info<< nl << "sizeof(scanToken): "
|
||||||
<< sizeof(tok) << nl;
|
<< sizeof(tok) << nl;
|
||||||
|
|
||||||
Info<< " type:" << int(tok.type_) << nl;
|
print(tok);
|
||||||
Info<< " ptr:" << Foam::name(tok.name_) << nl;
|
print(tok2);
|
||||||
|
|
||||||
Info<< " type:" << int(tok2.type_) << nl;
|
|
||||||
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
|
|
||||||
|
|
||||||
tok.setWord("hello");
|
tok.setWord("hello");
|
||||||
|
|
||||||
Info<< " type:" << int(tok.type_) << nl;
|
print(tok);
|
||||||
Info<< " ptr:" << Foam::name(tok.name_) << nl;
|
|
||||||
|
|
||||||
tok2 = tok;
|
tok2 = tok;
|
||||||
Info<< " type:" << int(tok2.type_) << nl;
|
print(tok2);
|
||||||
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
|
|
||||||
|
|
||||||
tok2.destroy();
|
tok2.destroy();
|
||||||
|
|
||||||
Info<< " type:" << int(tok2.type_) << nl;
|
print(tok); // Not a leak, but old rubbish
|
||||||
Info<< " ptr:" << Foam::name(tok2.name_) << nl;
|
print(tok2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "Done" << nl;
|
Info<< nl << "Done" << nl;
|
||||||
|
|||||||
3
applications/test/exprValue/Make/files
Normal file
3
applications/test/exprValue/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-exprValue.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-exprValue
|
||||||
2
applications/test/exprValue/Make/options
Normal file
2
applications/test/exprValue/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
141
applications/test/exprValue/Test-exprValue.C
Normal file
141
applications/test/exprValue/Test-exprValue.C
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-exprValue
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test low-level polymorphic value container (exprValue)
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "ITstream.H"
|
||||||
|
#include "exprValue.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
void printInfo(const expressions::exprValue& val)
|
||||||
|
{
|
||||||
|
Info<< "Boxed type:" << int(val.typeCode())
|
||||||
|
<< " (" << val.valueTypeName() << ") good:"
|
||||||
|
<< val.good() << " => " << val << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
expressions::exprValue tryParse(const std::string& str)
|
||||||
|
{
|
||||||
|
expressions::exprValue val, val2;
|
||||||
|
|
||||||
|
ITstream is(str);
|
||||||
|
|
||||||
|
const bool ok = val.read(is);
|
||||||
|
|
||||||
|
Info<< "read " << Foam::name(val.typeCode()) << " from " << str;
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
Info<< " trailing tokens:" << is.nRemainingTokens() << nl
|
||||||
|
<< "value: " << val << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " FAILED" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
Info<< "Direct from string: ";
|
||||||
|
if (expressions::exprValue::read(str, val2))
|
||||||
|
{
|
||||||
|
Info<< "good" << nl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "bad" << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noParallel();
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
// Aborts
|
||||||
|
// expressions::exprValue value(std::string(""));
|
||||||
|
|
||||||
|
{
|
||||||
|
expressions::exprValue value;
|
||||||
|
|
||||||
|
// Nothing
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value.set(scalar(100));
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value.set(vector(1,2,3));
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value = vector(4,5,6);
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value = Zero;
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value.clear();
|
||||||
|
printInfo(value);
|
||||||
|
|
||||||
|
value = 100 * vector(1,0,0);
|
||||||
|
printInfo(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
Info<< nl << "Test parsing" << nl << nl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
const auto& input :
|
||||||
|
stringList
|
||||||
|
({
|
||||||
|
"()", // bad
|
||||||
|
"( 1 2 ", // also bad
|
||||||
|
"( ", // really bad
|
||||||
|
"(1 16 12)",
|
||||||
|
"(1 bad)",
|
||||||
|
"(5)",
|
||||||
|
"1.2345",
|
||||||
|
"5.678 trailing",
|
||||||
|
"true",
|
||||||
|
"false",
|
||||||
|
" 1 ",
|
||||||
|
" yes no "
|
||||||
|
})
|
||||||
|
)
|
||||||
|
{
|
||||||
|
(void) tryParse(input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -38,7 +38,6 @@ Description
|
|||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
|
|
||||||
#include <csignal>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2022 OpenCFD Ltd.
|
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -139,7 +139,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
FixedList<label, 3> cellStats(Zero);
|
FixedList<label, 3> cellStats(Zero);
|
||||||
FixedList<label, 3> faceStats(Zero);
|
FixedList<label, 3> faceStats(Zero);
|
||||||
|
|
||||||
for (const auto& iter : mesh.cellZoneParts().sorted())
|
for (const auto& iter : mesh.cellZoneParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& iter : mesh.faceZoneParts().sorted())
|
for (const auto& iter : mesh.faceZoneParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& iter : mesh.boundaryParts().sorted())
|
for (const auto& iter : mesh.boundaryParts().csorted())
|
||||||
{
|
{
|
||||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||||
|
|
||||||
|
|||||||
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
|||||||
labelPair inOut;
|
labelPair inOut;
|
||||||
pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
|
pointField allCcs(globalNumbering.gather(mesh.cellCentres()));
|
||||||
inOut[0] = allCcs.size();
|
inOut[0] = allCcs.size();
|
||||||
Pstream::broadcast(allCcs);
|
Pstream::broadcastList(allCcs);
|
||||||
inOut[1] = allCcs.size();
|
inOut[1] = allCcs.size();
|
||||||
Pout<< " " << inOut << endl;
|
Pout<< " " << inOut << endl;
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Found: " << objects << nl << endl;
|
Info<< "Found: " << objects << nl << endl;
|
||||||
|
|
||||||
for (const IOobject& io : objects.sorted<uniformDimensionedVectorField>())
|
for (const IOobject& io : objects.csorted<uniformDimensionedVectorField>())
|
||||||
{
|
{
|
||||||
if (io.name() == meshObjects::gravity::typeName)
|
if (io.name() == meshObjects::gravity::typeName)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -68,25 +68,51 @@ int main(int argc, char *argv[])
|
|||||||
labelRange::debug = 1;
|
labelRange::debug = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl;
|
||||||
{
|
{
|
||||||
labelRange range(5, 10);
|
labelRange range(5, 10);
|
||||||
Info<< "identity: " << identity(range) << nl;
|
Info<< "identity: " << identity(range) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Info<<"test sorting" << endl;
|
Info<< "test sorting" << endl;
|
||||||
DynamicList<labelRange> list1(10);
|
labelRanges list1(10);
|
||||||
|
|
||||||
list1.emplace_back(25, 8);
|
list1.emplace_back(25, 8);
|
||||||
list1.emplace_back(8);
|
list1.emplace_back(8);
|
||||||
list1.emplace_back(15, 5);
|
list1.emplace_back(15, 5);
|
||||||
list1.emplace_back(50, -10, true);
|
list1.emplace_back(50, -10, true);
|
||||||
|
|
||||||
sort(list1);
|
// Move construct
|
||||||
Info<<"sorted" << list1 << endl;
|
labelRanges ranges(std::move(list1));
|
||||||
|
if (!list1.empty())
|
||||||
|
{
|
||||||
|
Info<< "Move construct failed? "
|
||||||
|
<< flatOutput(list1.ranges()) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "unsorted: ";
|
||||||
|
ranges.writeList(Info) << nl;
|
||||||
|
|
||||||
|
ranges.sort();
|
||||||
|
Info<< "sorted: ";
|
||||||
|
ranges.writeList(Info) << nl;
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "list linear length = " << ranges.totalSize() << nl;
|
||||||
|
|
||||||
|
Info<< "list labels = ";
|
||||||
|
ranges.labels().writeList(Info) << nl;
|
||||||
|
|
||||||
|
Info<< nl;
|
||||||
|
for (int i : { -1, 0, 5, 8, 10, 20, 26 })
|
||||||
|
{
|
||||||
|
Info<< "value at [" << i << "] = " << ranges[i] << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Info<<"test intersections" << endl;
|
Info<< "test intersections" << endl;
|
||||||
labelRange range1(-15, 25);
|
labelRange range1(-15, 25);
|
||||||
labelRange range2(7, 8);
|
labelRange range2(7, 8);
|
||||||
labelRange range3(-20, 8);
|
labelRange range3(-20, 8);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -78,8 +78,8 @@ void printRegistry
|
|||||||
Foam::label indent
|
Foam::label indent
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UPtrList<const regIOobject> objects(obr.sorted());
|
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||||
|
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
for (label i=indent; i; --i)
|
for (label i=indent; i; --i)
|
||||||
|
|||||||
@ -145,8 +145,8 @@ void printRegistry
|
|||||||
Foam::label indent
|
Foam::label indent
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UPtrList<const regIOobject> objects(obr.sorted());
|
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||||
|
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
for (label i=indent; i; --i)
|
for (label i=indent; i; --i)
|
||||||
@ -315,7 +315,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
registryTests(mesh);
|
registryTests(mesh);
|
||||||
|
|
||||||
report(mesh.sorted<const volScalarField>());
|
report(mesh.csorted<volScalarField>());
|
||||||
report(mesh.csorted<volVectorField>());
|
report(mesh.csorted<volVectorField>());
|
||||||
|
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,9 +30,12 @@ Description
|
|||||||
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "pTraits.H"
|
#include "pTraits.H"
|
||||||
|
#include "contiguous.H"
|
||||||
|
#include "boolVector.H" // A FixedList pretending to be a vector
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
#include "tensor.H"
|
#include "tensor.H"
|
||||||
#include "uLabel.H"
|
#include "uLabel.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -40,14 +44,72 @@ using namespace Foam;
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
|
//- Test if Type has typeName member
|
||||||
|
template<class T, class = void>
|
||||||
|
struct has_typeName : std::false_type {};
|
||||||
|
|
||||||
|
//- Test if Type has typeName member
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct has_typeName<T, stdFoam::void_t<decltype(pTraits<T>::typeName)>>
|
||||||
|
:
|
||||||
|
std::true_type
|
||||||
|
{};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<has_typeName<T>::value, void>::type
|
||||||
|
printTypeName()
|
||||||
|
{
|
||||||
|
Info<< pTraits<T>::typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<!has_typeName<T>::value, void>::type
|
||||||
|
printTypeName()
|
||||||
|
{
|
||||||
|
Info<< typeid(T).name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class = void>
|
||||||
|
struct has_zero_one : std::false_type {};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct has_zero_one
|
||||||
|
<
|
||||||
|
T,
|
||||||
|
stdFoam::void_t<decltype(pTraits<T>::zero), decltype(pTraits<T>::one)>
|
||||||
|
> : std::true_type {};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<has_zero_one<T>::value, void>::type
|
||||||
|
printMinMaxRange()
|
||||||
|
{
|
||||||
|
Info<< " zero=" << pTraits<T>::zero
|
||||||
|
<< " one=" << pTraits<T>::one;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
typename std::enable_if<!has_zero_one<T>::value, void>::type
|
||||||
|
printMinMaxRange()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
void printTraits()
|
void printTraits()
|
||||||
{
|
{
|
||||||
Info<< pTraits<T>::typeName
|
printTypeName<T>();
|
||||||
<< ": zero=" << pTraits<T>::zero
|
printMinMaxRange<T>();
|
||||||
<< " one=" << pTraits<T>::one
|
|
||||||
<< " integral=" << std::is_integral<T>::value
|
Info<< " integral=" << std::is_integral<T>::value
|
||||||
<< " floating=" << std::is_floating_point<T>::value
|
<< " floating=" << std::is_floating_point<T>::value
|
||||||
|
<< " rank=" << pTraits_rank<T>::value
|
||||||
|
<< " nComponents=" << pTraits_nComponents<T>::value
|
||||||
|
<< " vector-space=" << Switch::name(is_vectorspace<T>::value)
|
||||||
|
<< " is_label=" << Switch::name(is_contiguous_label<T>::value)
|
||||||
|
<< " is_scalar=" << Switch::name(is_contiguous_scalar<T>::value)
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,6 +131,9 @@ int main()
|
|||||||
printTraits<scalar>();
|
printTraits<scalar>();
|
||||||
printTraits<vector>();
|
printTraits<vector>();
|
||||||
printTraits<tensor>();
|
printTraits<tensor>();
|
||||||
|
printTraits<boolVector>();
|
||||||
|
printTraits<word>();
|
||||||
|
printTraits<std::string>();
|
||||||
|
|
||||||
{
|
{
|
||||||
pTraits<bool> b(true);
|
pTraits<bool> b(true);
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2022 OpenCFD Ltd.
|
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -75,6 +75,16 @@ void testBroadcast(List<T>& values)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void testBroadcast(std::vector<T>& values)
|
||||||
|
{
|
||||||
|
Info<< nl << "is_contiguous:" << is_contiguous<T>::value << endl;
|
||||||
|
Pout<< "pre-broadcast: " << flatOutput(values) << endl;
|
||||||
|
Pstream::broadcast(values);
|
||||||
|
Pout<< "post-broadcast: " << flatOutput(values) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void testBroadcast(bitSet& values)
|
void testBroadcast(bitSet& values)
|
||||||
{
|
{
|
||||||
Pout<< "pre-broadcast: "
|
Pout<< "pre-broadcast: "
|
||||||
@ -135,6 +145,20 @@ int main(int argc, char *argv[])
|
|||||||
testBroadcast(values);
|
testBroadcast(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<word> values;
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
values.resize(UPstream::nProcs());
|
||||||
|
|
||||||
|
for (decltype(values.size()) i=0; i < values.size(); ++i)
|
||||||
|
{
|
||||||
|
values[i] = "vector_" + Foam::name(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testBroadcast(values);
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
vector values(vector::uniform(-1));
|
vector values(vector::uniform(-1));
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
|
|||||||
@ -39,6 +39,7 @@ Description
|
|||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "PstreamReduceOps.H"
|
#include "PstreamReduceOps.H"
|
||||||
|
#include "bitSet.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -87,7 +88,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Reductions (using MPI intrinsics)
|
// Reductions (using MPI intrinsics)
|
||||||
{
|
{
|
||||||
label val = Pstream::myProcNo(UPstream::commWorld());
|
const label myRank = UPstream::myProcNo(UPstream::commWorld());
|
||||||
|
const label nProcs = UPstream::nProcs(UPstream::commWorld());
|
||||||
|
|
||||||
|
label val = myRank;
|
||||||
|
|
||||||
label worldVal = returnReduce
|
label worldVal = returnReduce
|
||||||
(
|
(
|
||||||
@ -108,6 +112,52 @@ int main(int argc, char *argv[])
|
|||||||
Pout<< "value " << val
|
Pout<< "value " << val
|
||||||
<< " (world) reduced " << worldVal
|
<< " (world) reduced " << worldVal
|
||||||
<< " (self) reduced " << selfVal << nl;
|
<< " (self) reduced " << selfVal << nl;
|
||||||
|
|
||||||
|
// Identical size on all procs
|
||||||
|
bitSet procUsed(nProcs);
|
||||||
|
|
||||||
|
if ((myRank % 4) == 0)
|
||||||
|
{
|
||||||
|
procUsed.set(myRank);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "local procUsed " << procUsed << nl;
|
||||||
|
reduce
|
||||||
|
(
|
||||||
|
procUsed.data(),
|
||||||
|
procUsed.size_data(),
|
||||||
|
bitOrOp<unsigned int>()
|
||||||
|
);
|
||||||
|
Pout<< "reduce procUsed " << procUsed << nl;
|
||||||
|
|
||||||
|
// Identical size on all procs
|
||||||
|
// encode as 0:empty, 1:uniform, 2:nonuniform, 3:mixed
|
||||||
|
PackedList<2> uniformity(10);
|
||||||
|
|
||||||
|
if ((myRank % 2) == 0)
|
||||||
|
{
|
||||||
|
// Every second is uniform
|
||||||
|
uniformity.set(2, 1);
|
||||||
|
uniformity.set(4, 1);
|
||||||
|
uniformity.set(6, 1);
|
||||||
|
uniformity.set(8, 1);
|
||||||
|
}
|
||||||
|
else if ((myRank % 3) == 0)
|
||||||
|
{
|
||||||
|
// Every third is nonuniform
|
||||||
|
uniformity.set(3, 2);
|
||||||
|
uniformity.set(6, 2);
|
||||||
|
uniformity.set(9, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "local uniform " << uniformity << nl;
|
||||||
|
reduce
|
||||||
|
(
|
||||||
|
uniformity.data(),
|
||||||
|
uniformity.size_data(),
|
||||||
|
bitOrOp<unsigned int>()
|
||||||
|
);
|
||||||
|
Pout<< "reduce uniform " << uniformity << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reductions (not using MPI intrinsics)
|
// Reductions (not using MPI intrinsics)
|
||||||
|
|||||||
3
applications/test/parallel-waitSome/Make/files
Normal file
3
applications/test/parallel-waitSome/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-parallel-waitSome.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-parallel-waitSome
|
||||||
2
applications/test/parallel-waitSome/Make/options
Normal file
2
applications/test/parallel-waitSome/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
328
applications/test/parallel-waitSome/Test-parallel-waitSome.C
Normal file
328
applications/test/parallel-waitSome/Test-parallel-waitSome.C
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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-parallel-waitSome
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test polling versus wait-all for processing receive data.
|
||||||
|
Will not see much difference between -wait-all and -no-polling though
|
||||||
|
since the master doesn't have enough other work.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "List.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IPstream.H"
|
||||||
|
#include "OPstream.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
#include "clockTime.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
|
||||||
|
// The 'classic' waiting receive, but also only waiting for recv request
|
||||||
|
template<class Type>
|
||||||
|
void waitingReceive
|
||||||
|
(
|
||||||
|
const labelRange& recvRequests,
|
||||||
|
const List<List<Type>>& recvBuffers,
|
||||||
|
const bool waitAll = false
|
||||||
|
)
|
||||||
|
{
|
||||||
|
clockTime waitTiming;
|
||||||
|
|
||||||
|
if (waitAll)
|
||||||
|
{
|
||||||
|
// Wait for send and recv (assumes recv followed by send)
|
||||||
|
UPstream::waitRequests(recvRequests.start(), -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wait for receives only
|
||||||
|
UPstream::waitRequests(recvRequests.start(), recvRequests.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
double waited = waitTiming.timeIncrement();
|
||||||
|
if (waited > 1e-3)
|
||||||
|
{
|
||||||
|
Pout<< "waited: " << waited << " before processing" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(recvBuffers, proci)
|
||||||
|
{
|
||||||
|
const auto& slice = recvBuffers[proci];
|
||||||
|
|
||||||
|
if (!slice.empty())
|
||||||
|
{
|
||||||
|
// Process data from proci
|
||||||
|
Pout<< "proc:" << proci
|
||||||
|
<< ' ' << flatOutput(slice) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Polling receive
|
||||||
|
template<class Type>
|
||||||
|
void pollingReceive
|
||||||
|
(
|
||||||
|
const labelRange& recvRequests,
|
||||||
|
const UList<int>& recvProcs,
|
||||||
|
const List<List<Type>>& recvBuffers
|
||||||
|
)
|
||||||
|
{
|
||||||
|
clockTime waitTiming;
|
||||||
|
|
||||||
|
DynamicList<int> indices(recvRequests.size());
|
||||||
|
|
||||||
|
if (!recvRequests.empty()) Pout<< "..." << endl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
label loop = 0;
|
||||||
|
UPstream::waitSomeRequests
|
||||||
|
(
|
||||||
|
recvRequests.start(),
|
||||||
|
recvRequests.size(),
|
||||||
|
&indices
|
||||||
|
);
|
||||||
|
++loop
|
||||||
|
)
|
||||||
|
{
|
||||||
|
double waited = waitTiming.timeIncrement();
|
||||||
|
if (waited <= 1e-3)
|
||||||
|
{
|
||||||
|
waited = 0;
|
||||||
|
}
|
||||||
|
Pout<< "loop:" << loop
|
||||||
|
<< " waited: " << waited
|
||||||
|
<< " before processing" << endl;
|
||||||
|
|
||||||
|
for (const int idx : indices)
|
||||||
|
{
|
||||||
|
const int proci = recvProcs[idx];
|
||||||
|
const auto& slice = recvBuffers[proci];
|
||||||
|
|
||||||
|
// Process data from proci
|
||||||
|
Pout<< "loop:" << loop << " polled:" << indices.size()
|
||||||
|
<< " proc:" << proci
|
||||||
|
<< ' ' << flatOutput(slice) << endl;
|
||||||
|
}
|
||||||
|
Pout<< "..." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
argList::addVerboseOption("timings etc");
|
||||||
|
argList::addBoolOption("no-polling", "wait all instead of polling");
|
||||||
|
argList::addBoolOption("wait-all", "wait all instead of polling");
|
||||||
|
argList::addOption("sleep", "s", "change sleep (default: 5)");
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
|
||||||
|
const label transferSize = 10;
|
||||||
|
label sleepSeconds = 5;
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
args.readIfPresent("sleep", sleepSeconds);
|
||||||
|
const bool waitAll = args.found("wait-all");
|
||||||
|
const bool nonPolling = args.found("no-polling");
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Calling with sleep=" << sleepSeconds
|
||||||
|
<< ", polling=" << Switch::name(!nonPolling)
|
||||||
|
<< ", wait-all=" << Switch::name(waitAll) << nl;
|
||||||
|
|
||||||
|
labelList sendBuffer;
|
||||||
|
List<labelList> recvBuffers;
|
||||||
|
|
||||||
|
if (UPstream::master())
|
||||||
|
{
|
||||||
|
recvBuffers.resize(UPstream::nProcs());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
recvBuffers.resize(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
clockTime timing;
|
||||||
|
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
|
// Setup receives
|
||||||
|
labelRange recvRequests(UPstream::nRequests(), 0);
|
||||||
|
DynamicList<int> recvProcs(UPstream::nProcs());
|
||||||
|
|
||||||
|
if (UPstream::master())
|
||||||
|
{
|
||||||
|
for (const int proci : UPstream::subProcs())
|
||||||
|
{
|
||||||
|
// The rank corresponding to the request
|
||||||
|
recvProcs.push_back(proci);
|
||||||
|
auto& slice = recvBuffers[proci];
|
||||||
|
slice.resize_nocopy(transferSize);
|
||||||
|
|
||||||
|
UIPstream::read
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
proci,
|
||||||
|
slice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int proci = UPstream::masterNo();
|
||||||
|
|
||||||
|
if ((UPstream::myProcNo() % 2) == 0)
|
||||||
|
{
|
||||||
|
recvProcs.push_back(proci);
|
||||||
|
auto& slice = recvBuffers[proci];
|
||||||
|
slice.resize_nocopy(transferSize);
|
||||||
|
|
||||||
|
UIPstream::read
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
proci,
|
||||||
|
slice
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// OR: recvRequests.size() = (UPstream::nRequests() - recvRequests.start());
|
||||||
|
recvRequests += recvProcs.size();
|
||||||
|
|
||||||
|
|
||||||
|
labelList overallRecvRequests
|
||||||
|
(
|
||||||
|
UPstream::listGatherValues<label>(recvRequests.size())
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Number of recv requests: "
|
||||||
|
<< flatOutput(overallRecvRequests) << nl << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Setup sends
|
||||||
|
sendBuffer.resize_nocopy(transferSize);
|
||||||
|
sendBuffer = UPstream::myProcNo();
|
||||||
|
|
||||||
|
const auto startBufferSend = [&]() -> void
|
||||||
|
{
|
||||||
|
if (sleepSeconds > 0)
|
||||||
|
{
|
||||||
|
// Dispatch some immediately, others with a delay
|
||||||
|
if ((UPstream::myProcNo() % 2) == 0)
|
||||||
|
{
|
||||||
|
sleep(sleepSeconds);
|
||||||
|
}
|
||||||
|
else if ((UPstream::myProcNo() % 3) == 0)
|
||||||
|
{
|
||||||
|
sleep(1.5*sleepSeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UOPstream::write
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
UPstream::masterNo(),
|
||||||
|
sendBuffer
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if (UPstream::master())
|
||||||
|
{
|
||||||
|
for (const int proci : UPstream::subProcs())
|
||||||
|
{
|
||||||
|
if ((UPstream::myProcNo() % 2) == 0)
|
||||||
|
{
|
||||||
|
UOPstream::write
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
proci,
|
||||||
|
sendBuffer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (waitAll)
|
||||||
|
{
|
||||||
|
startBufferSend();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Some skulduggery to get a differential in timings...
|
||||||
|
|
||||||
|
const int nloops = (UPstream::master() ? 1 : 2);
|
||||||
|
|
||||||
|
for (int loopi = 0; loopi < nloops; ++loopi)
|
||||||
|
{
|
||||||
|
if (waitAll || nonPolling)
|
||||||
|
{
|
||||||
|
waitingReceive(recvRequests, recvBuffers, waitAll);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pollingReceive(recvRequests, recvProcs, recvBuffers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timing for processing all the receives
|
||||||
|
if (args.verbose())
|
||||||
|
{
|
||||||
|
Pout<< "receive: " << timing.timeIncrement() << 's' << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!UPstream::master() && loopi == 0 && !waitAll)
|
||||||
|
{
|
||||||
|
startBufferSend();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.verbose())
|
||||||
|
{
|
||||||
|
Pout<< "timing: " << timing.elapsedTime() << 's' << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Final
|
||||||
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
|
||||||
|
Info<< "End\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -33,7 +33,7 @@ Description
|
|||||||
|
|
||||||
#include "scalar.H"
|
#include "scalar.H"
|
||||||
#include "FlatOutput.H"
|
#include "FlatOutput.H"
|
||||||
#include "ListStream.H"
|
#include "SpanStream.H"
|
||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
#include "NASCore.H"
|
#include "NASCore.H"
|
||||||
#include "parsing.H"
|
#include "parsing.H"
|
||||||
@ -443,22 +443,22 @@ int main(int argc, char *argv[])
|
|||||||
<< " read " << sizeof(scalar) << nl;
|
<< " read " << sizeof(scalar) << nl;
|
||||||
|
|
||||||
List<otherType> srcList(15);
|
List<otherType> srcList(15);
|
||||||
|
|
||||||
forAll(srcList, i)
|
forAll(srcList, i)
|
||||||
{
|
{
|
||||||
srcList[i] = 1 + 10*i;
|
srcList[i] = 1 + 10*i;
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicList<char> buf;
|
OCharStream os(IOstreamOption::BINARY);
|
||||||
|
|
||||||
OListStream os(std::move(buf), IOstreamOption::BINARY);
|
|
||||||
os << srcList;
|
os << srcList;
|
||||||
|
|
||||||
os.swap(buf); // Recover buffer
|
DynamicList<char> buf;
|
||||||
|
os.swap(buf); // Recover written contents
|
||||||
|
|
||||||
// Read back
|
// Read back
|
||||||
List<scalar> dstList;
|
List<scalar> dstList;
|
||||||
|
|
||||||
UIListStream is(buf, IOstreamOption::BINARY);
|
ISpanStream is(buf, IOstreamOption::BINARY);
|
||||||
is.setScalarByteSize(sizeof(otherType));
|
is.setScalarByteSize(sizeof(otherType));
|
||||||
|
|
||||||
Info<< "Stream scalar-size ("
|
Info<< "Stream scalar-size ("
|
||||||
|
|||||||
3
applications/test/readBroadcast1/Make/files
Normal file
3
applications/test/readBroadcast1/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-readBroadcast1.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-readBroadcast1
|
||||||
2
applications/test/readBroadcast1/Make/options
Normal file
2
applications/test/readBroadcast1/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
297
applications/test/readBroadcast1/Test-readBroadcast1.C
Normal file
297
applications/test/readBroadcast1/Test-readBroadcast1.C
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test file reading with broadcast
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "OSspecific.H" // For fileSize()
|
||||||
|
#include "Fstream.H"
|
||||||
|
#include "Pstream.H"
|
||||||
|
#include "SpanStream.H"
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool optUseSeek = false;
|
||||||
|
bool optVerbose = false;
|
||||||
|
|
||||||
|
// Get file contents. Usually master-only and broadcast
|
||||||
|
static List<char> slurpFile
|
||||||
|
(
|
||||||
|
const fileName& pathname,
|
||||||
|
const bool parallel = UPstream::parRun(),
|
||||||
|
const bool masterOnly = true
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "slurp master-only:" << masterOnly
|
||||||
|
<< " broadcast:" << (masterOnly && parallel)
|
||||||
|
<< " seek:" << optUseSeek
|
||||||
|
<< " file: " << pathname << nl;
|
||||||
|
|
||||||
|
if (optUseSeek)
|
||||||
|
{
|
||||||
|
Info<< "Rewinding gzstream does not work..." << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------
|
||||||
|
|
||||||
|
List<char> buffer;
|
||||||
|
|
||||||
|
ifstreamPointer ifp;
|
||||||
|
|
||||||
|
if (UPstream::master() || !masterOnly)
|
||||||
|
{
|
||||||
|
ifp.open(pathname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ifp && ifp->good())
|
||||||
|
{
|
||||||
|
Info<< "compressed:"
|
||||||
|
<< (IOstreamOption::COMPRESSED == ifp.whichCompression()) << nl;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
uint64_t inputSize = Foam::fileSize(pathname);
|
||||||
|
|
||||||
|
if (IOstreamOption::COMPRESSED == ifp.whichCompression())
|
||||||
|
{
|
||||||
|
ifp->ignore(std::numeric_limits<std::streamsize>::max());
|
||||||
|
|
||||||
|
const std::streamsize nread = ifp->gcount();
|
||||||
|
|
||||||
|
if (nread == std::numeric_limits<std::streamsize>::max())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Failed call to ignore()" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
inputSize = ifp->gcount();
|
||||||
|
|
||||||
|
if (optUseSeek)
|
||||||
|
{
|
||||||
|
// Rewinding gzstream does not really work...
|
||||||
|
ifp->rdbuf()->pubseekpos(0, std::ios_base::in);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Open it again - gzstream rewinding is unreliable...
|
||||||
|
ifp.open(pathname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.resize(label(inputSize));
|
||||||
|
ifp->read(buffer.data(), buffer.size_bytes());
|
||||||
|
|
||||||
|
const std::streamsize nread = ifp->gcount();
|
||||||
|
|
||||||
|
if (nread == std::numeric_limits<std::streamsize>::max())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Failed call to read()" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.resize(label(nread)); // Extra safety (paranoid)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
if (IOstreamOption::COMPRESSED == ifp.whichCompression())
|
||||||
|
{
|
||||||
|
// For compressed files we do not have any idea how large
|
||||||
|
// the result will be. So read chunk-wise.
|
||||||
|
// Using the compressed size for the chunk size:
|
||||||
|
// 50% compression = 2 iterations
|
||||||
|
// 66% compression = 3 iterations
|
||||||
|
// ...
|
||||||
|
|
||||||
|
const auto inputSize = Foam::fileSize(pathname + ".gz");
|
||||||
|
|
||||||
|
const uint64_t chunkSize =
|
||||||
|
(
|
||||||
|
(inputSize <= 1024)
|
||||||
|
? uint64_t(4096)
|
||||||
|
: uint64_t(2*inputSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
uint64_t beg = 0;
|
||||||
|
|
||||||
|
bool normalExit = false;
|
||||||
|
|
||||||
|
for (int iter = 1; iter < 100000; ++iter)
|
||||||
|
{
|
||||||
|
if (optVerbose)
|
||||||
|
{
|
||||||
|
Info<< "iter " << iter << nl;
|
||||||
|
Info<< "chunk " << label(chunkSize) << nl;
|
||||||
|
Info<< "size " << label(iter * chunkSize) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.resize(label(iter * chunkSize));
|
||||||
|
ifp->read(buffer.data() + beg, chunkSize);
|
||||||
|
|
||||||
|
const std::streamsize nread = ifp->gcount();
|
||||||
|
|
||||||
|
if (optVerbose)
|
||||||
|
{
|
||||||
|
Info<< "nread: " << nread << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
nread < 0
|
||||||
|
|| nread == std::numeric_limits<std::streamsize>::max()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (iter == 0)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Failed call to read()" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
beg += uint64_t(nread);
|
||||||
|
if (nread >= 0 && uint64_t(nread) < chunkSize)
|
||||||
|
{
|
||||||
|
normalExit = true;
|
||||||
|
if (optVerbose)
|
||||||
|
{
|
||||||
|
Info<< "stopped after "
|
||||||
|
<< iter << " iterations" << nl;
|
||||||
|
}
|
||||||
|
buffer.resize(label(beg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!normalExit)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Abnormal exit" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto inputSize = Foam::fileSize(pathname);
|
||||||
|
|
||||||
|
if (inputSize >= 0)
|
||||||
|
{
|
||||||
|
buffer.resize(label(inputSize));
|
||||||
|
ifp->read(buffer.data(), buffer.size_bytes());
|
||||||
|
|
||||||
|
const std::streamsize nread = ifp->gcount();
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
nread < 0
|
||||||
|
|| nread == std::numeric_limits<std::streamsize>::max()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Failed call to read()" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.resize(label(nread)); // Extra safety (paranoid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done with input file
|
||||||
|
ifp.reset(nullptr);
|
||||||
|
|
||||||
|
if (parallel && masterOnly)
|
||||||
|
{
|
||||||
|
// On the assumption of larger files,
|
||||||
|
// prefer two broadcasts instead of serialization
|
||||||
|
Pstream::broadcastList(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noFunctionObjects();
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
argList::addBoolOption("seek", "seek with gzstream (fails!)");
|
||||||
|
argList::addVerboseOption("addition information");
|
||||||
|
argList::addBoolOption("seek", "seek with gzstream");
|
||||||
|
argList::addBoolOption("no-broadcast", "suppress broadcast contents");
|
||||||
|
|
||||||
|
argList::addNote("Test master-only reading (with broadcast)");
|
||||||
|
|
||||||
|
argList::addArgument("srcFile");
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
const bool syncPar = (UPstream::parRun() && !args.found("no-broadcast"));
|
||||||
|
optUseSeek = args.found("seek");
|
||||||
|
optVerbose = args.verbose();
|
||||||
|
|
||||||
|
auto srcName = args.get<fileName>(1);
|
||||||
|
|
||||||
|
if (srcName.has_ext("gz"))
|
||||||
|
{
|
||||||
|
srcName.remove_ext();
|
||||||
|
Info<< "stripping extraneous .gz ending" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICharStream is;
|
||||||
|
|
||||||
|
{
|
||||||
|
List<char> buffer(slurpFile(srcName, syncPar));
|
||||||
|
|
||||||
|
is.swap(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "input:" << is.capacity() << endl;
|
||||||
|
|
||||||
|
for (string line; is.getLine(line); /*nil*/)
|
||||||
|
{
|
||||||
|
Pout<< "L:" << is.lineNumber() << ": " << line.c_str() << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2020-2022 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -105,12 +105,21 @@ int main()
|
|||||||
Info<< nl << "Construct from reference" << nl;
|
Info<< nl << "Construct from reference" << nl;
|
||||||
|
|
||||||
scalarField f2(10, Foam::sqrt(2.0));
|
scalarField f2(10, Foam::sqrt(2.0));
|
||||||
printInfo(refPtr<scalarField>(f2), true);
|
refPtr<scalarField> tfld2(f2);
|
||||||
|
printInfo(tfld2, true);
|
||||||
|
|
||||||
|
Info<< nl << "emplaced:"<< nl;
|
||||||
|
tfld2.emplace(25, scalar(1));
|
||||||
|
printInfo(tfld2, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Info<< nl << "Construct from New (is_pointer)" << nl;
|
Info<< nl << "Construct from New (is_pointer)" << nl;
|
||||||
auto tfld1 = refPtr<scalarField>::New(10, scalar(1));
|
auto tfld1 = refPtr<scalarField>::New(10, scalar(-1));
|
||||||
|
printInfo(tfld1, true);
|
||||||
|
|
||||||
|
Info<< nl << "emplaced:"<< nl;
|
||||||
|
tfld1.emplace(15, scalar(1));
|
||||||
printInfo(tfld1, true);
|
printInfo(tfld1, true);
|
||||||
|
|
||||||
Info<< nl << "Dereferenced: " << *tfld1 << nl;
|
Info<< nl << "Dereferenced: " << *tfld1 << nl;
|
||||||
|
|||||||
@ -51,13 +51,30 @@ int main(int argc, char *argv[])
|
|||||||
hmm.source()[1] = vector(1.0, 4.0, 3.0);
|
hmm.source()[1] = vector(1.0, 4.0, 3.0);
|
||||||
hmm.source()[2] = vector(0.0, 5.0, 2.0);
|
hmm.source()[2] = vector(0.0, 5.0, 2.0);
|
||||||
|
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
Info<< hmm.solve() << endl;
|
Info<< hmm.solve() << nl;
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
Info<< hmm.LUsolve() << endl;
|
Info<< hmm.LUsolve() << nl;
|
||||||
Info<< hmm << endl;
|
Info<< hmm << nl;
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
{
|
||||||
|
scalarSquareMatrix mat0;
|
||||||
|
Info<< "empty: " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(1);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (1x1): " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(3);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (3x3): " << mat0 << endl;
|
||||||
|
|
||||||
|
mat0.resize_nocopy(5);
|
||||||
|
mat0 = Identity<scalar>();
|
||||||
|
Info<< "ident (5x5): " << mat0 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
@ -78,7 +78,10 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto tfld1 = tmp<scalarField>::New(20, Zero);
|
auto tfld1 = tmp<scalarField>::New(10, Zero);
|
||||||
|
printInfo(tfld1, true);
|
||||||
|
|
||||||
|
tfld1.emplace(20, Zero);
|
||||||
printInfo(tfld1, true);
|
printInfo(tfld1, true);
|
||||||
|
|
||||||
// Hold on to the old content for a bit
|
// Hold on to the old content for a bit
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -34,6 +34,7 @@ Description
|
|||||||
#include "StringStream.H"
|
#include "StringStream.H"
|
||||||
#include "cpuTime.H"
|
#include "cpuTime.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
|
#include "scalarList.H"
|
||||||
#include "DynamicList.H"
|
#include "DynamicList.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
@ -49,7 +50,7 @@ int main(int argc, char *argv[])
|
|||||||
argList args(argc, argv, false, true);
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
token tok1;
|
token tok1;
|
||||||
Info<< "construct null: " << tok1.info() << endl;
|
Info<< "default construct: " << tok1.info() << endl;
|
||||||
|
|
||||||
tok1 = double(3.14159);
|
tok1 = double(3.14159);
|
||||||
Info<< "assign double: " << tok1.info() << endl;
|
Info<< "assign double: " << tok1.info() << endl;
|
||||||
@ -81,7 +82,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
token ctok1(new token::Compound<labelList>(identity(10)));
|
token ctok1(new token::Compound<labelList>(identity(10)));
|
||||||
|
|
||||||
Info<< "compound token: " << ctok1.info() << nl << ctok1 << endl;
|
Info<< "compound from pointer: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -94,26 +96,155 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
token ctok1(ptr.release()); // release() not get()!
|
token ctok1(ptr.release()); // release() not get()!
|
||||||
|
|
||||||
Info<< "compound token: " << ctok1.info() << nl << ctok1 << endl;
|
Info<< "compound from autoPtr: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
{
|
{
|
||||||
// This version will segfault.
|
// Construct from pointer
|
||||||
// The implicit pointer cast from autoPtr to pointer wracks havoc
|
autoPtr<token::compound> ptr
|
||||||
|
|
||||||
autoPtr<token::Compound<labelList>> ptr
|
|
||||||
(
|
(
|
||||||
new token::Compound<labelList>(identity(10))
|
token::compound::New("List<label>")
|
||||||
);
|
);
|
||||||
|
|
||||||
token ctok1(ptr);
|
token ctok1(ptr.release()); // release() not get()!
|
||||||
|
|
||||||
Info<< "compound token: " << ctok1.info() << nl << ctok1 << endl;
|
Info<< "compound from New (via pointer): "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Construct from autoPtr
|
||||||
|
autoPtr<token::compound> ptr
|
||||||
|
(
|
||||||
|
token::Compound<scalarList>::New(10, 1.0)
|
||||||
|
);
|
||||||
|
|
||||||
|
token ctok1(std::move(ptr));
|
||||||
|
Info<< "compound from autoPtr: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
|
||||||
|
// Shrink
|
||||||
|
ctok1.refCompoundToken().resize(5);
|
||||||
|
|
||||||
|
Info<< "resized: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
|
||||||
|
const scalarList* listptr = ctok1.compoundToken().isA<scalarList>();
|
||||||
|
if (listptr)
|
||||||
|
{
|
||||||
|
for (scalar& val : const_cast<scalarList&>(*listptr))
|
||||||
|
{
|
||||||
|
val *= 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "multiplied List<scalar>: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
listptr = ctok1.isCompound<scalarList>();
|
||||||
|
if (listptr)
|
||||||
|
{
|
||||||
|
for (scalar& val : const_cast<scalarList&>(*listptr))
|
||||||
|
{
|
||||||
|
val /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "divided List<scalar>: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const labelList* listptr2 = ctok1.isCompound<labelList>();
|
||||||
|
if (listptr2)
|
||||||
|
{
|
||||||
|
for (label& val : const_cast<labelList&>(*listptr2))
|
||||||
|
{
|
||||||
|
val /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "divided List<label>: "
|
||||||
|
<< ctok1.info() << nl << ctok1 << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "compound is not List<label>" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Before fill_zero: " << ctok1 << endl;
|
||||||
|
|
||||||
|
ctok1.refCompoundToken().fill_zero();
|
||||||
|
|
||||||
|
Info<< "After fill_zero: " << ctok1 << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (ctok1.isCompound())
|
||||||
|
{
|
||||||
|
auto& ct = ctok1.refCompoundToken();
|
||||||
|
|
||||||
|
ct.resize(20);
|
||||||
|
bool handled = true;
|
||||||
|
|
||||||
|
switch (ct.typeCode())
|
||||||
|
{
|
||||||
|
case token::tokenType::BOOL :
|
||||||
|
{
|
||||||
|
UList<bool> cmpts
|
||||||
|
(
|
||||||
|
reinterpret_cast<bool*>(ct.data_bytes()),
|
||||||
|
label(ct.size_bytes() / sizeof(bool))
|
||||||
|
);
|
||||||
|
cmpts = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::LABEL :
|
||||||
|
{
|
||||||
|
UList<label> cmpts
|
||||||
|
(
|
||||||
|
reinterpret_cast<label*>(ct.data_bytes()),
|
||||||
|
label(ct.size_bytes() / sizeof(label))
|
||||||
|
);
|
||||||
|
cmpts = 123;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::FLOAT :
|
||||||
|
{
|
||||||
|
UList<float> cmpts
|
||||||
|
(
|
||||||
|
reinterpret_cast<float*>(ct.data_bytes()),
|
||||||
|
label(ct.size_bytes() / sizeof(float))
|
||||||
|
);
|
||||||
|
cmpts = 2.7;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case token::tokenType::DOUBLE :
|
||||||
|
{
|
||||||
|
UList<double> cmpts
|
||||||
|
(
|
||||||
|
reinterpret_cast<double*>(ct.data_bytes()),
|
||||||
|
label(ct.size_bytes() / sizeof(double))
|
||||||
|
);
|
||||||
|
cmpts = 3.1415;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
handled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (handled)
|
||||||
|
{
|
||||||
|
Info<< "assigned: " << ctok1 << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -30,12 +30,7 @@ Input
|
|||||||
|
|
||||||
const labelList patchIDs
|
const labelList patchIDs
|
||||||
(
|
(
|
||||||
pbm.patchSet
|
pbm.indices(polyPatchNames, true) // useGroups
|
||||||
(
|
|
||||||
polyPatchNames,
|
|
||||||
false, // warnNotFound
|
|
||||||
true // useGroups
|
|
||||||
).sortedToc()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
label nFaceLabels = 0;
|
label nFaceLabels = 0;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -131,40 +131,56 @@ void modifyOrAddFace
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void subsetVolFields
|
PtrList<GeometricField<Type, fvPatchField, volMesh>> subsetVolFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const label patchi,
|
const label patchi,
|
||||||
const Type& exposedValue,
|
const Type& exposedValue
|
||||||
PtrList<GeometricField<Type, fvPatchField, volMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
typedef GeometricField<Type, fvPatchField, volMesh> GeoField;
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<GeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<GeoField> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
for (const IOobject& io : fieldObjects)
|
||||||
for (const word& fieldName : objects.sortedNames<GeoField>())
|
|
||||||
{
|
{
|
||||||
const IOobject* ioptr = objects.findObject(fieldName);
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << GeoField::typeName << nl;
|
Info<< "Subsetting " << GeoField::typeName << " (";
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << endl;
|
else
|
||||||
|
{
|
||||||
|
Info<< ' ';
|
||||||
|
}
|
||||||
|
Info<< " " << io.name() << endl;
|
||||||
|
|
||||||
GeoField origField(*ioptr, baseMesh);
|
// Read unregistered
|
||||||
|
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||||
|
GeoField origField(rio, baseMesh);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(origField));
|
subFields.set(nFields, subsetter.interpolate(origField));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
|
|
||||||
|
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||||
|
subField.rename(io.name());
|
||||||
|
subField.writeOpt(IOobjectOption::AUTO_WRITE);
|
||||||
|
|
||||||
|
|
||||||
// Explicitly set exposed faces (in patchi) to exposedValue.
|
// Explicitly set exposed faces (in patchi) to exposedValue.
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
fvPatchField<Type>& fld =
|
fvPatchField<Type>& fld = subField.boundaryFieldRef()[patchi];
|
||||||
subFields[nFields].boundaryFieldRef()[patchi];
|
|
||||||
|
|
||||||
const label newStart = fld.patch().patch().start();
|
const label newStart = fld.patch().patch().start();
|
||||||
const label oldPatchi = subsetter.patchMap()[patchi];
|
const label oldPatchi = subsetter.patchMap()[patchi];
|
||||||
@ -195,48 +211,68 @@ void subsetVolFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nFields)
|
||||||
|
{
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void subsetSurfaceFields
|
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>> subsetSurfaceFields
|
||||||
(
|
(
|
||||||
const fvMeshSubset& subsetter,
|
const fvMeshSubset& subsetter,
|
||||||
const IOobjectList& objects,
|
const IOobjectList& objects,
|
||||||
const label patchi,
|
const label patchi,
|
||||||
const Type& exposedValue,
|
const Type& exposedValue
|
||||||
PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& subFields
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> GeoField;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> GeoField;
|
||||||
|
|
||||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||||
|
|
||||||
|
const UPtrList<const IOobject> fieldObjects
|
||||||
|
(
|
||||||
|
objects.csorted<GeoField>()
|
||||||
|
);
|
||||||
|
|
||||||
|
PtrList<GeoField> subFields(fieldObjects.size());
|
||||||
|
|
||||||
label nFields = 0;
|
label nFields = 0;
|
||||||
|
for (const IOobject& io : fieldObjects)
|
||||||
for (const word& fieldName : objects.sortedNames<GeoField>())
|
|
||||||
{
|
{
|
||||||
const IOobject* ioptr = objects.findObject(fieldName);
|
|
||||||
|
|
||||||
if (!nFields)
|
if (!nFields)
|
||||||
{
|
{
|
||||||
Info<< "Subsetting " << GeoField::typeName << nl;
|
Info<< "Subsetting " << GeoField::typeName << " (";
|
||||||
}
|
}
|
||||||
Info<< " " << fieldName << endl;
|
else
|
||||||
|
{
|
||||||
|
Info<< ' ';
|
||||||
|
}
|
||||||
|
Info<< io.name();
|
||||||
|
|
||||||
GeoField origField(*ioptr, baseMesh);
|
// Read unregistered
|
||||||
|
IOobject rio(io, IOobjectOption::NO_REGISTER);
|
||||||
|
GeoField origField(rio, baseMesh);
|
||||||
|
|
||||||
subFields.set(nFields, subsetter.interpolate(origField));
|
subFields.set(nFields, subsetter.interpolate(origField));
|
||||||
|
auto& subField = subFields[nFields];
|
||||||
|
++nFields;
|
||||||
|
|
||||||
|
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
||||||
|
subField.rename(io.name());
|
||||||
|
subField.writeOpt(IOobjectOption::AUTO_WRITE);
|
||||||
|
|
||||||
|
|
||||||
// Explicitly set exposed faces (in patchi) to exposedValue.
|
// Explicitly set exposed faces (in patchi) to exposedValue.
|
||||||
if (patchi >= 0)
|
if (patchi >= 0)
|
||||||
{
|
{
|
||||||
fvsPatchField<Type>& fld =
|
fvsPatchField<Type>& fld = subField.boundaryFieldRef()[patchi];
|
||||||
subFields[nFields].boundaryFieldRef()[patchi];
|
|
||||||
|
|
||||||
const label newStart = fld.patch().patch().start();
|
const label newStart = fld.patch().patch().start();
|
||||||
const label oldPatchi = subsetter.patchMap()[patchi];
|
const label oldPatchi = subsetter.patchMap()[patchi];
|
||||||
@ -268,9 +304,14 @@ void subsetSurfaceFields
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
++nFields;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nFields)
|
||||||
|
{
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return subFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,16 +325,9 @@ void initCreatedPatches
|
|||||||
const typename GeoField::value_type initValue
|
const typename GeoField::value_type initValue
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
HashTable<const GeoField*> fields
|
for (const GeoField& field : mesh.objectRegistry::csorted<GeoField>())
|
||||||
(
|
|
||||||
mesh.objectRegistry::lookupClass<GeoField>()
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllIters(fields, fieldIter)
|
|
||||||
{
|
{
|
||||||
GeoField& field = const_cast<GeoField&>(*fieldIter());
|
auto& fieldBf = const_cast<GeoField&>(field).boundaryFieldRef();
|
||||||
|
|
||||||
auto& fieldBf = field.boundaryFieldRef();
|
|
||||||
|
|
||||||
forAll(fieldBf, patchi)
|
forAll(fieldBf, patchi)
|
||||||
{
|
{
|
||||||
@ -326,43 +360,36 @@ void subsetTopoSets
|
|||||||
PtrList<TopoSet> sets;
|
PtrList<TopoSet> sets;
|
||||||
ReadFields<TopoSet>(objects, sets);
|
ReadFields<TopoSet>(objects, sets);
|
||||||
|
|
||||||
subSets.resize(sets.size());
|
subSets.resize_null(sets.size());
|
||||||
|
|
||||||
forAll(sets, seti)
|
forAll(sets, seti)
|
||||||
{
|
{
|
||||||
TopoSet& set = sets[seti];
|
const TopoSet& set = sets[seti];
|
||||||
|
|
||||||
Info<< "Subsetting " << set.type() << " " << set.name() << endl;
|
Info<< "Subsetting " << set.type() << ' ' << set.name() << endl;
|
||||||
|
|
||||||
|
labelHashSet subset(2*min(set.size(), map.size()));
|
||||||
|
|
||||||
// Map the data
|
// Map the data
|
||||||
bitSet isSet(set.maxSize(mesh));
|
forAll(map, i)
|
||||||
for (const label id : set)
|
|
||||||
{
|
{
|
||||||
isSet.set(id);
|
if (set.contains(map[i]))
|
||||||
}
|
|
||||||
|
|
||||||
label nSet = 0;
|
|
||||||
for (const label id : map)
|
|
||||||
{
|
|
||||||
if (isSet.test(id))
|
|
||||||
{
|
{
|
||||||
++nSet;
|
subset.insert(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subSets.set
|
subSets.set
|
||||||
(
|
(
|
||||||
seti,
|
seti,
|
||||||
new TopoSet(subMesh, set.name(), nSet, IOobject::AUTO_WRITE)
|
new TopoSet
|
||||||
|
(
|
||||||
|
subMesh,
|
||||||
|
set.name(),
|
||||||
|
std::move(subset),
|
||||||
|
IOobjectOption::AUTO_WRITE
|
||||||
|
)
|
||||||
);
|
);
|
||||||
TopoSet& subSet = subSets[seti];
|
|
||||||
|
|
||||||
forAll(map, i)
|
|
||||||
{
|
|
||||||
if (isSet.test(map[i]))
|
|
||||||
{
|
|
||||||
subSet.insert(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,6 +640,7 @@ label findPatch(const polyBoundaryMesh& patches, const word& patchName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -844,138 +872,117 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read vol fields and subset.
|
// Read vol fields and subset.
|
||||||
|
PtrList<volScalarField> scalarFlds
|
||||||
wordList scalarNames(objects.sortedNames<volScalarField>());
|
|
||||||
PtrList<volScalarField> scalarFlds(scalarNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<scalar>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
scalar(Zero),
|
objects,
|
||||||
scalarFlds
|
defaultPatchi,
|
||||||
|
scalar(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList vectorNames(objects.sortedNames<volVectorField>());
|
PtrList<volVectorField> vectorFlds
|
||||||
PtrList<volVectorField> vectorFlds(vectorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<vector>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
vector(Zero),
|
objects,
|
||||||
vectorFlds
|
defaultPatchi,
|
||||||
|
vector(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList sphTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<volSphericalTensorField>()
|
|
||||||
);
|
|
||||||
PtrList<volSphericalTensorField> sphTensorFlds
|
PtrList<volSphericalTensorField> sphTensorFlds
|
||||||
(
|
(
|
||||||
sphTensorNames.size()
|
subsetVolFields<sphericalTensor>
|
||||||
);
|
(
|
||||||
subsetVolFields
|
subsetter,
|
||||||
(
|
objects,
|
||||||
subsetter,
|
defaultPatchi,
|
||||||
objects,
|
sphericalTensor(Zero)
|
||||||
defaultPatchi,
|
)
|
||||||
sphericalTensor(Zero),
|
|
||||||
sphTensorFlds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList symmTensorNames(objects.sortedNames<volSymmTensorField>());
|
PtrList<volSymmTensorField> symmTensorFlds
|
||||||
PtrList<volSymmTensorField> symmTensorFlds(symmTensorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<symmTensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
symmTensor(Zero),
|
objects,
|
||||||
symmTensorFlds
|
defaultPatchi,
|
||||||
|
symmTensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList tensorNames(objects.sortedNames<volTensorField>());
|
PtrList<volTensorField> tensorFlds
|
||||||
PtrList<volTensorField> tensorFlds(tensorNames.size());
|
|
||||||
subsetVolFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetVolFields<tensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
tensor(Zero),
|
objects,
|
||||||
tensorFlds
|
defaultPatchi,
|
||||||
|
tensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Read surface fields and subset.
|
// Read surface fields and subset.
|
||||||
|
PtrList<surfaceScalarField> surfScalarFlds
|
||||||
wordList surfScalarNames(objects.sortedNames<surfaceScalarField>());
|
|
||||||
PtrList<surfaceScalarField> surfScalarFlds(surfScalarNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<scalar>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
scalar(Zero),
|
objects,
|
||||||
surfScalarFlds
|
defaultPatchi,
|
||||||
|
scalar(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList surfVectorNames(objects.sortedNames<surfaceVectorField>());
|
PtrList<surfaceVectorField> surfVectorFlds
|
||||||
PtrList<surfaceVectorField> surfVectorFlds(surfVectorNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<vector>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
vector(Zero),
|
objects,
|
||||||
surfVectorFlds
|
defaultPatchi,
|
||||||
|
vector(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
wordList surfSphTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<surfaceSphericalTensorField>()
|
|
||||||
);
|
|
||||||
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
PtrList<surfaceSphericalTensorField> surfSphericalTensorFlds
|
||||||
(
|
(
|
||||||
surfSphTensorNames.size()
|
subsetSurfaceFields<sphericalTensor>
|
||||||
);
|
(
|
||||||
subsetSurfaceFields
|
subsetter,
|
||||||
(
|
objects,
|
||||||
subsetter,
|
defaultPatchi,
|
||||||
objects,
|
sphericalTensor(Zero)
|
||||||
defaultPatchi,
|
)
|
||||||
sphericalTensor(Zero),
|
|
||||||
surfSphericalTensorFlds
|
|
||||||
);
|
|
||||||
|
|
||||||
wordList surfSymmTensorNames
|
|
||||||
(
|
|
||||||
objects.sortedNames<surfaceSymmTensorField>()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
PtrList<surfaceSymmTensorField> surfSymmTensorFlds
|
||||||
(
|
(
|
||||||
surfSymmTensorNames.size()
|
subsetSurfaceFields<symmTensor>
|
||||||
|
(
|
||||||
|
subsetter,
|
||||||
|
objects,
|
||||||
|
defaultPatchi,
|
||||||
|
symmTensor(Zero)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
subsetSurfaceFields
|
PtrList<surfaceTensorField> surfTensorFlds
|
||||||
(
|
(
|
||||||
subsetter,
|
subsetSurfaceFields<tensor>
|
||||||
objects,
|
(
|
||||||
defaultPatchi,
|
subsetter,
|
||||||
symmTensor(Zero),
|
objects,
|
||||||
surfSymmTensorFlds
|
defaultPatchi,
|
||||||
);
|
tensor(Zero)
|
||||||
|
)
|
||||||
wordList surfTensorNames(objects.sortedNames<surfaceTensorField>());
|
|
||||||
PtrList<surfaceTensorField> surfTensorFlds(surfTensorNames.size());
|
|
||||||
subsetSurfaceFields
|
|
||||||
(
|
|
||||||
subsetter,
|
|
||||||
objects,
|
|
||||||
defaultPatchi,
|
|
||||||
tensor(Zero),
|
|
||||||
surfTensorFlds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -1017,62 +1024,8 @@ int main(int argc, char *argv[])
|
|||||||
++runTime;
|
++runTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Writing mesh without blockedCells to time " << runTime.value()
|
Info<< "Writing mesh without blockedCells to time "
|
||||||
<< endl;
|
<< runTime.value() << endl;
|
||||||
|
|
||||||
// Subsetting adds 'subset' prefix. Rename field to be like original.
|
|
||||||
forAll(scalarFlds, i)
|
|
||||||
{
|
|
||||||
scalarFlds[i].rename(scalarNames[i]);
|
|
||||||
scalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(vectorFlds, i)
|
|
||||||
{
|
|
||||||
vectorFlds[i].rename(vectorNames[i]);
|
|
||||||
vectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(sphTensorFlds, i)
|
|
||||||
{
|
|
||||||
sphTensorFlds[i].rename(sphTensorNames[i]);
|
|
||||||
sphTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(symmTensorFlds, i)
|
|
||||||
{
|
|
||||||
symmTensorFlds[i].rename(symmTensorNames[i]);
|
|
||||||
symmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(tensorFlds, i)
|
|
||||||
{
|
|
||||||
tensorFlds[i].rename(tensorNames[i]);
|
|
||||||
tensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Surface ones.
|
|
||||||
forAll(surfScalarFlds, i)
|
|
||||||
{
|
|
||||||
surfScalarFlds[i].rename(surfScalarNames[i]);
|
|
||||||
surfScalarFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfVectorFlds, i)
|
|
||||||
{
|
|
||||||
surfVectorFlds[i].rename(surfVectorNames[i]);
|
|
||||||
surfVectorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfSphericalTensorFlds, i)
|
|
||||||
{
|
|
||||||
surfSphericalTensorFlds[i].rename(surfSphTensorNames[i]);
|
|
||||||
surfSphericalTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfSymmTensorFlds, i)
|
|
||||||
{
|
|
||||||
surfSymmTensorFlds[i].rename(surfSymmTensorNames[i]);
|
|
||||||
surfSymmTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
forAll(surfTensorNames, i)
|
|
||||||
{
|
|
||||||
surfTensorFlds[i].rename(surfTensorNames[i]);
|
|
||||||
surfTensorFlds[i].writeOpt(IOobject::AUTO_WRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
subsetter.subMesh().write();
|
subsetter.subMesh().write();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2019 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -47,7 +47,7 @@ Description
|
|||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "cellSet.H"
|
#include "cellSet.H"
|
||||||
#include "SortableList.H"
|
#include "SortList.H"
|
||||||
#include "labelIOList.H"
|
#include "labelIOList.H"
|
||||||
#include "fvMesh.H"
|
#include "fvMesh.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
@ -128,71 +128,54 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
const scalarField& vols = mesh.cellVolumes();
|
const scalarField& vols = mesh.cellVolumes();
|
||||||
|
|
||||||
SortableList<scalar> sortedVols(vols);
|
SortList<scalar> sortedVols(vols);
|
||||||
|
|
||||||
// All cell labels, sorted per bin.
|
// All cell labels, sorted per bin.
|
||||||
DynamicList<DynamicList<label>> bins;
|
DynamicList<DynamicList<label>> bins;
|
||||||
|
|
||||||
// Lower/upper limits
|
// Lower/upper limits
|
||||||
DynamicList<scalar> lowerLimits;
|
DynamicList<scalarMinMax> limits;
|
||||||
DynamicList<scalar> upperLimits;
|
|
||||||
|
|
||||||
// Create bin0. Have upperlimit as factor times lowerlimit.
|
// Create bin0. Have upperlimit as factor times lowerlimit.
|
||||||
bins.append(DynamicList<label>());
|
bins.emplace_back();
|
||||||
lowerLimits.append(sortedVols[0]);
|
limits.emplace_back(sortedVols[0], 1.1*sortedVols[0]);
|
||||||
upperLimits.append(1.1 * lowerLimits.last());
|
|
||||||
|
|
||||||
forAll(sortedVols, i)
|
forAll(sortedVols, i)
|
||||||
{
|
{
|
||||||
if (sortedVols[i] > upperLimits.last())
|
if (sortedVols[i] > limits.back().max())
|
||||||
{
|
{
|
||||||
// New value outside of current bin
|
// New value outside of current bin
|
||||||
|
Info<< "Collected " << bins.back() << " elements in bin "
|
||||||
// Shrink old bin.
|
<< limits.back().min() << " .. "
|
||||||
DynamicList<label>& bin = bins.last();
|
<< limits.back().max() << endl;
|
||||||
|
|
||||||
bin.shrink();
|
|
||||||
|
|
||||||
Info<< "Collected " << bin.size() << " elements in bin "
|
|
||||||
<< lowerLimits.last() << " .. "
|
|
||||||
<< upperLimits.last() << endl;
|
|
||||||
|
|
||||||
// Create new bin.
|
// Create new bin.
|
||||||
bins.append(DynamicList<label>());
|
bins.emplace_back();
|
||||||
lowerLimits.append(sortedVols[i]);
|
limits.emplace_back(sortedVols[i], 1.1 * sortedVols[i]);
|
||||||
upperLimits.append(1.1 * lowerLimits.last());
|
|
||||||
|
|
||||||
Info<< "Creating new bin " << lowerLimits.last()
|
Info<< "Creating new bin "
|
||||||
<< " .. " << upperLimits.last()
|
<< limits.back().min() << " .. "
|
||||||
<< endl;
|
<< limits.back().max() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append to current bin.
|
// Add to current bin.
|
||||||
DynamicList<label>& bin = bins.last();
|
bins.back().push_back(sortedVols.indices()[i]);
|
||||||
|
|
||||||
bin.append(sortedVols.indices()[i]);
|
|
||||||
}
|
}
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
|
|
||||||
bins.last().shrink();
|
|
||||||
bins.shrink();
|
|
||||||
lowerLimits.shrink();
|
|
||||||
upperLimits.shrink();
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write to cellSets.
|
// Write to cellSets.
|
||||||
//
|
//
|
||||||
|
|
||||||
Info<< "Volume bins:" << nl;
|
Info<< "Volume bins:" << nl;
|
||||||
forAll(bins, binI)
|
forAll(bins, bini)
|
||||||
{
|
{
|
||||||
const DynamicList<label>& bin = bins[binI];
|
const auto& bin = bins[bini];
|
||||||
|
|
||||||
cellSet cells(mesh, "vol" + name(binI), bin.size());
|
cellSet cells(mesh, "vol" + Foam::name(bini), bin.size());
|
||||||
cells.insert(bin);
|
cells.insert(bin);
|
||||||
|
|
||||||
Info<< " " << lowerLimits[binI] << " .. " << upperLimits[binI]
|
Info<< " " << limits[bini].min() << " .. " << limits[bini].max()
|
||||||
<< " : writing " << bin.size() << " cells to cellSet "
|
<< " : writing " << bin.size() << " cells to cellSet "
|
||||||
<< cells.name() << endl;
|
<< cells.name() << endl;
|
||||||
|
|
||||||
@ -294,13 +277,13 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Set cell values
|
// Set cell values
|
||||||
forAll(bins, binI)
|
forAll(bins, bini)
|
||||||
{
|
{
|
||||||
const DynamicList<label>& bin = bins[binI];
|
const auto& bin = bins[bini];
|
||||||
|
|
||||||
forAll(bin, i)
|
forAll(bin, i)
|
||||||
{
|
{
|
||||||
refLevel[bin[i]] = bins.size() - binI - 1;
|
refLevel[bin[i]] = bins.size() - bini - 1;
|
||||||
postRefLevel[bin[i]] = refLevel[bin[i]];
|
postRefLevel[bin[i]] = refLevel[bin[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -143,10 +143,10 @@ void Foam::fileFormats::ensightMeshReader::setHandedness
|
|||||||
// if (((x ^ y) & z) < 0)
|
// if (((x ^ y) & z) < 0)
|
||||||
// {
|
// {
|
||||||
// // Flipped hex
|
// // Flipped hex
|
||||||
// Swap(verts[0], verts[4]);
|
// std::swap(verts[0], verts[4]);
|
||||||
// Swap(verts[1], verts[5]);
|
// std::swap(verts[1], verts[5]);
|
||||||
// Swap(verts[2], verts[6]);
|
// std::swap(verts[2], verts[6]);
|
||||||
// Swap(verts[3], verts[7]);
|
// std::swap(verts[3], verts[7]);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@ -155,27 +155,27 @@ void Foam::fileFormats::ensightMeshReader::setHandedness
|
|||||||
if (verts.size() == 8)
|
if (verts.size() == 8)
|
||||||
{
|
{
|
||||||
// Flipped hex
|
// Flipped hex
|
||||||
Swap(verts[0], verts[4]);
|
std::swap(verts[0], verts[4]);
|
||||||
Swap(verts[1], verts[5]);
|
std::swap(verts[1], verts[5]);
|
||||||
Swap(verts[2], verts[6]);
|
std::swap(verts[2], verts[6]);
|
||||||
Swap(verts[3], verts[7]);
|
std::swap(verts[3], verts[7]);
|
||||||
}
|
}
|
||||||
else if (verts.size() == 4)
|
else if (verts.size() == 4)
|
||||||
{
|
{
|
||||||
// Flipped tet. Change orientation of base
|
// Flipped tet. Change orientation of base
|
||||||
Swap(verts[0], verts[1]);
|
std::swap(verts[0], verts[1]);
|
||||||
}
|
}
|
||||||
else if (verts.size() == 5)
|
else if (verts.size() == 5)
|
||||||
{
|
{
|
||||||
// Flipped pyr. Change orientation of base
|
// Flipped pyr. Change orientation of base
|
||||||
Swap(verts[1], verts[3]);
|
std::swap(verts[1], verts[3]);
|
||||||
}
|
}
|
||||||
else if (verts.size() == 6)
|
else if (verts.size() == 6)
|
||||||
{
|
{
|
||||||
// Flipped prism.
|
// Flipped prism.
|
||||||
Swap(verts[0], verts[3]);
|
std::swap(verts[0], verts[3]);
|
||||||
Swap(verts[1], verts[4]);
|
std::swap(verts[1], verts[4]);
|
||||||
Swap(verts[2], verts[5]);
|
std::swap(verts[2], verts[5]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,7 +221,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
blockMesh blocks(meshDict, regionName, strategy, args.verbose());
|
blockMesh blocks(meshDict, regionName, strategy, args.verbose());
|
||||||
|
|
||||||
if (!blocks.valid())
|
if (!blocks.good())
|
||||||
{
|
{
|
||||||
// Could/should be Fatal?
|
// Could/should be Fatal?
|
||||||
|
|
||||||
|
|||||||
@ -54,56 +54,44 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
// An empty zone for cut points
|
// An empty zone for cut points
|
||||||
pzs.append
|
pzs.emplace_back
|
||||||
(
|
(
|
||||||
new pointZone
|
mergeName + "CutPointZone",
|
||||||
(
|
pzs.size(), // index
|
||||||
mergeName + "CutPointZone",
|
pzs
|
||||||
pzs.size(),
|
|
||||||
pzs
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
cleanupPointZones.insert(pzs.last().name());
|
cleanupPointZones.insert(pzs.back().name());
|
||||||
|
|
||||||
// Coupling side 0 (master)
|
// Coupling side 0 (master)
|
||||||
fzs.append
|
fzs.emplace_back
|
||||||
(
|
(
|
||||||
new faceZone
|
mergeName + "Side0Zone",
|
||||||
(
|
identity(patch0.range()),
|
||||||
mergeName + "Side0Zone",
|
false, // none are flipped
|
||||||
identity(patch0.range()),
|
fzs.size(), // index
|
||||||
false, // none are flipped
|
fzs
|
||||||
fzs.size(),
|
|
||||||
fzs
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
cleanupFaceZones.insert(fzs.last().name());
|
cleanupFaceZones.insert(fzs.back().name());
|
||||||
|
|
||||||
// Coupling side 1 (slave)
|
// Coupling side 1 (slave)
|
||||||
fzs.append
|
fzs.emplace_back
|
||||||
(
|
(
|
||||||
new faceZone
|
mergeName + "Side1Zone",
|
||||||
(
|
identity(patch1.range()),
|
||||||
mergeName + "Side1Zone",
|
false, // none are flipped
|
||||||
identity(patch1.range()),
|
fzs.size(), // index
|
||||||
false, // none are flipped
|
fzs
|
||||||
fzs.size(),
|
|
||||||
fzs
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
cleanupFaceZones.insert(fzs.last().name());
|
cleanupFaceZones.insert(fzs.back().name());
|
||||||
|
|
||||||
// An empty zone for cut faces
|
// An empty zone for cut faces
|
||||||
fzs.append
|
fzs.emplace_back
|
||||||
(
|
(
|
||||||
new faceZone
|
mergeName + "CutFaceZone",
|
||||||
(
|
fzs.size(), // index
|
||||||
mergeName + "CutFaceZone",
|
fzs
|
||||||
fzs.size(),
|
|
||||||
fzs
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
cleanupFaceZones.insert(fzs.last().name());
|
cleanupFaceZones.insert(fzs.back().name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -979,7 +979,7 @@ int main(int argc, char *argv[])
|
|||||||
// Change the front and back patch types as required
|
// Change the front and back patch types as required
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
word frontBackType(word::null);
|
word frontBackType;
|
||||||
|
|
||||||
if (isType<extrudeModels::wedge>(model()))
|
if (isType<extrudeModels::wedge>(model()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -947,7 +947,7 @@ void addZoneSidePatches
|
|||||||
|
|
||||||
forAll(zoneSidePatch, zoneI)
|
forAll(zoneSidePatch, zoneI)
|
||||||
{
|
{
|
||||||
if (oneDPolyPatchType != word::null)
|
if (!oneDPolyPatchType.empty())
|
||||||
{
|
{
|
||||||
// Reuse single empty patch.
|
// Reuse single empty patch.
|
||||||
word patchName;
|
word patchName;
|
||||||
|
|||||||
@ -47,7 +47,7 @@ void Foam::DelaunayMesh<Triangulation>::timeCheck
|
|||||||
<< time().elapsedCpuTime() << " s, "
|
<< time().elapsedCpuTime() << " s, "
|
||||||
<< "delta " << time().cpuTimeIncrement()<< " s";
|
<< "delta " << time().cpuTimeIncrement()<< " s";
|
||||||
|
|
||||||
if (description != word::null)
|
if (!description.empty())
|
||||||
{
|
{
|
||||||
Info<< ", " << description << " ";
|
Info<< ", " << description << " ";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ template<class KeyType, class DataType>
|
|||||||
Foam::PrintTable<KeyType, DataType>::PrintTable()
|
Foam::PrintTable<KeyType, DataType>::PrintTable()
|
||||||
:
|
:
|
||||||
table_(),
|
table_(),
|
||||||
title_(string::null)
|
title_()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -468,8 +468,8 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached
|
|||||||
|
|
||||||
forAll(c1Procs, aPI)
|
forAll(c1Procs, aPI)
|
||||||
{
|
{
|
||||||
procsAttached.appendUniq(c1Procs[aPI]);
|
procsAttached.push_uniq(c1Procs[aPI]);
|
||||||
procsAttached.appendUniq(c2Procs[aPI]);
|
procsAttached.push_uniq(c2Procs[aPI]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return List<label>(procsAttached);
|
return List<label>(procsAttached);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ void Foam::conformalVoronoiMesh::timeCheck
|
|||||||
<< runTime.elapsedCpuTime() << " s, "
|
<< runTime.elapsedCpuTime() << " s, "
|
||||||
<< "delta " << runTime.cpuTimeIncrement()<< " s";
|
<< "delta " << runTime.cpuTimeIncrement()<< " s";
|
||||||
|
|
||||||
if (description != word::null)
|
if (!description.empty())
|
||||||
{
|
{
|
||||||
Info<< ", " << description << " ";
|
Info<< ", " << description << " ";
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ void Foam::conformalVoronoiMesh::timeCheck
|
|||||||
|
|
||||||
memInfo m;
|
memInfo m;
|
||||||
|
|
||||||
if (m.valid())
|
if (m.good())
|
||||||
{
|
{
|
||||||
PrintTable<word, label> memoryTable
|
PrintTable<word, label> memoryTable
|
||||||
(
|
(
|
||||||
|
|||||||
@ -46,8 +46,8 @@ void Foam::shortEdgeFilter2D::assignBoundaryPointRegions
|
|||||||
const edge& e = iter.key();
|
const edge& e = iter.key();
|
||||||
const label regi = iter.val();
|
const label regi = iter.val();
|
||||||
|
|
||||||
boundaryPointRegions[e.start()].appendUniq(regi);
|
boundaryPointRegions[e.first()].push_uniq(regi);
|
||||||
boundaryPointRegions[e.end()].appendUniq(regi);
|
boundaryPointRegions[e.second()].push_uniq(regi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void Foam::shortEdgeFilter2D::updateEdgeRegionMap
|
|||||||
const edgeList& edges = surfMesh.edges();
|
const edgeList& edges = surfMesh.edges();
|
||||||
const labelList& meshPoints = surfMesh.meshPoints();
|
const labelList& meshPoints = surfMesh.meshPoints();
|
||||||
|
|
||||||
patchSizes.setSize(patchNames_.size(), 0);
|
patchSizes.resize_nocopy(patchNames_.size());
|
||||||
patchSizes = 0;
|
patchSizes = 0;
|
||||||
|
|
||||||
forAll(edges, edgeI)
|
forAll(edges, edgeI)
|
||||||
@ -78,15 +78,13 @@ void Foam::shortEdgeFilter2D::updateEdgeRegionMap
|
|||||||
|
|
||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgeI];
|
||||||
|
|
||||||
const label startI = meshPoints[e[0]];
|
|
||||||
const label endI = meshPoints[e[1]];
|
|
||||||
|
|
||||||
label region = -1;
|
label region = -1;
|
||||||
|
|
||||||
const DynamicList<label> startPtRegions =
|
const DynamicList<label>& startPtRegions =
|
||||||
boundaryPtRegions[surfPtToBoundaryPt[startI]];
|
boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.first()]]];
|
||||||
const DynamicList<label> endPtRegions =
|
|
||||||
boundaryPtRegions[surfPtToBoundaryPt[endI]];
|
const DynamicList<label>& endPtRegions =
|
||||||
|
boundaryPtRegions[surfPtToBoundaryPt[meshPoints[e.second()]]];
|
||||||
|
|
||||||
if (startPtRegions.size() > 1 && endPtRegions.size() > 1)
|
if (startPtRegions.size() > 1 && endPtRegions.size() > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user