Compare commits
135 Commits
multiNodeD
...
update-pst
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf5af9d3b | |||
| d5c0852de1 | |||
| 4284d02c99 | |||
| 82c0b360c6 | |||
| 99bf27cbee | |||
| d3867a2d34 | |||
| f75af788c1 | |||
| 790a5c26f9 | |||
| 9729617ae3 | |||
| afee861af9 | |||
| 72d2ff8249 | |||
| 0ab0ecb541 | |||
| 00f499d714 | |||
| 0fc2c817e1 | |||
| 117173aaba | |||
| b33b26ad34 | |||
| cdcbd05587 | |||
| 28b492bd54 | |||
| f0a196a908 | |||
| d51aa5a74d | |||
| e623e6a865 | |||
| d88272f031 | |||
| f3d447579a | |||
| 7246b49eac | |||
| 8a2cd2edfb | |||
| 9938a13b2a | |||
| 899d59686c | |||
| 0b7c0844f4 | |||
| d006339c9a | |||
| 74d65ed018 | |||
| 68bbd8f3a8 | |||
| 40bdab1c1a | |||
| f180740b03 | |||
| 1cc72ea7e3 | |||
| ba6667a344 | |||
| 4d45cfd5a9 | |||
| 128516b874 | |||
| 70d526cd82 | |||
| e1a710014c | |||
| ab10b4a05c | |||
| 6f68ce5239 | |||
| 3d8a6a5433 | |||
| 4d7180ae7c | |||
| a7d77391fa | |||
| 2569405383 | |||
| fb2bf77e8e | |||
| 446aff1350 | |||
| c9081d5daf | |||
| c038a9447c | |||
| fdd7e4d87f | |||
| 0767e21d8c | |||
| fe4688c27f | |||
| b71a05a72f | |||
| aef990f8df | |||
| cbb153372e | |||
| 58e4cfbc8a | |||
| a597c044c7 | |||
| d8c6b6b811 | |||
| 521bdf0f07 | |||
| f215ad15d1 | |||
| fb69a54bc3 | |||
| 1ce7a62209 | |||
| b6af124b80 | |||
| 83740ad408 | |||
| a16f09b10c | |||
| 702225c249 | |||
| 375a4792f9 | |||
| aafcd0b9e0 | |||
| 27a7ae2d1d | |||
| 35dae3fc3b | |||
| 2db3e2b64f | |||
| 1ab9dca2ab | |||
| 74fd94dff3 | |||
| 1dbb54c391 | |||
| d597b3f959 | |||
| 750381bd99 | |||
| ed39ee6afe | |||
| 422654a9ea | |||
| add61ca273 | |||
| 70d310329c | |||
| 4ec75d538f | |||
| df61104ef5 | |||
| 068ab8ccc7 | |||
| ab4c5f25ac | |||
| 173c9ac163 | |||
| 3e024d622b | |||
| d2ab9e9abf | |||
| e790e1c4ba | |||
| f713f74855 | |||
| 7c6232b8b3 | |||
| 56bf73d37d | |||
| c0e63a8de7 | |||
| 8b63f64503 | |||
| 1471d292bf | |||
| b93f038ea3 | |||
| a6b3a31b28 | |||
| 8ee7595a77 | |||
| 72bfaa2be9 | |||
| bebc6195a8 | |||
| c8a2d82094 | |||
| 39cabfca9c | |||
| 0190fed56b | |||
| c206b12c80 | |||
| 911c28f17d | |||
| 2faf361354 | |||
| 312037d4ea | |||
| 5672bb296f | |||
| ea2bedf073 | |||
| eb8b51b475 | |||
| 7c60c80edd | |||
| c1cdacc0b4 | |||
| 94a79ef24f | |||
| 0c756cc676 | |||
| ba153df8db | |||
| 3888bfa17f | |||
| 8a70c898ae | |||
| 1f5a75c3c2 | |||
| ecaa55295b | |||
| a50d32b587 | |||
| 0fa129e83c | |||
| 2641dc4c3a | |||
| b15638a2d2 | |||
| bf2f87f7e3 | |||
| bf99c104eb | |||
| bd0ad07d40 | |||
| 568ced68e2 | |||
| 2d4ecc4326 | |||
| 94a7945be3 | |||
| 06f479fbd4 | |||
| 35c5306544 | |||
| 248e5ff86f | |||
| 33c9df7741 | |||
| f08392010f | |||
| d74572cae8 | |||
| 1cd47839ac |
@ -1,2 +1,2 @@
|
|||||||
api=2212
|
api=2301
|
||||||
patch=230110
|
patch=230110
|
||||||
|
|||||||
@ -1,125 +1,4 @@
|
|||||||
Info<< "Reading velocity field U\n" << endl;
|
#include "../createFields.H"
|
||||||
volVectorField U
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"U",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
// Initialise the velocity internal field to zero
|
|
||||||
U = dimensionedVector(U.dimensions(), Zero);
|
|
||||||
|
|
||||||
surfaceScalarField phi
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"phi",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::NO_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
fvc::flux(U)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (args.found("initialiseUBCs"))
|
|
||||||
{
|
|
||||||
U.correctBoundaryConditions();
|
|
||||||
phi = fvc::flux(U);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Construct a pressure field
|
|
||||||
// If it is available read it otherwise construct from the velocity BCs
|
|
||||||
// converting fixed-value BCs to zero-gradient and vice versa.
|
|
||||||
|
|
||||||
// Allow override from command-line -pName option
|
|
||||||
const word pName = args.getOrDefault<word>("pName", "p");
|
|
||||||
|
|
||||||
// Infer the pressure BCs from the velocity
|
|
||||||
wordList pBCTypes
|
|
||||||
(
|
|
||||||
U.boundaryField().size(),
|
|
||||||
fixedValueFvPatchScalarField::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(U.boundaryField(), patchi)
|
|
||||||
{
|
|
||||||
if (U.boundaryField()[patchi].fixesValue())
|
|
||||||
{
|
|
||||||
pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that registerObject is false for the pressure field. The pressure
|
|
||||||
// field in this solver doesn't have a physical value during the solution.
|
|
||||||
// It shouldn't be looked up and used by sub models or boundary conditions.
|
|
||||||
Info<< "Constructing pressure field " << pName << nl << endl;
|
|
||||||
volScalarField p
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
pName,
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::READ_IF_PRESENT,
|
|
||||||
IOobject::NO_WRITE,
|
|
||||||
false
|
|
||||||
),
|
|
||||||
mesh,
|
|
||||||
dimensionedScalar(sqr(dimVelocity), Zero),
|
|
||||||
pBCTypes
|
|
||||||
);
|
|
||||||
|
|
||||||
// Infer the velocity potential BCs from the pressure
|
|
||||||
wordList PhiBCTypes
|
|
||||||
(
|
|
||||||
p.boundaryField().size(),
|
|
||||||
zeroGradientFvPatchScalarField::typeName
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(p.boundaryField(), patchi)
|
|
||||||
{
|
|
||||||
if (p.boundaryField()[patchi].fixesValue())
|
|
||||||
{
|
|
||||||
PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "Constructing velocity potential field Phi\n" << endl;
|
|
||||||
volScalarField Phi
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"Phi",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::READ_IF_PRESENT,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
),
|
|
||||||
mesh,
|
|
||||||
dimensionedScalar(dimLength*dimVelocity, Zero),
|
|
||||||
PhiBCTypes
|
|
||||||
);
|
|
||||||
|
|
||||||
label PhiRefCell = 0;
|
|
||||||
scalar PhiRefValue = 0;
|
|
||||||
setRefCell
|
|
||||||
(
|
|
||||||
Phi,
|
|
||||||
potentialFlow.dict(),
|
|
||||||
PhiRefCell,
|
|
||||||
PhiRefValue
|
|
||||||
);
|
|
||||||
mesh.setFluxRequired(Phi.name());
|
|
||||||
|
|
||||||
#include "createMRF.H"
|
|
||||||
|
|
||||||
// Add solver-specific interpolations
|
// Add solver-specific interpolations
|
||||||
{
|
{
|
||||||
|
|||||||
@ -83,6 +83,7 @@ Description
|
|||||||
\heading Options
|
\heading Options
|
||||||
\plaintable
|
\plaintable
|
||||||
-writep | write the Euler pressure
|
-writep | write the Euler pressure
|
||||||
|
-writephi | Write the final volumetric flux
|
||||||
-writePhi | Write the final velocity potential
|
-writePhi | Write the final velocity potential
|
||||||
-initialiseUBCs | Update the velocity boundaries before solving for Phi
|
-initialiseUBCs | Update the velocity boundaries before solving for Phi
|
||||||
\endplaintable
|
\endplaintable
|
||||||
@ -117,6 +118,12 @@ int main(int argc, char *argv[])
|
|||||||
"Initialise U boundary conditions"
|
"Initialise U boundary conditions"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"writephi",
|
||||||
|
"Write the final volumetric flux field"
|
||||||
|
);
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"writePhi",
|
"writePhi",
|
||||||
@ -135,6 +142,8 @@ int main(int argc, char *argv[])
|
|||||||
"Execute functionObjects"
|
"Execute functionObjects"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#include "addRegionOption.H"
|
||||||
|
#include "addCheckCaseOptions.H"
|
||||||
#include "setRootCaseLists.H"
|
#include "setRootCaseLists.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
#include "createNamedDynamicFvMesh.H"
|
#include "createNamedDynamicFvMesh.H"
|
||||||
@ -194,11 +203,16 @@ int main(int argc, char *argv[])
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write U and phi
|
// Write U
|
||||||
U.write();
|
U.write();
|
||||||
phi.write();
|
|
||||||
|
|
||||||
// Optionally write Phi
|
// Optionally write the volumetric flux, phi
|
||||||
|
if (args.found("writephi"))
|
||||||
|
{
|
||||||
|
phi.write();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optionally write velocity potential, Phi
|
||||||
if (args.found("writePhi"))
|
if (args.found("writePhi"))
|
||||||
{
|
{
|
||||||
Phi.write();
|
Phi.write();
|
||||||
|
|||||||
@ -171,10 +171,7 @@ if (ign.ignited())
|
|||||||
|
|
||||||
fvOptions.correct(Su);
|
fvOptions.correct(Su);
|
||||||
|
|
||||||
// Limit the maximum Su
|
Su.clamp_range(SuMin, SuMax);
|
||||||
// ~~~~~~~~~~~~~~~~~~~~
|
|
||||||
Su.min(SuMax);
|
|
||||||
Su.max(SuMin);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -218,7 +215,7 @@ if (ign.ignited())
|
|||||||
+ (
|
+ (
|
||||||
scalar(1)
|
scalar(1)
|
||||||
+ (2*XiShapeCoef)
|
+ (2*XiShapeCoef)
|
||||||
*(scalar(0.5) - min(max(b, scalar(0)), scalar(1)))
|
*(scalar(0.5) - clamp(b, zero_one{}))
|
||||||
)*(XiEqStar - scalar(1.001))
|
)*(XiEqStar - scalar(1.001))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -39,13 +39,13 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
|
|
||||||
radiation->correct();
|
radiation->correct();
|
||||||
|
|
||||||
|
|||||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,14 +165,10 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fvPatchScalarField& pmu =
|
const auto& pmu = patch().lookupPatchField<volScalarField>(muName_);
|
||||||
patch().lookupPatchField<volScalarField, scalar>(muName_);
|
const auto& prho = patch().lookupPatchField<volScalarField>(rhoName_);
|
||||||
const fvPatchScalarField& prho =
|
const auto& ppsi = patch().lookupPatchField<volScalarField>(psiName_);
|
||||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
const auto& pU = patch().lookupPatchField<volVectorField>(UName_);
|
||||||
const fvPatchField<scalar>& ppsi =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>(psiName_);
|
|
||||||
const fvPatchVectorField& pU =
|
|
||||||
patch().lookupPatchField<volVectorField, vector>(UName_);
|
|
||||||
|
|
||||||
// Prandtl number reading consistent with rhoCentralFoam
|
// Prandtl number reading consistent with rhoCentralFoam
|
||||||
const dictionary& thermophysicalProperties =
|
const dictionary& thermophysicalProperties =
|
||||||
@ -207,7 +203,7 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::updateCoeffs()
|
|||||||
// Write
|
// Write
|
||||||
void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchField<scalar>::write(os);
|
||||||
|
|
||||||
os.writeEntryIfDifferent<word>("U", "U", UName_);
|
os.writeEntryIfDifferent<word>("U", "U", UName_);
|
||||||
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
|
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
|
||||||
@ -217,7 +213,7 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const
|
|||||||
os.writeEntry("accommodationCoeff", accommodationCoeff_);
|
os.writeEntry("accommodationCoeff", accommodationCoeff_);
|
||||||
Twall_.writeEntry("Twall", os);
|
Twall_.writeEntry("Twall", os);
|
||||||
os.writeEntry("gamma", gamma_);
|
os.writeEntry("gamma", gamma_);
|
||||||
writeEntry("value", os);
|
fvPatchField<scalar>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -155,12 +155,9 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fvPatchScalarField& pmu =
|
const auto& pmu = patch().lookupPatchField<volScalarField>(muName_);
|
||||||
patch().lookupPatchField<volScalarField, scalar>(muName_);
|
const auto& prho = patch().lookupPatchField<volScalarField>(rhoName_);
|
||||||
const fvPatchScalarField& prho =
|
const auto& ppsi = patch().lookupPatchField<volScalarField>(psiName_);
|
||||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
|
||||||
const fvPatchField<scalar>& ppsi =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>(psiName_);
|
|
||||||
|
|
||||||
Field<scalar> C1
|
Field<scalar> C1
|
||||||
(
|
(
|
||||||
@ -187,8 +184,8 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
if (curvature_)
|
if (curvature_)
|
||||||
{
|
{
|
||||||
const fvPatchTensorField& ptauMC =
|
const auto& ptauMC =
|
||||||
patch().lookupPatchField<volTensorField, tensor>(tauMCName_);
|
patch().lookupPatchField<volTensorField>(tauMCName_);
|
||||||
vectorField n(patch().nf());
|
vectorField n(patch().nf());
|
||||||
|
|
||||||
refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
|
refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
|
||||||
@ -200,7 +197,7 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
|
void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchVectorField::write(os);
|
fvPatchField<vector>::write(os);
|
||||||
os.writeEntryIfDifferent<word>("T", "T", TName_);
|
os.writeEntryIfDifferent<word>("T", "T", TName_);
|
||||||
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
|
os.writeEntryIfDifferent<word>("rho", "rho", rhoName_);
|
||||||
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
|
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
|
||||||
@ -215,7 +212,7 @@ void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
|
|||||||
refValue().writeEntry("refValue", os);
|
refValue().writeEntry("refValue", os);
|
||||||
valueFraction().writeEntry("valueFraction", os);
|
valueFraction().writeEntry("valueFraction", os);
|
||||||
|
|
||||||
writeEntry("value", os);
|
fvPatchField<vector>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -104,11 +104,8 @@ void Foam::fixedRhoFvPatchScalarField::updateCoeffs()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fvPatchField<scalar>& psip =
|
const auto& psip = patch().lookupPatchField<volScalarField>(psiName_);
|
||||||
patch().lookupPatchField<volScalarField, scalar>(psiName_);
|
const auto& pp = patch().lookupPatchField<volScalarField>(pName_);
|
||||||
|
|
||||||
const fvPatchField<scalar>& pp =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>(pName_);
|
|
||||||
|
|
||||||
operator==(psip*pp);
|
operator==(psip*pp);
|
||||||
|
|
||||||
@ -118,11 +115,10 @@ void Foam::fixedRhoFvPatchScalarField::updateCoeffs()
|
|||||||
|
|
||||||
void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const
|
void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchField<scalar>::write(os);
|
||||||
|
|
||||||
os.writeEntryIfDifferent<word>("p", "p", pName_);
|
os.writeEntryIfDifferent<word>("p", "p", pName_);
|
||||||
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
|
os.writeEntryIfDifferent<word>("psi", "thermo:psi", psiName_);
|
||||||
writeEntry("value", os);
|
fvPatchField<scalar>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -88,26 +88,29 @@ kappa
|
|||||||
|
|
||||||
case mtLookup:
|
case mtLookup:
|
||||||
{
|
{
|
||||||
if (mesh.foundObject<volScalarField>(kappaName_))
|
|
||||||
{
|
{
|
||||||
return patch().lookupPatchField<volScalarField, scalar>
|
const auto* ptr =
|
||||||
(
|
mesh.cfindObject<volScalarField>(kappaName_);
|
||||||
kappaName_
|
|
||||||
);
|
if (ptr)
|
||||||
|
{
|
||||||
|
return patch().patchField(*ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (mesh.foundObject<volSymmTensorField>(kappaName_))
|
|
||||||
{
|
{
|
||||||
const symmTensorField& KWall =
|
const auto* ptr =
|
||||||
patch().lookupPatchField<volSymmTensorField, scalar>
|
mesh.cfindObject<volSymmTensorField>(kappaName_);
|
||||||
(
|
|
||||||
kappaName_
|
|
||||||
);
|
|
||||||
|
|
||||||
const vectorField n(patch().nf());
|
if (ptr)
|
||||||
|
{
|
||||||
|
const symmTensorField& KWall = patch().patchField(*ptr);
|
||||||
|
|
||||||
return n & KWall & n;
|
const vectorField n(patch().nf());
|
||||||
|
|
||||||
|
return n & KWall & n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Did not find field " << kappaName_
|
<< "Did not find field " << kappaName_
|
||||||
@ -117,9 +120,6 @@ kappa
|
|||||||
<< " or volSymmTensorField."
|
<< " or volSymmTensorField."
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,10 +131,8 @@ kappa
|
|||||||
mesh.lookupObject<phaseSystem>("phaseProperties")
|
mesh.lookupObject<phaseSystem>("phaseProperties")
|
||||||
);
|
);
|
||||||
|
|
||||||
tmp<scalarField> kappaEff
|
auto tkappaEff = tmp<scalarField>::New(patch().size(), Zero);
|
||||||
(
|
auto& kappaEff = tkappaEff.ref();
|
||||||
new scalarField(patch().size(), 0.0)
|
|
||||||
);
|
|
||||||
|
|
||||||
forAll(fluid.phases(), phasei)
|
forAll(fluid.phases(), phasei)
|
||||||
{
|
{
|
||||||
@ -142,10 +140,10 @@ kappa
|
|||||||
|
|
||||||
const fvPatchScalarField& alpha = phase.boundaryField()[patchi];
|
const fvPatchScalarField& alpha = phase.boundaryField()[patchi];
|
||||||
|
|
||||||
kappaEff.ref() += alpha*phase.kappaEff(patchi)();
|
kappaEff += alpha*phase.kappaEff(patchi)();
|
||||||
}
|
}
|
||||||
|
|
||||||
return kappaEff;
|
return tkappaEff;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -161,9 +159,11 @@ kappa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return scalarField(0);
|
// Return zero-sized (not nullptr)
|
||||||
|
return tmp<scalarField>::New();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
@ -308,12 +308,11 @@ updateCoeffs()
|
|||||||
|
|
||||||
scalarField& Tp = *this;
|
scalarField& Tp = *this;
|
||||||
|
|
||||||
const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField&
|
const auto& nbrField =
|
||||||
nbrField = refCast
|
refCast
|
||||||
<const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField>
|
<
|
||||||
(
|
const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
|
||||||
nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_)
|
>(nbrPatch.lookupPatchField<volScalarField>(TnbrName_));
|
||||||
);
|
|
||||||
|
|
||||||
// Swap to obtain full local values of neighbour internal field
|
// Swap to obtain full local values of neighbour internal field
|
||||||
scalarField TcNbr(nbrField.patchInternalField());
|
scalarField TcNbr(nbrField.patchInternalField());
|
||||||
@ -330,13 +329,13 @@ updateCoeffs()
|
|||||||
scalarField qr(Tp.size(), 0.0);
|
scalarField qr(Tp.size(), 0.0);
|
||||||
if (qrName_ != "none")
|
if (qrName_ != "none")
|
||||||
{
|
{
|
||||||
qr = patch().lookupPatchField<volScalarField, scalar>(qrName_);
|
qr = patch().lookupPatchField<volScalarField>(qrName_);
|
||||||
}
|
}
|
||||||
|
|
||||||
scalarField qrNbr(Tp.size(), 0.0);
|
scalarField qrNbr(Tp.size(), 0.0);
|
||||||
if (qrNbrName_ != "none")
|
if (qrNbrName_ != "none")
|
||||||
{
|
{
|
||||||
qrNbr = nbrPatch.lookupPatchField<volScalarField, scalar>(qrNbrName_);
|
qrNbr = nbrPatch.lookupPatchField<volScalarField>(qrNbrName_);
|
||||||
mpp.distribute(qrNbr);
|
mpp.distribute(qrNbr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +485,7 @@ void turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::write
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
mixedFvPatchScalarField::write(os);
|
mixedFvPatchField<scalar>::write(os);
|
||||||
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
|
os.writeEntry("kappaMethod", KMethodTypeNames_[method_]);
|
||||||
os.writeEntryIfDifferent<word>("kappa","none", kappaName_);
|
os.writeEntryIfDifferent<word>("kappa","none", kappaName_);
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ if (Y.size())
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,6 +56,6 @@ if (Y.size())
|
|||||||
if (Y.size())
|
if (Y.size())
|
||||||
{
|
{
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,17 +89,10 @@ void Foam::adjointOutletPressureFvPatchScalarField::updateCoeffs()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fvsPatchField<scalar>& phip =
|
const auto& phip = patch().lookupPatchField<surfaceScalarField>("phi");
|
||||||
patch().lookupPatchField<surfaceScalarField, scalar>("phi");
|
const auto& phiap = patch().lookupPatchField<surfaceScalarField>("phia");
|
||||||
|
const auto& Up = patch().lookupPatchField<volVectorField>("U");
|
||||||
const fvsPatchField<scalar>& phiap =
|
const auto& Uap = patch().lookupPatchField<volVectorField>("Ua");
|
||||||
patch().lookupPatchField<surfaceScalarField, scalar>("phia");
|
|
||||||
|
|
||||||
const fvPatchField<vector>& Up =
|
|
||||||
patch().lookupPatchField<volVectorField, vector>("U");
|
|
||||||
|
|
||||||
const fvPatchField<vector>& Uap =
|
|
||||||
patch().lookupPatchField<volVectorField, vector>("Ua");
|
|
||||||
|
|
||||||
operator==((phiap/patch().magSf() - 1.0)*phip/patch().magSf() + (Up & Uap));
|
operator==((phiap/patch().magSf() - 1.0)*phip/patch().magSf() + (Up & Uap));
|
||||||
|
|
||||||
@ -109,8 +102,8 @@ void Foam::adjointOutletPressureFvPatchScalarField::updateCoeffs()
|
|||||||
|
|
||||||
void Foam::adjointOutletPressureFvPatchScalarField::write(Ostream& os) const
|
void Foam::adjointOutletPressureFvPatchScalarField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchField<scalar>::write(os);
|
||||||
writeEntry("value", os);
|
fvPatchField<scalar>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -90,11 +90,8 @@ void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fvsPatchField<scalar>& phiap =
|
const auto& phiap = patch().lookupPatchField<surfaceScalarField>("phia");
|
||||||
patch().lookupPatchField<surfaceScalarField, scalar>("phia");
|
const auto& Up = patch().lookupPatchField<volVectorField>("U");
|
||||||
|
|
||||||
const fvPatchField<vector>& Up =
|
|
||||||
patch().lookupPatchField<volVectorField, vector>("U");
|
|
||||||
|
|
||||||
scalarField Un(mag(patch().nf() & Up));
|
scalarField Un(mag(patch().nf() & Up));
|
||||||
vectorField UtHat((Up - patch().nf()*Un)/(Un + SMALL));
|
vectorField UtHat((Up - patch().nf()*Un)/(Un + SMALL));
|
||||||
@ -110,8 +107,8 @@ void Foam::adjointOutletVelocityFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
void Foam::adjointOutletVelocityFvPatchVectorField::write(Ostream& os) const
|
void Foam::adjointOutletVelocityFvPatchVectorField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchVectorField::write(os);
|
fvPatchField<vector>::write(os);
|
||||||
writeEntry("value", os);
|
fvPatchField<vector>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ if (mesh.changing())
|
|||||||
{
|
{
|
||||||
if (refCells[zoneId] != -1)
|
if (refCells[zoneId] != -1)
|
||||||
{
|
{
|
||||||
validCells.append(refCells[zoneId]);
|
validCells.push_back(refCells[zoneId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,11 +40,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,11 +41,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,11 +38,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,11 @@ tmp<fv::convectionScheme<scalar>> mvConvection
|
|||||||
|
|
||||||
fvOptions.correct(Yi);
|
fvOptions.correct(Yi);
|
||||||
|
|
||||||
Yi.max(0.0);
|
Yi.clamp_min(0);
|
||||||
Yt += Yi;
|
Yt += Yi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Y[inertIndex] = scalar(1) - Yt;
|
Y[inertIndex] = scalar(1) - Yt;
|
||||||
Y[inertIndex].max(0.0);
|
Y[inertIndex].clamp_min(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,5 @@
|
|||||||
{
|
{
|
||||||
alphav =
|
alphav = clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});
|
||||||
max
|
|
||||||
(
|
|
||||||
min
|
|
||||||
(
|
|
||||||
(rho - rholSat)/(rhovSat - rholSat),
|
|
||||||
scalar(1)
|
|
||||||
),
|
|
||||||
scalar(0)
|
|
||||||
);
|
|
||||||
alphal = 1.0 - alphav;
|
alphal = 1.0 - alphav;
|
||||||
|
|
||||||
Info<< "max-min alphav: " << max(alphav).value()
|
Info<< "max-min alphav: " << max(alphav).value()
|
||||||
|
|||||||
@ -126,9 +126,9 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
|
|||||||
|
|
||||||
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
|
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchField<scalar>::write(os);
|
||||||
os.writeEntry("thetaProperties", thetaProps_);
|
os.writeEntry("thetaProperties", thetaProps_);
|
||||||
writeEntry("value", os);
|
fvPatchField<scalar>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -779,7 +779,7 @@ Foam::multiphaseMixtureThermo::surfaceTensionForce() const
|
|||||||
|
|
||||||
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
|
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
|
||||||
|
|
||||||
if (!sigma.found())
|
if (!sigma.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
||||||
@ -907,7 +907,7 @@ void Foam::multiphaseMixtureThermo::correctContactAngle
|
|||||||
const auto tp =
|
const auto tp =
|
||||||
acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
|
acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
|
||||||
|
|
||||||
if (!tp.found())
|
if (!tp.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
||||||
|
|||||||
@ -99,17 +99,6 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotAlphal() const
|
|||||||
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
||||||
{
|
{
|
||||||
|
|
||||||
volScalarField limitedAlpha1
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
volScalarField limitedAlpha2
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
||||||
|
|
||||||
const twoPhaseMixtureEThermo& thermo =
|
const twoPhaseMixtureEThermo& thermo =
|
||||||
@ -124,11 +113,15 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
|||||||
|
|
||||||
volScalarField mDotE
|
volScalarField mDotE
|
||||||
(
|
(
|
||||||
"mDotE", coeffE_*mixture_.rho1()*limitedAlpha1*max(T - TSat, T0)
|
"mDotE",
|
||||||
|
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||||
|
* max(T - TSat, T0)
|
||||||
);
|
);
|
||||||
volScalarField mDotC
|
volScalarField mDotC
|
||||||
(
|
(
|
||||||
"mDotC", coeffC_*mixture_.rho2()*limitedAlpha2*max(TSat - T, T0)
|
"mDotC",
|
||||||
|
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||||
|
* max(TSat - T, T0)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mesh_.time().outputTime())
|
if (mesh_.time().outputTime())
|
||||||
@ -148,16 +141,6 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDot() const
|
|||||||
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
||||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
|
Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
|
||||||
{
|
{
|
||||||
volScalarField limitedAlpha1
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
volScalarField limitedAlpha2
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
|
||||||
|
|
||||||
const twoPhaseMixtureEThermo& thermo =
|
const twoPhaseMixtureEThermo& thermo =
|
||||||
@ -170,8 +153,14 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::mDotDeltaT() const
|
|||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
coeffC_*mixture_.rho2()*limitedAlpha2*pos(TSat - T),
|
(
|
||||||
coeffE_*mixture_.rho1()*limitedAlpha1*pos(T - TSat)
|
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||||
|
* pos(TSat - T)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||||
|
* pos(T - TSat)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,25 +190,17 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const
|
|||||||
|
|
||||||
const dimensionedScalar& TSat = thermo.TSat();
|
const dimensionedScalar& TSat = thermo.TSat();
|
||||||
|
|
||||||
dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
|
const dimensionedScalar L = mixture_.Hf2() - mixture_.Hf1();
|
||||||
|
|
||||||
volScalarField limitedAlpha1
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
volScalarField limitedAlpha2
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
const volScalarField Vcoeff
|
const volScalarField Vcoeff
|
||||||
(
|
(
|
||||||
coeffE_*mixture_.rho1()*limitedAlpha1*L*pos(T - TSat)
|
coeffE_*mixture_.rho1()*clamp(mixture_.alpha1(), zero_one{})
|
||||||
|
* L*pos(T - TSat)
|
||||||
);
|
);
|
||||||
const volScalarField Ccoeff
|
const volScalarField Ccoeff
|
||||||
(
|
(
|
||||||
coeffC_*mixture_.rho2()*limitedAlpha2*L*pos(TSat - T)
|
coeffC_*mixture_.rho2()*clamp(mixture_.alpha2(), zero_one{})
|
||||||
|
* L*pos(TSat - T)
|
||||||
);
|
);
|
||||||
|
|
||||||
TSource =
|
TSource =
|
||||||
|
|||||||
@ -167,20 +167,10 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
|||||||
Foam::temperaturePhaseChangeTwoPhaseMixtures::interfaceHeatResistance::
|
Foam::temperaturePhaseChangeTwoPhaseMixtures::interfaceHeatResistance::
|
||||||
mDotAlphal() const
|
mDotAlphal() const
|
||||||
{
|
{
|
||||||
volScalarField limitedAlpha1
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha1(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
volScalarField limitedAlpha2
|
|
||||||
(
|
|
||||||
min(max(mixture_.alpha2(), scalar(0)), scalar(1))
|
|
||||||
);
|
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
(mDotc_/(limitedAlpha2 + SMALL)),
|
(mDotc_/clamp(mixture_.alpha2(), scalarMinMax(SMALL, 1))),
|
||||||
-(mDote_/(limitedAlpha1 + SMALL))
|
-(mDote_/clamp(mixture_.alpha1(), scalarMinMax(SMALL, 1)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -155,7 +155,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cp() const
|
|||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const volScalarField limitedAlpha1
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_, zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
@ -176,13 +176,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cp
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
alpha1p*Cp1().value() + (scalar(1) - alpha1p)*Cp2().value()
|
alpha1p*Cp1().value() + (scalar(1) - alpha1p)*Cp2().value()
|
||||||
@ -194,7 +192,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::rho() const
|
|||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const volScalarField limitedAlpha1
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_, zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
@ -214,13 +212,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::rho
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
alpha1p*rho1().value() + (scalar(1) - alpha1p)*rho2().value()
|
alpha1p*rho1().value() + (scalar(1) - alpha1p)*rho2().value()
|
||||||
@ -232,7 +228,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::Cv() const
|
|||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const volScalarField limitedAlpha1
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_, zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
@ -253,13 +249,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::Cv
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
alpha1p*Cv1().value() + (scalar(1) - alpha1p)*Cv2().value()
|
alpha1p*Cv1().value() + (scalar(1) - alpha1p)*Cv2().value()
|
||||||
@ -339,7 +333,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::kappa() const
|
|||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const volScalarField limitedAlpha1
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_, zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
@ -358,13 +352,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappa
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
return (alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value());
|
return (alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,13 +394,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::kappaEff
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
return
|
return
|
||||||
(alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value()) + kappat;
|
(alpha1p*kappa1().value() + (1 - alpha1p)*kappa2().value()) + kappat;
|
||||||
|
|
||||||
@ -435,13 +425,11 @@ Foam::tmp<Foam::scalarField> Foam::twoPhaseMixtureEThermo::alphaEff
|
|||||||
const label patchi
|
const label patchi
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const volScalarField limitedAlpha1
|
const scalarField alpha1p
|
||||||
(
|
(
|
||||||
min(max(alpha1_, scalar(0)), scalar(1))
|
clamp(alpha1_.boundaryField()[patchi], zero_one{})
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& alpha1p = limitedAlpha1.boundaryField()[patchi];
|
|
||||||
|
|
||||||
const scalarField rho
|
const scalarField rho
|
||||||
(
|
(
|
||||||
alpha1p*rho1().value() + (1.0 - alpha1p)*rho2().value()
|
alpha1p*rho1().value() + (1.0 - alpha1p)*rho2().value()
|
||||||
|
|||||||
@ -103,7 +103,7 @@
|
|||||||
{
|
{
|
||||||
if (refCells[zoneId] != -1)
|
if (refCells[zoneId] != -1)
|
||||||
{
|
{
|
||||||
validCells.append(refCells[zoneId]);
|
validCells.push_back(refCells[zoneId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
|||||||
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotAlphal() const
|
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotAlphal() const
|
||||||
{
|
{
|
||||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
@ -85,7 +85,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
|||||||
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotP() const
|
Foam::phaseChangeTwoPhaseMixtures::Kunz::mDotP() const
|
||||||
{
|
{
|
||||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
|
|||||||
@ -82,7 +82,7 @@ Foam::Pair<Foam::tmp<Foam::volScalarField>>
|
|||||||
Foam::phaseChangeTwoPhaseMixtures::Merkle::mDotP() const
|
Foam::phaseChangeTwoPhaseMixtures::Merkle::mDotP() const
|
||||||
{
|
{
|
||||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
|
|||||||
@ -99,7 +99,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::pCoeff
|
|||||||
const volScalarField& p
|
const volScalarField& p
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
volScalarField rho
|
volScalarField rho
|
||||||
(
|
(
|
||||||
limitedAlpha1*rho1() + (scalar(1) - limitedAlpha1)*rho2()
|
limitedAlpha1*rho1() + (scalar(1) - limitedAlpha1)*rho2()
|
||||||
@ -117,7 +117,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotAlphal() const
|
|||||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||||
volScalarField pCoeff(this->pCoeff(p));
|
volScalarField pCoeff(this->pCoeff(p));
|
||||||
|
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
(
|
(
|
||||||
@ -134,7 +134,7 @@ Foam::phaseChangeTwoPhaseMixtures::SchnerrSauer::mDotP() const
|
|||||||
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
|
||||||
volScalarField pCoeff(this->pCoeff(p));
|
volScalarField pCoeff(this->pCoeff(p));
|
||||||
|
|
||||||
volScalarField limitedAlpha1(min(max(alpha1_, scalar(0)), scalar(1)));
|
volScalarField limitedAlpha1(clamp(alpha1_, zero_one{}));
|
||||||
volScalarField apCoeff(limitedAlpha1*pCoeff);
|
volScalarField apCoeff(limitedAlpha1*pCoeff);
|
||||||
|
|
||||||
return Pair<tmp<volScalarField>>
|
return Pair<tmp<volScalarField>>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ surfaceScalarField phi
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar(dimArea*dimVelocity, Zero)
|
dimensionedScalar(dimVelocity*dimArea, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
multiphaseSystem fluid(U, phi);
|
multiphaseSystem fluid(U, phi);
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar(dimArea*dimVelocity, Zero)
|
dimensionedScalar(dimVelocity*dimArea, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
volScalarField rho("rho", fluid.rho());
|
volScalarField rho("rho", fluid.rho());
|
||||||
|
|||||||
@ -126,9 +126,9 @@ alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
|
|||||||
|
|
||||||
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
|
void alphaContactAngleFvPatchScalarField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchField<scalar>::write(os);
|
||||||
os.writeEntry("thetaProperties", thetaProps_);
|
os.writeEntry("thetaProperties", thetaProps_);
|
||||||
writeEntry("value", os);
|
fvPatchField<scalar>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -287,7 +287,7 @@ Foam::multiphaseMixture::surfaceTensionForce() const
|
|||||||
|
|
||||||
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
|
auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
|
||||||
|
|
||||||
if (!sigma.found())
|
if (!sigma.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
||||||
@ -463,7 +463,7 @@ void Foam::multiphaseMixture::correctBoundaryContactAngle
|
|||||||
|
|
||||||
const auto tp = acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
|
const auto tp = acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
|
||||||
|
|
||||||
if (!tp.found())
|
if (!tp.good())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
<< "Cannot find interface " << interfacePair(alpha1, alpha2)
|
||||||
|
|||||||
@ -180,7 +180,7 @@ while (pimple.correct())
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
|
dimensionedScalar(dimVelocity*dimArea, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(phases, phasei)
|
forAll(phases, phasei)
|
||||||
|
|||||||
@ -165,7 +165,7 @@ while (pimple.correct())
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar("phiHbyA", dimArea*dimVelocity, 0)
|
dimensionedScalar(dimVelocity*dimArea, Zero)
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(phases, phasei)
|
forAll(phases, phasei)
|
||||||
|
|||||||
@ -152,14 +152,9 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
|
|||||||
db().lookupObject<IOdictionary>("thermalProperties");
|
db().lookupObject<IOdictionary>("thermalProperties");
|
||||||
|
|
||||||
|
|
||||||
const fvPatchField<scalar>& rho =
|
const auto& rho = patch().lookupPatchField<volScalarField>("rho");
|
||||||
patch().lookupPatchField<volScalarField, scalar>("rho");
|
const auto& rhoE = patch().lookupPatchField<volScalarField>("E");
|
||||||
|
const auto& nu = patch().lookupPatchField<volScalarField>("nu");
|
||||||
const fvPatchField<scalar>& rhoE =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>("E");
|
|
||||||
|
|
||||||
const fvPatchField<scalar>& nu =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>("nu");
|
|
||||||
|
|
||||||
scalarField E(rhoE/rho);
|
scalarField E(rhoE/rho);
|
||||||
scalarField mu(E/(2.0*(1.0 + nu)));
|
scalarField mu(E/(2.0*(1.0 + nu)));
|
||||||
@ -176,8 +171,7 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
vectorField n(patch().nf());
|
vectorField n(patch().nf());
|
||||||
|
|
||||||
const fvPatchField<symmTensor>& sigmaD =
|
const auto& sigmaD = patch().lookupPatchField<volSymmTensorField>("sigmaD");
|
||||||
patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
|
|
||||||
|
|
||||||
gradient() =
|
gradient() =
|
||||||
(
|
(
|
||||||
@ -187,11 +181,10 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
if (thermalProperties.get<bool>("thermalStress"))
|
if (thermalProperties.get<bool>("thermalStress"))
|
||||||
{
|
{
|
||||||
const fvPatchField<scalar>& threeKalpha=
|
const auto& threeKalpha =
|
||||||
patch().lookupPatchField<volScalarField, scalar>("threeKalpha");
|
patch().lookupPatchField<volScalarField>("threeKalpha");
|
||||||
|
|
||||||
const fvPatchField<scalar>& T =
|
const auto& T = patch().lookupPatchField<volScalarField>("T");
|
||||||
patch().lookupPatchField<volScalarField, scalar>("T");
|
|
||||||
|
|
||||||
gradient() += n*threeKalpha*T/twoMuLambda;
|
gradient() += n*threeKalpha*T/twoMuLambda;
|
||||||
}
|
}
|
||||||
@ -202,10 +195,10 @@ void tractionDisplacementFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
|
void tractionDisplacementFvPatchVectorField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchVectorField::write(os);
|
fvPatchField<vector>::write(os);
|
||||||
traction_.writeEntry("traction", os);
|
traction_.writeEntry("traction", os);
|
||||||
pressure_.writeEntry("pressure", os);
|
pressure_.writeEntry("pressure", os);
|
||||||
writeEntry("value", os);
|
fvPatchField<vector>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -152,14 +152,9 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
|
|||||||
"mechanicalProperties"
|
"mechanicalProperties"
|
||||||
);
|
);
|
||||||
|
|
||||||
const fvPatchField<scalar>& rho =
|
const auto& rho = patch().lookupPatchField<volScalarField>("rho");
|
||||||
patch().lookupPatchField<volScalarField, scalar>("rho");
|
const auto& rhoE = patch().lookupPatchField<volScalarField>("E");
|
||||||
|
const auto& nu = patch().lookupPatchField<volScalarField>("nu");
|
||||||
const fvPatchField<scalar>& rhoE =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>("E");
|
|
||||||
|
|
||||||
const fvPatchField<scalar>& nu =
|
|
||||||
patch().lookupPatchField<volScalarField, scalar>("nu");
|
|
||||||
|
|
||||||
scalarField E(rhoE/rho);
|
scalarField E(rhoE/rho);
|
||||||
scalarField mu(E/(2.0*(1.0 + nu)));
|
scalarField mu(E/(2.0*(1.0 + nu)));
|
||||||
@ -172,11 +167,8 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
|
|||||||
|
|
||||||
vectorField n(patch().nf());
|
vectorField n(patch().nf());
|
||||||
|
|
||||||
const fvPatchField<symmTensor>& sigmaD =
|
const auto& sigmaD = patch().lookupPatchField<volSymmTensorField>("sigmaD");
|
||||||
patch().lookupPatchField<volSymmTensorField, symmTensor>("sigmaD");
|
const auto& sigmaExp = patch().lookupPatchField<volTensorField>("sigmaExp");
|
||||||
|
|
||||||
const fvPatchField<tensor>& sigmaExp =
|
|
||||||
patch().lookupPatchField<volTensorField, tensor>("sigmaExp");
|
|
||||||
|
|
||||||
gradient() =
|
gradient() =
|
||||||
(
|
(
|
||||||
@ -190,10 +182,10 @@ void tractionDisplacementCorrectionFvPatchVectorField::updateCoeffs()
|
|||||||
// Write
|
// Write
|
||||||
void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
|
void tractionDisplacementCorrectionFvPatchVectorField::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
fvPatchVectorField::write(os);
|
fvPatchField<vector>::write(os);
|
||||||
traction_.writeEntry("traction", os);
|
traction_.writeEntry("traction", os);
|
||||||
pressure_.writeEntry("pressure", os);
|
pressure_.writeEntry("pressure", os);
|
||||||
writeEntry("value", os);
|
fvPatchField<vector>::writeValueEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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.
|
||||||
@ -52,28 +53,29 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info << "testField:" << testField << endl;
|
Info << "testField:" << testField << endl;
|
||||||
|
|
||||||
testField.append(vector(0.5, 4.8, 6.2));
|
testField.emplace_back(0.5, 4.8, 6.2);
|
||||||
|
|
||||||
Info << "testField after appending:" << testField << endl;
|
Info << "testField after appending:" << testField << endl;
|
||||||
|
|
||||||
testField.append(vector(2.7, 2.3, 6.1));
|
testField.emplace_back(2.7, 2.3, 6.1);
|
||||||
|
|
||||||
Info << "testField after appending:" << testField << endl;
|
Info << "testField after appending:" << testField << endl;
|
||||||
|
|
||||||
vector elem = testField.remove();
|
vector elem = testField.back();
|
||||||
|
testField.pop_back();
|
||||||
|
|
||||||
Info << "removed element:" << elem << endl;
|
Info << "removed element:" << elem << endl;
|
||||||
Info << "testField:" << testField << endl;
|
Info << "testField:" << testField << endl;
|
||||||
|
|
||||||
testField.append(vector(3.0, 1.3, 9.2));
|
testField.emplace_back(3.0, 1.3, 9.2);
|
||||||
|
|
||||||
Info << "testField:" << testField << endl;
|
Info << "testField:" << testField << endl;
|
||||||
|
|
||||||
testField.setSize(10, vector(1.5, 0.6, -1.0));
|
testField.resize(10, vector(1.5, 0.6, -1.0));
|
||||||
|
|
||||||
Info << "testField after setSize:" << testField << endl;
|
Info << "testField after setSize:" << testField << endl;
|
||||||
|
|
||||||
testField.append(testField2);
|
testField.push_back(testField2);
|
||||||
|
|
||||||
Info << "testField after appending testField2:" << testField << endl;
|
Info << "testField after appending testField2:" << testField << endl;
|
||||||
|
|
||||||
@ -87,7 +89,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
testField.clear();
|
testField.clear();
|
||||||
|
|
||||||
testField.append(vector(3.0, 1.3, 9.2));
|
testField.emplace_back(3.0, 1.3, 9.2);
|
||||||
|
|
||||||
Info << "testField after clear and append:" << testField << endl;
|
Info << "testField after clear and append:" << testField << endl;
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -140,7 +140,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
0, 1, 2, 3, 4
|
0, 1, 2, 3, 4
|
||||||
};
|
};
|
||||||
dlA.append({ 5, 6 });
|
dlA.push_back({ 5, 6 });
|
||||||
dlA = { 1, 2, 4 };
|
dlA = { 1, 2, 4 };
|
||||||
|
|
||||||
DynamicList<label> dlB;
|
DynamicList<label> dlB;
|
||||||
@ -172,7 +172,7 @@ int main(int argc, char *argv[])
|
|||||||
// Copy back and append a few time
|
// Copy back and append a few time
|
||||||
for (label i=0; i < 3; i++)
|
for (label i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
dlB.append(lstA);
|
dlB.push_back(lstA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "appended list a few times" << endl;
|
Info<< "appended list a few times" << endl;
|
||||||
@ -186,7 +186,7 @@ int main(int argc, char *argv[])
|
|||||||
// Copy back and append a few time
|
// Copy back and append a few time
|
||||||
for (label i=0; i < 3; i++)
|
for (label i=0; i < 3; i++)
|
||||||
{
|
{
|
||||||
dlB.append(lstA);
|
dlB.push_back(lstA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -220,8 +220,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (label elemI=0; elemI < 5; ++elemI)
|
for (label elemI=0; elemI < 5; ++elemI)
|
||||||
{
|
{
|
||||||
dlE1.append(4 - elemI);
|
dlE1.push_back(4 - elemI);
|
||||||
dlE2.append(elemI);
|
dlE2.push_back(elemI);
|
||||||
}
|
}
|
||||||
|
|
||||||
printInfo("dlE2", dlE2, true);
|
printInfo("dlE2", dlE2, true);
|
||||||
@ -243,9 +243,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
{
|
{
|
||||||
DynamicList<label> addr(10);
|
DynamicList<label> addr(10);
|
||||||
addr.append(3);
|
addr.emplace_back(3);
|
||||||
addr.append(1);
|
addr.emplace_back(1);
|
||||||
addr.append(2);
|
addr.emplace_back(2);
|
||||||
|
|
||||||
|
// Can also use the return value
|
||||||
|
Info<< "adding " << addr.emplace_back(4) << endl;
|
||||||
|
|
||||||
forAll(dlE2, i)
|
forAll(dlE2, i)
|
||||||
{
|
{
|
||||||
@ -297,9 +300,9 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "test move-append with "
|
Info<< "test move-append with "
|
||||||
<< flatOutput(input1) << " and " << flatOutput(input2) << endl;
|
<< flatOutput(input1) << " and " << flatOutput(input2) << endl;
|
||||||
|
|
||||||
list2.append(std::move(list1));
|
list2.push_back(std::move(list1));
|
||||||
list2.append(std::move(input1));
|
list2.push_back(std::move(input1));
|
||||||
list2.append(std::move(input2));
|
list2.push_back(std::move(input2));
|
||||||
|
|
||||||
Info<< "result: " << flatOutput(list2) << nl
|
Info<< "result: " << flatOutput(list2) << nl
|
||||||
<< "inputs: " << flatOutput(list1) << " / "
|
<< "inputs: " << flatOutput(list1) << " / "
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -309,32 +309,45 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
|
// Fixed buffer would also work, but want to test using UList
|
||||||
|
List<labelPair> buffer;
|
||||||
|
|
||||||
|
const label startOfRequests = UPstream::nRequests();
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
buffer.resize(UPstream::nProcs());
|
||||||
|
buffer[0] = labelPair(0, UPstream::myProcNo());
|
||||||
|
|
||||||
for (const int proci : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
IPstream fromSlave(Pstream::commsTypes::blocking, proci);
|
UIPstream::read
|
||||||
FixedList<label, 2> list3(fromSlave);
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
Serr<< "Receiving from " << proci
|
proci,
|
||||||
<< " : " << list3 << endl;
|
buffer.slice(proci, 1)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Perr<< "Sending to master" << endl;
|
buffer.resize(1);
|
||||||
|
buffer[0] = labelPair(0, UPstream::myProcNo());
|
||||||
|
|
||||||
OPstream toMaster
|
Perr<< "Sending to master: " << buffer << endl;
|
||||||
|
|
||||||
|
UOPstream::write
|
||||||
(
|
(
|
||||||
Pstream::commsTypes::blocking,
|
UPstream::commsTypes::nonBlocking,
|
||||||
Pstream::masterNo()
|
UPstream::masterNo(),
|
||||||
|
buffer.slice(0, 1) // OK
|
||||||
|
/// buffer // Also OK
|
||||||
);
|
);
|
||||||
|
|
||||||
FixedList<label, 2> list3;
|
|
||||||
list3[0] = 0;
|
|
||||||
list3[1] = Pstream::myProcNo();
|
|
||||||
toMaster << list3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UPstream::waitRequests(startOfRequests);
|
||||||
|
|
||||||
|
Info<< "Gathered: " << buffer << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -109,7 +109,11 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
#include "setConstantRunTimeDictionaryIO.H"
|
#include "setConstantRunTimeDictionaryIO.H"
|
||||||
|
|
||||||
IOdictionary propsDict(dictIO);
|
#if (OPENFOAM > 2212)
|
||||||
|
dictionary propsDict(IOdictionary::readContents(dictIO));
|
||||||
|
#else
|
||||||
|
dictionary propsDict(static_cast<dictionary&&>(IOdictionary(dictIO)));
|
||||||
|
#endif
|
||||||
|
|
||||||
const scalarField xvals(propsDict.lookup("x"));
|
const scalarField xvals(propsDict.lookup("x"));
|
||||||
|
|
||||||
@ -132,7 +136,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (nameFilter(f))
|
if (nameFilter(f))
|
||||||
{
|
{
|
||||||
functionNames.append(f);
|
functionNames.push_back(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +144,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
for (label argi=1; argi < args.size(); ++argi)
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
{
|
{
|
||||||
functionNames.append(args[argi]);
|
functionNames.push_back(args[argi]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,11 +25,11 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
Some simple HashSet tests
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "hashedWordList.H"
|
#include "hashedWordList.H"
|
||||||
#include "nil.H"
|
|
||||||
#include "HashOps.H"
|
#include "HashOps.H"
|
||||||
#include "HashSet.H"
|
#include "HashSet.H"
|
||||||
#include "Map.H"
|
#include "Map.H"
|
||||||
@ -73,6 +73,22 @@ void printMinMax(const HashSet<Key, Hash>& set)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Key, class Hash>
|
||||||
|
void printHashSet(const HashSet<Key, Hash>& table)
|
||||||
|
{
|
||||||
|
Info<< table.size() << '(' << nl;
|
||||||
|
|
||||||
|
for (const auto& key : table.sortedToc())
|
||||||
|
{
|
||||||
|
const auto iter = table.find(key);
|
||||||
|
|
||||||
|
Info<< " " << key << " : " << Foam::name(&(iter.key())) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
@ -84,33 +100,33 @@ int main(int argc, char *argv[])
|
|||||||
<< typeid(HashSet<label>::hasher).name() << nl << nl;
|
<< typeid(HashSet<label>::hasher).name() << nl << nl;
|
||||||
|
|
||||||
hashedWordList words
|
hashedWordList words
|
||||||
{
|
({
|
||||||
"abc",
|
"abc",
|
||||||
"def",
|
"def",
|
||||||
"ghi"
|
"ghi"
|
||||||
};
|
});
|
||||||
words = { "def", "ghi", "xy", "all", "end", "all" };
|
words = { "def", "ghi", "xy", "all", "end", "all" };
|
||||||
|
|
||||||
wordHashSet setA
|
wordHashSet setA
|
||||||
{
|
({
|
||||||
"xx",
|
"xx",
|
||||||
"yy",
|
"yy",
|
||||||
"zz"
|
"zz"
|
||||||
};
|
});
|
||||||
|
|
||||||
setA = { "kjhk", "kjhk2", "abced" };
|
setA = { "kjhk", "kjhk2", "abced" };
|
||||||
|
|
||||||
HashTable<label> tableA
|
HashTable<label> tableA
|
||||||
{
|
({
|
||||||
{ "value1", 1 },
|
{ "value1", 1 },
|
||||||
{ "value2", 2 },
|
{ "value2", 2 },
|
||||||
{ "value3", 3 }
|
{ "value3", 3 }
|
||||||
};
|
});
|
||||||
|
|
||||||
HashTable<nil> tableB;
|
HashTable<Foam::zero> tableB;
|
||||||
tableB.insert("value4", nil());
|
tableB.emplace("value4");
|
||||||
tableB.insert("value5", nil());
|
tableB.emplace("value5");
|
||||||
tableB.insert("value6", nil());
|
tableB.emplace("value6");
|
||||||
|
|
||||||
Info<< "tableA keys: "; tableA.writeKeys(Info) << endl;
|
Info<< "tableA keys: "; tableA.writeKeys(Info) << endl;
|
||||||
|
|
||||||
@ -123,11 +139,11 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<label> mapA
|
Map<label> mapA
|
||||||
{
|
({
|
||||||
{ 1, 1 },
|
{ 1, 1 },
|
||||||
{ 2, 2 },
|
{ 2, 2 },
|
||||||
{ 3, 3 }
|
{ 3, 3 }
|
||||||
};
|
});
|
||||||
mapA.set(4, 4);
|
mapA.set(4, 4);
|
||||||
|
|
||||||
Info<< "hashedWordList: " << words << nl
|
Info<< "hashedWordList: " << words << nl
|
||||||
@ -169,7 +185,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< wordHashSet(setA) << endl;
|
Info<< wordHashSet(setA) << endl;
|
||||||
Info<< "create from HashTable<T>: ";
|
Info<< "create from HashTable<T>: ";
|
||||||
Info<< wordHashSet(tableA) << endl;
|
Info<< wordHashSet(tableA) << endl;
|
||||||
Info<< "create from HashTable<nil>: ";
|
Info<< "create from HashTable<zero>: ";
|
||||||
Info<< wordHashSet(tableB) << endl;
|
Info<< wordHashSet(tableB) << endl;
|
||||||
|
|
||||||
Info<< "create from Map<label>: ";
|
Info<< "create from Map<label>: ";
|
||||||
@ -185,9 +201,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
labelHashSet setB
|
labelHashSet setB
|
||||||
{
|
({
|
||||||
1, 11, 42
|
1, 11, 42
|
||||||
};
|
});
|
||||||
|
|
||||||
Info<<"Set with min/max:" << minMax(setB)
|
Info<<"Set with min/max:" << minMax(setB)
|
||||||
<< " min:" << min(setB) << " max:" << max(setB) << nl;
|
<< " min:" << min(setB) << " max:" << max(setB) << nl;
|
||||||
@ -309,6 +325,26 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "setA1: " << setA1 << nl
|
Info<< "setA1: " << setA1 << nl
|
||||||
<< "setB1: " << setB1 << nl;
|
<< "setB1: " << setB1 << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Merging
|
||||||
|
{
|
||||||
|
wordHashSet set0({ "abc", "kjhk", "kjhk2" });
|
||||||
|
wordHashSet set1({ "abc", "def", "ghi", "jkl" });
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Set0" << nl;
|
||||||
|
printHashSet(set0);
|
||||||
|
Info<< "Set1" << nl;
|
||||||
|
printHashSet(set1);
|
||||||
|
|
||||||
|
set1.merge(set0);
|
||||||
|
|
||||||
|
Info<< "merged 0" << nl;
|
||||||
|
printHashSet(set0);
|
||||||
|
Info<< "merged 1" << nl;
|
||||||
|
printHashSet(set1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,26 +79,56 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class T, class Key, class Hash>
|
||||||
|
void printTable(const HashPtrTable<T, Key, Hash>& table)
|
||||||
|
{
|
||||||
|
Info<< table.size() << '(' << nl;
|
||||||
|
|
||||||
|
for (const auto& key : table.sortedToc())
|
||||||
|
{
|
||||||
|
const auto iter = table.find(key);
|
||||||
|
|
||||||
|
Info
|
||||||
|
<< " " << iter.key() << " (" << Foam::name(&(iter.key()))
|
||||||
|
<< ") : ";
|
||||||
|
|
||||||
|
if (iter.val())
|
||||||
|
{
|
||||||
|
Info<< *(iter.val());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "nullptr";
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " (" << Foam::name(iter.val()) << ")" << nl;;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< ')' << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
HashTable<label, Foam::string> table1
|
HashTable<Label, Foam::string> table0
|
||||||
{
|
({
|
||||||
|
{"abc", 123},
|
||||||
{"kjhk", 10},
|
{"kjhk", 10},
|
||||||
{"kjhk2", 12}
|
{"kjhk2", 12}
|
||||||
};
|
});
|
||||||
|
|
||||||
Info<< "table1: " << table1 << nl
|
Info<< "table0: " << table0 << nl
|
||||||
<< "toc: " << flatOutput(table1.toc()) << nl;
|
<< "toc: " << flatOutput(table0.toc()) << nl;
|
||||||
|
|
||||||
HashTable<label, label, Hash<label>> table2
|
HashTable<label, label, Hash<label>> table2
|
||||||
{
|
({
|
||||||
{3, 10},
|
{3, 10},
|
||||||
{5, 12},
|
{5, 12},
|
||||||
{7, 16}
|
{7, 16}
|
||||||
};
|
});
|
||||||
|
|
||||||
Info<< "table2: " << table2 << nl
|
Info<< "table2: " << table2 << nl
|
||||||
<< "toc: " << flatOutput(table2.toc()) << nl;
|
<< "toc: " << flatOutput(table2.toc()) << nl;
|
||||||
@ -127,7 +157,7 @@ int main(int argc, char *argv[])
|
|||||||
table1.insert("ghi", 15);
|
table1.insert("ghi", 15);
|
||||||
table1.insert("jkl", 20);
|
table1.insert("jkl", 20);
|
||||||
|
|
||||||
Info<< nl << "Table toc: " << flatOutput(table1.toc()) << nl;
|
Info<< nl << "Table toc: " << flatOutput(table1.sortedToc()) << nl;
|
||||||
|
|
||||||
for (const word k : { "abc" })
|
for (const word k : { "abc" })
|
||||||
{
|
{
|
||||||
@ -153,16 +183,30 @@ int main(int argc, char *argv[])
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Table0: " << flatOutput(table0.sortedToc()) << nl
|
||||||
|
<< "Table1: " << flatOutput(table1.sortedToc()) << nl;
|
||||||
|
|
||||||
|
table1.merge(table0);
|
||||||
|
|
||||||
|
Info<< "merged 0: " << flatOutput(table0.sortedToc()) << nl
|
||||||
|
<< "merged 1: " << flatOutput(table1.sortedToc()) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
HashPtrTable<Label> ptable0(0);
|
||||||
|
ptable0.emplace("abc", 123),
|
||||||
|
ptable0.emplace("kjhk", 10);
|
||||||
|
ptable0.emplace("kjhk2", 12);
|
||||||
|
|
||||||
HashPtrTable<Label> ptable1(0);
|
HashPtrTable<Label> ptable1(0);
|
||||||
ptable1.insert("abc", autoPtr<Label>::New(5));
|
ptable1.insert("abc", autoPtr<Label>::New(5));
|
||||||
ptable1.insert("def", autoPtr<Label>::New(10));
|
ptable1.emplace("def", 10);
|
||||||
ptable1.insert("ghi", autoPtr<Label>::New(15));
|
ptable1.emplace("ghi", 15);
|
||||||
ptable1.insert("jkl", autoPtr<Label>::New(20));
|
ptable1.emplace("jkl", 20);
|
||||||
|
|
||||||
Info<< nl << "PtrTable toc: " << flatOutput(ptable1.toc()) << nl;
|
Info<< nl << "PtrTable toc: " << flatOutput(ptable1.sortedToc()) << nl;
|
||||||
|
|
||||||
for (const word k : { "abc" })
|
for (const word k : { "abc" })
|
||||||
{
|
{
|
||||||
@ -242,6 +286,20 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Table0" << nl;
|
||||||
|
printTable(ptable0);
|
||||||
|
|
||||||
|
Info<< "Table1" << nl;
|
||||||
|
printTable(ptable1);
|
||||||
|
|
||||||
|
ptable1.merge(ptable0);
|
||||||
|
|
||||||
|
Info<< "merged 0" << nl;
|
||||||
|
printTable(ptable0);
|
||||||
|
Info<< "merged 1" << nl;
|
||||||
|
printTable(ptable1);
|
||||||
|
|
||||||
Info<< nl << "Ending scope" << nl;
|
Info<< nl << "Ending scope" << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,6 +335,28 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "got with " << (*iter).size() << nl;
|
Info<< "got with " << (*iter).size() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Test (DIY) insert_or_assign" << nl;
|
||||||
|
|
||||||
|
label nKeys = 0;
|
||||||
|
|
||||||
|
for (const auto& key : { "abc", "foo", "mno", "xyz" })
|
||||||
|
{
|
||||||
|
Info<< key;
|
||||||
|
if (ltable1.contains(key))
|
||||||
|
{
|
||||||
|
Info<< " : " << ltable1[key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " : n/a";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ltable1.insert_or_assign(key, identity(++nKeys));
|
||||||
|
ltable1(key) = identity(++nKeys);
|
||||||
|
|
||||||
|
Info<< " --> " << ltable1[key] << nl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|||||||
@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "==target==" << nl; reportDetail(objects);
|
Info<< "==target==" << nl; reportDetail(objects);
|
||||||
Info<< "==source==" << nl; reportDetail(other);
|
Info<< "==source==" << nl; reportDetail(other);
|
||||||
|
|
||||||
objects.merge(std::move(other));
|
objects.merge(other);
|
||||||
Info<< nl << "After merge" << nl;
|
Info<< nl << "After merge" << nl;
|
||||||
|
|
||||||
Info<< "==target==" << nl; reportDetail(objects);
|
Info<< "==target==" << nl; reportDetail(objects);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -81,7 +81,7 @@ namespace ListPolicy
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Override on a per-type basis
|
// Override on a per-type basis
|
||||||
template<> struct short_length<short> : std::integral_constant<short,20> {};
|
template<> struct short_length<short> : std::integral_constant<int,20> {};
|
||||||
|
|
||||||
} // End namespace ListPolicy
|
} // End namespace ListPolicy
|
||||||
} // End namespace Detail
|
} // End namespace Detail
|
||||||
@ -365,6 +365,12 @@ int main(int argc, char *argv[])
|
|||||||
Info<<"assigned identity in range:" << subset
|
Info<<"assigned identity in range:" << subset
|
||||||
<< "=> " << flatOutput(longLabelList) << nl;
|
<< "=> " << flatOutput(longLabelList) << nl;
|
||||||
|
|
||||||
|
// Assign values in iterator range
|
||||||
|
std::iota(longLabelList.begin(15), longLabelList.begin(50), 115);
|
||||||
|
|
||||||
|
Info<<"assigned values in iterator range "
|
||||||
|
<< "=> " << flatOutput(longLabelList) << nl;
|
||||||
|
|
||||||
labelList someList(identity(24));
|
labelList someList(identity(24));
|
||||||
|
|
||||||
longLabelList.slice(subset) =
|
longLabelList.slice(subset) =
|
||||||
@ -410,8 +416,20 @@ int main(int argc, char *argv[])
|
|||||||
longLabelList.slice({5,-5}) = 42;
|
longLabelList.slice({5,-5}) = 42;
|
||||||
longLabelList.slice({21,100}) = 42;
|
longLabelList.slice({21,100}) = 42;
|
||||||
|
|
||||||
//Good: does not compile
|
#if 0
|
||||||
longLabelList.slice(labelRange(20,50)) = constLabelList;
|
// Compiles, but is runtime abort!
|
||||||
|
const bool oldThrowingError = FatalError.throwing(true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
longLabelList.slice(labelRange(20,50)) = constLabelList;
|
||||||
|
}
|
||||||
|
catch (const Foam::error& err)
|
||||||
|
{
|
||||||
|
Info<< "Caught FatalError "
|
||||||
|
<< err << nl << endl;
|
||||||
|
}
|
||||||
|
FatalError.throwing(oldThrowingError);
|
||||||
|
#endif
|
||||||
|
|
||||||
//Good: does not compile
|
//Good: does not compile
|
||||||
// longLabelList[labelRange(20,50)] = fixedLabelList;
|
// longLabelList[labelRange(20,50)] = fixedLabelList;
|
||||||
|
|||||||
@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
|||||||
<< IndirectList<label>::subset_if(test6, evenNonZero) << nl
|
<< IndirectList<label>::subset_if(test6, evenNonZero) << nl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
test6.append(identity(13, 12));
|
test6.push_back(identity(13, 12));
|
||||||
|
|
||||||
Info<< "Randomized: " << flatOutput(test6) << endl;
|
Info<< "Randomized: " << flatOutput(test6) << endl;
|
||||||
inplaceUniqueSort(test6);
|
inplaceUniqueSort(test6);
|
||||||
|
|||||||
@ -191,7 +191,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< nl << "list: " << flatOutput(list) << nl << endl;
|
Info<< nl << "list: " << flatOutput(list) << nl << endl;
|
||||||
|
|
||||||
list.remove();
|
list.pop_back();
|
||||||
Info<<"remove = " << flatOutput(list) << nl;
|
Info<<"remove = " << flatOutput(list) << nl;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -52,13 +52,13 @@ int main(int argc, char *argv[])
|
|||||||
// Same, but with non-const access
|
// Same, but with non-const access
|
||||||
// Map<bool>::iterator map1Iter = map1.find(5);
|
// Map<bool>::iterator map1Iter = map1.find(5);
|
||||||
|
|
||||||
if (!map1Iter.found()) // same as (map1Iter == map1.end())
|
if (!map1Iter.good())
|
||||||
{
|
{
|
||||||
Info<< "not found" << endl;
|
Info<< "not found" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< "5 is " << *map1Iter << endl;
|
Info<< "5 is " << map1Iter.val() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repeat with std::map
|
// Repeat with std::map
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -71,16 +72,9 @@ int main(int argc, char *argv[])
|
|||||||
label edgeI = 0;
|
label edgeI = 0;
|
||||||
Info<< "Starting walk on edge " << edgeI << endl;
|
Info<< "Starting walk on edge " << edgeI << endl;
|
||||||
|
|
||||||
initialEdges.append(edgeI);
|
initialEdges.push_back(edgeI);
|
||||||
const edge& e = patch.edges()[edgeI];
|
const edge& e = patch.edges()[edgeI];
|
||||||
initialEdgesInfo.append
|
initialEdgesInfo.emplace_back(e.centre(patch.localPoints()), 0);
|
||||||
(
|
|
||||||
patchEdgeFaceInfo
|
|
||||||
(
|
|
||||||
e.centre(patch.localPoints()),
|
|
||||||
0.0
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -268,10 +268,7 @@ Ostream& report
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
PtrList<Scalar> list1(10);
|
#if 0
|
||||||
PtrList<Scalar> list2(15);
|
|
||||||
PtrList<Scalar> listApp;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
DLPtrList<Scalar> llist1;
|
DLPtrList<Scalar> llist1;
|
||||||
llist1.push_front(new Scalar(100));
|
llist1.push_front(new Scalar(100));
|
||||||
@ -301,8 +298,10 @@ int main(int argc, char *argv[])
|
|||||||
<< "for-: " << it << endl;
|
<< "for-: " << it << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Same but as SLPtrList
|
// Same but as SLPtrList
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
SLPtrList<Scalar> llist1;
|
SLPtrList<Scalar> llist1;
|
||||||
llist1.push_front(new Scalar(100));
|
llist1.push_front(new Scalar(100));
|
||||||
@ -318,24 +317,27 @@ int main(int argc, char *argv[])
|
|||||||
PtrList<Scalar> list1b(llist1);
|
PtrList<Scalar> list1b(llist1);
|
||||||
Info<< list1b << endl;
|
Info<< list1b << endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PtrList<Scalar> list1(10);
|
||||||
|
|
||||||
forAll(list1, i)
|
forAll(list1, i)
|
||||||
{
|
{
|
||||||
list1.set(i, new Scalar(1.3*i));
|
list1.set(i, new Scalar(1.3*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PtrList<Scalar> list2(15);
|
||||||
Info<< "Emplace set " << list2.size() << " values" << nl;
|
Info<< "Emplace set " << list2.size() << " values" << nl;
|
||||||
forAll(list2, i)
|
forAll(list2, i)
|
||||||
{
|
{
|
||||||
list2.emplace(i, (10 + 1.3*i));
|
list2.emplace(i, (10 + 1.3*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PtrList<Scalar> listApp;
|
||||||
for (label i = 0; i < 5; ++i)
|
for (label i = 0; i < 5; ++i)
|
||||||
{
|
{
|
||||||
listApp.append(new Scalar(1.3*i));
|
listApp.emplace_back(1.3*i);
|
||||||
}
|
}
|
||||||
listApp.emplace_back(100);
|
|
||||||
|
|
||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "list1: " << list1 << nl
|
<< "list1: " << list1 << nl
|
||||||
@ -353,7 +355,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (old)
|
if (old)
|
||||||
{
|
{
|
||||||
ptrs.append(old.release());
|
ptrs.push_back(old.release());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,6 +379,24 @@ int main(int argc, char *argv[])
|
|||||||
list1.set(i, nullptr);
|
list1.set(i, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Info<< "range-for of list (" << list1.count() << '/'
|
||||||
|
<< list1.size() << ") non-null entries" << nl
|
||||||
|
<< "(" << nl;
|
||||||
|
for (const auto& item : list1)
|
||||||
|
{
|
||||||
|
Info<< " " << item << nl;
|
||||||
|
}
|
||||||
|
Info<< ")" << nl;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Info<< "iterate on non-null:" << endl;
|
||||||
|
forAllConstIters(list1, iter)
|
||||||
|
{
|
||||||
|
Info<< " " << iter.key() << " : " << iter.val() << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "release some items:" << endl;
|
Info<< "release some items:" << endl;
|
||||||
|
|
||||||
for (label i = -2; i < 5; i++)
|
for (label i = -2; i < 5; i++)
|
||||||
@ -459,8 +479,8 @@ int main(int argc, char *argv[])
|
|||||||
printAddr(Info, dynlist1b);
|
printAddr(Info, dynlist1b);
|
||||||
printAddr(Info, dynlist1c);
|
printAddr(Info, dynlist1c);
|
||||||
|
|
||||||
dynlist1d.append(std::move(dynlist1b));
|
dynlist1d.push_back(std::move(dynlist1b));
|
||||||
dynlist1d.append(std::move(dynlist1c));
|
dynlist1d.push_back(std::move(dynlist1c));
|
||||||
|
|
||||||
Info<< "result:" << nl;
|
Info<< "result:" << nl;
|
||||||
print(Info, dynlist1d);
|
print(Info, dynlist1d);
|
||||||
@ -477,8 +497,8 @@ int main(int argc, char *argv[])
|
|||||||
printAddr(Info, list1b);
|
printAddr(Info, list1b);
|
||||||
printAddr(Info, list1c);
|
printAddr(Info, list1c);
|
||||||
|
|
||||||
list1d.append(std::move(list1b));
|
list1d.push_back(std::move(list1b));
|
||||||
list1d.append(std::move(list1c));
|
list1d.push_back(std::move(list1c));
|
||||||
|
|
||||||
Info<< "result:" << nl;
|
Info<< "result:" << nl;
|
||||||
print(Info, list1d);
|
print(Info, list1d);
|
||||||
@ -523,7 +543,7 @@ int main(int argc, char *argv[])
|
|||||||
printAddr(Info, ulist1);
|
printAddr(Info, ulist1);
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|
||||||
ulist1c.append(std::move(ulist1b));
|
ulist1c.push_back(std::move(ulist1b));
|
||||||
|
|
||||||
Info<< "UPtrList append/append:";
|
Info<< "UPtrList append/append:";
|
||||||
printAddr(Info, ulist1c);
|
printAddr(Info, ulist1c);
|
||||||
@ -564,6 +584,7 @@ int main(int argc, char *argv[])
|
|||||||
<< "ulist2: " << ulist2 << nl;
|
<< "ulist2: " << ulist2 << nl;
|
||||||
|
|
||||||
// Test iterator random access
|
// Test iterator random access
|
||||||
|
#if (OPENFOAM <= 2212)
|
||||||
{
|
{
|
||||||
auto iter1 = ulist1.begin();
|
auto iter1 = ulist1.begin();
|
||||||
auto iter2 = iter1 + 3;
|
auto iter2 = iter1 + 3;
|
||||||
@ -578,6 +599,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "*" << (*iter1).value() << nl;
|
Info<< "*" << (*iter1).value() << nl;
|
||||||
Info<< "()" << iter1().value() << nl;
|
Info<< "()" << iter1().value() << nl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
PtrList<plane> planes;
|
PtrList<plane> planes;
|
||||||
planes.emplace_back(vector::one, vector::one);
|
planes.emplace_back(vector::one, vector::one);
|
||||||
@ -596,12 +618,14 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
dynPlanes.emplace_back(vector::one, vector::one);
|
dynPlanes.emplace_back(vector::one, vector::one);
|
||||||
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
||||||
dynPlanes.append(nullptr);
|
dynPlanes.push_back(nullptr);
|
||||||
|
|
||||||
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));
|
||||||
|
|
||||||
dynPlanes.emplace(12, vector(3,2,1), vector::one);
|
Info<< "emplaced :"
|
||||||
|
<< dynPlanes.emplace(12, vector(3,2,1), vector::one) << endl;
|
||||||
|
|
||||||
dynPlanes.emplace_back(Zero, vector::one);
|
dynPlanes.emplace_back(Zero, vector::one);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,10 +643,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "now append again" << endl;
|
Info<< "now append again" << endl;
|
||||||
{
|
{
|
||||||
dynPlanes.append(new plane(vector::one, vector::one));
|
dynPlanes.emplace_back(vector::one, vector::one);
|
||||||
dynPlanes.append(new plane(vector(1,2,3), vector::one));
|
dynPlanes.emplace_back(vector(1,2,3), vector::one);
|
||||||
|
|
||||||
dynPlanes.set(5, new plane(vector(2,2,1), vector::one));
|
dynPlanes.emplace(5, vector(2,2,1), vector::one);
|
||||||
}
|
}
|
||||||
|
|
||||||
report(Info, dynPlanes, true);
|
report(Info, dynPlanes, true);
|
||||||
@ -658,12 +682,12 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
PtrDynList<plane> dynPlanes2;
|
PtrDynList<plane> dynPlanes2;
|
||||||
|
|
||||||
dynPlanes2.append(new plane(vector::one, vector::one));
|
dynPlanes2.emplace_back(vector::one, vector::one);
|
||||||
dynPlanes2.append(new plane(vector(1,2,3), vector::one));
|
dynPlanes2.emplace_back(vector(1,2,3), vector::one);
|
||||||
dynPlanes2.append(nullptr);
|
dynPlanes2.push_back(nullptr);
|
||||||
|
|
||||||
dynPlanes2.set(6, new plane(vector(2,2,1), vector::one));
|
dynPlanes2.emplace(6, vector(2,2,1), vector::one);
|
||||||
dynPlanes2.set(10, new plane(Zero, vector::one));
|
dynPlanes2.emplace(10, Zero, vector::one);
|
||||||
|
|
||||||
labelList order;
|
labelList order;
|
||||||
sortedOrder(dynPlanes2, order);
|
sortedOrder(dynPlanes2, order);
|
||||||
@ -701,7 +725,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Append" << endl;
|
Info<< "Append" << endl;
|
||||||
report(Info, dynPlanes2, false);
|
report(Info, dynPlanes2, false);
|
||||||
|
|
||||||
dynPlanes.append(std::move(dynPlanes2));
|
dynPlanes.push_back(std::move(dynPlanes2));
|
||||||
|
|
||||||
Info<< "Result" << endl;
|
Info<< "Result" << endl;
|
||||||
report(Info, dynPlanes, false);
|
report(Info, dynPlanes, false);
|
||||||
|
|||||||
@ -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.
|
||||||
@ -130,7 +131,7 @@ int main(int argc, char *argv[])
|
|||||||
flatList = labelUIndList(completeList, addresses);
|
flatList = labelUIndList(completeList, addresses);
|
||||||
Info<< "List assign from UIndirectList: " << flatOutput(flatList) << nl;
|
Info<< "List assign from UIndirectList: " << flatOutput(flatList) << nl;
|
||||||
|
|
||||||
flatList.append(labelUIndList(completeList, addresses));
|
flatList.push_back(labelUIndList(completeList, addresses));
|
||||||
Info<< "List::append(UIndirectList): " << flatOutput(flatList) << nl;
|
Info<< "List::append(UIndirectList): " << flatOutput(flatList) << nl;
|
||||||
|
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "DynamicList construct from UIndirectList: " << flatOutput(dynList)
|
Info<< "DynamicList construct from UIndirectList: " << flatOutput(dynList)
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
dynList.append(labelUIndList(completeList, addresses));
|
flatList.push_back(labelUIndList(completeList, addresses));
|
||||||
Info<< "DynamicList::append(UIndirectList): " << flatOutput(dynList) << nl;
|
Info<< "DynamicList::append(UIndirectList): " << flatOutput(dynList) << nl;
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -59,9 +59,24 @@ int main(int argc, char *argv[])
|
|||||||
<< "complexVector::one : " << complexVector::one << nl
|
<< "complexVector::one : " << complexVector::one << nl
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
|
{
|
||||||
|
const complex a(0, 1);
|
||||||
|
const complex b(20, 100);
|
||||||
|
|
||||||
|
Info<< "lerp of " << a << " : " << b << nl;
|
||||||
|
|
||||||
|
for (const double t : { 0.0, 0.5, 1.0, -0.5, 1.5 })
|
||||||
|
{
|
||||||
|
Info<< " " << t << " = " << lerp(a, b, t) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (complex c : { complex{1, 0}, complex{1, 2}} )
|
for (complex c : { complex{1, 0}, complex{1, 2}} )
|
||||||
{
|
{
|
||||||
Info<< nl << "complex : " << c << nl;
|
Info<< nl << "complex : " << c
|
||||||
|
<< " mag = " << c.magnitude()
|
||||||
|
<< " norm = " << c.magSqr()
|
||||||
|
<< nl;
|
||||||
|
|
||||||
Info<< "sin: " << sin(c) << nl
|
Info<< "sin: " << sin(c) << nl
|
||||||
<< "pow(3.0f): " << pow(c, 3.0f) << nl
|
<< "pow(3.0f): " << pow(c, 3.0f) << nl
|
||||||
@ -130,6 +145,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
complexField cmplx(4);
|
complexField cmplx(4);
|
||||||
|
|
||||||
|
zip(cmplx, reals, zero{});
|
||||||
|
zip(cmplx, 1, imags);
|
||||||
zip(cmplx, reals, imags);
|
zip(cmplx, reals, imags);
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "zip " << reals << nl
|
<< "zip " << reals << nl
|
||||||
@ -345,6 +362,24 @@ int main(int argc, char *argv[])
|
|||||||
// MinMax fails since there is no less comparison operator
|
// MinMax fails since there is no less comparison operator
|
||||||
// Info<< "min/max = " << MinMax<complex>(fld1) << nl;
|
// Info<< "min/max = " << MinMax<complex>(fld1) << nl;
|
||||||
|
|
||||||
|
|
||||||
|
// Cross-product
|
||||||
|
{
|
||||||
|
const vector vec(1, 2, 3);
|
||||||
|
const vector realValue(4, 5, 6);
|
||||||
|
const vector imagValue(7, 8, 9);
|
||||||
|
|
||||||
|
complexVector cmplxVec(zip(realValue, imagValue));
|
||||||
|
|
||||||
|
Info<< "complexVector: " << cmplxVec << nl;
|
||||||
|
Info<< "cross: " << (vec ^ cmplxVec) << nl;
|
||||||
|
|
||||||
|
Info<< "cross real: " << (vec ^ realValue) << nl
|
||||||
|
<< "cross imag: " << (vec ^ imagValue) << nl
|
||||||
|
<< "cross : "
|
||||||
|
<< zip((vec ^ realValue), (vec ^ imagValue)) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -28,7 +28,6 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "string.H"
|
|
||||||
#include "macros.H"
|
#include "macros.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
|
|||||||
@ -84,10 +84,10 @@ int main(int argc, char *argv[])
|
|||||||
DynamicList<string> dynlst;
|
DynamicList<string> dynlst;
|
||||||
dynlst.reserve(16);
|
dynlst.reserve(16);
|
||||||
|
|
||||||
dynlst.append("string1 with content");
|
dynlst.push_back("string1 with content");
|
||||||
dynlst.append("string2 other content");
|
dynlst.push_back("string2 other content");
|
||||||
dynlst.append("string3 more");
|
dynlst.push_back("string3 more");
|
||||||
dynlst.append("string4 done");
|
dynlst.push_back("string4 done");
|
||||||
|
|
||||||
{
|
{
|
||||||
CStringList inC(dynlst);
|
CStringList inC(dynlst);
|
||||||
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
|
|||||||
dynlst.clear();
|
dynlst.clear();
|
||||||
for (int i=0; i<argc; ++i)
|
for (int i=0; i<argc; ++i)
|
||||||
{
|
{
|
||||||
dynlst.append(argv[i]);
|
dynlst.push_back(argv[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "input: " << dynlst << endl;
|
Info<< "input: " << dynlst << endl;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "string.H"
|
#include "word.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|||||||
39
applications/test/dictionary/testDictEval5
Normal file
39
applications/test/dictionary/testDictEval5
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2306 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object dictionary;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// Test evaluation with small values
|
||||||
|
|
||||||
|
dp #eval{ sqrt(3./2.) *1e-3};
|
||||||
|
a #eval{ 2/sqrt(2.)*$dp };
|
||||||
|
A_square #eval{ $a*$a };
|
||||||
|
A_inlet #eval{ $A_square-2*degToRad(180)*$dp*$dp*0.25 };
|
||||||
|
Q $A_inlet;
|
||||||
|
Qerror #eval{$A_inlet};
|
||||||
|
e #eval{0.2526944494428081};
|
||||||
|
Uin #eval{ $Q/($A_square*$e) };
|
||||||
|
|
||||||
|
// Bypass
|
||||||
|
|
||||||
|
alt_dp #eval{ sqrt(3./2.) *1e-3};
|
||||||
|
alt_a #eval{ 2/sqrt(2.)*$[alt_dp] };
|
||||||
|
alt_A_square #eval{ $[alt_a]*$[alt_a] };
|
||||||
|
alt_A_inlet #eval{ $[alt_A_square]-2*degToRad(180)*$[alt_dp]*$[alt_dp]*0.25 };
|
||||||
|
alt_Q $alt_A_inlet;
|
||||||
|
alt_Qerror #eval{ $[alt_A_inlet] };
|
||||||
|
alt_e #eval{0.2526944494428081};
|
||||||
|
alt_Uin #eval{ $[alt_Q]/($[alt_A_square]*$[alt_e]) };
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -110,8 +110,7 @@ unsigned checkDimensions
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// min(a, b);
|
min(a, b);
|
||||||
clip(a, b);
|
|
||||||
dimsOk = true;
|
dimsOk = true;
|
||||||
}
|
}
|
||||||
catch (const Foam::error& err)
|
catch (const Foam::error& err)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,8 +28,7 @@ License
|
|||||||
|
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "primitiveEntry.H"
|
#include "primitiveEntry.H"
|
||||||
#include "dimensionedScalar.H"
|
#include "dimensionedTypes.H"
|
||||||
#include "dimensionedTensor.H"
|
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -102,6 +101,18 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
dimensionedLabel a("min", dimTime, -10);
|
||||||
|
dimensionedLabel b("max", dimTime, 100);
|
||||||
|
scalar t = 0.5;
|
||||||
|
|
||||||
|
Info<< "lerp of" << nl
|
||||||
|
<< " " << a << nl
|
||||||
|
<< " " << b << nl
|
||||||
|
<< " = " << lerp(a, b, t) << nl
|
||||||
|
<< " vs " << ((1-t)*a + t*b) << nl
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
Pout<< "zero scalar (time): " << dimensionedScalar(dimTime) << endl;
|
Pout<< "zero scalar (time): " << dimensionedScalar(dimTime) << endl;
|
||||||
Pout<< "zero vector: " << dimensionedVector(dimLength) << endl;
|
Pout<< "zero vector: " << dimensionedVector(dimLength) << endl;
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2012 OpenFOAM Foundation
|
Copyright (C) 2012 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -67,14 +68,14 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
scalar factor = pI/scalar(size);
|
scalar factor = pI/scalar(size);
|
||||||
|
|
||||||
pointList.append(0.99*point(factor, factor, factor));
|
pointList.push_back(0.99*point::uniform(factor));
|
||||||
pointFieldList[pI] = 0.99*point(factor, factor, factor);
|
pointFieldList[pI] = 0.99*point::uniform(factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label i=0; i<5; ++i)
|
for (label i=0; i<5; ++i)
|
||||||
{
|
{
|
||||||
pointList.append(point(0.95, 0.95,0.95));
|
pointList.emplace_back(0.95, 0.95, 0.95);
|
||||||
pointFieldList.append(point(0.95, 0.95,0.95));
|
pointFieldList.emplace_back(0.95, 0.95, 0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Time to construct lists of points: "
|
Info<< "Time to construct lists of points: "
|
||||||
@ -148,7 +149,7 @@ int main(int argc, char *argv[])
|
|||||||
// Test point insertion
|
// Test point insertion
|
||||||
|
|
||||||
label index = pointList.size();
|
label index = pointList.size();
|
||||||
pointList.append(p);
|
pointList.push_back(p);
|
||||||
|
|
||||||
Info<< nl << "Inserting point " << p << " with index " << index << endl;
|
Info<< nl << "Inserting point " << p << " with index " << index << endl;
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ int main(int argc, char *argv[])
|
|||||||
<< tree.findNearest(p, 0.4) << endl;
|
<< tree.findNearest(p, 0.4) << endl;
|
||||||
|
|
||||||
index = pointList.size();
|
index = pointList.size();
|
||||||
pointList.append(p);
|
pointList.push_back(p);
|
||||||
|
|
||||||
Info<< "Inserting same point " << p << " with index " << index << endl;
|
Info<< "Inserting same point " << p << " with index " << index << endl;
|
||||||
|
|
||||||
|
|||||||
@ -85,8 +85,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
libPtrs_.append(ptr);
|
libPtrs_.push_back(ptr);
|
||||||
libNames_.append(libName);
|
libNames_.push_back(libName);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,12 +48,6 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool notEqual(const scalar s1, const scalar s2, const scalar tol)
|
|
||||||
{
|
|
||||||
return mag(s1-s2) > tol;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Main program:
|
// Main program:
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -154,6 +148,8 @@ int main(int argc, char *argv[])
|
|||||||
// Face removal engine. No checking for not merging boundary faces.
|
// Face removal engine. No checking for not merging boundary faces.
|
||||||
removeFaces faceRemover(mesh, GREAT);
|
removeFaces faceRemover(mesh, GREAT);
|
||||||
|
|
||||||
|
// Comparison for inequality
|
||||||
|
const auto isNotEqual = notEqualOp<scalar>(1e-10);
|
||||||
|
|
||||||
while (runTime.loop())
|
while (runTime.loop())
|
||||||
{
|
{
|
||||||
@ -254,7 +250,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check constant profile
|
// Check constant profile
|
||||||
{
|
{
|
||||||
const scalar max = gMax(one);
|
const scalar max = gMax(one);
|
||||||
@ -263,7 +258,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Uniform one field min = " << min
|
Info<< "Uniform one field min = " << min
|
||||||
<< " max = " << max << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (notEqual(max, 1.0, 1e-10) || notEqual(min, 1.0, 1e-10))
|
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform volVectorField not preserved."
|
<< "Uniform volVectorField not preserved."
|
||||||
@ -287,7 +282,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Linear profile field min = " << min
|
Info<< "Linear profile field min = " << min
|
||||||
<< " max = " << max << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (notEqual(max, 0.0, 1e-10) || notEqual(min, 0.0, 1e-10))
|
if (isNotEqual(max, 0) || isNotEqual(min, 0))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Linear profile not preserved."
|
<< "Linear profile not preserved."
|
||||||
@ -310,7 +305,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Uniform surface field min = " << min
|
Info<< "Uniform surface field min = " << min
|
||||||
<< " max = " << max << endl;
|
<< " max = " << max << endl;
|
||||||
|
|
||||||
if (notEqual(max, 1.0, 1e-10) || notEqual(min, 1.0, 1e-10))
|
if (isNotEqual(max, 1) || isNotEqual(min, 1))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Uniform surfaceScalarField not preserved."
|
<< "Uniform surfaceScalarField not preserved."
|
||||||
|
|||||||
@ -35,15 +35,18 @@ Description
|
|||||||
#include "vector2D.H"
|
#include "vector2D.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
typedef GeometricField<vector2D, fvPatchField, volMesh> volVector2DField;
|
typedef GeometricField<vector2D, fvPatchField, volMesh> volVector2DField;
|
||||||
|
typedef fvPatchField<vector2D> fvPatchVector2DField;
|
||||||
|
|
||||||
defineTemplateTypeNameAndDebug(volVector2DField::Internal, 0);
|
defineTemplateTypeNameAndDebug(volVector2DField::Internal, 0);
|
||||||
defineTemplateTypeNameAndDebug(volVector2DField, 0);
|
defineTemplateTypeNameAndDebug(volVector2DField, 0);
|
||||||
|
|
||||||
typedef fvPatchField<vector2D> fvPatchVector2DField;
|
defineTemplateRunTimeSelectionTable(fvPatchVector2DField, patch);
|
||||||
makeFvPatchField(fvPatchVector2DField)
|
defineTemplateRunTimeSelectionTable(fvPatchVector2DField, patchMapper);
|
||||||
|
defineTemplateRunTimeSelectionTable(fvPatchVector2DField, dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
Copyright (C) 2021-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
|||||||
DynamicList<label> globalIDs;
|
DynamicList<label> globalIDs;
|
||||||
for (label i = 0; i < 100; i++)
|
for (label i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
globalIDs.append(rndGen.position(label(0), nTotalCells-1));
|
globalIDs.push_back(rndGen.position(label(0), nTotalCells-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the cell centres at those cell indices
|
// Get the cell centres at those cell indices
|
||||||
|
|||||||
3
applications/test/gravityMeshObject/Make/files
Normal file
3
applications/test/gravityMeshObject/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-gravityMeshObject.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-gravityMeshObject
|
||||||
5
applications/test/gravityMeshObject/Make/options
Normal file
5
applications/test/gravityMeshObject/Make/options
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
EXE_INC = \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
-lfiniteVolume
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -23,50 +23,66 @@ License
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::EdgeMap
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Map from edge (expressed as its endpoints) to value.
|
Test loading of different gravity items
|
||||||
For easier forward declaration it is currently implemented as a
|
|
||||||
separate class rather than a template alias.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef EdgeMap_H
|
#include "MeshObject.H"
|
||||||
#define EdgeMap_H
|
#include "gravityMeshObject.H"
|
||||||
|
#include "IOobjectList.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
#include "edge.H"
|
using namespace Foam;
|
||||||
#include "HashTable.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
void printInfo(const meshObjects::gravity& g)
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
{
|
||||||
|
Pout<< "name:" << g.uniformDimensionedVectorField::name()
|
||||||
|
<< " type:" << g.type()
|
||||||
|
<< " value:" << g.value() << nl;
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class EdgeMap Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
template<class T>
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
class EdgeMap
|
// Main program:
|
||||||
:
|
|
||||||
public HashTable<T, edge, Hash<edge>>
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
public:
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
|
||||||
//- Inherit constructors from HashTable
|
IOobjectList objects(runTime, runTime.constant());
|
||||||
using HashTable<T, edge, Hash<edge>>::HashTable;
|
|
||||||
|
|
||||||
};
|
Info<< "Found: " << objects << nl << endl;
|
||||||
|
|
||||||
|
for (const IOobject& io : objects.sorted<uniformDimensionedVectorField>())
|
||||||
|
{
|
||||||
|
if (io.name() == meshObjects::gravity::typeName)
|
||||||
|
{
|
||||||
|
const auto& g = meshObjects::gravity::New(runTime);
|
||||||
|
printInfo(g);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto& g = meshObjects::gravity::New(io.name(), runTime);
|
||||||
|
printInfo(g);
|
||||||
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
} // End namespace Foam
|
meshObjects::gravity::Delete("g", runTime);
|
||||||
|
meshObjects::gravity::Delete("something-not-in-registry", runTime);
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
Info<< "after Delete" << nl;
|
||||||
|
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << endl;
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
21
applications/test/gravityMeshObject/case1/constant/banana
Normal file
21
applications/test/gravityMeshObject/case1/constant/banana
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2212 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class uniformDimensionedVectorField;
|
||||||
|
location "constant";
|
||||||
|
object banana;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 1 -2 0 0 0 0];
|
||||||
|
value (0 0 -10);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
21
applications/test/gravityMeshObject/case1/constant/g
Normal file
21
applications/test/gravityMeshObject/case1/constant/g
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2212 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class uniformDimensionedVectorField;
|
||||||
|
location "constant";
|
||||||
|
object g;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 1 -2 0 0 0 0];
|
||||||
|
value (0 -9.81 0);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
21
applications/test/gravityMeshObject/case1/constant/saturn
Normal file
21
applications/test/gravityMeshObject/case1/constant/saturn
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2212 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class uniformDimensionedVectorField;
|
||||||
|
location "constant";
|
||||||
|
object saturn;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dimensions [0 1 -2 0 0 0 0];
|
||||||
|
value (-100 0 0);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
34
applications/test/gravityMeshObject/case1/system/controlDict
Normal file
34
applications/test/gravityMeshObject/case1/system/controlDict
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: v2212 |
|
||||||
|
| \\ / A nd | Website: www.openfoam.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object controlDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
application blockMesh;
|
||||||
|
|
||||||
|
startFrom startTime;
|
||||||
|
|
||||||
|
startTime 0;
|
||||||
|
|
||||||
|
stopAt endTime;
|
||||||
|
|
||||||
|
endTime 10;
|
||||||
|
|
||||||
|
deltaT 1;
|
||||||
|
|
||||||
|
writeControl timeStep;
|
||||||
|
|
||||||
|
writeInterval 1;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -62,20 +62,20 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
DynamicList<instant> times;
|
DynamicList<instant> times;
|
||||||
|
|
||||||
times.append(instant{});
|
times.emplace_back();
|
||||||
times.append({12, "abc"});
|
times.emplace_back(12, "abc");
|
||||||
times.append(instant{3.14159});
|
times.emplace_back(3.14159);
|
||||||
times.append({300.456, "def"});
|
times.emplace_back(300.456, "def");
|
||||||
times.append({454.456, "xyz"});
|
times.emplace_back(454.456, "xyz");
|
||||||
times.append({10, "ten"});
|
times.emplace_back(10, "ten");
|
||||||
times.append({15, "fifteen"});
|
times.push_back({15, "fifteen"});
|
||||||
|
|
||||||
{
|
{
|
||||||
word timeName("twenty");
|
word timeName("twenty");
|
||||||
|
|
||||||
Info<<"move append: " << timeName << nl;
|
Info<<"move append: <" << timeName << '>' << nl;
|
||||||
times.append({20, std::move(timeName)});
|
times.emplace_back(20, std::move(timeName));
|
||||||
Info<<"after append: " << timeName << nl;
|
Info<<"after append: <" << timeName << '>' << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "times:" << times << nl;
|
Info<< nl << "times:" << times << nl;
|
||||||
@ -97,12 +97,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
DynamicList<fileNameInstant> files;
|
DynamicList<fileNameInstant> files;
|
||||||
files.append(fileNameInstant{});
|
files.emplace_back();
|
||||||
files.append({12, "twelve"});
|
files.emplace_back(12, "twelve");
|
||||||
files.append({3.14, "/path/almost-pi"});
|
files.emplace_back(3.14, "/path/almost-pi");
|
||||||
files.append({300, "/dev/value"});
|
files.emplace_back(300, "/dev/value");
|
||||||
files.append({454, "/tmp/xyz"});
|
files.emplace_back(454, "/tmp/xyz");
|
||||||
files.append({10, "ten"});
|
files.emplace_back(10, "ten");
|
||||||
|
|
||||||
Info<< nl << "files:" << files << nl;
|
Info<< nl << "files:" << files << nl;
|
||||||
sort(files);
|
sort(files);
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011 OpenFOAM Foundation
|
Copyright (C) 2011 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -37,9 +37,7 @@ using namespace Foam;
|
|||||||
|
|
||||||
void printInfo(const labelRange& range)
|
void printInfo(const labelRange& range)
|
||||||
{
|
{
|
||||||
Info<< "first " << range.first() << nl
|
Info<< "min " << range.min() << nl
|
||||||
<< "last " << range.last() << nl
|
|
||||||
<< "min " << range.min() << nl
|
|
||||||
<< "max " << range.max() << nl
|
<< "max " << range.max() << nl
|
||||||
<< "end " << range.end_value() << nl
|
<< "end " << range.end_value() << nl
|
||||||
<< "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl;
|
<< "begin/end " << *range.cbegin() << ' ' << *range.cend() << nl;
|
||||||
@ -78,10 +76,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Info<<"test sorting" << endl;
|
Info<<"test sorting" << endl;
|
||||||
DynamicList<labelRange> list1(10);
|
DynamicList<labelRange> list1(10);
|
||||||
list1.append(labelRange(25, 8));
|
list1.emplace_back(25, 8);
|
||||||
list1.append(labelRange(8));
|
list1.emplace_back(8);
|
||||||
list1.append(labelRange(15, 5));
|
list1.emplace_back(15, 5);
|
||||||
list1.append(labelRange(50, -10, true));
|
list1.emplace_back(50, -10, true);
|
||||||
|
|
||||||
sort(list1);
|
sort(list1);
|
||||||
Info<<"sorted" << list1 << endl;
|
Info<<"sorted" << list1 << endl;
|
||||||
|
|||||||
@ -32,8 +32,8 @@ Description
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include "int.H"
|
#include "int.H"
|
||||||
#include "uint.H"
|
#include "uint.H"
|
||||||
#include "string.H"
|
|
||||||
#include "scalar.H"
|
#include "scalar.H"
|
||||||
|
#include "word.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|||||||
@ -468,13 +468,13 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (auto& val : A)
|
for (auto& val : A)
|
||||||
{
|
{
|
||||||
val.Re() = rndGen.GaussNormal<scalar>();
|
val.real(rndGen.GaussNormal<scalar>());
|
||||||
val.Im() = rndGen.GaussNormal<scalar>();
|
val.imag(rndGen.GaussNormal<scalar>());
|
||||||
}
|
}
|
||||||
for (auto& val : B)
|
for (auto& val : B)
|
||||||
{
|
{
|
||||||
val.Re() = rndGen.GaussNormal<scalar>();
|
val.real(rndGen.GaussNormal<scalar>());
|
||||||
val.Im() = rndGen.GaussNormal<scalar>();
|
val.imag(rndGen.GaussNormal<scalar>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "# (A.T()).T() = A:" << nl;
|
Info<< nl << "# (A.T()).T() = A:" << nl;
|
||||||
@ -893,8 +893,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
for (auto& val : A)
|
for (auto& val : A)
|
||||||
{
|
{
|
||||||
val.Re() = rndGen.GaussNormal<scalar>();
|
val.real(rndGen.GaussNormal<scalar>());
|
||||||
val.Im() = rndGen.GaussNormal<scalar>();
|
val.imag(rndGen.GaussNormal<scalar>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "# SquareMatrix<complex>.symmetric():" << nl
|
Info<< "# SquareMatrix<complex>.symmetric():" << nl
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2022 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -83,6 +83,9 @@ int main(int argc, char *argv[])
|
|||||||
Info<<"Construct zero : ";
|
Info<<"Construct zero : ";
|
||||||
printInfo(MinMax<scalar>(Zero)) << nl;
|
printInfo(MinMax<scalar>(Zero)) << nl;
|
||||||
|
|
||||||
|
Info<<"Construct zero_one : ";
|
||||||
|
printInfo(MinMax<scalar>(zero_one{})) << nl;
|
||||||
|
|
||||||
Info<<"Construct range : ";
|
Info<<"Construct range : ";
|
||||||
printInfo(MinMax<scalar>(1, 20)) << nl;
|
printInfo(MinMax<scalar>(1, 20)) << nl;
|
||||||
|
|
||||||
@ -92,6 +95,26 @@ int main(int argc, char *argv[])
|
|||||||
Info<<"A 0-1 vector range : ";
|
Info<<"A 0-1 vector range : ";
|
||||||
printInfo(MinMax<vector>::zero_one()) << nl;
|
printInfo(MinMax<vector>::zero_one()) << nl;
|
||||||
|
|
||||||
|
{
|
||||||
|
vector a(0, 1, 20);
|
||||||
|
vector b(2, 1, 0);
|
||||||
|
vector c(4, 10, 12);
|
||||||
|
|
||||||
|
Info<< "vectors:"
|
||||||
|
<< " a = " << a
|
||||||
|
<< " b = " << b
|
||||||
|
<< " c = " << c << nl;
|
||||||
|
|
||||||
|
Info<< "min max = " << min(max(a, b), c) << nl;
|
||||||
|
Info<< "range clamp= " << MinMax<vector>(b, c).clamp(a) << nl;
|
||||||
|
Info<< "clamp = " << clamp(a, b, c) << nl;
|
||||||
|
|
||||||
|
Info<< "clamp 0/1 = " << clamp(a, vector::zero, vector::one) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scalar promotion
|
||||||
|
Info<< "clamp (scalar) = " << clamp(15.0, -1, 1) << nl;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
scalarMinMax range1(10, 20);
|
scalarMinMax range1(10, 20);
|
||||||
@ -180,6 +203,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
{
|
{
|
||||||
MinMax<scalar> limiter(10, 200);
|
MinMax<scalar> limiter(10, 200);
|
||||||
|
clampOp<scalar> clipper(limiter);
|
||||||
|
// clampOp<scalar> clipper(zero_one{});
|
||||||
|
// clampOp<scalar> clipper(10, 200);
|
||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "Test clipping limiter: " << limiter << nl
|
<< "Test clipping limiter: " << limiter << nl
|
||||||
@ -196,7 +222,10 @@ int main(int argc, char *argv[])
|
|||||||
Info<< nl << "test clip() with limiter: " << limiter << nl;
|
Info<< nl << "test clip() with limiter: " << limiter << nl;
|
||||||
for (const scalar& val : values1)
|
for (const scalar& val : values1)
|
||||||
{
|
{
|
||||||
Info<< "clipped : " << val << " = " << clip(val, limiter) << nl;
|
Info<< "clipped : " << val << " = "
|
||||||
|
<< clip(val, limiter)
|
||||||
|
<< " or " << clip(val, limiter)
|
||||||
|
<< " or " << clipper(val) << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< nl << "test clip(Field) with limiter: " << limiter << nl;
|
Info<< nl << "test clip(Field) with limiter: " << limiter << nl;
|
||||||
@ -208,9 +237,15 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "before " << flatOutput(values2) << nl;
|
Info<< "before " << flatOutput(values2) << nl;
|
||||||
|
|
||||||
|
// Too much clutter
|
||||||
|
// for (scalar& val : values2)
|
||||||
|
// {
|
||||||
|
// clampEqOp<scalar>{limiter}(val);
|
||||||
|
// }
|
||||||
|
|
||||||
for (scalar& val : values2)
|
for (scalar& val : values2)
|
||||||
{
|
{
|
||||||
clipEqOp<scalar>()(val, limiter);
|
val = clipper(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "after: " << flatOutput(values2) << nl;
|
Info<< "after: " << flatOutput(values2) << nl;
|
||||||
|
|||||||
@ -1,7 +1,2 @@
|
|||||||
EXE_INC = \
|
/* EXE_INC = */
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
/* EXE_LIBS = */
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
|
||||||
|
|
||||||
EXE_LIBS = \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lmeshTools
|
|
||||||
|
|||||||
@ -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.
|
||||||
@ -24,11 +24,11 @@ License
|
|||||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Test minMax
|
Test-minMax2
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "fvCFD.H"
|
#include "argList.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "BitOps.H"
|
#include "BitOps.H"
|
||||||
#include "HashOps.H"
|
#include "HashOps.H"
|
||||||
@ -37,6 +37,7 @@ Description
|
|||||||
#include "MinMax.H"
|
#include "MinMax.H"
|
||||||
#include "dimensionedScalar.H"
|
#include "dimensionedScalar.H"
|
||||||
#include "dimensionedMinMax.H"
|
#include "dimensionedMinMax.H"
|
||||||
|
#include "Random.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -78,7 +79,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Test min/max " << nl;
|
Info<< "Test min/max " << nl;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
scalarMinMax range1(10, 20);
|
scalarMinMax range1(10, 20);
|
||||||
scalarMinMax range2(40, 50);
|
scalarMinMax range2(40, 50);
|
||||||
@ -140,7 +140,42 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
scalarField someField(25);
|
||||||
|
|
||||||
|
Random rnd(4567);
|
||||||
|
for (scalar& val : someField)
|
||||||
|
{
|
||||||
|
val = rnd.position(scalar(-0.2), scalar(1.2));
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "field: " << flatOutput(someField) << nl;
|
||||||
|
Info<< "clamp01: "
|
||||||
|
<< flatOutput(clamp(someField, zero_one{})()) << nl;
|
||||||
|
|
||||||
|
Info<< "clamp01: "
|
||||||
|
<< clamp(tmp<scalarField>(someField), zero_one{})<< nl;
|
||||||
|
|
||||||
|
scalarField result(10);
|
||||||
|
clamp(result, someField, zero_one{});
|
||||||
|
|
||||||
|
Info<< "result: " << result << nl;
|
||||||
|
|
||||||
|
someField.clamp_range(zero_one{});
|
||||||
|
Info<< "inplace: " << someField << nl;
|
||||||
|
|
||||||
|
scalar val(1.414);
|
||||||
|
|
||||||
|
Info<< "clamp " << val
|
||||||
|
// nope << " : " << clamp(val, zero_one{})
|
||||||
|
// nope << " : " << clamp(val, scalarMinMax(zero_one{}))
|
||||||
|
<< " : " << clamp(val, 0, 1)
|
||||||
|
<< " : " << clamp(val, zero_one{})
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << "\nDone\n" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@ Description
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define Foam_PstreamExchange_debug_chunks
|
||||||
|
|
||||||
#include "List.H"
|
#include "List.H"
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
@ -371,6 +373,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Manually
|
// Manually
|
||||||
|
Info<< "perform list exchange" << endl;
|
||||||
{
|
{
|
||||||
labelListList sendBufs(UPstream::nProcs());
|
labelListList sendBufs(UPstream::nProcs());
|
||||||
labelListList recvBufs(UPstream::nProcs());
|
labelListList recvBufs(UPstream::nProcs());
|
||||||
@ -397,6 +400,34 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Info<< "perform Map exchange" << endl;
|
||||||
|
{
|
||||||
|
Map<labelList> sendBufs;
|
||||||
|
Map<labelList> recvBufs;
|
||||||
|
Map<label> recvSizes;
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
for (const int proci : Pstream::allProcs())
|
||||||
|
{
|
||||||
|
if (proci != Pstream::myProcNo())
|
||||||
|
{
|
||||||
|
sendBufs(proci) = identity(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pstream::exchangeSizes(sendBufs, recvSizes);
|
||||||
|
|
||||||
|
Pstream::exchange<labelList, label>
|
||||||
|
(
|
||||||
|
sendBufs,
|
||||||
|
recvSizes,
|
||||||
|
recvBufs
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,2 +1,4 @@
|
|||||||
/* EXE_INC = */
|
include $(GENERAL_RULES)/mpi-rules
|
||||||
/* EXE_LIBS = */
|
|
||||||
|
EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN)
|
||||||
|
EXE_LIBS = $(PLIBS)
|
||||||
|
|||||||
@ -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.
|
||||||
@ -39,6 +39,7 @@ Description
|
|||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "PstreamReduceOps.H"
|
#include "PstreamReduceOps.H"
|
||||||
|
#include <mpi.h>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -62,6 +63,8 @@ int main(int argc, char *argv[])
|
|||||||
argList::noBanner();
|
argList::noBanner();
|
||||||
argList::noCheckProcessorDirectories();
|
argList::noCheckProcessorDirectories();
|
||||||
argList::addBoolOption("verbose", "Set debug level");
|
argList::addBoolOption("verbose", "Set debug level");
|
||||||
|
argList::addBoolOption("comm-split", "Test simple comm split");
|
||||||
|
argList::addBoolOption("host-comm", "Test DIY host-comm split");
|
||||||
|
|
||||||
// Capture manually. We need values before proper startup
|
// Capture manually. We need values before proper startup
|
||||||
int nVerbose = 0;
|
int nVerbose = 0;
|
||||||
@ -139,6 +142,91 @@ int main(int argc, char *argv[])
|
|||||||
Pout<< endl;
|
Pout<< endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (Pstream::parRun() && args.found("comm-split"))
|
||||||
|
{
|
||||||
|
MPI_Comm hostComm;
|
||||||
|
MPI_Comm_split_type
|
||||||
|
(
|
||||||
|
MPI_COMM_WORLD,
|
||||||
|
MPI_COMM_TYPE_SHARED, // OMPI_COMM_TYPE_NODE
|
||||||
|
0, MPI_INFO_NULL, &hostComm
|
||||||
|
);
|
||||||
|
|
||||||
|
int host_nprocs = 0;
|
||||||
|
int host_rank = 0;
|
||||||
|
MPI_Comm_size(hostComm, &host_nprocs);
|
||||||
|
MPI_Comm_rank(hostComm, &host_rank);
|
||||||
|
|
||||||
|
Pout<< nl << "Host comm with "
|
||||||
|
<< host_rank << " / " << host_nprocs
|
||||||
|
<< " (using MPI_Comm_split_type)" << endl;
|
||||||
|
|
||||||
|
MPI_Comm_free(&hostComm);
|
||||||
|
}
|
||||||
|
if (Pstream::parRun() && args.found("host-comm"))
|
||||||
|
{
|
||||||
|
// Host communicator, based on the current worldComm
|
||||||
|
// Use hostname
|
||||||
|
// Lowest rank per hostname is the IO rank
|
||||||
|
|
||||||
|
label numprocs = UPstream::nProcs(UPstream::globalComm);
|
||||||
|
|
||||||
|
stringList hosts(numprocs);
|
||||||
|
hosts[Pstream::myProcNo(UPstream::globalComm)] = hostName();
|
||||||
|
|
||||||
|
labelList hostIDs_;
|
||||||
|
|
||||||
|
// Compact
|
||||||
|
if (Pstream::master(UPstream::globalComm))
|
||||||
|
{
|
||||||
|
DynamicList<word> hostNames(numprocs);
|
||||||
|
hostIDs_.resize_nocopy(numprocs);
|
||||||
|
|
||||||
|
forAll(hosts, proci)
|
||||||
|
{
|
||||||
|
const word& host = hosts[proci];
|
||||||
|
|
||||||
|
hostIDs_[proci] = hostNames.find(host);
|
||||||
|
|
||||||
|
if (hostIDs_[proci] == -1)
|
||||||
|
{
|
||||||
|
hostIDs_[proci] = hostNames.size();
|
||||||
|
hostNames.push_back(host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pstream::broadcasts(UPstream::globalComm, hostIDs_);
|
||||||
|
|
||||||
|
const label myHostId =
|
||||||
|
hostIDs_[Pstream::myProcNo(UPstream::globalComm)];
|
||||||
|
|
||||||
|
DynamicList<label> subRanks;
|
||||||
|
forAll(hostIDs_, proci)
|
||||||
|
{
|
||||||
|
if (hostIDs_[proci] == myHostId)
|
||||||
|
{
|
||||||
|
subRanks.push_back(proci);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate new communicator with globalComm as its parent
|
||||||
|
const label hostComm =
|
||||||
|
UPstream::allocateCommunicator
|
||||||
|
(
|
||||||
|
UPstream::globalComm, // parent
|
||||||
|
subRanks,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
Pout<< nl << "Host comm with "
|
||||||
|
<< UPstream::myProcNo(hostComm)
|
||||||
|
<< " / " << UPstream::nProcs(hostComm)
|
||||||
|
<< nl;
|
||||||
|
|
||||||
|
UPstream::freeCommunicator(hostComm, true);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
3
applications/test/parallel-comm3a/Make/files
Normal file
3
applications/test/parallel-comm3a/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-parallel-comm3a.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-parallel-comm3a
|
||||||
4
applications/test/parallel-comm3a/Make/options
Normal file
4
applications/test/parallel-comm3a/Make/options
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
include $(GENERAL_RULES)/mpi-rules
|
||||||
|
|
||||||
|
EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN)
|
||||||
|
EXE_LIBS = $(PLIBS)
|
||||||
249
applications/test/parallel-comm3a/Test-parallel-comm3a.C
Normal file
249
applications/test/parallel-comm3a/Test-parallel-comm3a.C
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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-comm3a
|
||||||
|
|
||||||
|
Description
|
||||||
|
Basic communicator tests
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IPstream.H"
|
||||||
|
#include "OPstream.H"
|
||||||
|
#include "Pair.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "StringStream.H"
|
||||||
|
#include "Random.H"
|
||||||
|
#include <mpi.h>
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
|
||||||
|
void printRequests(const UList<MPI_Request>& requests)
|
||||||
|
{
|
||||||
|
OStringStream buf;
|
||||||
|
|
||||||
|
buf << "request: " << requests.size() << '(';
|
||||||
|
|
||||||
|
for (const auto& req : requests)
|
||||||
|
{
|
||||||
|
if (req == MPI_REQUEST_NULL)
|
||||||
|
{
|
||||||
|
buf << " null";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf << " " << Foam::name(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf << " )";
|
||||||
|
Pout << buf.str().c_str() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int tag = (UPstream::msgType() + 314159);
|
||||||
|
// const label comm = UPstream::worldComm;
|
||||||
|
|
||||||
|
Random rnd(20*UPstream::myProcNo());
|
||||||
|
|
||||||
|
Map<DynamicList<char>> sendBufs;
|
||||||
|
Map<DynamicList<char>> recvBufs;
|
||||||
|
|
||||||
|
DynamicList<MPI_Request> sendRequests(10);
|
||||||
|
DynamicList<MPI_Request> recvRequests(10);
|
||||||
|
|
||||||
|
|
||||||
|
if (!Pstream::master())
|
||||||
|
{
|
||||||
|
// Send some random length to master
|
||||||
|
|
||||||
|
const int toProci = UPstream::masterNo();
|
||||||
|
|
||||||
|
label len = rnd.position<label>(10, 20);
|
||||||
|
if (UPstream::myProcNo() && (UPstream::myProcNo() % 3) == 0) len = 0;
|
||||||
|
|
||||||
|
// Has data to send
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
auto& buf = sendBufs(toProci);
|
||||||
|
buf.resize(len, 'x');
|
||||||
|
|
||||||
|
MPI_Issend
|
||||||
|
(
|
||||||
|
buf.cdata_bytes(),
|
||||||
|
buf.size_bytes(),
|
||||||
|
MPI_BYTE,
|
||||||
|
toProci,
|
||||||
|
tag,
|
||||||
|
MPI_COMM_WORLD,
|
||||||
|
&sendRequests.emplace_back()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Probe and receive
|
||||||
|
|
||||||
|
MPI_Request barrierReq;
|
||||||
|
|
||||||
|
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||||
|
{
|
||||||
|
int flag = 0;
|
||||||
|
MPI_Status status;
|
||||||
|
|
||||||
|
MPI_Iprobe
|
||||||
|
(
|
||||||
|
MPI_ANY_SOURCE,
|
||||||
|
tag,
|
||||||
|
MPI_COMM_WORLD,
|
||||||
|
&flag,
|
||||||
|
&status
|
||||||
|
);
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
// Message found, receive into dest buffer location
|
||||||
|
const label fromProci = status.MPI_SOURCE;
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
MPI_Get_count(&status, MPI_BYTE, &count);
|
||||||
|
|
||||||
|
auto& buf = recvBufs(fromProci);
|
||||||
|
buf.resize_nocopy(count);
|
||||||
|
|
||||||
|
MPI_Irecv
|
||||||
|
(
|
||||||
|
buf.data_bytes(),
|
||||||
|
buf.size_bytes(),
|
||||||
|
MPI_BYTE,
|
||||||
|
fromProci,
|
||||||
|
tag,
|
||||||
|
MPI_COMM_WORLD,
|
||||||
|
&recvRequests.emplace_back()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barrier_active)
|
||||||
|
{
|
||||||
|
// Test barrier for completion
|
||||||
|
// - all received, or nothing to receive
|
||||||
|
MPI_Test(&barrierReq, &flag, MPI_STATUS_IGNORE);
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check if all sends have arrived
|
||||||
|
MPI_Testall
|
||||||
|
(
|
||||||
|
sendRequests.size(), sendRequests.data(),
|
||||||
|
&flag, MPI_STATUSES_IGNORE
|
||||||
|
);
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
MPI_Ibarrier(MPI_COMM_WORLD, &barrierReq);
|
||||||
|
barrier_active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recvRequests.empty())
|
||||||
|
{
|
||||||
|
Pout << "No receive requests" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printRequests(recvRequests);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Either MPI_Waitall, or MPI_Waitany...
|
||||||
|
|
||||||
|
label loop = 0;
|
||||||
|
for (bool dispatched = recvRequests.empty(); !dispatched; /*nil*/)
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
MPI_Waitany
|
||||||
|
(
|
||||||
|
recvRequests.size(),
|
||||||
|
recvRequests.data(),
|
||||||
|
&index,
|
||||||
|
MPI_STATUS_IGNORE
|
||||||
|
);
|
||||||
|
|
||||||
|
if (index == MPI_UNDEFINED)
|
||||||
|
{
|
||||||
|
//Pout<< "Testany is " << (flag ? "done" : "waiting") << endl;
|
||||||
|
Pout<< "Waitany (loop:" << loop << ") : done" << endl;
|
||||||
|
dispatched = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pout<< "Waitany (loop:"
|
||||||
|
<< loop << ") "
|
||||||
|
<< index << " of " << recvRequests.size() << endl;
|
||||||
|
|
||||||
|
printRequests(recvRequests);
|
||||||
|
}
|
||||||
|
|
||||||
|
++loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not needed: all tested...
|
||||||
|
// MPI_Waitall(recvRequests.size(), recvRequests.data(), MPI_STATUSES_IGNORE);
|
||||||
|
|
||||||
|
MPI_Barrier(MPI_COMM_WORLD);
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
3
applications/test/parallel-comm3b/Make/files
Normal file
3
applications/test/parallel-comm3b/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-parallel-comm3b.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-parallel-comm3b
|
||||||
2
applications/test/parallel-comm3b/Make/options
Normal file
2
applications/test/parallel-comm3b/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC */
|
||||||
|
/* EXE_LIBS = */
|
||||||
228
applications/test/parallel-comm3b/Test-parallel-comm3b.C
Normal file
228
applications/test/parallel-comm3b/Test-parallel-comm3b.C
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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-comm3b
|
||||||
|
|
||||||
|
Description
|
||||||
|
Basic communicator tests
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IPstream.H"
|
||||||
|
#include "OPstream.H"
|
||||||
|
#include "Pair.H"
|
||||||
|
#include "Tuple2.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "StringStream.H"
|
||||||
|
#include "Random.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
|
||||||
|
void printRequests(const UList<UPstream::Request>& requests)
|
||||||
|
{
|
||||||
|
OStringStream buf;
|
||||||
|
|
||||||
|
buf << "request: " << requests.size() << '(';
|
||||||
|
|
||||||
|
for (const auto& req : requests)
|
||||||
|
{
|
||||||
|
if (req.good())
|
||||||
|
{
|
||||||
|
buf << " " << Foam::name(req.pointer());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buf << " null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buf << " )";
|
||||||
|
Pout << buf.str().c_str() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noBanner();
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int tag = (UPstream::msgType() + 314159);
|
||||||
|
const label comm = UPstream::worldComm;
|
||||||
|
|
||||||
|
Random rnd(20*UPstream::myProcNo());
|
||||||
|
|
||||||
|
Map<DynamicList<char>> sendBufs;
|
||||||
|
Map<DynamicList<char>> recvBufs;
|
||||||
|
|
||||||
|
DynamicList<UPstream::Request> sendRequests(10);
|
||||||
|
DynamicList<UPstream::Request> recvRequests(10);
|
||||||
|
|
||||||
|
// Map request indices to procs
|
||||||
|
Map<label> recvFromProc(20);
|
||||||
|
|
||||||
|
if (!Pstream::master())
|
||||||
|
{
|
||||||
|
// Send some random length to master
|
||||||
|
|
||||||
|
const int toProci = UPstream::masterNo();
|
||||||
|
|
||||||
|
label len = rnd.position<label>(10, 20);
|
||||||
|
if (UPstream::myProcNo() && (UPstream::myProcNo() % 3) == 0) len = 0;
|
||||||
|
|
||||||
|
// Has data to send
|
||||||
|
if (len)
|
||||||
|
{
|
||||||
|
auto& buf = sendBufs(toProci);
|
||||||
|
buf.resize(len, 'x');
|
||||||
|
|
||||||
|
UOPstream::write
|
||||||
|
(
|
||||||
|
sendRequests.emplace_back(),
|
||||||
|
UPstream::masterNo(),
|
||||||
|
sendBufs[toProci],
|
||||||
|
tag,
|
||||||
|
comm,
|
||||||
|
UPstream::sendModes::sync
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Probe and receive
|
||||||
|
|
||||||
|
UPstream::Request barrierReq;
|
||||||
|
|
||||||
|
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||||
|
{
|
||||||
|
std::pair<int, int> probed =
|
||||||
|
UPstream::probeMessage
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
-1, // ANY_SOURCE
|
||||||
|
tag,
|
||||||
|
comm
|
||||||
|
);
|
||||||
|
|
||||||
|
if (probed.second > 0)
|
||||||
|
{
|
||||||
|
// Message found and had size: receive it
|
||||||
|
|
||||||
|
const label proci = probed.first;
|
||||||
|
const label count = probed.second;
|
||||||
|
|
||||||
|
recvBufs(proci).resize_nocopy(count);
|
||||||
|
recvFromProc(recvRequests.size()) = proci;
|
||||||
|
|
||||||
|
// Non-blocking read
|
||||||
|
UIPstream::read
|
||||||
|
(
|
||||||
|
recvRequests.emplace_back(),
|
||||||
|
proci,
|
||||||
|
recvBufs[proci],
|
||||||
|
tag,
|
||||||
|
comm
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barrier_active)
|
||||||
|
{
|
||||||
|
// Test barrier for completion
|
||||||
|
if (UPstream::finishedRequest(barrierReq))
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check if all sends have arrived
|
||||||
|
if (UPstream::finishedRequests(sendRequests))
|
||||||
|
{
|
||||||
|
UPstream::barrier(comm, &barrierReq);
|
||||||
|
barrier_active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recvRequests.empty())
|
||||||
|
{
|
||||||
|
Pout << "No receive requests" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printRequests(recvRequests);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Either MPI_Waitall, or MPI_Waitany...
|
||||||
|
|
||||||
|
label loop = 0;
|
||||||
|
for (bool dispatched = recvRequests.empty(); !dispatched; /*nil*/)
|
||||||
|
{
|
||||||
|
label index = UPstream::waitAnyRequest(recvRequests);
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
{
|
||||||
|
Pout<< "Waitany (loop:" << loop << ") : done" << endl;
|
||||||
|
dispatched = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pout<< "Waitany (loop:"
|
||||||
|
<< loop << ") "
|
||||||
|
<< index << " of " << recvRequests.size()
|
||||||
|
<< " from proc:" << recvFromProc.lookup(index, -1)
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
printRequests(recvRequests);
|
||||||
|
}
|
||||||
|
++loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not needed: all tested...
|
||||||
|
// UPstream::waitRequest(recvRequests);
|
||||||
|
|
||||||
|
UPstream::barrier(UPstream::worldComm);
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
3
applications/test/parallel-nbx2/Make/files
Normal file
3
applications/test/parallel-nbx2/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-parallel-nbx2.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-parallel-nbx2
|
||||||
2
applications/test/parallel-nbx2/Make/options
Normal file
2
applications/test/parallel-nbx2/Make/options
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/* EXE_INC = */
|
||||||
|
/* EXE_LIBS = */
|
||||||
227
applications/test/parallel-nbx2/Test-parallel-nbx2.C
Normal file
227
applications/test/parallel-nbx2/Test-parallel-nbx2.C
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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-nbx2
|
||||||
|
|
||||||
|
Description
|
||||||
|
Test for send/receive data
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "List.H"
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "IPstream.H"
|
||||||
|
#include "OPstream.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "Random.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noCheckProcessorDirectories();
|
||||||
|
argList::addBoolOption("non-blocking", "Test with non-blocking receives");
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
const bool optNonBlocking = args.found("non-blocking");
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nTesting with non-blocking receives: " << optNonBlocking << nl;
|
||||||
|
|
||||||
|
|
||||||
|
const int tag = (UPstream::msgType() + 314159);
|
||||||
|
const label comm = UPstream::worldComm;
|
||||||
|
|
||||||
|
Random rnd(20*UPstream::myProcNo());
|
||||||
|
|
||||||
|
// Looks a bit like a DIY PstreamBuffers...
|
||||||
|
Map<DynamicList<char>> sendBufs;
|
||||||
|
Map<DynamicList<char>> recvBufs;
|
||||||
|
|
||||||
|
DynamicList<UPstream::Request> sendRequests(10);
|
||||||
|
DynamicList<UPstream::Request> recvRequests(10);
|
||||||
|
|
||||||
|
if (!Pstream::master())
|
||||||
|
{
|
||||||
|
// Send some random length to master
|
||||||
|
|
||||||
|
const int toProci = UPstream::masterNo();
|
||||||
|
|
||||||
|
label len = rnd.position<label>(10, 20);
|
||||||
|
if (UPstream::myProcNo() && (UPstream::myProcNo() % 3) == 0) len = 0;
|
||||||
|
|
||||||
|
scalarField fld(len, scalar(UPstream::myProcNo()));
|
||||||
|
|
||||||
|
// Format for sending
|
||||||
|
if (!fld.empty())
|
||||||
|
{
|
||||||
|
auto& buf = sendBufs(toProci);
|
||||||
|
UOPstream os(buf);
|
||||||
|
os << fld;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start nonblocking synchronous send to process dest
|
||||||
|
|
||||||
|
if (sendBufs.found(toProci) && !sendBufs[toProci].empty())
|
||||||
|
{
|
||||||
|
Pout<< "send: [" << sendBufs[toProci].size() << " bytes] "
|
||||||
|
<< flatOutput(fld) << endl;
|
||||||
|
|
||||||
|
// Has data to send
|
||||||
|
UOPstream::write
|
||||||
|
(
|
||||||
|
sendRequests.emplace_back(),
|
||||||
|
UPstream::masterNo(),
|
||||||
|
sendBufs[toProci],
|
||||||
|
tag,
|
||||||
|
comm,
|
||||||
|
UPstream::sendModes::sync
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Probe and receive
|
||||||
|
|
||||||
|
UPstream::Request barrierReq;
|
||||||
|
|
||||||
|
for (bool barrier_active = false, done = false; !done; /*nil*/)
|
||||||
|
{
|
||||||
|
std::pair<int, int> probed =
|
||||||
|
UPstream::probeMessage
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::nonBlocking,
|
||||||
|
-1, // ANY_SOURCE
|
||||||
|
tag,
|
||||||
|
comm
|
||||||
|
);
|
||||||
|
|
||||||
|
if (probed.second > 0)
|
||||||
|
{
|
||||||
|
// Message found and had size: receive it
|
||||||
|
|
||||||
|
const label proci = probed.first;
|
||||||
|
const label count = probed.second;
|
||||||
|
|
||||||
|
if (optNonBlocking)
|
||||||
|
{
|
||||||
|
recvBufs(proci).resize_nocopy(count);
|
||||||
|
|
||||||
|
// Non-blocking read
|
||||||
|
UIPstream::read
|
||||||
|
(
|
||||||
|
recvRequests.emplace_back(),
|
||||||
|
proci,
|
||||||
|
recvBufs[proci],
|
||||||
|
tag,
|
||||||
|
comm
|
||||||
|
);
|
||||||
|
// Pout<< "Done: "
|
||||||
|
// << UPstream::finishedRequests(recvRequests) << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPstream is
|
||||||
|
(
|
||||||
|
UPstream::commsTypes::scheduled,
|
||||||
|
probed.first,
|
||||||
|
probed.second,
|
||||||
|
tag,
|
||||||
|
comm
|
||||||
|
);
|
||||||
|
|
||||||
|
scalarField fld(is);
|
||||||
|
|
||||||
|
Info<< "from [" << probed.first
|
||||||
|
<< "] : " << flatOutput(fld) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (barrier_active)
|
||||||
|
{
|
||||||
|
// Test barrier for completion
|
||||||
|
if (UPstream::finishedRequest(barrierReq))
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check if all sends have arrived
|
||||||
|
if (UPstream::finishedRequests(sendRequests))
|
||||||
|
{
|
||||||
|
UPstream::barrier(comm, &barrierReq);
|
||||||
|
barrier_active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "pending receives: " << recvRequests.size() << endl;
|
||||||
|
|
||||||
|
// Wait for receives to complete
|
||||||
|
UPstream::waitRequests(recvRequests);
|
||||||
|
|
||||||
|
// It could be we need this type of synchronization point
|
||||||
|
// if the receives are non-blocking
|
||||||
|
if (optNonBlocking)
|
||||||
|
{
|
||||||
|
UPstream::barrier(comm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recvBufs.empty())
|
||||||
|
{
|
||||||
|
Pout<< "Receives from: " << flatOutput(recvBufs.sortedToc()) << endl;
|
||||||
|
|
||||||
|
forAllConstIters(recvBufs, iter)
|
||||||
|
{
|
||||||
|
Pout<< "proc:" << iter.key() << " len:" << iter.val().size() << nl;
|
||||||
|
|
||||||
|
if (!iter.val().empty())
|
||||||
|
{
|
||||||
|
UIPstream is(iter.val());
|
||||||
|
scalarField fld(is);
|
||||||
|
|
||||||
|
Pout<< "recv:" << iter.key()
|
||||||
|
<< " : " << flatOutput(fld) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -50,9 +50,8 @@ using namespace Foam;
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#include "setRootCase.H"
|
argList::noCheckProcessorDirectories();
|
||||||
#include "createTime.H"
|
argList args(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
// Test PstreamBuffers
|
// Test PstreamBuffers
|
||||||
// ~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~
|
||||||
@ -83,13 +82,13 @@ int main(int argc, char *argv[])
|
|||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
// Collect my own data
|
// Collect my own data
|
||||||
allData.append(data);
|
allData.push_back(data);
|
||||||
|
|
||||||
for (const int proci : Pstream::subProcs())
|
for (const int proci : Pstream::subProcs())
|
||||||
{
|
{
|
||||||
Perr << "master receiving from " << proci << endl;
|
Perr << "master receiving from " << proci << endl;
|
||||||
UIPstream fromProc(proci, pBufs);
|
UIPstream fromProc(proci, pBufs);
|
||||||
allData.append(vector(fromProc));
|
allData.push_back(vector(fromProc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
Perr << "master sending to " << proci << endl;
|
Perr << "master sending to " << proci << endl;
|
||||||
UOPstream toProc(proci, pBufs);
|
UOPstream toProc(proci, pBufs);
|
||||||
toSlave << allData;
|
toProc << allData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,13 +124,27 @@ int main(int argc, char *argv[])
|
|||||||
scalar data1 = 1.0;
|
scalar data1 = 1.0;
|
||||||
label request1 = -1;
|
label request1 = -1;
|
||||||
{
|
{
|
||||||
Foam::reduce(data1, sumOp<scalar>(), UPstream::msgType(), request1);
|
Foam::reduce
|
||||||
|
(
|
||||||
|
data1,
|
||||||
|
sumOp<scalar>(),
|
||||||
|
UPstream::msgType(),
|
||||||
|
UPstream::worldComm,
|
||||||
|
request1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar data2 = 0.1;
|
scalar data2 = 0.1;
|
||||||
label request2 = -1;
|
UPstream::Request request2;
|
||||||
{
|
{
|
||||||
Foam::reduce(data2, sumOp<scalar>(), UPstream::msgType(), request2);
|
Foam::reduce
|
||||||
|
(
|
||||||
|
data2,
|
||||||
|
sumOp<scalar>(),
|
||||||
|
UPstream::msgType(),
|
||||||
|
UPstream::worldComm,
|
||||||
|
request2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -168,23 +181,23 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (request1 != -1)
|
if (request1 != -1)
|
||||||
{
|
{
|
||||||
Pout<< "Waiting for non-blocking reduce with request " << request1
|
Pout<< "Waiting for non-blocking reduce with request "
|
||||||
<< endl;
|
<< request1 << endl;
|
||||||
Pstream::waitRequest(request1);
|
UPstream::waitRequest(request1);
|
||||||
}
|
}
|
||||||
Info<< "Reduced data1:" << data1 << endl;
|
Info<< "Reduced data1:" << data1 << endl;
|
||||||
|
|
||||||
if (request2 != -1)
|
if (request2.good())
|
||||||
{
|
{
|
||||||
Pout<< "Waiting for non-blocking reduce with request " << request1
|
Pout<< "Waiting for non-blocking reduce with request "
|
||||||
<< endl;
|
<< Foam::name(request2.pointer()) << endl;
|
||||||
Pstream::waitRequest(request2);
|
UPstream::waitRequest(request2);
|
||||||
}
|
}
|
||||||
Info<< "Reduced data2:" << data2 << endl;
|
Info<< "Reduced data2:" << data2 << endl;
|
||||||
|
|
||||||
|
|
||||||
// Clear any outstanding requests
|
// Clear all outstanding requests
|
||||||
Pstream::resetRequests(0);
|
UPstream::resetRequests(0);
|
||||||
|
|
||||||
Info<< "End\n" << endl;
|
Info<< "End\n" << endl;
|
||||||
|
|
||||||
|
|||||||
@ -67,54 +67,24 @@ void testMapDistribute()
|
|||||||
labelList nSend(Pstream::nProcs(), Zero);
|
labelList nSend(Pstream::nProcs(), Zero);
|
||||||
forAll(complexData, i)
|
forAll(complexData, i)
|
||||||
{
|
{
|
||||||
const label procI = complexData[i].first();
|
const label proci = complexData[i].first();
|
||||||
nSend[procI]++;
|
nSend[proci]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect items to be sent
|
// Collect items to be sent
|
||||||
labelListList sendMap(Pstream::nProcs());
|
labelListList sendMap(Pstream::nProcs());
|
||||||
forAll(sendMap, procI)
|
forAll(sendMap, proci)
|
||||||
{
|
{
|
||||||
sendMap[procI].setSize(nSend[procI]);
|
sendMap[proci].resize_nocopy(nSend[proci]);
|
||||||
|
nSend[proci] = 0;
|
||||||
}
|
}
|
||||||
nSend = 0;
|
|
||||||
forAll(complexData, i)
|
forAll(complexData, i)
|
||||||
{
|
{
|
||||||
const label procI = complexData[i].first();
|
const label proci = complexData[i].first();
|
||||||
sendMap[procI][nSend[procI]++] = i;
|
sendMap[proci][nSend[proci]++] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync how many to send
|
mapDistribute map(std::move(sendMap));
|
||||||
labelList nRecv;
|
|
||||||
Pstream::exchangeSizes(sendMap, nRecv);
|
|
||||||
|
|
||||||
// Collect items to be received
|
|
||||||
labelListList recvMap(Pstream::nProcs());
|
|
||||||
forAll(recvMap, procI)
|
|
||||||
{
|
|
||||||
recvMap[procI].setSize(nRecv[procI]);
|
|
||||||
}
|
|
||||||
|
|
||||||
label constructSize = 0;
|
|
||||||
// Construct with my own elements first
|
|
||||||
forAll(recvMap[Pstream::myProcNo()], i)
|
|
||||||
{
|
|
||||||
recvMap[Pstream::myProcNo()][i] = constructSize++;
|
|
||||||
}
|
|
||||||
// Construct from other processors
|
|
||||||
forAll(recvMap, procI)
|
|
||||||
{
|
|
||||||
if (procI != Pstream::myProcNo())
|
|
||||||
{
|
|
||||||
forAll(recvMap[procI], i)
|
|
||||||
{
|
|
||||||
recvMap[procI][i] = constructSize++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Construct distribute map (destructively)
|
|
||||||
mapDistribute map(constructSize, std::move(sendMap), std::move(recvMap));
|
|
||||||
|
|
||||||
// Distribute complexData
|
// Distribute complexData
|
||||||
map.distribute(complexData);
|
map.distribute(complexData);
|
||||||
|
|||||||
@ -86,11 +86,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
forAll(fEdges, i)
|
forAll(fEdges, i)
|
||||||
{
|
{
|
||||||
changedEdges.append(fEdges[i]);
|
changedEdges.push_back(fEdges[i]);
|
||||||
changedInfo.append
|
changedInfo.emplace_back(labelPair(globalFacei, globalFacei));
|
||||||
(
|
|
||||||
patchEdgeFaceRegions(labelPair(globalFacei, globalFacei))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,8 @@ Description
|
|||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
|
#include "primitiveFields.H"
|
||||||
|
#include "labelVector.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -93,6 +95,13 @@ void printValPair(const char* desc, const T1& val1, const T2& val2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The 'naive' implementation. Not exact at end points
|
||||||
|
inline scalar naive_lerp(const scalar a, const scalar b, const scalar t)
|
||||||
|
{
|
||||||
|
return a + t*(b - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
@ -180,6 +189,113 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
unsigned nFail = 0;
|
unsigned nFail = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
const float a = 1e8f, b = 1.0f;
|
||||||
|
|
||||||
|
Info<< "lerp exact: "
|
||||||
|
<< (a == lerp(a, b, 0.0f)) << " "
|
||||||
|
<< (b == lerp(a, b, 1.0f)) << nl;
|
||||||
|
|
||||||
|
Info<< "naive lerp exact: "
|
||||||
|
<< (a == naive_lerp(a, b, 0.0f)) << " "
|
||||||
|
<< (b == naive_lerp(a, b, 1.0f)) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const scalar a = 1e24, b = 1.0;
|
||||||
|
|
||||||
|
Info<< "lerp exact: "
|
||||||
|
<< (a == lerp(a, b, 0.0)) << " "
|
||||||
|
<< (b == lerp(a, b, 1.0)) << nl;
|
||||||
|
|
||||||
|
Info<< "naive lerp exact: "
|
||||||
|
<< (a == naive_lerp(a, b, 0.0)) << " "
|
||||||
|
<< (b == naive_lerp(a, b, 1.0)) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const vector a(vector::uniform(1e24)), b(vector::uniform(1.0));
|
||||||
|
|
||||||
|
Info<<"lerp exact: "
|
||||||
|
<< (a == lerp(a, b, 0.0f)) << " "
|
||||||
|
<< (b == lerp(a, b, 1.0f)) << nl;
|
||||||
|
|
||||||
|
Info<< "lerp: "
|
||||||
|
<< lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const lerpOp1<vector> half(0.5);
|
||||||
|
|
||||||
|
const vector a(vector::uniform(20));
|
||||||
|
const vector b(vector::uniform(100));
|
||||||
|
|
||||||
|
Info<< "lerp half: "
|
||||||
|
<< a << " : " << b << " => " << half(a, b) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const labelVector a(labelVector::uniform(10000));
|
||||||
|
const labelVector b(labelVector::uniform(1));
|
||||||
|
|
||||||
|
Info<< "lerp (labelVector) = "
|
||||||
|
<< lerp(a, b, 0.1) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const scalar a(0);
|
||||||
|
const scalar b(100);
|
||||||
|
|
||||||
|
Info<< "lerp of " << a << " : " << b << nl;
|
||||||
|
|
||||||
|
for (const double t : { 0.0, 0.5, 1.0, -0.5, 1.5 })
|
||||||
|
{
|
||||||
|
Info<< " " << t << " = " << lerp(a, b, t) << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// No yet
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
const label a(10000);
|
||||||
|
const label b(1);
|
||||||
|
|
||||||
|
Info<<"lerp (label) = "
|
||||||
|
<< label(lerp(a, b, 0.1)) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const bool a(true);
|
||||||
|
const bool b(false);
|
||||||
|
|
||||||
|
Info<<"lerp (bool) = "
|
||||||
|
<< (lerp(a, b, 0.5)) << nl;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
const sphericalTensor a(10), b(20);
|
||||||
|
|
||||||
|
Info<<"lerp exact: "
|
||||||
|
<< (a == lerp(a, b, 0.0f)) << " "
|
||||||
|
<< (b == lerp(a, b, 1.0f)) << nl;
|
||||||
|
// Info<< "lerp: "
|
||||||
|
// << lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const tensor a(tensor::uniform(1e24));
|
||||||
|
const tensor b(tensor::uniform(0));
|
||||||
|
|
||||||
|
Info<<"lerp exact: "
|
||||||
|
<< (a == lerp(a, b, 0.0f)) << " "
|
||||||
|
<< (b == lerp(a, b, 1.0f)) << nl;
|
||||||
|
// Info<< "lerp: "
|
||||||
|
// << lerp(vector::uniform(0), vector::uniform(100), 0.5) << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
Info<< nl << "Test Switch parsing:" << nl;
|
Info<< nl << "Test Switch parsing:" << nl;
|
||||||
nFail += testParsing
|
nFail += testParsing
|
||||||
|
|||||||
@ -1,2 +1,4 @@
|
|||||||
/* EXE_INC = */
|
include $(GENERAL_RULES)/mpi-rules
|
||||||
/* EXE_LIBS = */
|
|
||||||
|
EXE_INC = $(PFLAGS) $(PINC) $(c++LESSWARN)
|
||||||
|
EXE_LIBS = $(PLIBS)
|
||||||
|
|||||||
@ -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.
|
||||||
@ -33,6 +33,7 @@ Description
|
|||||||
#include "polyMesh.H"
|
#include "polyMesh.H"
|
||||||
#include "globalMeshData.H"
|
#include "globalMeshData.H"
|
||||||
#include "OFstream.H"
|
#include "OFstream.H"
|
||||||
|
#include <mpi.h>
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -42,11 +43,25 @@ using namespace Foam;
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::noFunctionObjects();
|
argList::noFunctionObjects();
|
||||||
|
argList::addBoolOption("verbose", "Set debug level");
|
||||||
|
argList::addBoolOption("comm-graph", "Test simple graph communicator");
|
||||||
argList::addNote
|
argList::addNote
|
||||||
(
|
(
|
||||||
"Create graph of OpenFOAM mesh connections"
|
"Create graph of OpenFOAM mesh connections"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Capture manually. We need values before proper startup
|
||||||
|
int nVerbose = 0;
|
||||||
|
for (int argi = 1; argi < argc; ++argi)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[argi], "-verbose") == 0)
|
||||||
|
{
|
||||||
|
++nVerbose;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UPstream::debug = nVerbose;
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
if (!Pstream::parRun())
|
if (!Pstream::parRun())
|
||||||
@ -61,7 +76,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
// Adjacency table
|
// Adjacency table
|
||||||
const labelListList& connectivity =
|
const labelListList& connectivity =
|
||||||
mesh.globalData().topology().procNeighbours();
|
mesh.globalData().topology().procAdjacency();
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
@ -105,6 +120,127 @@ int main(int argc, char *argv[])
|
|||||||
<< "Use neato, circo or fdp graphviz tools" << nl;
|
<< "Use neato, circo or fdp graphviz tools" << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Pstream::parRun() && args.found("comm-graph"))
|
||||||
|
{
|
||||||
|
Info<< nl;
|
||||||
|
|
||||||
|
// Local neighbours
|
||||||
|
const labelList& neighbours =
|
||||||
|
mesh.globalData().topology().procNeighbours();
|
||||||
|
|
||||||
|
Pout<< "Neigbours: " << flatOutput(neighbours) << endl;
|
||||||
|
|
||||||
|
// As integers values
|
||||||
|
List<int> connected(neighbours.size());
|
||||||
|
List<int> weights(neighbours.size());
|
||||||
|
forAll(neighbours, i)
|
||||||
|
{
|
||||||
|
connected[i] = neighbours[i];
|
||||||
|
weights[i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MPI_Comm topoComm;
|
||||||
|
|
||||||
|
int mpiErrorCode =
|
||||||
|
MPI_Dist_graph_create_adjacent
|
||||||
|
(
|
||||||
|
MPI_COMM_WORLD,
|
||||||
|
// Connections into this rank
|
||||||
|
connected.size(), connected.cdata(), MPI_UNWEIGHTED,
|
||||||
|
// Connections out of this rank
|
||||||
|
connected.size(), connected.cdata(), MPI_UNWEIGHTED,
|
||||||
|
MPI_INFO_NULL,
|
||||||
|
0, // no reordering (apparently broken anyhow)
|
||||||
|
&topoComm
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mpiErrorCode)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "Failed to create topo communicator. Error:"
|
||||||
|
<< mpiErrorCode << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
int topo_rank = 0;
|
||||||
|
int topo_nprocs = 0;
|
||||||
|
int topo_inCount = 0;
|
||||||
|
int topo_outCount = 0;
|
||||||
|
int topo_isWeighted = 0;
|
||||||
|
MPI_Comm_rank(topoComm, &topo_rank);
|
||||||
|
MPI_Comm_size(topoComm, &topo_nprocs);
|
||||||
|
|
||||||
|
{
|
||||||
|
int topo_type = 0;
|
||||||
|
MPI_Topo_test(topoComm, &topo_type);
|
||||||
|
|
||||||
|
if (MPI_CART == topo_type)
|
||||||
|
{
|
||||||
|
Info<< "MPI topology : Cartesian" << endl;
|
||||||
|
}
|
||||||
|
else if (MPI_GRAPH == topo_type)
|
||||||
|
{
|
||||||
|
Info<< "MPI topology : Graph" << endl;
|
||||||
|
}
|
||||||
|
else if (MPI_DIST_GRAPH == topo_type)
|
||||||
|
{
|
||||||
|
Info<< "MPI topology : Distributed graph" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "MPI topology : None" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MPI_Dist_graph_neighbors_count
|
||||||
|
(
|
||||||
|
topoComm,
|
||||||
|
&topo_inCount,
|
||||||
|
&topo_outCount,
|
||||||
|
&topo_isWeighted
|
||||||
|
);
|
||||||
|
|
||||||
|
Pout<< "Topo comm with "
|
||||||
|
<< topo_rank << " / " << topo_nprocs
|
||||||
|
<< " from " << connected.size() << flatOutput(connected)
|
||||||
|
<< " numNbr:" << topo_inCount
|
||||||
|
<< nl;
|
||||||
|
|
||||||
|
|
||||||
|
List<int> myPatchIds(neighbours.size());
|
||||||
|
forAll(myPatchIds, i)
|
||||||
|
{
|
||||||
|
// Patches to neighbours
|
||||||
|
myPatchIds[i] =
|
||||||
|
mesh.globalData().topology().procPatchLookup(neighbours[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> nbrPatchIds(neighbours.size(), Zero);
|
||||||
|
|
||||||
|
mpiErrorCode = MPI_Neighbor_alltoall
|
||||||
|
(
|
||||||
|
myPatchIds.data(),
|
||||||
|
1, // one element per neighbour
|
||||||
|
MPI_INT,
|
||||||
|
nbrPatchIds.data(),
|
||||||
|
1, // one element per neighbour
|
||||||
|
MPI_INT,
|
||||||
|
topoComm
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mpiErrorCode)
|
||||||
|
{
|
||||||
|
FatalError
|
||||||
|
<< "MPI Error: " << mpiErrorCode << exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pout<< "proc neighbours:" << flatOutput(neighbours)
|
||||||
|
<< " my patches:" << flatOutput(myPatchIds)
|
||||||
|
<< " their patches:" << flatOutput(nbrPatchIds)
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
MPI_Comm_free(&topoComm);
|
||||||
|
}
|
||||||
|
|
||||||
Info<< nl << "End\n" << endl;
|
Info<< nl << "End\n" << endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -108,8 +108,8 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (surf->interfaceCell()[celli])
|
if (surf->interfaceCell()[celli])
|
||||||
{
|
{
|
||||||
centres.append(surf->centre()[celli]);
|
centres.push_back(surf->centre()[celli]);
|
||||||
normals.append(surf->normal()[celli]);
|
normals.push_back(surf->normal()[celli]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -249,7 +249,7 @@ void Foam::router::storeRoute
|
|||||||
{
|
{
|
||||||
if (weights_[nodeI] == pathValue)
|
if (weights_[nodeI] == pathValue)
|
||||||
{
|
{
|
||||||
route.append(nodeI);
|
route.push_back(nodeI);
|
||||||
|
|
||||||
storeRoute
|
storeRoute
|
||||||
(
|
(
|
||||||
@ -386,7 +386,7 @@ Foam::labelList Foam::router::getRoute(const label pathValue) const
|
|||||||
|
|
||||||
DynamicList<label> route(weights_.size());
|
DynamicList<label> route(weights_.size());
|
||||||
|
|
||||||
route.append(startNodeI);
|
route.push_back(startNodeI);
|
||||||
|
|
||||||
storeRoute(startNodeI, -1, pathValue, route);
|
storeRoute(startNodeI, -1, pathValue, route);
|
||||||
|
|
||||||
|
|||||||
@ -31,9 +31,8 @@ Description
|
|||||||
|
|
||||||
#include "bool.H"
|
#include "bool.H"
|
||||||
#include "Switch.H"
|
#include "Switch.H"
|
||||||
#include "string.H"
|
|
||||||
#include "dictionary.H"
|
#include "dictionary.H"
|
||||||
#include "nil.H"
|
#include "zero.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "PstreamBuffers.H"
|
#include "PstreamBuffers.H"
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
@ -82,8 +81,8 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
nil x;
|
zero x;
|
||||||
cout<<"nil:" << sizeof(x) << nl;
|
cout<<"zero:" << sizeof(x) << nl;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -47,10 +47,10 @@ void printInfo(const sliceCoeffs& coeffs)
|
|||||||
|
|
||||||
Info<< nl
|
Info<< nl
|
||||||
<< "coeffs: " << coeffs << nl
|
<< "coeffs: " << coeffs << nl
|
||||||
<< "range: " << range << nl
|
<< "range: " << range << nl
|
||||||
<< "first: " << range.first() << nl
|
<< "min: " << range.min() << nl
|
||||||
<< "*begin " << *range.begin() << nl
|
<< "*begin " << *range.begin() << nl
|
||||||
<< "last: " << range.last() << nl
|
<< "max: " << range.max() << nl
|
||||||
<< "*end " << *range.end() << nl
|
<< "*end " << *range.end() << nl
|
||||||
<< "values: " << flatOutput(range.labels()) << nl;
|
<< "values: " << flatOutput(range.labels()) << nl;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
-I$(LIB_SRC)/meshTools/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lfiniteVolume \
|
-lfiniteVolume \
|
||||||
|
-lfiniteArea \
|
||||||
-lmeshTools
|
-lmeshTools
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user