Compare commits

..

5 Commits

Author SHA1 Message Date
11964a4731 ENH: reduce overhead and clearer data ownership for OFstreamCollator
- local data to be written is now transferable into the
  OFstreamCollator. This avoids making a full copy when threading is
  active.

- use plain lists for managing proc data
  * storage: List<List<char>> instead of PtrList<List<char>>
  * views:   List<stdFoam::span<char>> instead of PtrList<SubList<char>>

- use gather/write (unthreaded) as backstop if the output is too big
  to fit in the buffer size. Emit warning instead of FatalError
2024-01-23 17:16:02 +01:00
c82facdc8e ENH: reduce overhead of decomposedBlockData IO
- OCharStream for serializing
- skip intermediate blocks without reading
- support character spans
- read and distribute with direct non-blocking send/recv
  instead of PstreamBuffers or with IPstream/OPstream streaming
  operators.
- non-blocking gather/write when using intermediate buffer space
2024-01-23 17:16:02 +01:00
da560be4df ENH: reduce overhead of masterOFstream
- use OCharStream instead of OStringStream to avoid copying char data.

- direct non-blocking send/recv with probing instead of PstreamBuffers
  to avoid serialization/de-serialization of char data and reduce the
  memory footprint somewhat.

- polling dispatch to write file content as it becomes available,
  which should improve communication and IO overlap
2024-01-23 17:16:02 +01:00
cf6e3a1acf CONFIG: adjust compile-time value of maxThreadFileBufferSize to 0
- consistent with etc/controlDict default

STYLE: update banner message for collated
2024-01-23 17:16:02 +01:00
0a51a4848c TEST: add standalone test application: Test-checkIOspeed 2024-01-23 17:16:02 +01:00
1922 changed files with 26788 additions and 48624 deletions

View File

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

9
.gitmodules vendored
View File

@ -1,8 +1,8 @@
[submodule "cfmesh"]
path = plugins/cfmesh
path = modules/cfmesh
url = https://develop.openfoam.com/Community/integration-cfmesh.git
[submodule "avalanche"]
path = plugins/avalanche
path = modules/avalanche
url = https://develop.openfoam.com/Community/avalanche.git
[submodule "adios"]
path = modules/adios
@ -18,8 +18,5 @@
path = modules/external-solver
url = https://develop.openfoam.com/Modules/external-solver.git
[submodule "turbulence-community"]
path = plugins/turbulence-community
path = modules/turbulence-community
url = https://gitlab.com/openfoam/community/tc-turbulence/turbulence-community.git
[submodule "plugins/data-community"]
path = plugins/data-community
url = https://gitlab.com/openfoam/community/sig-data-modelling/data-community.git

View File

@ -9,7 +9,6 @@ It is likely incomplete...
- Yu Ankun
- Tetsuo Aoyagi
- Akira Azami
- Pete Bachant
- William Bainbridge
- Gabriel Barajas
- Kutalmis Bercin

View File

@ -1,2 +1,2 @@
api=2406
api=2312
patch=0

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2406 version:
For example, for the OpenFOAM-v2312 version:
```
source /installation/path/OpenFOAM-v2406/etc/bashrc
source /installation/path/OpenFOAM-v2312/etc/bashrc
```
## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example,
```
/path/parent
|-- OpenFOAM-v2406
\-- ThirdParty-v2406
|-- OpenFOAM-v2312
\-- ThirdParty-v2312
```
There are, however, many cases where this simple convention is inadequate:
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2406, etc..
directory name, e.g. openfoam-sandbox2312, etc..
* When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2406-myCustom`,
* allows for an updated value of VERSION, *eg*, `v2312-myCustom`,
without requiring a renamed ThirdParty. The API value would still
be `2406` and the original `ThirdParty-v2406/` would be found.
be `2312` and the original `ThirdParty-v2312/` would be found.
4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common
@ -213,4 +213,4 @@ ThirdParty directory will contain either an `Allwmake` file or a
- [Governance](http://www.openfoam.com/governance/), [Governance Projects](https://www.openfoam.com/governance/projects)
- [Contacting OpenCFD](http://www.openfoam.com/contact/)
Copyright 2016-2024 OpenCFD Ltd
Copyright 2016-2023 OpenCFD Ltd

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,14 +93,24 @@ Foam::PDRDragModels::basic::~basic()
Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
{
auto tDragDcu = volSymmTensorField::New
tmp<volSymmTensorField> tDragDcu
(
"tDragDcu",
IOobject::NO_REGISTER,
U_.mesh(),
dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero)
new volSymmTensorField
(
IOobject
(
"tDragDcu",
U_.mesh().time().constant(),
U_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U_.mesh(),
dimensionedSymmTensor(dimMass/dimTime/dimVolume, Zero)
)
);
auto& DragDcu = tDragDcu.ref();
volSymmTensorField& DragDcu = tDragDcu.ref();
if (on_)
{
@ -118,14 +127,24 @@ Foam::tmp<Foam::volSymmTensorField> Foam::PDRDragModels::basic::Dcu() const
Foam::tmp<Foam::volScalarField> Foam::PDRDragModels::basic::Gk() const
{
auto tGk = volScalarField::New
tmp<volScalarField> tGk
(
"tGk",
IOobject::NO_REGISTER,
U_.mesh(),
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
new volScalarField
(
IOobject
(
"tGk",
U_.mesh().time().constant(),
U_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
U_.mesh(),
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
)
);
auto& Gk = tGk.ref();
volScalarField& Gk = tGk.ref();
if (on_)
{

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,14 +93,23 @@ Foam::tmp<Foam::volScalarField> Foam::XiEqModels::SCOPEXiEq::XiEq() const
volScalarField K(0.157*upBySu/sqrt(Rl));
volScalarField Ma(MaModel.Ma());
auto tXiEq = volScalarField::New
tmp<volScalarField> tXiEq
(
"XiEq",
IOobject::NO_REGISTER,
epsilon.mesh(),
dimensionedScalar(dimless, Zero)
new volScalarField
(
IOobject
(
"XiEq",
epsilon.time().timeName(),
epsilon.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
epsilon.mesh(),
dimensionedScalar(dimless, Zero)
)
);
auto& xieq = tXiEq.ref();
volScalarField& xieq = tXiEq.ref();
forAll(xieq, celli)
{

View File

@ -78,10 +78,11 @@ bool Foam::XiEqModel::read(const dictionary& XiEqProperties)
void Foam::XiEqModel::writeFields() const
{
//***HGW It is not clear why B is written here
const auto* B = Su_.mesh().cfindObject<volSymmTensorField>("B");
if (B)
if (Su_.mesh().foundObject<volSymmTensorField>("B"))
{
B->write();
const volSymmTensorField& B =
Su_.mesh().lookupObject<volSymmTensorField>("B");
B.write();
}
}
@ -97,26 +98,39 @@ Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
const volSymmTensorField& nsv =
mesh.lookupObject<volSymmTensorField>("nsv");
auto tN = volScalarField::New
tmp<volScalarField> tN
(
"tN",
IOobject::NO_REGISTER,
mesh,
dimensionedScalar(Nv.dimensions(), Zero)
new volScalarField
(
IOobject
(
"tN",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh,
dimensionedScalar(Nv.dimensions(), Zero)
)
);
auto& N = tN.ref();
volScalarField& N = tN.ref();
N.primitiveFieldRef() = Nv.primitiveField()*pow(mesh.V(), 2.0/3.0);
auto tns = volSymmTensorField::New
volSymmTensorField ns
(
"tns",
IOobject::NO_REGISTER,
IOobject
(
"tns",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedSymmTensor(nsv.dimensions(), Zero)
);
auto& ns = tns.ref();
ns.primitiveFieldRef() = nsv.primitiveField()*pow(mesh.V(), 2.0/3.0);
const volVectorField Uhat

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -256,14 +255,24 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
scalar phi
) const
{
auto tSu0 = volScalarField::New
tmp<volScalarField> tSu0
(
"Su0",
IOobject::NO_REGISTER,
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
new volScalarField
(
IOobject
(
"Su0",
p.time().timeName(),
p.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
)
);
auto& Su0 = tSu0.ref();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli)
{
@ -295,14 +304,24 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
const volScalarField& phi
) const
{
auto tSu0 = volScalarField::New
tmp<volScalarField> tSu0
(
"Su0",
IOobject::NO_REGISTER,
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
new volScalarField
(
IOobject
(
"Su0",
p.time().timeName(),
p.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
p.mesh(),
dimensionedScalar(dimVelocity, Zero)
)
);
auto& Su0 = tSu0.ref();
volScalarField& Su0 = tSu0.ref();
forAll(Su0, celli)
{
@ -339,14 +358,24 @@ Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Ma
const volScalarField& phi
) const
{
auto tMa = volScalarField::New
tmp<volScalarField> tMa
(
"Ma",
IOobject::NO_REGISTER,
phi.mesh(),
dimensionedScalar(dimless, Zero)
new volScalarField
(
IOobject
(
"Ma",
phi.time().timeName(),
phi.db(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
phi.mesh(),
dimensionedScalar(dimless, Zero)
)
);
auto& ma = tMa.ref();
volScalarField& ma = tMa.ref();
forAll(ma, celli)
{
@ -389,12 +418,21 @@ Foam::laminarFlameSpeedModels::SCOPE::Ma() const
{
const fvMesh& mesh = psiuReactionThermo_.p().mesh();
return volScalarField::New
return tmp<volScalarField>
(
"Ma",
IOobject::NO_REGISTER,
mesh,
dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_))
new volScalarField
(
IOobject
(
"Ma",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_))
)
);
}
}

View File

@ -10,8 +10,7 @@ if (pimple.dict().getOrDefault("hydrostaticInitialization", false))
"0",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::REGISTER
IOobject::NO_WRITE
),
mesh
)

View File

@ -21,11 +21,6 @@
+ fvOptions(rho, he)
);
if (MRF.active())
{
EEqn += fvc::div(MRF.phi(), p);
}
EEqn.relax();
fvOptions.constrain(EEqn);

View File

@ -20,11 +20,6 @@
fvOptions(rho, he)
);
if (MRF.active())
{
EEqn += fvc::div(MRF.phi(), p);
}
EEqn.relax();
fvOptions.constrain(EEqn);

View File

@ -14,11 +14,6 @@
fvOptions(rho, he)
);
if (MRF.active())
{
EEqn += fvc::div(MRF.phi(), p);
}
EEqn.relax();
fvOptions.constrain(EEqn);

View File

@ -9,11 +9,6 @@
fvOptions(rho, e)
);
if (MRF.active())
{
EEqn += fvc::div(MRF.phi(), p);
}
EEqn.relax();
fvOptions.constrain(EEqn);

View File

@ -3,7 +3,12 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -3,7 +3,12 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -4,19 +4,26 @@ if (nAlphaSubCycles > 1)
{
dimensionedScalar totalDeltaT = runTime.deltaT();
talphaPhi1.reset
talphaPhi1 = new surfaceScalarField
(
new surfaceScalarField
IOobject
(
mesh.newIOobject("alphaPhi1"),
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
)
"alphaPhi1",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
);
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -13,19 +13,26 @@ if (nAlphaSubCycles > 1)
{
dimensionedScalar totalDeltaT = runTime.deltaT();
talphaPhi1.reset
talphaPhi1 = new surfaceScalarField
(
new surfaceScalarField
IOobject
(
mesh.newIOobject("alphaPhi1"),
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
)
"alphaPhi1",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(alphaPhi10.dimensions(), Zero)
);
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -135,14 +135,14 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return const_cast<volScalarField&>(volScalarField::null());
return thermo1_->he();
}
//- Enthalpy/Internal energy [J/kg]
virtual const volScalarField& he() const
{
NotImplemented;
return volScalarField::null();
return thermo1_->he();
}
//- Enthalpy/Internal energy
@ -213,7 +213,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Heat capacity at constant volume [J/kg/K]
@ -236,7 +236,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Gamma = Cp/Cv []

View File

@ -99,8 +99,7 @@ Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimless, Zero)
@ -999,12 +998,19 @@ Foam::tmp<Foam::volScalarField> Foam::multiphaseMixtureThermo::K
Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixtureThermo::nearInterface() const
{
auto tnearInt = volScalarField::New
tmp<volScalarField> tnearInt
(
"nearInterface",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(dimless, Zero)
new volScalarField
(
IOobject
(
"nearInterface",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimless, Zero)
)
);
for (const phaseModel& phase : phases_)

View File

@ -243,14 +243,14 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return const_cast<volScalarField&>(volScalarField::null());
return phases_[0].thermo().he();
}
//- Enthalpy/Internal energy [J/kg]
virtual const volScalarField& he() const
{
NotImplemented;
return volScalarField::null();
return phases_[0].thermo().he();
}
//- Enthalpy/Internal energy
@ -327,7 +327,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Heat capacity at constant volume [J/kg/K]
@ -350,7 +350,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Gamma = Cp/Cv []

View File

@ -18,7 +18,12 @@
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField alphaPhiSum
(
mesh.newIOobject("alphaPhiSum"),
IOobject
(
"alphaPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(phi.dimensions(), Zero)
);

View File

@ -158,11 +158,13 @@ Foam::tmp<Foam::volSymmTensorField> Foam::relativeVelocityModel::tauDm() const
// Calculate the relative velocity of the continuous phase w.r.t the mean
volVectorField Ucm(betad*Udm_/betac);
return volSymmTensorField::New
return tmp<volSymmTensorField>
(
"tauDm",
IOobject::NO_REGISTER,
betad*sqr(Udm_) + betac*sqr(Ucm)
new volSymmTensorField
(
"tauDm",
betad*sqr(Udm_) + betac*sqr(Ucm)
)
);
}

View File

@ -130,17 +130,10 @@ int main(int argc, char *argv[])
}
}
}
#include "UEqn.H"
#include "YEqns.H"
#include "TEqn.H"
if (pimple.frozenFlow())
{
continue;
}
#include "UEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2023 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -407,8 +407,7 @@ Foam::radiation::laserDTRM::laserDTRM(const volScalarField& T)
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimPower/dimVolume, Zero)
@ -505,8 +504,7 @@ Foam::radiation::laserDTRM::laserDTRM
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimPower/pow3(dimLength), Zero)
@ -537,23 +535,42 @@ Foam::label Foam::radiation::laserDTRM::nBands() const
void Foam::radiation::laserDTRM::calculate()
{
auto treflectingCells = volScalarField::New
tmp<volScalarField> treflectingCells
(
"reflectingCellsVol",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar("zero", dimless, -1)
new volScalarField
(
IOobject
(
"reflectingCellsVol",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("zero", dimless, -1)
)
);
auto& reflectingCellsVol = treflectingCells.ref();
volScalarField& reflectingCellsVol = treflectingCells.ref();
auto tnHat = volVectorField::New
tmp<volVectorField> tnHat
(
"nHat",
IOobject::NO_REGISTER,
mesh_,
dimensionedVector(dimless, Zero)
new volVectorField
(
IOobject
(
"nHat",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedVector(dimless, Zero)
)
);
auto& nHat = tnHat.ref();
volVectorField& nHat = tnHat.ref();
// Reset the field
@ -669,9 +686,9 @@ void Foam::radiation::laserDTRM::calculate()
globalIndex::gatherInplaceOp(lines);
if (UPstream::master())
if (Pstream::master())
{
OBJstream os(type() + "-particlePath.obj");
OBJstream os(type() + ":particlePath.obj");
for (label pointi = 0; pointi < lines.size(); pointi += 2)
{

View File

@ -88,14 +88,25 @@ Foam::radiation::localDensityAbsorptionEmission::localDensityAbsorptionEmission
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
{
auto ta = volScalarField::New
tmp<volScalarField> ta
(
"a",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(inv(dimLength), Zero)
new volScalarField
(
IOobject
(
"a",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(inv(dimLength), Zero)
)
);
auto& a = ta.ref();
volScalarField& a = ta.ref();
forAll(alphaNames_, i)
{
@ -110,14 +121,25 @@ Foam::radiation::localDensityAbsorptionEmission::aCont(const label bandI) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
{
auto te = volScalarField::New
tmp<volScalarField> te
(
"e",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(inv(dimLength), Zero)
new volScalarField
(
IOobject
(
"e",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(inv(dimLength), Zero)
)
);
auto& e = te.ref();
volScalarField& e = te.ref();
forAll(alphaNames_, i)
{
@ -132,12 +154,22 @@ Foam::radiation::localDensityAbsorptionEmission::eCont(const label bandI) const
Foam::tmp<Foam::volScalarField>
Foam::radiation::localDensityAbsorptionEmission::ECont(const label bandI) const
{
auto tE = volScalarField::New
tmp<volScalarField> tE
(
"E",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
new volScalarField
(
IOobject
(
"E",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
),
mesh_,
dimensionedScalar(dimMass/dimLength/pow3(dimTime), Zero)
)
);
scalarField& E = tE.ref().primitiveFieldRef();

View File

@ -171,8 +171,16 @@ Foam::temperaturePhaseChangeTwoPhaseMixtures::constant::TSource() const
const volScalarField& T = mesh_.lookupObject<volScalarField>("T");
auto tTSource = tmp<fvScalarMatrix>::New(T, dimEnergy/dimTime);
auto& TSource = tTSource.ref();
tmp<fvScalarMatrix> tTSource
(
new fvScalarMatrix
(
T,
dimEnergy/dimTime
)
);
fvScalarMatrix& TSource = tTSource.ref();
const twoPhaseMixtureEThermo& thermo =
refCast<const twoPhaseMixtureEThermo>

View File

@ -382,7 +382,7 @@ Foam::tmp<Foam::volScalarField> Foam::twoPhaseMixtureEThermo::kappaEff
const volScalarField& kappat
) const
{
tmp<volScalarField> kappaEff(kappa() + kappat);
tmp<Foam::volScalarField> kappaEff(kappa() + kappat);
kappaEff.ref().rename("kappaEff");
return kappaEff;
}

View File

@ -86,14 +86,14 @@ public:
virtual volScalarField& he()
{
NotImplemented;
return const_cast<volScalarField&>(volScalarField::null());
return p();
}
//- Return access to the internal energy field [J/Kg]
virtual const volScalarField& he() const
{
NotImplemented;
return volScalarField::null();
return p();
}
//- Enthalpy/Internal energy
@ -182,7 +182,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Return Cv of the mixture
@ -205,7 +205,7 @@ public:
) const
{
NotImplemented;
return nullptr;
return tmp<scalarField>::New(p);
}
//- Gamma = Cp/Cv []

View File

@ -3,7 +3,12 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -32,7 +32,12 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -21,7 +21,12 @@
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -50,8 +50,7 @@
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar(dimVelocity*dimArea, Zero)

View File

@ -68,9 +68,8 @@ Foam::multiphaseMixture::multiphaseMixture
"transportProperties",
U.time().constant(),
U.db(),
IOobject::READ_MODIFIED,
IOobject::NO_WRITE,
IOobject::REGISTER
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
@ -86,7 +85,9 @@ Foam::multiphaseMixture::multiphaseMixture
(
"rhoPhi",
mesh_.time().timeName(),
mesh_
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar(dimMass/dimTime, Zero)
@ -100,8 +101,7 @@ Foam::multiphaseMixture::multiphaseMixture
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar(dimless, Zero)
@ -257,12 +257,19 @@ Foam::multiphaseMixture::nuf() const
Foam::tmp<Foam::surfaceScalarField>
Foam::multiphaseMixture::surfaceTensionForce() const
{
auto tstf = surfaceScalarField::New
tmp<surfaceScalarField> tstf
(
"surfaceTensionForce",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero)
new surfaceScalarField
(
IOobject
(
"surfaceTensionForce",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero)
)
);
surfaceScalarField& stf = tstf.ref();
@ -317,7 +324,12 @@ void Foam::multiphaseMixture::solve()
{
surfaceScalarField rhoPhiSum
(
mesh_.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh_
),
mesh_,
dimensionedScalar(rhoPhi_.dimensions(), Zero)
);
@ -540,12 +552,19 @@ Foam::tmp<Foam::volScalarField> Foam::multiphaseMixture::K
Foam::tmp<Foam::volScalarField>
Foam::multiphaseMixture::nearInterface() const
{
auto tnearInt = volScalarField::New
tmp<volScalarField> tnearInt
(
"nearInterface",
IOobject::NO_REGISTER,
mesh_,
dimensionedScalar(dimless, Zero)
new volScalarField
(
IOobject
(
"nearInterface",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimless, Zero)
)
);
for (const phase& ph : phases_)
@ -630,7 +649,12 @@ void Foam::multiphaseMixture::solveAlphas
volScalarField sumAlpha
(
mesh_.newIOobject("sumAlpha"),
IOobject
(
"sumAlpha",
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(dimless, Zero)
);

View File

@ -272,7 +272,10 @@ while (pimple.correct())
).ptr()
);
pEqnComps[phasei].faceFluxCorrectionPtr(nullptr);
deleteDemandDrivenData
(
pEqnComps[phasei].faceFluxCorrectionPtr()
);
pEqnComps[phasei].relax();
}

View File

@ -5,7 +5,12 @@ if (nAlphaSubCycles > 1)
dimensionedScalar totalDeltaT = runTime.deltaT();
surfaceScalarField rhoPhiSum
(
mesh.newIOobject("rhoPhiSum"),
IOobject
(
"rhoPhiSum",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(rhoPhi.dimensions(), Zero)
);

View File

@ -70,10 +70,7 @@ int main(int argc, char *argv[])
);
labelList cellToCoarse(identity(mesh.nCells()));
CompactListList<label> coarseToCell
(
invertOneToManyCompact(mesh.nCells(), cellToCoarse)
);
labelListList coarseToCell(invertOneToMany(mesh.nCells(), cellToCoarse));
++runTime;
@ -81,11 +78,16 @@ int main(int argc, char *argv[])
{
volScalarField scalarAgglomeration
(
mesh.thisDb().newIOobject("agglomeration"),
IOobject
(
"agglomeration",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
Foam::zero{},
dimless,
fvPatchFieldBase::zeroGradientType()
dimensionedScalar(dimless, Zero)
);
scalarField& fld = scalarAgglomeration.primitiveFieldRef();
forAll(fld, celli)
@ -140,23 +142,31 @@ int main(int argc, char *argv[])
}
forAll(addr, finei)
forAll(addr, fineI)
{
labelUIndList(cellToCoarse, coarseToCell[finei]) = addr[finei];
const labelList& cellLabels = coarseToCell[fineI];
forAll(cellLabels, i)
{
cellToCoarse[cellLabels[i]] = addr[fineI];
}
}
coarseToCell = invertOneToManyCompact(coarseSize, cellToCoarse);
coarseToCell = invertOneToMany(coarseSize, cellToCoarse);
// Write agglomeration
{
volScalarField scalarAgglomeration
(
mesh.thisDb().newIOobject("agglomeration"),
IOobject
(
"agglomeration",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
Foam::zero{},
dimless,
fvPatchFieldBase::zeroGradientType()
dimensionedScalar(dimless, Zero)
);
scalarField& fld = scalarAgglomeration.primitiveFieldRef();
forAll(fld, celli)
{
@ -183,9 +193,9 @@ int main(int argc, char *argv[])
}
// Determine coarse cc
forAll(coarseToCell, coarsei)
forAll(coarseToCell, coarseI)
{
const auto& cellLabels = coarseToCell[coarsei];
const labelList& cellLabels = coarseToCell[coarseI];
point coarseCc = average
(
@ -194,8 +204,10 @@ int main(int argc, char *argv[])
meshTools::writeOBJ(str, coarseCc);
vertI++;
for (label celli : cellLabels)
forAll(cellLabels, i)
{
label celli = cellLabels[i];
str << "l " << celli+1 << ' ' << vertI << nl;
}
}

View File

@ -124,11 +124,11 @@ int main(int argc, char *argv[])
<< "toc: " << flatOutput(table0.toc()) << nl;
HashTable<label, label, Hash<label>> table2
(
// From key/value pairs
labelList({3, 5, 7}),
labelList({10, 12, 16})
);
({
{3, 10},
{5, 12},
{7, 16}
});
Info<< "table2: " << table2 << nl
<< "toc: " << flatOutput(table2.toc()) << nl;

View File

@ -206,7 +206,7 @@ int main(int argc, char *argv[])
#endif
loopInsert(map, nElem);
timer.resetCpuTimeIncrement();
(void)timer.cpuTimeIncrement();
unsigned long sum = 0;
for (label loopi = 0; loopi < nFind*nLoops; ++loopi)
@ -268,7 +268,7 @@ int main(int argc, char *argv[])
HashSet<label, Hash<label>> map(32);
loopInsert(map, nElem);
timer.resetCpuTimeIncrement();
(void)timer.cpuTimeIncrement();
unsigned long sum = 0;
for (label loopi = 0; loopi < nFind*nLoops; ++loopi)

View File

@ -188,6 +188,8 @@ int main(int argc, char *argv[])
argList::addBoolOption("label", "Use label for tests (default)");
argList::addBoolOption("ref", "Test writing by ref");
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
@ -278,6 +280,7 @@ int main(int argc, char *argv[])
{
IOFieldRef<vector>(ioOutput, mesh.points()).write();
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -156,24 +156,29 @@ int main(int argc, char *argv[])
os.writeEntry("idl3", idl3);
}
if (UPstream::parRun())
if (Pstream::parRun())
{
if (UPstream::master())
if (Pstream::master())
{
Pout<< "full: " << flatOutput(idl3.values()) << nl
<< "send: " << flatOutput(idl3) << endl;
for (const int proci : UPstream::subProcs())
for (const int proci : Pstream::subProcs())
{
OPstream::send(idl3, proci);
OPstream toSlave(Pstream::commsTypes::scheduled, proci);
toSlave << idl3;
}
}
else
{
// From master
List<label> recv;
IPstream fromMaster
(
Pstream::commsTypes::scheduled,
Pstream::masterNo()
);
IPstream::recv(recv, UPstream::masterNo());
List<label> recv(fromMaster);
Pout<<"recv: " << flatOutput(recv) << endl;
}

View File

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

View File

@ -65,11 +65,11 @@ int main(int argc, char *argv[])
OCountStream cnt;
OCharStream cstr;
OStringStream sstr;
OStringStream str;
ocountstream plain;
generateOutput(cstr);
generateOutput(sstr);
generateOutput(str);
generateOutput(cnt);
generateOutput(plain);
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
Info<< "counter state: " << (cnt.stdStream().rdstate()) << nl
<< "via char-stream: " << label(cstr.view().size()) << " chars" << nl
<< "via string-stream: " << label(sstr.count()) << " chars" << nl
<< "via string-stream: " << str.str().size() << " chars" << nl
<< "via ocountstream: " << plain.count() << " chars" << endl;
fileName outputName;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,14 +32,10 @@ Description
#include "IOstreams.H"
#include "OSspecific.H"
#include "argList.H"
#include "clock.H"
#include "Switch.H"
#include "ListOps.H"
using namespace Foam;
std::string time_stamp;
void listFiles(const fileName& dir)
{
wordList files = ListOps::create<word>
@ -59,150 +55,25 @@ void listFiles(const fileName& dir)
}
OSstream& printInfo(OFstream& os)
{
InfoErr
<< "open: " << os.name() << nl
<< "appending: " << Switch::name(os.is_appending())
<< " tellp: "<< os.stdStream().tellp()
<< " gz: " << Switch::name(os.compression()) << nl;
return InfoErr.stream();
}
void withHeader(OFstream& os)
{
const auto tellp = os.stdStream().tellp();
if (tellp <= 0)
{
InfoErr
<< "Add header" << nl;
os << "HEADER: " << time_stamp.c_str() << nl;
}
}
template<class OSstreamType>
void generateLines(OSstreamType& os, label count = 1)
{
for (label line = 1; line <= count; ++line)
{
os << "[" << line
<< "] =============================================" << nl;
}
}
template<class OSstreamType>
void generateContent
(
OSstreamType& os,
const bool with_seekend,
const bool test_overwrite = false,
const int64_t seek_out = -1
)
{
if (with_seekend)
{
os.stdStream().seekp(0, std::ios_base::end);
// OR? os.seek_end();
}
printInfo(os);
withHeader(os);
if (test_overwrite && seek_out >= 0)
{
InfoErr<< "... seekp(" << seek_out << ")" << nl;
auto& oss = os.stdStream();
// Actually std::streampos, but cannot increment that
int64_t pos(seek_out);
const int64_t tellp_end = oss.tellp();
if (pos >= 0 && pos < tellp_end)
{
InfoErr
<< "... fill from " << label(pos)
<< " to " << label(tellp_end) << nl;
oss.seekp(pos);
while (pos < tellp_end)
{
// Fill with char 'X', rely on streambuf buffering
oss << 'X';
++pos;
}
oss.seekp(seek_out);
os << "More content [at " << seek_out << ']' << endl;
}
}
generateLines(os, 4);
printInfo(os)
<< "... sleep" << endl;
listFiles(os.name().path());
sleep(2);
os << "[new content] +++++++++++++++++++++++++++++++++++" << endl;
}
template<class OSstreamType>
void generateOverwriteContent
(
OSstreamType& os,
const bool with_seekend,
const int64_t seek_out = -1
)
{
generateContent(os, with_seekend, true, seek_out);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::addBoolOption("gz", "Use compression");
argList::addBoolOption("append-app", "Use append app mode");
argList::addBoolOption("append-ate", "Use append ate mode");
argList::addBoolOption("seekend", "Seek to end after non-append open");
argList::addOption("seek", "value", "Seek from start (default: 100)");
argList::addBoolOption("append", "Use append mode");
argList::addBoolOption("atomic", "Use atomic");
argList::addBoolOption("keep", "Do not remove test directory");
argList::addOption("write", "file", "test writing to file");
#include "setRootCase.H"
// Same time-stamp for all generated files
time_stamp = clock::dateTime();
const fileName baseDir("Test-OFstream-directory");
Foam::mkDir(baseDir);
InfoErr<< "mkdir: " << baseDir << endl;
Info<< "start:" << nl;
listFiles(baseDir);
const bool with_seekend = args.found("seekend");
const int seek_out = args.getOrDefault<int>("seek", 100);
IOstreamOption streamOpt;
if (args.found("gz"))
@ -212,11 +83,10 @@ int main(int argc, char *argv[])
IOstreamOption::appendType append =
(
args.found("append-app") ? IOstreamOption::APPEND_APP
: args.found("append-ate") ? IOstreamOption::APPEND_ATE
: IOstreamOption::NO_APPEND
args.found("append")
? IOstreamOption::APPEND
: IOstreamOption::NON_APPEND
);
IOstreamOption::atomicType atomic =
(
args.found("atomic")
@ -227,6 +97,7 @@ int main(int argc, char *argv[])
{
OFstream(baseDir/"dummy")() << "Some file content" << endl;
Foam::ln("dummy", baseDir/"Test2.txt");
Foam::ln("dummy", baseDir/"Test3.txt");
Foam::ln("dummy", baseDir/"Test4.txt");
Foam::ln("dummy", baseDir/"Test4.txt.gz");
@ -243,31 +114,16 @@ int main(int argc, char *argv[])
append
);
generateOverwriteContent(os, with_seekend, seek_out);
}
os << "=========================" << endl;
{
OFstream os
(
atomic,
baseDir/"Test1-app.txt",
streamOpt,
IOstreamOption::APPEND_APP
);
InfoErr<< "open: " << os.name() << endl;
InfoErr<< "... sleep" << endl;
generateOverwriteContent(os, with_seekend, seek_out);
}
listFiles(baseDir);
{
OFstream os
(
atomic,
baseDir/"Test1-ate.txt",
streamOpt,
IOstreamOption::APPEND_ATE
);
sleep(2);
generateOverwriteContent(os, with_seekend, seek_out);
os << "+++++++++++++++++++++++++++++++++++" << endl;
}
{
@ -276,21 +132,39 @@ int main(int argc, char *argv[])
atomic,
baseDir/"Test2.txt",
streamOpt
// NON_APPEND
);
generateContent(os, with_seekend);
}
os << "=========================" << endl;
InfoErr<< "open: " << os.name() << endl;
InfoErr<< "... sleep" << endl;
listFiles(baseDir);
sleep(2);
os << "+++++++++++++++++++++++++++++++++++" << endl;
}
{
OFstream os
(
atomic,
baseDir/"Test3.txt",
streamOpt,
IOstreamOption::APPEND_APP
IOstreamOption::APPEND
);
generateContent(os, with_seekend, with_seekend);
os << "=========================" << endl;
InfoErr<< "open: " << os.name() << endl;
InfoErr<< "... sleep" << endl;
listFiles(baseDir);
sleep(2);
os << "+++++++++++++++++++++++++++++++++++" << endl;
}
{
OFstream os
@ -300,17 +174,35 @@ int main(int argc, char *argv[])
IOstreamOption::COMPRESSED
);
// No seekend with COMPRESSED
generateContent(os, false);
os << "=========================" << endl;
InfoErr<< "open: " << os.name() << endl;
InfoErr<< "... sleep" << endl;
listFiles(baseDir);
sleep(2);
os << "+++++++++++++++++++++++++++++++++++" << endl;
}
{
OFstream os
(
IOstreamOption::ATOMIC,
baseDir/"Test5.txt"
// ASCII UNCOMPRESSED NON_APPEND
);
generateContent(os, with_seekend);
os << "=========================" << endl;
InfoErr<< "open: " << os.name() << endl;
InfoErr<< "... sleep" << endl;
listFiles(baseDir);
sleep(2);
os << "+++++++++++++++++++++++++++++++++++" << endl;
}
Info<< nl << "done:" << endl;

View File

@ -67,8 +67,8 @@ using namespace Foam;
// // (note:without calculating pointNormals
// // to avoid them being stored)
//
// auto textrudeN = tmp<pointField>::New(p.nPoints(), Zero);
// auto& extrudeN = textrudeN.ref();
// tmp<pointField> textrudeN(new pointField(p.nPoints(), Zero));
// pointField& extrudeN = textrudeN();
// {
// const faceList& localFaces = p.localFaces();
// const vectorField& faceAreas = mesh.faceAreas();
@ -201,6 +201,7 @@ using namespace Foam;
int main(int argc, char *argv[])
{
#include "addTimeOptions.H"
argList::addArgument("patch");
#include "setRootCase.H"
#include "createTime.H"

View File

@ -412,7 +412,7 @@ int main(int argc, char *argv[])
}
{
Info<< "range-for of list (" << list1.count_nonnull() << '/'
Info<< "range-for of list (" << list1.count() << '/'
<< list1.size() << ") non-null entries" << nl
<< "(" << nl;
for (const auto& item : list1)

View File

@ -53,37 +53,46 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
word coherentInst;
fileName coherentInst;
coherentInst =
(
runTime.findInstance
(
polyMesh::meshSubDir,
"coherent",
IOobject::READ_IF_PRESENT,
word::null, // No stop instance
false // No "constant" fallback (word::null instead)
IOobject::READ_IF_PRESENT
)
);
Info<< "Found coherent \"" << coherentInst << '"' << nl;
// Unfortunately with READ_IF_PRESENT, cannot tell if the file
// was actually found or not
Info<< "check: " << (coherentInst/polyMesh::meshSubDir/"coherent") << nl;
if (!Foam::isFile(coherentInst/polyMesh::meshSubDir/"coherent"))
{
coherentInst.clear();
}
Info<< "found coherent: " << coherentInst << nl;
PtrList<entry> entries;
if (!coherentInst.empty())
{
dictionary coherent =
IOdictionary::readContents
IOdictionary coherent
(
IOobject
(
IOobject
(
"coherent",
coherentInst,
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ
)
);
"coherent",
coherentInst,
polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
)
);
ITstream& is = coherent.lookup("boundary");
is >> entries;
@ -96,7 +105,7 @@ int main(int argc, char *argv[])
Info<< "size: " << polyBoundaryMeshEntries::patchSizes(entries) << nl;
Info<< nl;
word boundaryInst;
fileName boundaryInst;
boundaryInst =
(
runTime.findInstance
@ -107,7 +116,7 @@ int main(int argc, char *argv[])
)
);
Info<< "Found boundary: \"" << boundaryInst << '"' << nl;
Info<< "found boundary: " << boundaryInst << nl;
polyBoundaryMeshEntries pbm
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-checkDecomposePar
checkDecomposePar
Group
grpParallelUtilities
@ -35,9 +35,8 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "polyMesh.H"
#include "OSspecific.H"
#include "fvCFD.H"
#include "cpuTime.H"
#include "IFstream.H"
#include "regionProperties.H"
@ -45,14 +44,10 @@ Description
#include "decompositionInformation.H"
#include "decompositionModel.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Check decomposition from kaffpa (KaHIP) output"
@ -70,6 +65,9 @@ int main(int argc, char *argv[])
argList::addArgument("kaffpa-output-file");
// Include explicit constant options, have zero from time range
timeSelector::addOptions(true, false);
#include "setRootCase.H"
const auto decompFile = args.get<fileName>(1);
@ -77,8 +75,8 @@ int main(int argc, char *argv[])
// Set time from database
#include "createTime.H"
// Allow override of time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
// Allow override of time
instantList times = timeSelector::selectIfPresent(runTime, args);
// Allow override of decomposeParDict location
const fileName decompDictFile =
@ -97,7 +95,7 @@ int main(int argc, char *argv[])
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
Info<< "Create mesh..." << flush;
polyMesh mesh
fvMesh mesh
(
IOobject
(
@ -113,7 +111,7 @@ int main(int argc, char *argv[])
Info<< " nCells = " << mesh.nCells() << endl;
// Expected format is a simple ASCII list
cellToProc.resize(mesh.nCells());
cellToProc.setSize(mesh.nCells());
{
IFstream is(decompFile);
@ -125,9 +123,15 @@ int main(int argc, char *argv[])
const label nDomains = max(cellToProc) + 1;
// Local mesh connectivity
CompactListList<label> cellCells;
globalMeshData::calcCellCells(mesh, cellCells);
globalMeshData::calcCellCells
(
mesh,
identity(mesh.nCells()),
mesh.nCells(),
false,
cellCells
);
decompositionInformation info
(

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,7 +81,8 @@ int print(char *argv[])
int main(int argc, char *argv[])
{
DynamicList<string> dynlst(16);
DynamicList<string> dynlst;
dynlst.reserve(16);
dynlst.push_back("string1 with content");
dynlst.push_back("string2 other content");
@ -103,18 +104,6 @@ int main(int argc, char *argv[])
Info<< nl;
}
{
CStringList inC({ "string1", "string2", "string3", "end" });
Info<< "null-terminated string list from " << nl;
print(inC.strings());
Info<< "sublist: starting at " << inC.size()/2 << nl;
print(inC.strings(inC.size()/2));
Info<< nl;
}
{
string testInput
(
@ -123,7 +112,7 @@ int main(int argc, char *argv[])
);
Info<< testInput << nl;
auto args = stringOps::splitSpace(testInput);
SubStrings<string> args = stringOps::splitSpace(testInput);
Info<< "split into " << args.size() << " args" << nl;
CStringList inC(args);
@ -135,7 +124,7 @@ int main(int argc, char *argv[])
Info<< nl;
}
Info<< "command-line with " << CStringList::count(argv) << " items" << nl;
Info<<"command-line with " << CStringList::count(argv) << " items"<< endl;
print(argc, argv);

View File

@ -64,7 +64,6 @@ int main(int argc, char *argv[])
// Add some more entries
{
label idx = 0;
dictionary subdict;
subdict.add("key", 100);
@ -73,30 +72,23 @@ int main(int argc, char *argv[])
subdict.add
(
new formattingEntry(++idx, "// comment - without newline.")
new formattingEntry(10, "// comment - without newline.")
);
subdict.add
(
// NB newline must be part of the content!
new formattingEntry(++idx, "// some comment - with newline?\n")
new formattingEntry(11, "// some comment - with newline?\n")
);
subdict.add
(
// NB newline must be part of the content!
new formattingEntry(++idx, "/* other comment */\n")
new formattingEntry(12, "/* other comment */\n")
);
// Other - invisible
subdict.add(new formattingEntry(++idx, token(123), false));
// Other - visible (probably not what anyone wants!)
subdict.add(new formattingEntry(++idx, token(456)));
subdict.add("val", 42);
Info<< "subdict keys:" << flatOutput(subdict.toc()) << nl;
dict.add("subdict", std::move(subdict));
}

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2024 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,7 +24,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-dimField1
Test-dimField
Description
Simple tests for DimensionedField
@ -52,12 +52,7 @@ namespace Foam
int main(int argc, char *argv[])
{
argList::addBoolOption("write", "write some test fields");
#include "setRootCase.H"
const bool doWrite = args.found("write");
#include "createTime.H"
#include "createMesh.H"
@ -65,23 +60,19 @@ int main(int argc, char *argv[])
Info<< "Tensor field\n" << endl;
DimensionedField<tensor, volMesh> tensorfld
(
mesh.newIOobject
IOobject
(
"tensor",
{ IOobject::READ_IF_PRESENT, IOobject::NO_WRITE }
runTime.timeName(),
mesh,
{ IOobject::READ_IF_PRESENT, IOobject::NO_REGISTER }
),
mesh,
dimensioned<tensor>(dimless, tensor(1,2,3,4,5,6,7,8,9))
);
if (doWrite)
{
tensorfld.write();
}
Info<< nl;
Info().beginBlock("transformed") << tensorfld.T();
Info().beginBlock("transformed")
<< tensorfld.T() << nl;
Info().endBlock();
{
@ -93,8 +84,8 @@ int main(int argc, char *argv[])
dimensioned<scalar>(14)
);
Info<< nl;
Info().beginBlock(tfld().type()) << tfld;
Info().beginBlock(tfld().type())
<< tfld << nl;
Info().endBlock();
}
@ -107,8 +98,8 @@ int main(int argc, char *argv[])
dimensioned<scalar>(5)
);
Info<< nl;
Info().beginBlock(tfld().type()) << tfld();
Info().beginBlock(tfld().type())
<< tfld() << nl;
Info().endBlock();
// From dissimilar types
@ -120,8 +111,8 @@ int main(int argc, char *argv[])
dimensioned<vector>(Zero)
);
Info<< nl;
Info().beginBlock(tfld2().type()) << tfld2();
Info().beginBlock(tfld2().type())
<< tfld2() << nl;
Info().endBlock();
}
}
@ -131,13 +122,20 @@ int main(int argc, char *argv[])
Info<< "uint8 field\n" << endl;
DimensionedField<uint8_t, volMesh> statefld
(
mesh.newIOobject("state")
IOobject
(
"state",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensioned<uint8_t>(dimless, uint8_t{100})
);
Info<< nl;
Info().beginBlock("stateField") << statefld;
Info().beginBlock("stateField")
<< statefld << nl;
Info().endBlock();
}
#endif

View File

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

View File

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

View File

@ -0,0 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/conversion/lnInclude
EXE_LIBS = \
-lmeshTools \
-lconversion

View File

@ -24,10 +24,10 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-ensightFileName
Test-ensightFile
Description
Check cleanup of ensight file and variable names
check cleanup of ensight file and variable names
\*---------------------------------------------------------------------------*/

View File

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

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfileFormats

View File

@ -1,137 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 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-ensightFile
Description
check cleanup of ensight file and variable names
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "ensightFile.H"
#include "ensightGeoFile.H"
#include "Switch.H"
#include "IOstreams.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::addBoolOption("ascii", "open as ascii instead of binary");
argList::addBoolOption("binary", "(default)");
argList::addBoolOption("clear", "force clear of time-steps");
argList::addBoolOption("no-end", "skip use of endTimeStep");
argList::addBoolOption("append", "open in append mode");
argList::addOption("geom", "geometry file");
argList::addOption("field", "field file");
#include "setRootCase.H"
const bool with_ascii = args.found("ascii") && !args.found("binary");
// const bool with_binary = args.found("binary");
const bool with_append = args.found("append");
const bool with_clear = args.found("clear");
const bool without_end = args.found("no-end");
const IOstreamOption::streamFormat fmt =
(
with_ascii
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
const IOstreamOption::appendType append =
(
with_append
? IOstreamOption::APPEND_ATE
: IOstreamOption::NO_APPEND
);
fileName file;
if (args.readIfPresent("geom", file))
{
Info<< "Open " << file << " as geometry "
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
<< " append:" << Switch::name(with_append) << nl;
ensightGeoFile ensFile(append, file, fmt);
if (append)
{
ensFile.beginTimeStep();
// At the moment need to pair begin/end time-step calls
if (!without_end)
{
ensFile.endTimeStep();
}
}
if (with_clear)
{
ensFile.clearTimeSteps();
}
}
if (args.readIfPresent("field", file))
{
Info<< "Open " << file << " as field"
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
<< " append:" << Switch::name(with_append) << nl;
ensightFile ensFile(append, file, fmt);
if (append)
{
ensFile.beginTimeStep();
// At the moment need to pair begin/end time-step calls
if (!without_end)
{
ensFile.endTimeStep();
}
}
if (with_clear)
{
ensFile.clearTimeSteps();
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfileFormats

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -21,8 +21,6 @@ Description
#include "argList.H"
#include "IOstreams.H"
#include "ITstream.H"
#include "OTstream.H"
#include "SpanStream.H"
#include "exprValue.H"
#include "Pstream.H"
@ -36,41 +34,6 @@ void printInfo(const expressions::exprValue& val)
}
void write_read(const expressions::exprValue& val)
{
OCharStream os;
os << val;
ISpanStream is(os.view());
expressions::exprValue val2;
is >> val2;
Pout<< "wrote " << os.count() << " chars: " << os.str() << nl;
printInfo(val);
printInfo(val2);
Pout<< "====" << nl;
}
tokenList tokens_of(const expressions::exprValue& val)
{
OTstream toks;
toks << val;
Pout<< "val with tokens: ";
toks.writeList(Pout, 0) << nl;
for (const auto& t : toks)
{
Pout<< " " << t.info() << nl;
}
Pout<< nl;
return toks;
}
expressions::exprValue tryParse(const std::string& str)
{
expressions::exprValue val, val2;
@ -127,7 +90,6 @@ int main(int argc, char *argv[])
{
expressions::exprValue value;
tokenList toks;
Info<< "exprValue"
<< " sizeof:" << value.size_bytes()
@ -137,31 +99,21 @@ int main(int argc, char *argv[])
// Nothing
printInfo(value);
toks = tokens_of(value);
write_read(value);
value.set(scalar(100));
printInfo(value); write_read(value); toks = tokens_of(value);
value.set(scalar(100.01));
printInfo(value); write_read(value); toks = tokens_of(value);
printInfo(value);
value.set(vector(1,2,3));
printInfo(value); write_read(value); toks = tokens_of(value);
printInfo(value);
value = vector(4,5,6);
printInfo(value); write_read(value); toks = tokens_of(value);
printInfo(value);
value = Zero;
printInfo(value); write_read(value); toks = tokens_of(value);
printInfo(value);
value.clear();
printInfo(value); write_read(value); toks = tokens_of(value);
value.set<bool>(true);
printInfo(value);
printInfo(value); write_read(value); toks = tokens_of(value);
if (UPstream::parRun())
{

View File

@ -1,3 +1,5 @@
exprValueFieldTag.cxx
Test-exprValue2.cxx
EXE = $(FOAM_USER_APPBIN)/Test-exprValue2

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,6 +36,7 @@ Description
#include "vectorField.H"
#include "DynamicList.H"
#include "Random.H"
#include "exprValue.H"
#include "exprValueFieldTag.H"
using namespace Foam;
@ -60,81 +61,27 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
DynamicList<fieldTag> allTags;
{
scalarField fld1(20);
scalarField fld2a(20, Zero);
scalarField fld2b(10, 3.10);
scalarField fld3;
for (auto& val : fld1)
forAll(fld1, i)
{
val = rnd.position<scalar>(0, 20);
}
if (!UPstream::master())
{
fld2b.resize(5);
fld2b *= 2;
fld1[i] = rnd.position<scalar>(0, 20);
}
fieldTag tag1(fld1.begin(), fld1.end());
fieldTag tag2a(fld2a.begin(), fld2a.end());
fieldTag tag2b(fld2b.begin(), fld2b.end());
fieldTag tag3(fld3.begin(), fld3.end());
fieldTag tag4(fld3.begin(), fld3.end());
printInfo(tag1) << nl;
printInfo(tag2a) << nl;
printInfo(tag2b) << nl;
printInfo(tag3) << nl;
{
Pout<< "Test reduce" << nl;
fieldTag work(fld2b.begin(), fld2b.end());
Pout<< "Before" << nl;
printInfo(work) << nl;
work.reduce();
Pout<< "After" << nl;
printInfo(work) << nl;
Pout<< "====" << nl;
}
allTags.clear();
allTags.push_back(tag1);
allTags.push_back(tag2a);
allTags.push_back(tag2b);
allTags.push_back(tag3);
allTags.push_back(tag4);
allTags.push_back(fieldTag::make_empty<tensor>());
// Add some other types
{
vectorField vfld2a(20, vector::uniform(1.23));
allTags.emplace_back
(
vfld2a.begin(),
vfld2a.end()
);
allTags.emplace_back(vector(1.01, 2.02, 3.03));
allTags.emplace_back(12.4);
allTags.emplace_back().set_value(vector::uniform(2.0));
allTags.back().set_empty();
}
Info<< "all tags: " << allTags << nl;
Foam::sort(allTags);
Info<< "sorted: " << allTags << nl;
fieldTag result;
result = fieldTag::combineOp{}(tag1, tag2a);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,11 +27,11 @@ Class
Foam::expressions::exprValueFieldTag
Description
An expressions::exprValue (polymorphic typed union) with an additional
flag for tracking Field content as uniform etc.
A polymorphic single-value container for tracking Field content
as uniform etc.
SourceFiles
exprValueFieldTag.C
exprValueFieldTag.cxx
\*---------------------------------------------------------------------------*/
@ -39,7 +39,7 @@ SourceFiles
#define Foam_expressions_exprValueFieldTag_H
#include "exprValue.H"
#include "UList.H" // For ListPolicy
#include "List.H" // For ListPolicy
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,38 +54,20 @@ namespace expressions
class exprValueFieldTag
{
// Private Data
// Private data
//- Uniformity of field (0: empty, 1: uniform, 2: non-uniform, ...)
// Values as per internal enum Foam::Detail::ListPolicy::uniformity
//- Uniformity of field
int uniformity_{};
//- Representative (uniform) type/value for the field
//- Representative (uniform) value for the field
expressions::exprValue value_{};
public:
// Generated Methods
//- Default construct. Uniformity = empty, type = none
exprValueFieldTag() = default;
//- Copy construct
exprValueFieldTag(const exprValueFieldTag&) = default;
//- Copy assignment
exprValueFieldTag& operator=(const exprValueFieldTag&) = default;
// Constructors
//- Construct as uniform with the specified type/value
template<class Type>
explicit exprValueFieldTag(const Type& val)
{
set_value(val);
}
//- Default construct
exprValueFieldTag() = default;
//- Construct from a range of values
template<class Type>
@ -95,18 +77,6 @@ public:
}
// Factory Methods
//- Make an empty field tag with the specified type (zero-value)
template<class Type>
static exprValueFieldTag make_empty()
{
exprValueFieldTag tag; // construct empty, no type
tag.set_zero<Type>(); // set type and zero value
return tag;
}
// Member Functions
//- True if the uniformity is "empty"
@ -118,18 +88,9 @@ public:
//- True if the uniformity is "non-uniform"
bool is_nonuniform() const noexcept;
//- Representative (uniform) value for the field
const expressions::exprValue& value() const noexcept;
//- Compare (uniformity, type, value)
int compare(const exprValueFieldTag& rhs) const;
//- Test for equality of the values
bool equal(const exprValueFieldTag& rhs) const;
// Setters
//- Set value and uniformity from range of data
template<class Type>
void set(const Type* first, const Type* last)
@ -143,48 +104,29 @@ public:
}
else
{
// Is empty, set zero value
value_.set<Type>(Foam::zero{});
}
}
//- Set as uniform, with specified value
//- Set uniform type and value
template<class Type>
void set_value(const Type& val)
void set_uniform(const Type& val)
{
uniformity_ = Foam::Detail::ListPolicy::uniformity::UNIFORM;
value_.set<Type>(val);
}
//- Set type and zero value (does not affect uniformity)
template<class Type>
void set_zero()
{
value_.set<Type>(Foam::zero{});
}
//- Set as empty with zero value, leave type unchanged
void set_empty();
//- Set as non-uniform with zero value, leave type unchanged
void set_nouniform();
// Parallel
//- Inplace parallel reduction, uses worldComm
void reduce();
//- Perform a reduction on a copy and return the result
static exprValueFieldTag returnReduce(const exprValueFieldTag& tag);
//- Set as non-uniform
void set_nouniform() noexcept;
// Reduction operations
//- Inplace combine - eg, for global uniformity
//- Combine - eg, for global uniformity
void combine(const exprValueFieldTag& b);
//- Binary combine operator, e.g. for global reduction
//- Binary operator to be used by reduce function for detecting
//- global uniformity
struct combineOp
{
exprValueFieldTag operator()
@ -202,32 +144,11 @@ public:
// IO Operations
//- Read uniformity label and the value as pair
void read(Istream& is);
//- Write uniformity label and the value as pair
void write(Ostream& os) const;
//- Print description to Ostream
void print(Ostream& os) const;
// Member Operators
//- Assign from zero. Changes value but not type
void operator=(const Foam::zero) { value_ = Foam::zero{}; }
//- Compare (uniformity,value) for equality
bool operator==(const exprValueFieldTag&) const;
//- Compare (uniformity,value) for inequality
bool operator!=(const exprValueFieldTag& rhs) const
{
return !(*this == rhs);
}
//- Compare (uniformity,value)
bool operator<(const exprValueFieldTag&) const;
};
} // End namespace expressions

View File

@ -0,0 +1,160 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
#include "exprValueFieldTag.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::expressions::exprValueFieldTag::empty() const noexcept
{
return
(
uniformity_ == Foam::Detail::ListPolicy::uniformity::EMPTY
);
}
bool Foam::expressions::exprValueFieldTag::is_uniform() const noexcept
{
return
(
uniformity_ == Foam::Detail::ListPolicy::uniformity::UNIFORM
);
}
bool Foam::expressions::exprValueFieldTag::is_nonuniform() const noexcept
{
return
(
uniformity_ == Foam::Detail::ListPolicy::uniformity::NONUNIFORM
);
}
bool Foam::expressions::exprValueFieldTag::equal
(
const exprValueFieldTag& rhs
) const
{
return (value_ == rhs.value_);
}
void Foam::expressions::exprValueFieldTag::set_nouniform() noexcept
{
uniformity_ = Foam::Detail::ListPolicy::uniformity::NONUNIFORM;
value_ = Foam::zero{};
}
void Foam::expressions::exprValueFieldTag::combine
(
const exprValueFieldTag& b
)
{
if (b.empty())
{
// no-op
return;
}
exprValueFieldTag& a = *this;
if (a.empty())
{
a = b;
}
else if (a.is_nonuniform())
{
// Already non-uniform/mixed
// a.uniformity_ |= b.uniformity_;
a.value_ = Foam::zero{};
}
else if (a.is_uniform() && b.is_uniform())
{
// Both are uniform, but are they the same value?
if (!a.equal(b))
{
a.set_nouniform();
}
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
void Foam::expressions::exprValueFieldTag::read(Istream& is)
{
label uniformTag;
is >> uniformTag;
uniformity_ = int(uniformTag);
value_.read(is);
}
void Foam::expressions::exprValueFieldTag::write(Ostream& os) const
{
os << label(uniformity_);
value_.write(os, false); // No pruning
}
void Foam::expressions::exprValueFieldTag::print(Ostream& os) const
{
os << "{ uniform:"
<< label(uniformity_)
<< " type:" << label(value_.typeCode())
<< " value: " << value_ << " }";
}
Foam::Istream& Foam::operator>>
(
Istream& is,
expressions::exprValueFieldTag& tag
)
{
tag.read(is);
return is;
}
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const expressions::exprValueFieldTag& tag
)
{
tag.write(os);
return os;
}
// ************************************************************************* //

View File

@ -32,7 +32,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "volFields.H"
#include "Time.H"
@ -127,14 +126,14 @@ void writeStencilStats(const labelListList& stencil)
int main(int argc, char *argv[])
{
timeSelector::addOptions_singleTime(); // Single-time options
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
// Set time from specified time options, or force start from Time=0
timeSelector::setTimeIfPresent(runTime, args, true);
// Get times list
instantList Times = runTime.times();
#include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
#include "createMesh.H"
// Force calculation of extended edge addressing

View File

@ -32,7 +32,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "volFields.H"
#include "surfaceFields.H"
@ -108,16 +107,14 @@ void writeStencilStats(const labelListList& stencil)
int main(int argc, char *argv[])
{
argList::noFunctionObjects(); // Never use function objects
timeSelector::addOptions_singleTime(); // Single-time options
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
// Set time from specified time options, or force start from Time=0
timeSelector::setTimeIfPresent(runTime, args, true);
// Get times list
instantList Times = runTime.times();
#include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
#include "createMesh.H"

View File

@ -1,3 +0,0 @@
Test-faMesh-try.cxx
EXE = $(FOAM_USER_APPBIN)/Test-faMesh-try

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lmeshTools

View File

@ -1,63 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-faMesh-try
Description
Test for loading of faMesh
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "faMesh.H"
#include "polyMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
#include "getFaRegionOption.H"
autoPtr<faMesh> aMeshPtr = faMesh::TryNew(areaRegionName, mesh);
Info<< "area-mesh: " << Switch::name(aMeshPtr) << nl;
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

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

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteArea \
-lmeshTools

View File

@ -1,68 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-faMeshesRegistry
Description
Basic tests for faMeshesRegistry
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "faMesh.H"
#include "faMeshesRegistry.H"
#include "polyMesh.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
Info<< "mesh 0: " << mesh.sortedNames() << nl;
faMeshesRegistry& reg =
const_cast<faMeshesRegistry&>(faMeshesRegistry::New(mesh));
// faMeshesRegistry faReg = faMeshesRegistry(mesh);
faMesh mesh1(mesh, Foam::zero{});
faMesh mesh2("mesh2", mesh, Foam::zero{});
reg.write();
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //

View File

@ -5,5 +5,4 @@ EXE_INC = \
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh

View File

@ -32,7 +32,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "volFields.H"
#include "Time.H"
@ -52,33 +51,22 @@ using namespace Foam;
int main(int argc, char *argv[])
{
timeSelector::addOptions_singleTime(); // Single-time options
argList::addBoolOption
(
"inflate",
"Use inflation/deflation for deleting cells"
);
#include "addTimeOptions.H"
argList::addArgument("inflate (true|false)");
#include "setRootCase.H"
#include "createTime.H"
// Allow override of time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
#include "createMesh.H"
const bool inflate = args.found("inflate");
const Switch inflate(args[1]);
if (inflate)
{
Info<< "Deleting cells using inflation/deflation"
<< nl << endl;
Info<< "Deleting cells using inflation/deflation" << nl << endl;
}
else
{
Info<< "Deleting cells, introducing points at new position"
<< nl << endl;
Info<< "Deleting cells, introducing points at new position" << nl
<< endl;
}

View File

@ -47,7 +47,7 @@ using namespace Foam;
template<class PrimitiveType>
static List<PrimitiveType> splitStringToList(const std::string& str)
{
const auto items = stringOps::splitAny(str, " ,;");
const SubStrings<std::string> items = stringOps::splitAny(str, " ,;");
DynamicList<PrimitiveType> values(items.size());

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
const labelList localValues
(
identity(2 *(UPstream::myProcNo()+1), -5*UPstream::myProcNo())
identity(2 *(Pstream::myProcNo()+1), -5*Pstream::myProcNo())
);
// Test resize
@ -76,8 +76,8 @@ int main(int argc, char *argv[])
// One-sided sizing! master only
const globalIndex allProcAddr
(
globalIndex::gatherOnly{},
sendData.size()
sendData.size(),
globalIndex::gatherOnly{}
);
Pout<< "listGather sizes: " << flatOutput(allProcAddr.sizes()) << nl;
@ -98,8 +98,8 @@ int main(int argc, char *argv[])
// One-sided sizing! master only
const globalIndex allProcAddr
(
globalIndex::gatherOnly{},
sendData.size()
sendData.size(),
globalIndex::gatherOnly{}
);
Pout<< "listGather sizes: " << flatOutput(allProcAddr.sizes()) << nl;
@ -116,7 +116,7 @@ int main(int argc, char *argv[])
{
const labelList::subList& sendData =
(
UPstream::master()
Pstream::master()
? SubList<label>(localValues, 0) // exclude
: SubList<label>(localValues)
);
@ -147,11 +147,11 @@ int main(int argc, char *argv[])
<< UPstream::listScatterValues(subProcAddr.offsets()) << nl;
Pout<< endl << "local list [" << UPstream::myProcNo() << "] "
Pout<< endl << "local list [" << Pstream::myProcNo() << "] "
<< flatOutput(localValues) << nl;
Pout<< endl << "local send [" << UPstream::myProcNo() << "] "
Pout<< endl << "local send [" << Pstream::myProcNo() << "] "
<< sendSize << nl;
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
Pout<< "off-proc: " << allValues << endl;
if (UPstream::master())
if (Pstream::master())
{
Info<< "master: " << flatOutput(localValues) << nl;
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
{
globalIndex glob
(
globalIndex::gatherNone{},
globalIndex:gatherNone{},
labelList(Foam::one{}, 0)
);
Info<< "single:" << nl;
@ -208,37 +208,35 @@ int main(int argc, char *argv[])
}
}
// Non-contiguous gather - use Pstream, not UPstream!
// This will likely fail - not declared as is_contiguous
// Cannot even catch since it triggers an abort()
#if 0
{
typedef std::pair<label,vector> valueType;
std::pair<label,vector> sendData(Pstream::myProcNo(), vector::one);
valueType sendData(UPstream::myProcNo(), vector::one);
const bool oldThrowingError = FatalError.throwing(true);
List<valueType> countValues
(
Pstream::listGatherValues(sendData)
);
Pout<< "listGather: " << flatOutput(countValues) << nl;
}
// Non-contiguous scatter - use Pstream, not UPstream!
{
List<fileName> allValues;
if (UPstream::master())
try
{
allValues.resize(UPstream::nProcs());
forAll(allValues, proci)
{
allValues[proci] = "processor" + Foam::name(proci);
}
List<std::pair<label,vector>> countValues
(
UPstream::listGatherValues<std::pair<label, vector>>
(
sendData
)
);
Pout<< "listGather: " << flatOutput(countValues) << nl;
}
catch (const Foam::error& err)
{
Info<< err.message().c_str() << nl;
}
fileName procName = Pstream::listScatterValues(allValues);
Pout<< "listScatter: " << procName << nl;
FatalError.throwing(oldThrowingError);
}
#endif
Info<< "\nEnd\n" << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,9 +50,6 @@ void printInfo(const meshObjects::gravity& g)
int main(int argc, char *argv[])
{
argList::addBoolOption("checkout", "Test checkout with release");
argList::addBoolOption("release", "Test release instead of delete");
#include "setRootCase.H"
#include "createTime.H"
@ -73,81 +70,14 @@ int main(int argc, char *argv[])
printInfo(g);
}
Pout<< "registered:"
<< flatOutput(runTime.sortedToc()) << nl << endl;
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << nl << endl;
}
std::unique_ptr<meshObjects::gravity> release1;
std::unique_ptr<meshObjects::gravity> release2;
meshObjects::gravity::Delete("g", runTime);
meshObjects::gravity::Delete("something-not-in-registry", runTime);
if (args.found("release"))
{
// Ugly!
typedef
MeshObject<Time, TopologicalMeshObject, meshObjects::gravity>
parent_type;
release1 = meshObjects::gravity::Release("g", runTime);
release2 = meshObjects::gravity::Release("#none#", runTime);
Info<< "release: " << Switch::name(bool(release1))
<< ", " << Switch::name(bool(release2)) << nl;
Info<< "after Release: "
<< flatOutput(runTime.sortedToc()) << endl;
// Do checkout by hand (ugly)
if (args.found("checkout"))
{
if (release1)
{
release1->parent_type::checkOut();
}
if (release2)
{
release2->parent_type::checkOut();
}
Info<< "after checkout: "
<< flatOutput(runTime.sortedToc()) << endl;
}
}
else if (args.found("checkout"))
{
// Do checkout as part of release
release1 = meshObjects::gravity::Release("g", runTime, true);
release2 = meshObjects::gravity::Release("#none#", runTime, true);
Info<< "release: " << Switch::name(bool(release1))
<< ", " << Switch::name(bool(release2)) << nl;
Info<< "after Release/Checkout(true) : "
<< flatOutput(runTime.sortedToc()) << endl;
}
else
{
meshObjects::gravity::Delete("g", runTime);
meshObjects::gravity::Delete("#none#", runTime);
Info<< "after Delete: "
<< flatOutput(runTime.sortedToc()) << endl;
}
if (meshObjects::gravity::Store(std::move(release1)))
{
Info<< "Store pointer" << endl;
}
if (release2)
{
release2.reset();
Info<< "Clear pointer" << endl;
}
Info<< "Before exit: "
<< flatOutput(runTime.sortedToc()) << endl;
Info<< "after Delete" << nl;
Pout<< "registered:" << flatOutput(runTime.sortedToc()) << endl;
Info<< "\nEnd\n" << endl;

View File

@ -5,5 +5,4 @@ EXE_INC = \
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh

View File

@ -33,7 +33,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "volFields.H"
#include "surfaceFields.H"
@ -53,28 +52,21 @@ using namespace Foam;
// Main program:
int main(int argc, char *argv[])
{
timeSelector::addOptions_singleTime(); // Single-time options
argList::addBoolOption
(
"inflate",
"Use inflation/deflation for splitting/deleting cells"
);
#include "addTimeOptions.H"
argList::addArgument("inflate (true|false)");
#include "setRootCase.H"
#include "createTime.H"
// Allow override of time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
#include "createMesh.H"
const bool inflate = args.found("inflate");
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
const Switch inflate(args[1]);
if (inflate)
{
Info<< "Splitting/deleting cells using inflation/deflation"
<< nl << endl;
Info<< "Splitting/deleting cells using inflation/deflation" << nl
<< endl;
}
else
{
@ -83,8 +75,6 @@ int main(int argc, char *argv[])
}
const pointConstraints& pc = pointConstraints::New(pointMesh::New(mesh));
Random rndGen(0);

View File

@ -0,0 +1,112 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
note "mesh renumbering dictionary";
object renumberMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Write maps from renumbered back to original mesh
writeMaps true;
// Optional entry: sort cells on coupled boundaries to last for use with
// e.g. nonBlockingGaussSeidel.
sortCoupledFaceCells false;
// Optional entry: renumber on a block-by-block basis. It uses a
// blockCoeffs dictionary to construct a decompositionMethod to do
// a block subdivision) and then applies the renumberMethod to each
// block in turn. This can be used in large cases to keep the blocks
// fitting in cache with all the cache misses bunched at the end.
// This number is the approximate size of the blocks - this gets converted
// to a number of blocks that is the input to the decomposition method.
//blockSize 1000;
// Optional entry: sort points into internal and boundary points
//orderPoints false;
// Optional: suppress renumbering cellSets,faceSets,pointSets
//renumberSets false;
//method CuthillMcKee;
//method Sloan;
//method manual;
method random;
//method structured;
//method spring;
//method zoltan; // only if compiled with zoltan support
//CuthillMcKeeCoeffs
//{
// // Reverse CuthillMcKee (RCM) or plain
// reverse true;
//}
manualCoeffs
{
// In system directory: new-to-original (i.e. order) labelIOList
dataFile "cellMap";
}
// For extruded (i.e. structured in one direction) meshes
structuredCoeffs
{
// Patches that mesh was extruded from. These determine the starting
// layer of cells
patches (movingWall);
// Method to renumber the starting layer of cells
method random;
// Renumber in columns (depthFirst) or in layers
depthFirst true;
// Reverse ordering
reverse false;
}
springCoeffs
{
// Maximum jump of cell indices. Is fraction of number of cells
maxCo 0.01;
// Limit the amount of movement; the fraction maxCo gets decreased
// with every iteration
freezeFraction 0.999;
// Maximum number of iterations
maxIter 1000;
}
blockCoeffs
{
method scotch;
//method hierarchical;
//hierarchicalCoeffs
//{
// n (1 2 1);
// delta 0.001;
// order xyz;
//}
}
zoltanCoeffs
{
ORDER_METHOD LOCAL_HSFC;
}
// ************************************************************************* //

View File

@ -51,6 +51,7 @@ using namespace Foam;
int main(int argc, char *argv[])
{
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

View File

@ -66,13 +66,13 @@ int main(int argc, char *argv[])
for (const entry& dEntry : dict)
{
if (dEntry.isStream())
if (!dEntry.isStream())
{
List<namedDictionary> list(dEntry.stream());
Info<< "input: " << dEntry << nl
<< "list: " << list << nl;
continue;
}
Info<< "input: " << dEntry << nl;
List<namedDictionary> list(dEntry.stream());
Info<< "list: " << list << nl;
}
}
}

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,7 +37,6 @@ Description
#include "HashSet.H"
#include "faceList.H"
#include "pointField.H"
#include "globalIndex.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +48,7 @@ class SimpleClass
public:
//- Default construct
SimpleClass() = default;
SimpleClass() {}
};
@ -74,8 +73,9 @@ void printInfo(const UList<T>& list)
int main()
{
// Test pointer and reference to a class
auto ptrToClass = autoPtr<SimpleClass>::New();
auto& refToClass = ptrToClass.ref();
SimpleClass* ptrToClass = new SimpleClass;
SimpleClass& refToClass(*ptrToClass);
std::cout
<< "nullObject addr=" << name(&(nullObjectPtr)) << nl
@ -89,13 +89,13 @@ int main()
<< " pointer:" << name(nullObjectPtr->pointer()) << nl
<< " value:" << nullObjectPtr->value() << nl << nl;
if (notNull(ptrToClass.get()))
if (notNull(ptrToClass))
{
Info<< "Pass: ptrToClass is not null" << nl;
}
else
{
Info<< "FAIL: ptrToClass is null" << nl;
Info<< "FAIL: refToClass is null" << nl;
}
if (notNull(refToClass))
@ -110,8 +110,8 @@ int main()
// Test pointer and reference to the nullObject
const SimpleClass* ptrToNull = NullObjectPtr<SimpleClass>();
const SimpleClass& refToNull = (*ptrToNull);
const SimpleClass* ptrToNull(NullObjectPtr<SimpleClass>());
const SimpleClass& refToNull(*ptrToNull);
if (isNull(ptrToNull))
{
@ -131,6 +131,9 @@ int main()
Info<< "FAIL: refToNull is not null" << nl;
}
// Clean-up
delete ptrToClass;
// Test List casting
{
@ -149,19 +152,7 @@ int main()
// Looks pretty ugly though!
NullObject::nullObject = "hello world";
NullObject::nullObject = Foam::identity(5);
{
const auto& gi = globalIndex::null();
Info<< "globalIndex::null() => "
<< " empty: " << gi.empty()
<< " nProcs: " << gi.nProcs()
<< " total-size: " << gi.totalSize() << nl;
// Even this works
Info<< " offsets: " << gi.offsets() << nl;
}
NullObject::nullObject = labelList({1, 2, 3});
Info<< nl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,62 +44,175 @@ Description
using namespace Foam;
//- Number of elements corresponding to max byte transfer.
// Normal upper limit is INT_MAX since MPI sizes are limited to <int>.
template<class Type>
inline std::size_t maxTransferCount
// Looks like Pstream::exchangeBuf
template<class T>
void do_exchangeBuf
(
const std::size_t max_bytes = std::size_t(0)
) noexcept
const label sendSize,
const char* sendData,
const label recvSize,
char* recvData,
const int tag,
const label comm,
const bool wait
)
{
return
(
(max_bytes == 0) // ie, unlimited
? (std::size_t(0)) //
: (max_bytes > std::size_t(INT_MAX)) // MPI limit is <int>
? (std::size_t(INT_MAX) / sizeof(Type)) //
: (max_bytes > sizeof(Type)) // require an integral number
? (max_bytes / sizeof(Type)) //
: (std::size_t(1)) // min of one element
);
const label startOfRequests = UPstream::nRequests();
// Set up receives
// ~~~~~~~~~~~~~~~
// forAll(recvSizes, proci)
{
// if (proci != Pstream::myProcNo(comm) && recvSizes[proci] > 0)
if (!Pstream::master(comm) && recvSize > 0)
{
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
UPstream::myProcNo(comm), // proci,
recvData,
recvSize*sizeof(T),
tag,
comm
);
}
}
// Set up sends
// ~~~~~~~~~~~~
// forAll(sendBufs, proci)
for (const int proci : Pstream::subProcs(comm))
{
if (sendSize > 0)
// if (proci != Pstream::myProcNo(comm) && sendSizes[proci] > 0)
{
if
(
!UOPstream::write
(
UPstream::commsTypes::nonBlocking,
proci,
sendData,
sendSize*sizeof(T),
tag,
comm
)
)
{
FatalErrorInFunction
<< "Cannot send outgoing message. "
<< "to:" << proci << " nBytes:"
<< label(sendSize*sizeof(T))
<< Foam::abort(FatalError);
}
}
}
// Wait for all to finish
// ~~~~~~~~~~~~~~~~~~~~~~
if (wait)
{
UPstream::waitRequests(startOfRequests);
}
}
//- Upper limit on number of transfer bytes.
// Max bytes is normally INT_MAX since MPI sizes are limited to <int>.
// Negative values indicate a subtraction from INT_MAX.
inline std::size_t PstreamDetail_maxTransferBytes
// Looks like Pstream::exchangeContainer
template<class Container, class T>
void do_exchangeContainer
(
const int64_t max_bytes
) noexcept
const Container& sendData,
const label recvSize,
Container& recvData,
const int tag,
const label comm,
const bool wait
)
{
return
(
(max_bytes < 0) // (numBytes fewer than INT_MAX)
? std::size_t(INT_MAX + max_bytes)
: std::size_t(max_bytes)
);
const label startOfRequests = UPstream::nRequests();
// Set up receives
// ~~~~~~~~~~~~~~~
// for (const int proci : Pstream::allProcs(comm))
{
if (!Pstream::master(comm) && recvSize > 0)
// if (proci != Pstream::myProcNo(comm) && recvSize > 0)
{
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
UPstream::myProcNo(comm), // proci,
recvData.data_bytes(),
recvSize*sizeof(T),
tag,
comm
);
}
}
// Set up sends
// ~~~~~~~~~~~~
if (Pstream::master(comm) && sendData.size() > 0)
{
for (const int proci : Pstream::subProcs(comm))
{
if
(
!UOPstream::write
(
UPstream::commsTypes::nonBlocking,
proci,
sendData.cdata_bytes(),
sendData.size_bytes(),
tag,
comm
)
)
{
FatalErrorInFunction
<< "Cannot send outgoing message. "
<< "to:" << proci << " nBytes:"
<< label(sendData.size_bytes())
<< Foam::abort(FatalError);
}
}
}
// Wait for all to finish
// ~~~~~~~~~~~~~~~~~~~~~~
if (wait)
{
UPstream::waitRequests(startOfRequests);
}
}
template<class Container, class Type>
template<class Container, class T>
void broadcast_chunks
(
Container& sendData,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
const int64_t maxComms_bytes = UPstream::maxCommsSize
const label comm = UPstream::worldComm,
const bool wait = true
)
{
// OR static_assert(is_contiguous<T>::value, "Contiguous data only!")
if (!is_contiguous<Type>::value)
if (!is_contiguous<T>::value)
{
FatalErrorInFunction
<< "Contiguous data only." << sizeof(Type)
<< Foam::abort(FatalError);
<< "Contiguous data only." << sizeof(T) << Foam::abort(FatalError);
}
if (maxComms_bytes == 0)
if (UPstream::maxCommsSize <= 0)
{
// Do in one go
Info<< "send " << sendData.size() << " elements in one go" << endl;
@ -114,90 +227,93 @@ void broadcast_chunks
sendData.resize_nocopy(recvSize); // A no-op on master
// Determine the number of chunks to send. Note that we
// only have to look at the sending data since we are
// guaranteed that some processor's sending size is some other
// processor's receive size. Also we can ignore any local comms.
// The chunk size (number of elements) corresponding to max byte transfer
// Is zero for non-chunked exchanges.
const std::size_t chunkSize
// We need to send chunks so the number of iterations:
// maxChunkSize iterations
// ------------ ----------
// 0 0
// 1..maxChunkSize 1
// maxChunkSize+1..2*maxChunkSize 2
// ...
const label maxChunkSize
(
PstreamDetail_maxTransferCount<Type>
max
(
PstreamDetail_maxTransferBytes(maxComms_bytes)
static_cast<label>(1),
static_cast<label>(UPstream::maxCommsSize/sizeof(T))
)
);
if (chunkSize)
label nChunks(0);
{
// Get max send count (elements)
// forAll(sendBufs, proci)
// {
// if (proci != Pstream::myProcNo(comm))
// {
// nChunks = max(nChunks, sendBufs[proci].size());
// }
// }
nChunks = sendSize;
// Convert from send count (elements) to number of chunks.
// Can normally calculate with (count-1), but add some safety
label nChunks = 1 + (sendSize/label(chunkSize));
if (nChunks)
{
nChunks = 1 + (nChunks/maxChunkSize);
}
reduce(nChunks, maxOp<label>(), tag, comm);
Info
<< "send " << sendSize << " elements ("
<< (sendSize*sizeof(Type)) << " bytes) in " << nChunks
<< " chunks of " << label(chunkSize) << " elements ("
<< label(chunkSize*sizeof(Type)) << " bytes) for maxCommsSize:"
<< label(maxComms_bytes)
<< (sendSize*sizeof(T)) << " bytes) in " << nChunks
<< " chunks of " << maxChunkSize << " elements ("
<< (maxChunkSize*sizeof(T)) << " bytes) for maxCommsSize:"
<< Pstream::maxCommsSize
<< endl;
}
// stress-test with shortened sendSize
// will produce useless loops, but no calls
// sendSize /= 2;
typedef stdFoam::span<Type> sendType;
label nSend(0);
label startSend(0);
char* charPtrSend;
do
for (label iter = 0; iter < nChunks; ++iter)
{
sendType payload(sendData.data(), sendData.size());
nSend = min
(
maxChunkSize,
sendSize-startSend
);
if (!chunkSize)
charPtrSend =
(
nSend > 0
? reinterpret_cast<char*>(&(sendData[startSend]))
: nullptr
);
Info<< "iter " << iter
<< ": beg=" << startSend << " len=" << nSend
<< " (" << (nSend*sizeof(T)) << " bytes)" << endl;
UPstream::broadcast(charPtrSend, nSend*sizeof(T), comm);
// forAll(nSend, proci)
{
UPstream::broadcast
(
payload.data_bytes(),
payload.size_bytes(),
comm
);
break;
}
// Dispatch chunk-wise until there is nothing left
for (int iter = 0; /*true*/; ++iter)
{
// The begin/end for the data window
const std::size_t beg = (std::size_t(iter)*chunkSize);
const std::size_t end = (std::size_t(iter+1)*chunkSize);
if (payload.size() <= beg)
{
// No more data windows
break;
}
sendType window
(
(end < payload.size())
? payload.subspan(beg, end - beg)
: payload.subspan(beg)
);
Info<< "iter " << iter
<< ": beg=" << label(beg) << " len=" << label(window.size())
<< " (" << label(window.size_bytes()) << " bytes)" << endl;
UPstream::broadcast
(
window.data_bytes(),
window.size_bytes(),
comm
);
startSend += nSend;
}
}
while (false);
Info<< "final" << endl;
Info<< "final: " << startSend << endl;
}
@ -217,7 +333,7 @@ int main(int argc, char *argv[])
}
labelList input1;
if (UPstream::master())
if (Pstream::master())
{
input1 = identity(500);
}
@ -232,7 +348,7 @@ int main(int argc, char *argv[])
// Mostly the same with PstreamBuffers
if (false)
{
PstreamBuffers pBufs;
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
labelList sendData;
if (Pstream::master())

View File

@ -50,37 +50,37 @@ scalar sumReduce
)
{
scalar sum = 0;
if (UPstream::parRun())
if (Pstream::parRun())
{
if (UPstream::master(comm))
{
// Add master value and all sub-procs
// Add master value and all slaves
sum = localValue;
for (const int proci : UPstream::subProcs(comm))
for (const int slave : UPstream::subProcs(comm))
{
scalar procValue;
scalar slaveValue;
UIPstream::read
(
UPstream::commsTypes::buffered,
proci,
reinterpret_cast<char*>(&procValue),
Pstream::commsTypes::blocking,
slave,
reinterpret_cast<char*>(&slaveValue),
sizeof(scalar),
UPstream::msgType(), // tag
comm // communicator
);
sum += procValue;
sum += slaveValue;
}
// Send back
// Send back to slaves
for (const int proci : UPstream::subProcs(comm))
for (const int slave : UPstream::subProcs(comm))
{
UOPstream::write
(
UPstream::commsTypes::buffered,
proci,
UPstream::commsTypes::blocking,
slave,
reinterpret_cast<const char*>(&sum),
sizeof(scalar),
UPstream::msgType(), // tag
@ -93,7 +93,7 @@ scalar sumReduce
{
UOPstream::write
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
UPstream::masterNo(),
reinterpret_cast<const char*>(&localValue),
sizeof(scalar),
@ -105,7 +105,7 @@ scalar sumReduce
{
UIPstream::read
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
UPstream::masterNo(),
reinterpret_cast<char*>(&sum),
sizeof(scalar),

View File

@ -41,7 +41,14 @@ Description
#include "PstreamReduceOps.H"
#include "SHA1.H"
#include "openfoam_mpi.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
using namespace Foam;

View File

@ -41,7 +41,14 @@ Description
#include "StringStream.H"
#include "Random.H"
#include "openfoam_mpi.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
using namespace Foam;

View File

@ -130,7 +130,7 @@ int main(int argc, char *argv[])
for (bool barrier_active = false, done = false; !done; /*nil*/)
{
std::pair<int, int64_t> probed =
std::pair<int, int> probed =
UPstream::probeMessage
(
UPstream::commsTypes::nonBlocking,
@ -143,8 +143,8 @@ int main(int argc, char *argv[])
{
// Message found and had size: receive it
const label proci(probed.first);
const label count(probed.second);
const label proci = probed.first;
const label count = probed.second;
recvBufs(proci).resize_nocopy(count);
recvFromProc(recvRequests.size()) = proci;

View File

@ -40,7 +40,14 @@ Description
#include "Pstream.H"
#include <iostream>
#include "openfoam_mpi.H"
// Include MPI without any C++ bindings
#ifndef MPICH_SKIP_MPICXX
#define MPICH_SKIP_MPICXX
#endif
#ifndef OMPI_SKIP_MPICXX
#define OMPI_SKIP_MPICXX
#endif
#include <mpi.h>
using namespace Foam;

View File

@ -119,7 +119,7 @@ int main(int argc, char *argv[])
for (bool barrier_active = false, done = false; !done; /*nil*/)
{
std::pair<int, int64_t> probed =
std::pair<int, int> probed =
UPstream::probeMessage
(
UPstream::commsTypes::nonBlocking,
@ -132,14 +132,14 @@ int main(int argc, char *argv[])
{
// Message found and had size: receive it
const label proci(probed.first);
const label count(probed.second);
const label proci = probed.first;
const label count = probed.second;
if (optNonBlocking)
{
recvBufs(proci).resize_nocopy(count);
// Non-blocking read - MPI_Irecv()
// Non-blocking read
UIPstream::read
(
recvRequests.emplace_back(),
@ -155,9 +155,9 @@ int main(int argc, char *argv[])
{
IPstream is
(
UPstream::commsTypes::scheduled, // ie, MPI_Recv()
proci,
count, // bufSize
UPstream::commsTypes::scheduled,
probed.first,
probed.second,
tag,
comm
);

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
Pstream::myProcNo()
);
PstreamBuffers pBufs;
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
if (!Pstream::master())
{
@ -150,7 +150,7 @@ int main(int argc, char *argv[])
// Do a non-blocking send inbetween
{
PstreamBuffers pBufs;
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
for (const int proci : Pstream::allProcs())
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,27 +52,27 @@ void testMapDistribute()
// Generate random data.
List<Tuple2<label, List<scalar>>> complexData(100);
for (auto& data : complexData)
forAll(complexData, i)
{
data.first() = rndGen.position(0, UPstream::nProcs()-1);
data.second().resize(3);
data.second()[0] = 1;
data.second()[1] = 2;
data.second()[2] = 3;
complexData[i].first() = rndGen.position(0, Pstream::nProcs()-1);
complexData[i].second().setSize(3);
complexData[i].second()[0] = 1;
complexData[i].second()[1] = 2;
complexData[i].second()[2] = 3;
}
// Send all ones to processor indicated by .first()
// Count how many to send
labelList nSend(UPstream::nProcs(), Foam::zero{});
for (const auto& data : complexData)
labelList nSend(Pstream::nProcs(), Zero);
forAll(complexData, i)
{
const label proci = data.first();
const label proci = complexData[i].first();
nSend[proci]++;
}
// Collect items to be sent
labelListList sendMap(UPstream::nProcs());
labelListList sendMap(Pstream::nProcs());
forAll(sendMap, proci)
{
sendMap[proci].resize_nocopy(nSend[proci]);
@ -116,35 +116,40 @@ void testTransfer(const T& input)
{
T data = input;
if (UPstream::master())
if (Pstream::master())
{
Perr<<"test transfer (" << (typeid(T).name()) << "): ";
perrInfo(data) << nl << endl;
}
for (const int proci : UPstream::subProcs())
if (Pstream::master())
{
for (const int slave : Pstream::subProcs())
{
Perr<< "master receiving from proc:" << proci << endl;
IPstream::recv(data, proci);
Perr<< "master receiving from slave " << slave << endl;
IPstream fromSlave(Pstream::commsTypes::blocking, slave);
fromSlave >> data;
perrInfo(data) << endl;
}
for (const int proci : UPstream::subProcs())
for (const int slave : Pstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::buffered, proci);
os << data;
Perr<< "master sending to slave " << slave << endl;
OPstream toSlave(Pstream::commsTypes::blocking, slave);
toSlave << data;
}
}
else
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
os << data;
Perr<< "slave sending to master " << Pstream::masterNo() << endl;
OPstream toMaster(Pstream::commsTypes::blocking, Pstream::masterNo());
toMaster << data;
}
Perr<< "proc receiving from master" << endl;
IPstream::recv(data, UPstream::masterNo());
Perr<< "slave receiving from master " << Pstream::masterNo() << endl;
IPstream fromMaster(Pstream::commsTypes::blocking, Pstream::masterNo());
fromMaster >> data;
perrInfo(data) << endl;
}
}
@ -155,35 +160,49 @@ void testTokenized(const T& data)
{
token tok;
if (UPstream::master())
if (Pstream::master())
{
Perr<< "test tokenized \"" << data << "\"" << nl << endl;
Perr<<"test tokenized \"" << data << "\"" << nl << endl;
}
for (const int proci : UPstream::subProcs())
if (Pstream::master())
{
for (const int slave : Pstream::subProcs())
{
Perr<< "master receiving from proc:" << proci << endl;
IPstream::recv(tok, proci);
Perr<< "master receiving from slave " << slave << endl;
IPstream fromSlave(Pstream::commsTypes::blocking, slave);
fromSlave >> tok;
Perr<< tok.info() << endl;
}
for (const int proci : UPstream::subProcs())
for (const int slave : Pstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::buffered, proci);
os << tok;
Perr<< "master sending to slave " << slave << endl;
OPstream toSlave(Pstream::commsTypes::blocking, slave);
toSlave << data;
}
}
else
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
os << tok;
Perr<< "slave sending to master " << Pstream::masterNo() << endl;
OPstream toMaster
(
Pstream::commsTypes::blocking,
Pstream::masterNo()
);
toMaster << data;
}
Perr<< "proc receiving from master" << endl;
IPstream::recv(tok, UPstream::masterNo());
Perr<< "slave receiving from master " << Pstream::masterNo() << endl;
IPstream fromMaster
(
Pstream::commsTypes::blocking,
Pstream::masterNo()
);
fromMaster >> tok;
Perr<< tok.info() << endl;
}
}
@ -193,14 +212,12 @@ void testTokenized(const T& data)
int main(int argc, char *argv[])
{
argList::noCheckProcessorDirectories();
#include "setRootCase.H"
#include "createTime.H"
testMapDistribute();
if (!UPstream::parRun())
if (!Pstream::parRun())
{
Info<< "\nWarning: not parallel - skipping further tests\n" << endl;
return 0;

View File

@ -7,6 +7,5 @@ EXE_INC = \
EXE_LIBS = \
-lfiniteVolume \
-ldynamicFvMesh \
-lsampling \
-loverset

View File

@ -56,7 +56,6 @@ Description
#include "fvCFD.H"
#include "simpleControl.H"
#include "predicates.H"
#include "dynamicFvMesh.H"
#include "dynamicOversetFvMesh.H"
@ -98,7 +97,6 @@ int main(int argc, char *argv[])
component(T.ref(), mesh.C(), 1);
// Interpolate + halo swap
T.correctBoundaryConditions();
// T.boundaryFieldRef().evaluate_if(predicates::always{});
// Check halo swap
dynamicOversetFvMesh::checkCoupledBC(T);
}

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