Compare commits

..

8 Commits

Author SHA1 Message Date
dd7cdf11c5 BUG: GAMG: processorAgglomeration not merging proc coeffs. Fixes #3172 2024-05-22 10:27:58 +01:00
0ef7589979 BUG: sampledMeshSurface sampling on "empty" patch fails
- requires a field size check when copying into the flat boundary
2024-05-02 10:24:28 +02:00
e651d63566 ENH: cyclicAMI - clear finished send/recv requests 2024-03-18 17:00:34 +01:00
119dd84327 CONFIG: bump patch level 2024-02-20 14:58:28 +01:00
08df023808 BUG: fvSchemes/fvSolution not properly updated on copy from fallback 2024-02-20 14:58:03 +01:00
a9b451b3e4 SUBMODULE: re-enable turbulence-community build
- compilation issues caused by hidden python dependency now alleviated
2024-02-13 09:31:38 +01:00
852f66fc11 CONFIG: add user/group libraries into path separately (#2948)
- on Darwin _foamAddLib() also checks the library path existence
  so passing in "path1:path2" together fails.
2024-02-06 22:16:22 +01:00
08c23685c3 BUG: incorrect cumulative area in triangulatedPatch (fixes #3097)
BUG: bad processor selection. Failed to select anything on non-master
2024-02-06 11:02:26 +01:00
836 changed files with 10507 additions and 24277 deletions

View File

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

View File

@ -1,15 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-ltopoChangerFvMesh \
-lsampling

View File

@ -56,7 +56,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "fvOptions.H"
#include "simpleControl.H"
@ -72,7 +71,7 @@ int main(int argc, char *argv[])
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "createMesh.H"
simpleControl simple(mesh);
@ -88,16 +87,6 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << nl << endl;
// Do any mesh changes
mesh.controlledUpdate();
if (mesh.changing())
{
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & fvc::interpolate(U);
}
while (simple.correctNonOrthogonal())
{
fvScalarMatrix TEqn

View File

@ -69,8 +69,7 @@ Foam::XiEqModels::Gulder::~Gulder()
Foam::tmp<Foam::volScalarField> Foam::XiEqModels::Gulder::XiEq() const
{
volScalarField up(sqrt((2.0/3.0)*turbulence_.k()));
const tmp<volScalarField> tepsilon(turbulence_.epsilon());
const volScalarField& epsilon = tepsilon();
const volScalarField& epsilon = turbulence_.epsilon();
if (subGridSchelkin_)
{

View File

@ -75,10 +75,8 @@ Foam::XiEqModels::SCOPEXiEq::~SCOPEXiEq()
Foam::tmp<Foam::volScalarField> Foam::XiEqModels::SCOPEXiEq::XiEq() const
{
const tmp<volScalarField> tk(turbulence_.k());
const volScalarField& k = tk();
const tmp<volScalarField> tepsilon(turbulence_.epsilon());
const volScalarField& epsilon = tepsilon();
const volScalarField& k = turbulence_.k();
const volScalarField& epsilon = turbulence_.epsilon();
volScalarField up(sqrt((2.0/3.0)*k));
if (subGridSchelkin_)

View File

@ -66,8 +66,7 @@ Foam::XiGModels::KTS::~KTS()
Foam::tmp<Foam::volScalarField> Foam::XiGModels::KTS::G() const
{
volScalarField up(sqrt((2.0/3.0)*turbulence_.k()));
const tmp<volScalarField> tepsilon(turbulence_.epsilon());
const volScalarField& epsilon = tepsilon();
const volScalarField& epsilon = turbulence_.epsilon();
volScalarField tauEta(sqrt(mag(thermo_.muu()/(thermo_.rhou()*epsilon))));

View File

@ -110,6 +110,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new smoluchowskiJumpTFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
smoluchowskiJumpTFvPatchScalarField
(
@ -117,22 +126,18 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new smoluchowskiJumpTFvPatchScalarField(*this, iF)
);
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object

View File

@ -118,6 +118,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new maxwellSlipUFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
maxwellSlipUFvPatchVectorField
(
@ -125,19 +134,16 @@ public:
const DimensionedField<vector, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<vector>> clone() const
{
return fvPatchField<vector>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<vector>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return fvPatchField<vector>::Clone(*this, iF);
return tmp<fvPatchVectorField>
(
new maxwellSlipUFvPatchVectorField(*this, iF)
);
}

View File

@ -135,6 +135,15 @@ public:
const fixedRhoFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new fixedRhoFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
fixedRhoFvPatchScalarField
(
@ -142,19 +151,16 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new fixedRhoFvPatchScalarField(*this, iF)
);
}

View File

@ -1,9 +1,10 @@
volScalarField& p = thermo.p();
const volScalarField& T = thermo.T();
const volScalarField& psi = thermo.psi();
const volScalarField& mu = thermo.mu();
bool inviscid(true);
if (max(thermo.mu().cref().primitiveField()) > 0.0)
if (max(mu.primitiveField()) > 0.0)
{
inviscid = false;
}

View File

@ -196,6 +196,18 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
(
@ -203,19 +215,20 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField
(
*this,
iF
)
);
}

View File

@ -85,6 +85,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new adjointOutletPressureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
adjointOutletPressureFvPatchScalarField
(
@ -92,19 +101,16 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new adjointOutletPressureFvPatchScalarField(*this, iF)
);
}

View File

@ -85,6 +85,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new adjointOutletVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
adjointOutletVelocityFvPatchVectorField
(
@ -92,19 +101,16 @@ public:
const DimensionedField<vector, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<vector>> clone() const
{
return fvPatchField<vector>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<vector>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return fvPatchField<vector>::Clone(*this, iF);
return tmp<fvPatchVectorField>
(
new adjointOutletVelocityFvPatchVectorField(*this, iF)
);
}

View File

@ -160,8 +160,7 @@ void VoFPatchTransfer::correct
const volScalarField& heVoF = thermo.thermo1().he();
const volScalarField& TVoF = thermo.thermo1().T();
const volScalarField CpVoF(thermo.thermo1().Cp());
const tmp<volScalarField> trhoVoF(thermo.thermo1().rho());
const volScalarField& rhoVoF = trhoVoF();
const volScalarField& rhoVoF = thermo.thermo1().rho()();
const volScalarField& alphaVoF = thermo.alpha1();
forAll(patchIDs_, pidi)

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

@ -164,6 +164,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new alphaContactAngleFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
alphaContactAngleFvPatchScalarField
(
@ -171,19 +180,16 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new alphaContactAngleFvPatchScalarField(*this, iF)
);
}

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

@ -28,8 +28,7 @@
forAllConstIters(mixture.phases(), phase)
{
const rhoThermo& thermo = phase().thermo();
const tmp<volScalarField> trho(thermo.rho());
const volScalarField& rho = trho();
const volScalarField& rho = thermo.rho()();
p_rghEqnComps.set
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2024 OpenCFD Ltd
Copyright (C) 2017-2019 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -206,13 +206,9 @@ public:
//- Construct as copy
DTRMParticle(const DTRMParticle& p);
//- Return a clone
virtual autoPtr<particle> clone() const
{
return particle::Clone(*this);
}
//- Factory class to read-construct particles (for parallel transfer)
//- Factory class to read-construct particles used for
// parallel transfer
class iNew
{
const polyMesh& mesh_;

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

@ -164,6 +164,15 @@ public:
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new alphaContactAngleFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
alphaContactAngleFvPatchScalarField
(
@ -171,19 +180,16 @@ public:
const DimensionedField<scalar, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<scalar>> clone() const
{
return fvPatchField<scalar>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<scalar>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return fvPatchField<scalar>::Clone(*this, iF);
return tmp<fvPatchScalarField>
(
new alphaContactAngleFvPatchScalarField(*this, iF)
);
}

View File

@ -100,6 +100,15 @@ public:
const tractionDisplacementFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
tractionDisplacementFvPatchVectorField
(
@ -107,19 +116,16 @@ public:
const DimensionedField<vector, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<vector>> clone() const
{
return fvPatchField<vector>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<vector>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return fvPatchField<vector>::Clone(*this, iF);
return tmp<fvPatchVectorField>
(
new tractionDisplacementFvPatchVectorField(*this, iF)
);
}

View File

@ -98,6 +98,15 @@ public:
const tractionDisplacementCorrectionFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new tractionDisplacementCorrectionFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
tractionDisplacementCorrectionFvPatchVectorField
(
@ -105,19 +114,16 @@ public:
const DimensionedField<vector, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<vector>> clone() const
{
return fvPatchField<vector>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<vector>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return fvPatchField<vector>::Clone(*this, iF);
return tmp<fvPatchVectorField>
(
new tractionDisplacementCorrectionFvPatchVectorField(*this, iF)
);
}

View File

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

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lblockMesh

View File

@ -1,400 +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-checkIOspeed
Description
Simple test of file writing, including timings
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "profiling.H"
#include "clockTime.H"
#include "fileName.H"
#include "fileOperation.H"
#include "IOstreams.H"
#include "OSspecific.H"
#include "globalIndex.H"
#include "volFields.H"
#include "IOField.H"
#include "PDRblock.H"
// Not really great since CoherentMesh only works with reading!
#ifdef USE_COHERENT
#include "OFCstream.H"
#include "SliceStreamRepo.H"
#endif
#include <numeric>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::addNote("Rewrites fields multiple times");
argList::noFunctionObjects(); // Disallow function objects
argList::noCheckProcessorDirectories();
argList::addVerboseOption("additional verbosity");
argList::addOption
(
"output",
"N",
"Begin output iteration (default: 10000)"
);
argList::addOption
(
"count",
"N",
"Number of writes (default: 1)"
);
argList::addOption
(
"fields",
"N",
"Number of fields to write (default: 1)"
);
argList::addOption
(
"global",
"N",
"Global field size"
);
argList::addOption
(
"local",
"N",
"Local fields size (default: 1000)"
);
argList::addOption
(
"mesh",
"(nx ny nz)",
"Create with a mesh"
);
argList::addOption
(
"exclude",
"(int ... )",
"zero-sized on ranks with specified modulo"
);
argList::addBoolOption("coherent", "Force coherent output");
#include "setRootCase.H"
#include "createTime.H"
const label firstOutput = args.getOrDefault("output", 10000);
const label nOutput = args.getOrDefault("count", 1);
const label nFields = args.getOrDefault("fields", 1);
labelVector meshCells(0, 0, 0);
const int verbose = args.verbose();
const bool useCoherent = args.found("coherent");
labelList excludes;
args.readListIfPresent("exclude", excludes);
bool writeOnProc = true;
const label myProci = UPstream::myProcNo();
for (const label excl : excludes)
{
if (excl > 1 && myProci > 0 && (myProci % excl) == 0)
{
writeOnProc = false;
break;
}
}
const label nProcsEff =
returnReduce((writeOnProc ? 1 : 0), sumOp<label>());
Info<< "Output " << nProcsEff
<< "/" << UPstream::nProcs()
<< " ranks" << nl;
if (args.readIfPresent("mesh", meshCells))
{
if (!writeOnProc)
{
meshCells = Zero;
}
PDRblock block(boundBox(point::zero, point::one), meshCells);
// Advance time
// - coherent currently still needs to read the mesh itself!
runTime.setTime(firstOutput, firstOutput);
IOobject meshIO
(
polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
autoPtr<polyMesh> pmeshPtr(block.innerMesh(meshIO));
fvMesh mesh
(
meshIO,
pointField(pmeshPtr->points()),
faceList(pmeshPtr->faces()),
labelList(pmeshPtr->faceOwner()),
labelList(pmeshPtr->faceNeighbour())
);
pmeshPtr.reset(nullptr);
const label fieldSize = mesh.nCells();
const globalIndex giCells(fieldSize);
// Create fields
Info<< nl << "Create " << nFields << " fields" << nl
<< "field-size:" << fieldSize
<< " total-size:" << giCells.totalSize() << nl;
// Dimensioned field (no proc boundaries)
PtrList<volScalarField::Internal> fields(nFields);
{
IOobject io
(
"field",
runTime.timeName(),
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
forAll(fields, fieldi)
{
io.resetHeader("field" + Foam::name(fieldi));
fields.set
(
fieldi,
new volScalarField::Internal(io, mesh, dimless)
);
auto& fld = fields[fieldi];
std::iota(fld.begin(), fld.end(), scalar(0));
}
}
IOstreamOption streamOpt(IOstreamOption::BINARY);
if (useCoherent)
{
#ifdef USE_COHERENT
streamOpt.format(IOstreamOption::COHERENT);
runTime.writeFormat(IOstreamOption::COHERENT);
mesh.writeObject(streamOpt, true);
Info<< nl
<< "Specified -coherent (instance: "
<< mesh.pointsInstance() << ")" << endl;
const auto& coherent = CoherentMesh::New(mesh);
Info<< " points = "
<< coherent.globalPointOffsets().totalSize() << nl
<< " cells = "
<< coherent.globalCellOffsets().totalSize() << nl
<< " patches = "
<< coherent.nNonProcessorPatches() << nl;
#else
Info<< "Warning: -coherent ignored" << nl;
#endif
}
Info<< nl
<< "Writing " << nOutput << " times starting at "
<< firstOutput << nl;
clockTime timing;
if (verbose) Info<< "Time:";
for
(
label timeIndex = firstOutput, count = 0;
count < nOutput;
++timeIndex, ++count
)
{
runTime.setTime(timeIndex, timeIndex);
if (verbose) Info<< ' ' << runTime.timeName() << flush;
runTime.writeNow();
for (const auto& fld : fields)
{
fld.regIOobject::writeObject(streamOpt, writeOnProc);
}
}
if (useCoherent)
{
#ifdef USE_COHERENT
SliceStreamRepo::closeInstance();
#endif
}
if (verbose) Info<< nl;
Info<< nl << "Writing took "
<< timing.timeIncrement() << "s" << endl;
Info<< nl
<< "Cleanup newly generated files with" << nl << nl
<< " foamListTimes -rm -time "
<< firstOutput << ":" << nl
<< " foamListTimes -processor -rm -time "
<< firstOutput << ":" << nl;
}
else
{
label fieldSize = 1000;
if (args.readIfPresent("global", fieldSize))
{
fieldSize /= nProcsEff;
}
else
{
args.readIfPresent("local", fieldSize);
}
if (!writeOnProc)
{
fieldSize = 0;
}
const globalIndex giCells(fieldSize);
// Create fields
Info<< nl << "Create " << nFields << " fields" << nl
<< "field-size:" << fieldSize
<< " total-size:" << giCells.totalSize() << nl;
PtrList<IOField<scalar>> fields(nFields);
{
IOobject io
(
"field",
runTime.timeName(),
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
);
forAll(fields, fieldi)
{
io.resetHeader("field" + Foam::name(fieldi));
fields.set
(
fieldi,
new IOField<scalar>(io, fieldSize)
);
auto& fld = fields[fieldi];
std::iota(fld.begin(), fld.end(), scalar(0));
}
}
IOstreamOption streamOpt(IOstreamOption::BINARY);
if (useCoherent)
{
Info<< "Warning: -coherent ignored" << nl;
}
Info<< nl
<< "Writing " << nOutput << " times starting at "
<< firstOutput << nl;
clockTime timing;
if (verbose) Info<< "Time:";
for
(
label timeIndex = firstOutput, count = 0;
count < nOutput;
++timeIndex, ++count
)
{
runTime.setTime(timeIndex, timeIndex);
if (verbose) Info<< ' ' << runTime.timeName() << flush;
runTime.writeNow();
for (const auto& fld : fields)
{
fld.regIOobject::writeObject(streamOpt, writeOnProc);
}
}
if (verbose) Info<< nl;
Info<< nl << "Writing took "
<< timing.timeIncrement() << "s" << endl;
Info<< nl
<< "Cleanup newly generated files with" << nl << nl
<< " foamListTimes -rm -time "
<< firstOutput << ":" << nl
<< " foamListTimes -processor -rm -time "
<< firstOutput << ":" << nl;
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

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

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

View File

@ -56,18 +56,8 @@ int main(int argc, char *argv[])
argList::noFunctionObjects(); // Disallow function objects
argList::addVerboseOption("additional verbosity");
argList::addOption
(
"output",
"N",
"Begin output iteration (default: 10000)"
);
argList::addOption
(
"count",
"N",
"Number of writes (default: 1)"
);
argList::addOption("output", "Begin output iteration (default: 10000)");
argList::addOption("count", "Number of writes (default: 1)");
#include "setRootCase.H"
#include "createTime.H"

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

@ -59,7 +59,7 @@ int main(int argc, char *argv[])
(
"procAddressing",
instance,
polyMesh::meshSubDir,
fvMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,

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.
@ -48,7 +48,7 @@ class SimpleClass
public:
//- Default construct
SimpleClass() = default;
SimpleClass() {}
};
@ -73,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
@ -88,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))
@ -109,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))
{
@ -130,6 +131,9 @@ int main()
Info<< "FAIL: refToNull is not null" << nl;
}
// Clean-up
delete ptrToClass;
// Test List casting
{
@ -148,7 +152,7 @@ int main()
// Looks pretty ugly though!
NullObject::nullObject = "hello world";
NullObject::nullObject = Foam::identity(5);
NullObject::nullObject = labelList({1, 2, 3});
Info<< nl;

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::blocking,
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::blocking,
proci,
slave,
reinterpret_cast<const char*>(&sum),
sizeof(scalar),
UPstream::msgType(), // tag

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,31 +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::bsend(data, proci);
Perr<< "master sending to slave " << slave << endl;
OPstream toSlave(Pstream::commsTypes::blocking, slave);
toSlave << data;
}
}
else
{
Perr<< "proc sending to master" << endl;
OPstream::bsend(data, UPstream::masterNo());
{
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;
}
}
@ -151,31 +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::bsend(tok, proci);
Perr<< "master sending to slave " << slave << endl;
OPstream toSlave(Pstream::commsTypes::blocking, slave);
toSlave << data;
}
}
else
{
Perr<< "proc sending to master" << endl;
OPstream::bsend(tok, UPstream::masterNo());
{
Perr<< "slave sending to master " << Pstream::masterNo() << endl;
OPstream toMaster
(
Pstream::commsTypes::blocking,
Pstream::masterNo()
);
Perr<< "proc receiving from master" << endl;
IPstream::recv(tok, UPstream::masterNo());
toMaster << data;
}
Perr<< "slave receiving from master " << Pstream::masterNo() << endl;
IPstream fromMaster
(
Pstream::commsTypes::blocking,
Pstream::masterNo()
);
fromMaster >> tok;
Perr<< tok.info() << endl;
}
}
@ -185,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

@ -51,7 +51,7 @@ void printConnection(Ostream& os, const label proci, const labelUList& below)
// The number of receives - as per gatherList (v2112)
void printRecvCount_gatherList
(
const UList<UPstream::commsStruct>& comms,
const List<UPstream::commsStruct>& comms,
const label comm = UPstream::worldComm
)
{
@ -91,7 +91,7 @@ void printRecvCount_gatherList
// The number of sends - as per scatterList (v2112)
void printSendCount_scatterList
(
const UList<UPstream::commsStruct>& comms,
const List<UPstream::commsStruct>& comms,
const label comm = UPstream::worldComm
)
{
@ -131,7 +131,7 @@ void printSendCount_scatterList
// Transmission widths (contiguous data)
void printWidths
(
const UList<UPstream::commsStruct>& comms,
const List<UPstream::commsStruct>& comms,
const label comm = UPstream::worldComm
)
{

View File

@ -118,8 +118,7 @@ PtrList<GeoField> create
(
word("cmpt." + name(i)),
mesh,
Foam::zero{}, // value
dimless
dimensioned<typename GeoField::value_type>(Zero)
).ptr()
);
}

View File

@ -43,7 +43,6 @@ Description
#include "argList.H"
#include "Time.H"
#include "polyTopoChange.H"
#include "batchPolyTopoChange.H"
#include "polyTopoChanger.H"
#include "edgeCollapser.H"
#include "perfectInterface.H"
@ -1060,8 +1059,7 @@ int main(int argc, char *argv[])
);
// Topo change container
//polyTopoChange meshMod(mesh);
batchPolyTopoChange meshMod(mesh);
polyTopoChange meshMod(mesh);
perfectStitcher.setRefinement
(
@ -1087,9 +1085,7 @@ int main(int argc, char *argv[])
);
// Construct new mesh from polyTopoChange.
//autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
polyTopoChanger XXX (mesh, IOobject::NO_READ);
autoPtr<mapPolyMesh> map = XXX.changeMesh(mesh, meshMod);
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
// Update fields
mesh.updateMesh(map());

View File

@ -482,8 +482,8 @@ void Foam::searchableSurfaceControl::cellSizeFunctionVertices
DynamicList<scalar>& sizes
) const
{
const tmp<pointField> tpoints(searchableSurface_.points());
const pointField& points = tpoints();
const tmp<pointField> tmpPoints = searchableSurface_.points();
const pointField& points = tmpPoints();
const scalar nearFeatDistSqrCoeff = 1e-8;

View File

@ -110,8 +110,7 @@ Foam::scalar Foam::nonUniformField::interpolate
{
const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
const tmp<pointField> tpoints(surfaceTriMesh_.points());
const pointField& pts = tpoints();
const pointField& pts = surfaceTriMesh_.points();
// const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
triPointRef tri

View File

@ -982,7 +982,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces
offsetBoundaryCells.write();
}
return offsetBoundaryCells;
return std::move(offsetBoundaryCells);
}

View File

@ -1371,7 +1371,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findRemainingProtrusionSet
protrudingCells.write();
}
return protrudingCells;
return std::move(protrudingCells);
}

View File

@ -579,8 +579,8 @@ inline bool CGAL::indexedCell<Gt, Cb>::potentialCoplanarCell() const
if (nMasters == 2 && nSlaves == 2)
{
Foam::vector vp0(Foam::zero{});
Foam::vector vp1(Foam::zero{});
Foam::vector vp0(Foam::Zero);
Foam::vector vp1(Foam::Zero);
if
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,33 +53,26 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Name of region to create
const word singleCellName = "singleCell";
const string singleCellName = "singleCell";
template<class GeoField>
wordList interpolateFields
void interpolateFields
(
const singleCellFvMesh& subsetter,
const singleCellFvMesh& scMesh,
const PtrList<GeoField>& flds
)
{
wordList names(flds.size());
forAll(flds, i)
{
GeoField* subFld = subsetter.interpolate(flds[i]).ptr();
subFld->writeOpt(IOobject::AUTO_WRITE);
subFld->store();
names[i] = subFld->name();
tmp<GeoField> scFld = scMesh.interpolate(flds[i]);
GeoField* scFldPtr = scFld.ptr();
scFldPtr->writeOpt(IOobject::AUTO_WRITE);
scFldPtr->store();
}
return names;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
@ -101,7 +94,7 @@ int main(int argc, char *argv[])
if (regionName == singleCellName)
{
FatalErrorInFunction
<< "Cannot convert region " << regionName
<< "Cannot convert region " << singleCellName
<< " since result would overwrite it. Please rename your region."
<< exit(FatalError);
}
@ -118,8 +111,7 @@ int main(int argc, char *argv[])
mesh.pointsInstance(),
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::NO_REGISTER
IOobject::AUTO_WRITE
),
mesh
)
@ -139,27 +131,18 @@ int main(int argc, char *argv[])
}
// List of stored objects to clear prior to reading
DynamicList<word> storedObjects;
forAll(timeDirs, timei)
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timei], timei);
runTime.setTime(timeDirs[timeI], timeI);
Info<< nl << "Time = " << runTime.timeName() << endl;
// Purge any previously interpolated fields
if (!storedObjects.empty())
{
static_cast<objectRegistry&>(scMesh()).erase(storedObjects);
storedObjects.clear();
}
// Check for new mesh
if (mesh.readUpdate() != polyMesh::UNCHANGED)
{
Info<< "Detected changed mesh. Recreating singleCell mesh." << endl;
scMesh.reset(nullptr); // first free any stored objects
scMesh.clear(); // remove any registered objects
scMesh.reset
(
new singleCellFvMesh
@ -170,37 +153,43 @@ int main(int argc, char *argv[])
mesh.pointsInstance(),
runTime,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::NO_REGISTER
IOobject::AUTO_WRITE
),
mesh
)
);
}
// Read objects in time directory
IOobjectList objects(mesh, runTime.timeName());
storedObjects.reserve(objects.size());
// Read fvMesh fields, map and store the interpolated fields
#define doLocalCode(GeoField) \
{ \
PtrList<GeoField> flds; \
ReadFields(mesh, objects, flds); \
storedObjects.push_back(interpolateFields(scMesh(), flds)); \
}
// Read vol fields.
PtrList<volScalarField> vsFlds;
ReadFields(mesh, objects, vsFlds);
doLocalCode(volScalarField);
doLocalCode(volVectorField);
doLocalCode(volSphericalTensorField);
doLocalCode(volSymmTensorField);
doLocalCode(volTensorField);
PtrList<volVectorField> vvFlds;
ReadFields(mesh, objects, vvFlds);
PtrList<volSphericalTensorField> vstFlds;
ReadFields(mesh, objects, vstFlds);
PtrList<volSymmTensorField> vsymtFlds;
ReadFields(mesh, objects, vsymtFlds);
PtrList<volTensorField> vtFlds;
ReadFields(mesh, objects, vtFlds);
// Map and store the fields on the scMesh.
interpolateFields(scMesh(), vsFlds);
interpolateFields(scMesh(), vvFlds);
interpolateFields(scMesh(), vstFlds);
interpolateFields(scMesh(), vsymtFlds);
interpolateFields(scMesh(), vtFlds);
#undef doLocalCode
// Write
Info<< "Writing " << singleCellName
<< " mesh/fields to time " << runTime.timeName() << endl;
Info<< "Writing mesh to time " << runTime.timeName() << endl;
scMesh().write();
}

View File

@ -622,7 +622,7 @@ int main(int argc, char *argv[])
}
// Execute all polyMeshModifiers
autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh();
autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh(true);
mesh.movePoints(morphMap->preMotionPoints());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,8 +30,9 @@ License
#include "Time.H"
#include "PtrList.H"
#include "fvPatchFields.H"
#include "fvsPatchFields.H"
#include "emptyFvPatch.H"
#include "emptyFvPatchField.H"
#include "emptyFvsPatchField.H"
#include "IOobjectList.H"
#include "mapDistributePolyMesh.H"
#include "processorFvPatch.H"
@ -122,19 +123,15 @@ Foam::parFvFieldDistributor::distributeField
{
if (patchFaceMaps_.set(patchi))
{
// Clone local patch field
oldPatchFields.set(patchi, bfld[patchi].clone());
distributedFvPatchFieldMapper mapper
(
labelUList::null(),
patchFaceMaps_[patchi]
);
// Clone local patch field
oldPatchFields.set
(
patchi,
bfld[patchi].clone(fld.internalField())
);
// Map into local copy
oldPatchFields[patchi].autoMap(mapper);
}
@ -162,7 +159,7 @@ Foam::parFvFieldDistributor::distributeField
(
pfld,
tgtMesh_.boundary()[patchi],
fvPatchField<Type>::Internal::null(),
DimensionedField<Type, volMesh>::null(),
dummyMapper
)
);
@ -181,9 +178,9 @@ Foam::parFvFieldDistributor::distributeField
patchi,
fvPatchField<Type>::New
(
fvPatchFieldBase::emptyType(),
emptyFvPatchField<Type>::typeName,
tgtMesh_.boundary()[patchi],
fvPatchField<Type>::Internal::null()
DimensionedField<Type, volMesh>::null()
)
);
}
@ -271,19 +268,15 @@ Foam::parFvFieldDistributor::distributeField
{
if (patchFaceMaps_.set(patchi))
{
// Clone local patch field
oldPatchFields.set(patchi, bfld[patchi].clone());
distributedFvPatchFieldMapper mapper
(
labelUList::null(),
patchFaceMaps_[patchi]
);
// Clone local patch field
oldPatchFields.set
(
patchi,
bfld[patchi].clone(fld.internalField())
);
// Map into local copy
oldPatchFields[patchi].autoMap(mapper);
}
@ -310,7 +303,7 @@ Foam::parFvFieldDistributor::distributeField
(
pfld,
tgtMesh_.boundary()[patchi],
fvsPatchField<Type>::Internal::null(),
DimensionedField<Type, surfaceMesh>::null(),
dummyMapper
)
);
@ -328,9 +321,9 @@ Foam::parFvFieldDistributor::distributeField
patchi,
fvsPatchField<Type>::New
(
fvsPatchFieldBase::emptyType(),
emptyFvsPatchField<Type>::typeName,
tgtMesh_.boundary()[patchi],
fvsPatchField<Type>::Internal::null()
DimensionedField<Type, surfaceMesh>::null()
)
);
}

View File

@ -26,11 +26,11 @@ License
\*---------------------------------------------------------------------------*/
#include "Time.H"
#include "emptyPointPatchField.H"
#include "IOobjectList.H"
#include "mapDistributePolyMesh.H"
#include "distributedFieldMapper.H"
#include "distributedPointPatchFieldMapper.H"
#include "emptyPointPatch.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -108,7 +108,7 @@ Foam::parPointFieldDistributor::distributeField
(
bfld[patchi],
tgtMesh.boundary()[patchi], // pointPatch
pointPatchField<Type>::Internal::null(),
DimensionedField<Type, pointMesh>::null(),
mapper
)
);
@ -122,7 +122,7 @@ Foam::parPointFieldDistributor::distributeField
// bfld[patchi].clone
// (
// tgtMesh.boundary()[patchi],
// pointPatchField<Type>::Internal::null(),
// DimensionedField<Type, pointMesh>::null(),
// mapper
// )
//);
@ -140,9 +140,9 @@ Foam::parPointFieldDistributor::distributeField
patchi,
pointPatchField<Type>::New
(
pointPatchFieldBase::emptyType(),
emptyPointPatchField<Type>::typeName,
tgtMesh.boundary()[patchi],
pointPatchField<Type>::Internal::null()
DimensionedField<Type, pointMesh>::null()
)
);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -100,10 +100,10 @@ public:
cachedPosition_(p.cachedPosition_)
{}
//- Return a clone
//- Construct and return a clone
virtual autoPtr<particle> clone() const
{
return particle::Clone(*this);
return autoPtr<particle>(new passivePositionParticle(*this));
}

View File

@ -148,8 +148,7 @@ bool setField
(
fieldName,
mesh,
Foam::zero{}, // value
dims
dimensioned<typename GeoField::value_type>(dims)
);
}
else

View File

@ -221,10 +221,9 @@ void detectSelfIntersections
const edgeList& edges = s.edges();
const indexedOctree<treeDataTriSurface>& tree = s.tree();
const labelList& meshPoints = s.meshPoints();
const tmp<pointField> tpoints(s.points());
const pointField& points = tpoints();
const pointField& points = s.points();
isEdgeIntersecting.resize_nocopy(edges.size());
isEdgeIntersecting.setSize(edges.size());
isEdgeIntersecting = false;
forAll(edges, edgeI)
@ -312,8 +311,7 @@ label detectIntersectionPoints
detectSelfIntersections(s, isEdgeIntersecting);
const edgeList& edges = s.edges();
const tmp<pointField> tpoints(s.points());
const pointField& points = tpoints();
const pointField& points = s.points();
forAll(edges, edgeI)
{
@ -838,10 +836,9 @@ int main(int argc, char *argv[])
// Do some smoothing (Lloyds algorithm)
lloydsSmoothing(nSmooth, s, isFeaturePoint, edgeStat, isAffectedPoint);
// Update pointDisplacement
const tmp<pointField> tpoints(s.points());
const pointField& pts = tpoints();
// Update pointDisplacement
const pointField& pts = s.points();
forAll(meshPoints, i)
{
label meshPointI = meshPoints[i];

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -86,10 +86,13 @@ public:
const ${typeName}Function1_${TemplateType}& rhs
) = default;
//- Return a clone
//- Construct and return a clone
virtual tmp<Function1<${TemplateType}>> clone() const
{
return Function1<${TemplateType}>::Clone(*this);
return tmp<Function1<${TemplateType}>>
(
new ${typeName}Function1_${TemplateType}(*this)
);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2024 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,6 +85,12 @@ public:
const bool faceValues = true
);
//- Copy construct
${typeName}PatchFunction1${FieldType}
(
const ${typeName}PatchFunction1${FieldType}& rhs
) = default;
//- Copy construct, resetting patch
${typeName}PatchFunction1${FieldType}
(
@ -92,25 +98,25 @@ public:
const polyPatch& pp
);
//- Copy construct
${typeName}PatchFunction1${FieldType}
(
const ${typeName}PatchFunction1${FieldType}& rhs
) = default;
//- Return a clone
//- Construct and return a clone
virtual tmp<PatchFunction1<${TemplateType}>> clone() const
{
return PatchFunction1<${TemplateType}>::Clone(*this);
return tmp<PatchFunction1<${TemplateType}>>
(
new ${typeName}PatchFunction1${FieldType}(*this)
);
}
//- Return a clone, setting the patch
//- Construct and return a clone setting patch
virtual tmp<PatchFunction1<${TemplateType}>> clone
(
const polyPatch& pp
) const
{
return PatchFunction1<${TemplateType}>::Clone(*this, pp);
return tmp<PatchFunction1<${TemplateType}>>
(
new ${typeName}PatchFunction1${FieldType}(*this, pp)
);
}

View File

@ -107,6 +107,15 @@ public:
const ${typeName}FixedValueFvPatch${FieldType}&
);
//- Construct and return a clone
virtual tmp<fvPatch${FieldType}> clone() const
{
return tmp<fvPatch${FieldType}>
(
new ${typeName}FixedValueFvPatch${FieldType}(*this)
);
}
//- Construct as copy setting internal field reference
${typeName}FixedValueFvPatch${FieldType}
(
@ -114,19 +123,16 @@ public:
const DimensionedField<${TemplateType}, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<${TemplateType}>> clone() const
{
return fvPatchField<${TemplateType}>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<${TemplateType}>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatch${FieldType}> clone
(
const DimensionedField<${TemplateType}, volMesh>& iF
) const
{
return fvPatchField<${TemplateType}>::Clone(*this, iF);
return tmp<fvPatch${FieldType}>
(
new ${typeName}FixedValueFvPatch${FieldType}(*this, iF)
);
}

View File

@ -108,6 +108,15 @@ public:
const ${typeName}FixedValuePointPatch${FieldType}&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<${TemplateType}>> clone() const
{
return autoPtr<pointPatchField<${TemplateType}>>
(
new ${typeName}FixedValuePointPatch${FieldType}(*this)
);
}
//- Construct as copy setting internal field reference
${typeName}FixedValuePointPatch${FieldType}
(
@ -115,19 +124,16 @@ public:
const DimensionedField<${TemplateType}, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<${TemplateType}>> clone() const
{
return pointPatchField<${TemplateType}>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<${TemplateType}>> clone
(
const DimensionedField<${TemplateType}, pointMesh>& iF
) const
{
return pointPatchField<${TemplateType}>::Clone(*this, iF);
return autoPtr<pointPatchField<${TemplateType}>>
(
new ${typeName}FixedValuePointPatch${FieldType}(*this, iF)
);
}

View File

@ -107,6 +107,15 @@ public:
const ${typeName}MixedValueFvPatch${FieldType}&
);
//- Construct and return a clone
virtual tmp<fvPatch${FieldType}> clone() const
{
return tmp<fvPatch${FieldType}>
(
new ${typeName}MixedValueFvPatch${FieldType}(*this)
);
}
//- Construct as copy setting internal field reference
${typeName}MixedValueFvPatch${FieldType}
(
@ -114,19 +123,16 @@ public:
const DimensionedField<${TemplateType}, volMesh>&
);
//- Return a clone
virtual tmp<fvPatchField<${TemplateType}>> clone() const
{
return fvPatchField<${TemplateType}>::Clone(*this);
}
//- Clone with an internal field reference
virtual tmp<fvPatchField<${TemplateType}>> clone
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatch${FieldType}> clone
(
const DimensionedField<${TemplateType}, volMesh>& iF
) const
{
return fvPatchField<${TemplateType}>::Clone(*this, iF);
return tmp<fvPatch${FieldType}>
(
new ${typeName}MixedValueFvPatch${FieldType}(*this, iF)
);
}

View File

@ -197,8 +197,8 @@ if ( "$FOAM_MPI" != dummy ) then
_foamAddLib "${FOAM_LIBBIN}/${FOAM_MPI}"
endif
# OpenFOAM user, group libraries
_foamAddLib "${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}"
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
if ( -d "$WM_PROJECT_DIR/doc/man1" ) then
_foamAddMan "$WM_PROJECT_DIR/doc"

View File

@ -229,8 +229,8 @@ then
_foamAddLib "$FOAM_LIBBIN/$FOAM_MPI"
fi
# OpenFOAM user, group libraries
_foamAddLib "$FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN"
_foamAddLib "$FOAM_SITE_LIBBIN" # OpenFOAM group libraries
_foamAddLib "$FOAM_USER_LIBBIN" # OpenFOAM user libraries
if [ -d "$WM_PROJECT_DIR/doc/man1" ]
then

View File

@ -114,7 +114,7 @@ OptimisationSwitches
// (sized with magnitude of value) is large enough to hold all
// outstanding writes so will not try to initialise the Pstream with
// threading support.
// Default: 0
// Default: 1e9
maxThreadFileBufferSize 0;
//- masterUncollated: non-blocking buffer size.

View File

@ -75,7 +75,7 @@ wmake $targetType lagrangian/distributionModels
parallel/Allwmake $targetType $*
wmake $targetType dynamicFvMesh
#HJ wmake $targetType topoChangerFvMesh
wmake $targetType topoChangerFvMesh
wmake $targetType sampling
transportModels/Allwmake $targetType $*
@ -130,9 +130,6 @@ wmake $targetType rigidBodyMeshMotion
wmake $targetType atmosphericModels
wmake $targetType optimisation/adjointOptimisation/adjoint
# Moved by HJ
wmake $targetType topoChangerFvMesh
# interfaceTracking libs
dynamicFaMesh/Allwmake $targetType $*

View File

@ -120,11 +120,8 @@ public:
// Static Member Functions
//- Return a null bitSet (reference to a nullObject).
static const bitSet& null() noexcept
{
return NullObjectRef<bitSet>();
}
//- Return a null bitSet reference
inline static const bitSet& null();
//- Declare type-name (with debug switch)

View File

@ -405,6 +405,12 @@ inline Foam::label Foam::bitSet::find_next(label pos) const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::bitSet& Foam::bitSet::null()
{
return NullObjectRef<bitSet>();
}
inline bool Foam::bitSet::all() const
{
if (empty()) return true; // SIC. boost convention

View File

@ -81,7 +81,7 @@ Foam::CompactListList<T> Foam::CompactListList<T>::pack_impl
if (len)
{
newOffsets.resize(len+1, Foam::zero{});
newOffsets.resize(len+1, Zero);
for (label i = 0; i < len; ++i)
{

View File

@ -138,11 +138,8 @@ public:
// Static Member Functions
//- Return a null CompactListList (reference to a nullObject).
static const CompactListList<T>& null() noexcept
{
return NullObjectRef<CompactListList<T>>();
}
//- Return a CompactListList reference to a nullObject
inline static const CompactListList<T>& null();
//- Construct by packing together the list of lists
template<class SubListType = List<T>>

View File

@ -29,6 +29,15 @@ License
#include "ListOps.H"
#include "SubList.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null()
{
return NullObjectRef<CompactListList<T>>();
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
@ -89,7 +98,7 @@ inline Foam::CompactListList<T>::CompactListList
const label nVals
)
:
offsets_(mRows+1, Foam::zero{}),
offsets_(mRows+1, Zero),
values_(nVals)
{
// Optionally: enforceSizeSanity();
@ -104,8 +113,8 @@ inline Foam::CompactListList<T>::CompactListList
const Foam::zero
)
:
offsets_(mRows+1, Foam::zero{}),
values_(nVals, Foam::zero{})
offsets_(mRows+1, Zero),
values_(nVals, Zero)
{
// Optionally: enforceSizeSanity();
}
@ -119,7 +128,7 @@ inline Foam::CompactListList<T>::CompactListList
const T& val
)
:
offsets_(mRows+1, Foam::zero{}),
offsets_(mRows+1, Zero),
values_(nVals, val)
{
// Optionally: enforceSizeSanity();
@ -378,7 +387,7 @@ inline void Foam::CompactListList<T>::resize
}
else
{
offsets_.resize(mRows+1, Foam::zero{});
offsets_.resize(mRows+1, Zero);
values_.resize(nVals);
}
}
@ -399,7 +408,7 @@ inline void Foam::CompactListList<T>::resize_nocopy
}
else
{
offsets_.resize(mRows+1, Foam::zero{});
offsets_.resize(mRows+1, Zero);
values_.resize_nocopy(nVals);
}
}
@ -421,7 +430,7 @@ inline void Foam::CompactListList<T>::resize
}
else
{
offsets_.resize(mRows+1, Foam::zero{});
offsets_.resize(mRows+1, Zero);
values_.resize(nVals, val);
}
}

View File

@ -46,10 +46,9 @@ SourceFiles
#include "zero.H"
#include "contiguous.H"
#include "stdFoam.H"
#include "nullObject.H"
#include "autoPtr.H"
#include "Hash.H"
#include "ListPolicy.H"
#include "autoPtr.H"
// <algorithm> already included by stdFoam.H
#include <iterator>
@ -140,12 +139,8 @@ public:
// Static Functions
//- Return a null FixedList (reference to a nullObject).
//- Read/write access is questionable
static const FixedList<T, N>& null() noexcept
{
return NullObjectRef<FixedList<T, N>>();
}
//- Return a null FixedList
inline static const FixedList<T, N>& null();
// Constructors

View File

@ -28,6 +28,15 @@ License
#include "UList.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T, unsigned N>
inline const Foam::FixedList<T, N>& Foam::FixedList<T, N>::null()
{
return NullObjectRef<FixedList<T, N>>();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T, unsigned N>

View File

@ -129,12 +129,8 @@ public:
// Static Member Functions
//- Return a null List (reference to a nullObject).
//- Behaves like an empty List.
static const List<T>& null() noexcept
{
return NullObjectRef<List<T>>();
}
//- Return a null List
inline static const List<T>& null();
// Constructors

View File

@ -133,6 +133,13 @@ inline Foam::autoPtr<Foam::List<T>> Foam::List<T>::clone() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const Foam::List<T>& Foam::List<T>::null()
{
return NullObjectRef<List<T>>();
}
template<class T>
inline void Foam::List<T>::clear()
{

View File

@ -73,12 +73,8 @@ public:
// Static Functions
//- Return a null SubList (reference to a nullObject).
//- Behaves like an empty SubList.
static const SubList<T>& null() noexcept
{
return NullObjectRef<SubList<T>>();
}
//- Return a null SubList
inline static const SubList<T>& null();
// Generated Methods

View File

@ -28,6 +28,15 @@ License
#include "FixedList.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class T>
inline const Foam::SubList<T>& Foam::SubList<T>::null()
{
return NullObjectRef<SubList<T>>();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
@ -115,7 +124,7 @@ inline Foam::SubList<T>::SubList
template<class T>
inline Foam::UList<T>& Foam::SubList<T>::reset(std::nullptr_t) noexcept
{
UList<T>::shallowCopy(nullptr);
UList<T>::shallowCopy(nullptr, 0);
return *this;
}

View File

@ -183,12 +183,8 @@ public:
// Static Functions
//- Return a null UList (reference to a nullObject).
//- Behaves like an empty UList.
static const UList<T>& null() noexcept
{
return NullObjectRef<UList<T>>();
}
//- Return a UList reference to a nullObject
inline static const UList<T>& null();
// Public Classes
@ -371,9 +367,6 @@ public:
//- Copy the pointer and size
inline void shallowCopy(T* __restrict__ ptr, const label len) noexcept;
//- Copy nullptr and zero size
inline void shallowCopy(std::nullptr_t) noexcept;
//- Copy the pointer and size held by the given UList
inline void shallowCopy(const UList<T>& list) noexcept;

View File

@ -93,6 +93,13 @@ inline void Foam::UList<T>::fill_uniform(const Foam::zero)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const Foam::UList<T>& Foam::UList<T>::null()
{
return NullObjectRef<UList<T>>();
}
template<class T>
inline Foam::label Foam::UList<T>::fcIndex(const label i) const noexcept
{
@ -323,14 +330,6 @@ inline void Foam::UList<T>::shallowCopy
}
template<class T>
inline void Foam::UList<T>::shallowCopy(std::nullptr_t) noexcept
{
size_ = 0;
v_ = nullptr;
}
template<class T>
inline void Foam::UList<T>::shallowCopy(const UList<T>& list) noexcept
{

View File

@ -116,7 +116,7 @@ Foam::labelListList Foam::invertOneToMany
const labelUList& map
)
{
labelList sizes(len, Foam::zero{});
labelList sizes(len, Zero);
for (const label newIdx : map)
{

View File

@ -707,7 +707,7 @@ void Foam::invertManyToMany
)
{
// The output list sizes
labelList sizes(len, Foam::zero{});
labelList sizes(len, Zero);
for (const InputIntListType& sublist : input)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,33 +71,6 @@ public:
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Receive and deserialize a value.
//- Uses \c operator>> for de-serialization
template<class Type>
static void recv
(
Type& value,
const int fromProcNo,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
IPstream is
(
UPstream::commsTypes::scheduled,
fromProcNo,
0, // bufSize
tag,
comm,
fmt
);
is >> value;
}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,73 +71,6 @@ public:
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Serialize a value and send (buffered/blocking or standard mode).
//- Uses \c operator<< for serialization
template<class Type>
static void send
(
const Type& value,
//! blocking or scheduled only!
const UPstream::commsTypes commsType,
const int toProcNo,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
OPstream os(commsType, toProcNo, 0, tag, comm, fmt);
os << value;
}
//- Serialize a value and send (buffered/blocking mode).
//- Uses \c operator<< for serialization
template<class Type>
static void bsend
(
const Type& value,
const int toProcNo,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
OPstream::send
(
value,
UPstream::commsTypes::blocking,
toProcNo,
tag,
comm,
fmt
);
}
//- Serialize a value and send (standard mode).
//- Uses \c operator<< for serialization
template<class Type>
static void send
(
const Type& value,
const int toProcNo,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
OPstream::send
(
value,
UPstream::commsTypes::scheduled,
toProcNo,
tag,
comm,
fmt
);
}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -47,6 +47,9 @@ SourceFiles
#include "UPstream.H"
#include "DynamicList.H"
// Legacy
// #define Foam_Pstream_scatter_nobroadcast
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
@ -127,9 +130,22 @@ public:
// Gather
//- Gather (reduce) data, appyling \c bop to combine \c value
//- from different processors. The basis for Foam::reduce().
// Uses the specified communication schedule.
template<class T, class BinaryOp>
static void gather
(
const List<commsStruct>& comms,
T& value,
const BinaryOp& bop,
const int tag,
const label comm
);
//- Gather (reduce) data, applying \c bop to combine \c value
//- from different processors. The basis for Foam::reduce().
// Uses linear/tree communication (with parallel guard).
// Uses linear/tree communication.
template<class T, class BinaryOp>
static void gather
(
@ -139,46 +155,46 @@ public:
const label comm = UPstream::worldComm
);
//- Gather individual values into list locations.
// On master list length == nProcs, otherwise zero length.
// \n
// For \b non-parallel :
// the returned list length is 1 with localValue.
template<class T>
static List<T> listGatherValues
(
const T& localValue,
const label comm = UPstream::worldComm,
//! Only used for non-contiguous types
const int tag = UPstream::msgType()
);
//- Scatter individual values from list locations.
// On master input list length == nProcs, ignored on other procs.
// \n
// For \b non-parallel :
// returns the first list element (or default initialized).
template<class T>
static T listScatterValues
(
const UList<T>& allValues,
const label comm = UPstream::worldComm,
//! Only used for non-contiguous types
const int tag = UPstream::msgType()
);
// Gather/combine data
// Inplace combine values from processors.
// (Uses construct from Istream instead of \c << operator)
// (Uses construct from Istream instead of <<)
//- Gather data, applying \c cop to inplace combine \c value
//- from different processors.
// Uses linear/tree communication (with parallel guard).
// Uses the specified communication schedule.
template<class T, class CombineOp>
static void combineGather
(
//! [in,out]
const List<commsStruct>& comms,
T& value,
const CombineOp& cop,
const int tag,
const label comm
);
//- Gather data, applying \c cop to inplace combine \c value
//- from different processors.
// Uses linear/tree communication.
template<class T, class CombineOp>
static void combineGather
(
T& value,
const CombineOp& cop,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Reduce inplace (cf. MPI Allreduce)
//- applying \c cop to inplace combine \c value
//- from different processors.
//- After completion all processors have the same data.
// Uses the specified communication schedule.
// Wraps combineGather/broadcast (may change in the future).
template<class T, class CombineOp>
static void combineReduce
(
const List<commsStruct>& comms,
T& value,
const CombineOp& cop,
const int tag = UPstream::msgType(),
@ -194,7 +210,6 @@ public:
template<class T, class CombineOp>
static void combineReduce
(
//! [in,out]
T& value,
const CombineOp& cop,
const int tag = UPstream::msgType(),
@ -217,25 +232,30 @@ public:
// Combine variants working on whole List at a time.
//- Combines List elements.
// Uses linear/tree communication (with parallel guard).
template<class T, class CombineOp>
static void listCombineGather
(
//! [in,out]
UList<T>& values,
const List<commsStruct>& comms,
List<T>& values,
const CombineOp& cop,
const int tag,
const label comm
);
//- Like above but switches between linear/tree communication
template<class T, class CombineOp>
static void listCombineGather
(
List<T>& values,
const CombineOp& cop,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Combines List elements.
//- After completion all processors have the same data.
// Uses linear/tree communication (with parallel guard).
template<class T, class CombineOp>
static void listCombineReduce
(
//! [in,out] - List (not UList) due to broadcast()
List<T>& values,
const CombineOp& cop,
const int tag = UPstream::msgType(),
@ -246,7 +266,6 @@ public:
template<class T, class CombineOp>
static void listCombineAllGather
(
//! [in,out] - List (not UList) due to broadcast()
List<T>& values,
const CombineOp& cop,
const int tag = UPstream::msgType(),
@ -260,8 +279,17 @@ public:
// Combine variants working on whole map at a time.
// Container needs iterators, find() and insert methods defined.
//- Combine Map elements.
// Uses linear/tree communication (with parallel guard).
template<class Container, class CombineOp>
static void mapCombineGather
(
const List<commsStruct>& comms,
Container& values,
const CombineOp& cop,
const int tag,
const label comm
);
//- Like above but switches between linear/tree communication
template<class Container, class CombineOp>
static void mapCombineGather
(
@ -310,9 +338,8 @@ public:
template<class T>
static void gatherList
(
const UList<commsStruct>& comms,
//! [in,out]
UList<T>& values,
const List<commsStruct>& comms,
List<T>& values,
const int tag,
const label comm
);
@ -322,48 +349,133 @@ public:
template<class T>
static void gatherList
(
//! [in,out]
UList<T>& values,
List<T>& values,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Gather data, but keep individual values separate.
//- Uses MPI_Allgather or manual linear/tree communication.
//- Uses linear/tree communication.
// After completion all processors have the same data.
// Wraps gatherList/scatterList (may change in the future).
template<class T>
static void allGatherList
(
//! [in,out]
UList<T>& values,
List<T>& values,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
// Scatter
// Scatter
//- Inverse of gatherList.
//- Uses the specified communication schedule.
template<class T>
static void scatterList
(
const UList<commsStruct>& comms,
UList<T>& values,
const int tag,
const label comm
);
//- Broadcast data: Distribute without modification.
// \note comms and tag parameters only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void scatter
(
const List<commsStruct>& comms,
T& value,
const int tag,
const label comm
);
//- Inverse of gatherList.
//- Uses linear/tree communication.
template<class T>
static void scatterList
(
UList<T>& values,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Broadcast data: Distribute without modification.
// \note tag parameter only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void scatter
(
T& value,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Broadcast data: Distribute without modification.
// \note tag parameter only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void combineScatter
(
const List<commsStruct>& comms,
T& value,
const int tag,
const label comm
);
//- Broadcast data: Distribute without modification.
// \note tag parameter only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void combineScatter
(
T& value,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Broadcast data: Distribute without modification.
// \note comms and tag parameters only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void listCombineScatter
(
const List<commsStruct>& comms,
List<T>& value,
const int tag,
const label comm
);
//- Broadcast data: Distribute without modification.
// \note comms and tag parameters only used when
// Foam_Pstream_scatter_nobroadcast is defined
template<class T>
static void listCombineScatter
(
List<T>& value,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Broadcast data: Distribute without modification.
template<class Container>
static void mapCombineScatter
(
const List<commsStruct>& comms,
Container& values,
const int tag,
const label comm
);
//- Like above but switches between linear/tree communication
template<class Container>
static void mapCombineScatter
(
Container& values,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
//- Scatter data. Reverse of gatherList
template<class T>
static void scatterList
(
const List<commsStruct>& comms,
List<T>& values,
const int tag,
const label comm
);
//- Like above but switches between linear/tree communication
template<class T>
static void scatterList
(
List<T>& values,
const int tag = UPstream::msgType(),
const label comm = UPstream::worldComm
);
// Exchange
@ -542,61 +654,6 @@ public:
const label comm,
const bool wait = true //!< (ignored)
);
// Housekeeping
//- \deprecated(2024-01) Broadcast data
template<class T>
FOAM_DEPRECATED_FOR(2024-01, "Pstream::broadcast()")
static void scatter
(
T& value,
const int tag = UPstream::msgType(), //!< ignored
const label comm = UPstream::worldComm
)
{
Pstream::broadcast(value, comm);
}
//- \deprecated(2024-01) Broadcast data
template<class T>
FOAM_DEPRECATED_FOR(2024-01, "Pstream::broadcast()")
static void combineScatter
(
T& value,
const int tag = UPstream::msgType(), //!< ignored
const label comm = UPstream::worldComm
)
{
Pstream::broadcast(value, comm);
}
//- \deprecated(2024-01) Broadcast data
template<class T>
FOAM_DEPRECATED_FOR(2024-01, "Pstream::broadcast()")
static void listCombineScatter
(
List<T>& value,
const int tag = UPstream::msgType(), //!< ignored
const label comm = UPstream::worldComm
)
{
Pstream::broadcast(value, comm);
}
//- \deprecated(2024-01) Broadcast data
template<class Container>
FOAM_DEPRECATED_FOR(2024-01, "Pstream::broadcast()")
static void mapCombineScatter
(
Container& values,
const int tag = UPstream::msgType(), //!< ignored
const label comm = UPstream::worldComm
)
{
Pstream::broadcast(values, comm);
}
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -137,32 +137,4 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convenience wrappers - defined after all specialisations are known
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Return a broadcasted value (uses a copy internally)
template<class Type>
Type returnBroadcast
(
const Type& value,
const label comm = UPstream::worldComm
)
{
Type work(value);
Pstream::broadcast(work, comm);
return work;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,7 +25,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Variant of gather.
Variant of gather, scatter.
Normal gather uses:
- default construct and read (>>) from Istream
- binary operator and assignment operator to combine values
@ -46,6 +46,7 @@ Description
template<class T, class CombineOp>
void Foam::Pstream::combineGather
(
const List<UPstream::commsStruct>& comms,
T& value,
const CombineOp& cop,
const int tag,
@ -54,10 +55,8 @@ void Foam::Pstream::combineGather
{
if (UPstream::is_parallel(comm))
{
// Communication order
const auto& comms = UPstream::whichCommunication(comm);
// if (comms.empty()) return; // extra safety?
const auto& myComm = comms[UPstream::myProcNo(comm)];
// My communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from my downstairs neighbours
for (const label belowID : myComm.below())
@ -90,7 +89,7 @@ void Foam::Pstream::combineGather
(
UPstream::commsTypes::scheduled,
belowID,
0, // bufsize
0,
tag,
comm
);
@ -107,7 +106,7 @@ void Foam::Pstream::combineGather
}
// Send up value
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
if (debug & 2)
{
@ -133,7 +132,7 @@ void Foam::Pstream::combineGather
(
UPstream::commsTypes::scheduled,
myComm.above(),
0, // bufsize
0,
tag,
comm
);
@ -144,6 +143,144 @@ void Foam::Pstream::combineGather
}
template<class T>
void Foam::Pstream::combineScatter
(
const List<UPstream::commsStruct>& comms,
T& value,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(value, comm);
#else
if (UPstream::is_parallel(comm))
{
// My communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from up
if (myComm.above() != -1)
{
if (is_contiguous<T>::value)
{
UIPstream::read
(
UPstream::commsTypes::scheduled,
myComm.above(),
reinterpret_cast<char*>(&value),
sizeof(T),
tag,
comm
);
}
else
{
IPstream fromAbove
(
UPstream::commsTypes::scheduled,
myComm.above(),
0,
tag,
comm
);
value = T(fromAbove);
}
}
// Send to my downstairs neighbours
forAllReverse(myComm.below(), belowI)
{
const label belowID = myComm.below()[belowI];
if (is_contiguous<T>::value)
{
UOPstream::write
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(&value),
sizeof(T),
tag,
comm
);
}
else
{
OPstream toBelow
(
UPstream::commsTypes::scheduled,
belowID,
0,
tag,
comm
);
toBelow << value;
}
}
}
#endif
}
template<class T, class CombineOp>
void Foam::Pstream::combineGather
(
T& value,
const CombineOp& cop,
const int tag,
const label comm
)
{
Pstream::combineGather
(
UPstream::whichCommunication(comm),
value,
cop,
tag,
comm
);
}
template<class T>
void Foam::Pstream::combineScatter
(
T& value,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(value, comm);
#else
Pstream::combineScatter
(
UPstream::whichCommunication(comm),
value,
tag,
comm
);
#endif
}
template<class T, class CombineOp>
void Foam::Pstream::combineReduce
(
const List<UPstream::commsStruct>& comms,
T& value,
const CombineOp& cop,
const int tag,
const label comm
)
{
Pstream::combineGather(comms, value, cop, tag, comm);
Pstream::broadcast(value, comm);
}
template<class T, class CombineOp>
void Foam::Pstream::combineReduce
(
@ -155,7 +292,9 @@ void Foam::Pstream::combineReduce
{
if (UPstream::is_parallel(comm))
{
Pstream::combineGather(value, cop, tag, comm);
const auto& comms = UPstream::whichCommunication(comm);
Pstream::combineGather(comms, value, cop, tag, comm);
Pstream::broadcast(value, comm);
}
}
@ -166,7 +305,8 @@ void Foam::Pstream::combineReduce
template<class T, class CombineOp>
void Foam::Pstream::listCombineGather
(
UList<T>& values,
const List<UPstream::commsStruct>& comms,
List<T>& values,
const CombineOp& cop,
const int tag,
const label comm
@ -174,10 +314,8 @@ void Foam::Pstream::listCombineGather
{
if (UPstream::is_parallel(comm))
{
// Communication order
const auto& comms = UPstream::whichCommunication(comm);
// if (comms.empty()) return; // extra safety?
const auto& myComm = comms[UPstream::myProcNo(comm)];
// My communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from my downstairs neighbours
for (const label belowID : myComm.below())
@ -213,7 +351,7 @@ void Foam::Pstream::listCombineGather
(
UPstream::commsTypes::scheduled,
belowID,
0, // bufsize
0,
tag,
comm
);
@ -233,7 +371,7 @@ void Foam::Pstream::listCombineGather
}
// Send up values
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
if (debug & 2)
{
@ -259,7 +397,7 @@ void Foam::Pstream::listCombineGather
(
UPstream::commsTypes::scheduled,
myComm.above(),
0, // bufsize
0,
tag,
comm
);
@ -270,6 +408,129 @@ void Foam::Pstream::listCombineGather
}
template<class T>
void Foam::Pstream::listCombineScatter
(
const List<UPstream::commsStruct>& comms,
List<T>& values,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(values, comm);
#else
if (UPstream::is_parallel(comm))
{
// My communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from up
if (myComm.above() != -1)
{
if (is_contiguous<T>::value)
{
UIPstream::read
(
UPstream::commsTypes::scheduled,
myComm.above(),
values.data_bytes(),
values.size_bytes(),
tag,
comm
);
}
else
{
IPstream fromAbove
(
UPstream::commsTypes::scheduled,
myComm.above(),
0,
tag,
comm
);
fromAbove >> values;
}
}
// Send to my downstairs neighbours
forAllReverse(myComm.below(), belowI)
{
const label belowID = myComm.below()[belowI];
if (is_contiguous<T>::value)
{
UOPstream::write
(
UPstream::commsTypes::scheduled,
belowID,
values.cdata_bytes(),
values.size_bytes(),
tag,
comm
);
}
else
{
OPstream toBelow
(
UPstream::commsTypes::scheduled,
belowID,
0,
tag,
comm
);
toBelow << values;
}
}
}
#endif
}
template<class T, class CombineOp>
void Foam::Pstream::listCombineGather
(
List<T>& values,
const CombineOp& cop,
const int tag,
const label comm
)
{
Pstream::listCombineGather
(
UPstream::whichCommunication(comm),
values,
cop,
tag,
comm
);
}
template<class T>
void Foam::Pstream::listCombineScatter
(
List<T>& values,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(values, comm);
#else
Pstream::listCombineScatter
(
UPstream::whichCommunication(comm),
values,
tag,
comm
);
#endif
}
template<class T, class CombineOp>
void Foam::Pstream::listCombineReduce
(
@ -281,7 +542,9 @@ void Foam::Pstream::listCombineReduce
{
if (UPstream::is_parallel(comm))
{
Pstream::listCombineGather(values, cop, tag, comm);
const auto& comms = UPstream::whichCommunication(comm);
Pstream::listCombineGather(comms, values, cop, tag, comm);
Pstream::broadcast(values, comm);
}
}
@ -292,6 +555,7 @@ void Foam::Pstream::listCombineReduce
template<class Container, class CombineOp>
void Foam::Pstream::mapCombineGather
(
const List<UPstream::commsStruct>& comms,
Container& values,
const CombineOp& cop,
const int tag,
@ -300,10 +564,8 @@ void Foam::Pstream::mapCombineGather
{
if (UPstream::is_parallel(comm))
{
// Communication order
const auto& comms = UPstream::whichCommunication(comm);
// if (comms.empty()) return; // extra safety?
const auto& myComm = comms[UPstream::myProcNo(comm)];
// My communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from my downstairs neighbours
for (const label belowID : myComm.below())
@ -314,7 +576,7 @@ void Foam::Pstream::mapCombineGather
(
UPstream::commsTypes::scheduled,
belowID,
0, // bufsize
0,
tag,
comm
);
@ -349,7 +611,7 @@ void Foam::Pstream::mapCombineGather
}
// Send up values
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
if (debug & 2)
{
@ -361,7 +623,7 @@ void Foam::Pstream::mapCombineGather
(
UPstream::commsTypes::scheduled,
myComm.above(),
0, // bufsize
0,
tag,
comm
);
@ -371,6 +633,110 @@ void Foam::Pstream::mapCombineGather
}
template<class Container>
void Foam::Pstream::mapCombineScatter
(
const List<UPstream::commsStruct>& comms,
Container& values,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(values, comm);
#else
if (UPstream::is_parallel(comm))
{
// My communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from up
if (myComm.above() != -1)
{
IPstream fromAbove
(
UPstream::commsTypes::scheduled,
myComm.above(),
0,
tag,
comm
);
fromAbove >> values;
if (debug & 2)
{
Pout<< " received from "
<< myComm.above() << " data:" << values << endl;
}
}
// Send to my downstairs neighbours
forAllReverse(myComm.below(), belowI)
{
const label belowID = myComm.below()[belowI];
if (debug & 2)
{
Pout<< " sending to " << belowID << " data:" << values << endl;
}
OPstream toBelow
(
UPstream::commsTypes::scheduled,
belowID,
0,
tag,
comm
);
toBelow << values;
}
}
#endif
}
template<class Container, class CombineOp>
void Foam::Pstream::mapCombineGather
(
Container& values,
const CombineOp& cop,
const int tag,
const label comm
)
{
Pstream::mapCombineGather
(
UPstream::whichCommunication(comm),
values,
cop,
tag,
comm
);
}
template<class Container>
void Foam::Pstream::mapCombineScatter
(
Container& values,
const int tag,
const label comm
)
{
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(values, comm);
#else
Pstream::mapCombineScatter
(
UPstream::whichCommunication(comm),
values,
tag,
comm
);
#endif
}
template<class Container, class CombineOp>
void Foam::Pstream::mapCombineReduce
(
@ -382,7 +748,9 @@ void Foam::Pstream::mapCombineReduce
{
if (UPstream::is_parallel(comm))
{
Pstream::mapCombineGather(values, cop, tag, comm);
const auto& comms = UPstream::whichCommunication(comm);
Pstream::mapCombineGather(comms, values, cop, tag, comm);
Pstream::broadcast(values, comm);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,7 @@ License
Description
Gather data from all processors onto single processor according to some
communication schedule (usually tree-to-master).
communication schedule (usually linear-to-master or tree-to-master).
The gathered data will be a single value constructed from the values
on individual processors using a user-specified operator.
@ -41,6 +41,7 @@ Description
template<class T, class BinaryOp>
void Foam::Pstream::gather
(
const List<UPstream::commsStruct>& comms,
T& value,
const BinaryOp& bop,
const int tag,
@ -49,10 +50,8 @@ void Foam::Pstream::gather
{
if (UPstream::is_parallel(comm))
{
// Communication order
const auto& comms = UPstream::whichCommunication(comm);
// if (comms.empty()) return; // extra safety?
const auto& myComm = comms[UPstream::myProcNo(comm)];
// My communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from my downstairs neighbours
for (const label belowID : myComm.below())
@ -77,7 +76,7 @@ void Foam::Pstream::gather
(
UPstream::commsTypes::scheduled,
belowID,
0, // bufsize
0,
tag,
comm
);
@ -88,7 +87,7 @@ void Foam::Pstream::gather
}
// Send up value
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
if (is_contiguous<T>::value)
{
@ -108,7 +107,7 @@ void Foam::Pstream::gather
(
UPstream::commsTypes::scheduled,
myComm.above(),
0, // bufsize
0,
tag,
comm
);
@ -120,181 +119,110 @@ void Foam::Pstream::gather
template<class T>
Foam::List<T> Foam::Pstream::listGatherValues
void Foam::Pstream::scatter
(
const T& localValue,
const label comm,
const int tag
const List<UPstream::commsStruct>& comms,
T& value,
const int tag,
const label comm
)
{
// OR
// if (is_contiguous<T>::value)
// {
// return UPstream::listGatherValues(localValue, comm);
// }
List<T> allValues;
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(value, comm);
#else
if (UPstream::is_parallel(comm))
{
const label numProc = UPstream::nProcs(comm);
// My communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
if (UPstream::master(comm))
// Receive from up
if (myComm.above() != -1)
{
allValues.resize(numProc);
}
if (is_contiguous<T>::value)
{
UPstream::mpiGather
(
reinterpret_cast<const char*>(&localValue),
allValues.data_bytes(),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
if (UPstream::master(comm))
if (is_contiguous<T>::value)
{
// Non-trivial to manage non-blocking gather without a
// PEX/NBX approach (eg, PstreamBuffers) but leave with
// with simple exchange for now
allValues[0] = localValue;
for (int proci = 1; proci < numProc; ++proci)
{
IPstream fromProc
(
UPstream::commsTypes::scheduled,
proci,
0, // bufsize
tag,
comm
);
fromProc >> allValues[proci];
}
}
else if (UPstream::is_rank(comm))
{
OPstream toProc
UIPstream::read
(
UPstream::commsTypes::scheduled,
UPstream::masterNo(),
0, // bufsize
myComm.above(),
reinterpret_cast<char*>(&value),
sizeof(T),
tag,
comm
);
toProc << localValue;
}
else
{
IPstream fromAbove
(
UPstream::commsTypes::scheduled,
myComm.above(),
0,
tag,
comm
);
fromAbove >> value;
}
}
// Send to my downstairs neighbours. Note reverse order (compared to
// receiving). This is to make sure to send to the critical path
// (only when using a tree schedule!) first.
forAllReverse(myComm.below(), belowI)
{
const label belowID = myComm.below()[belowI];
if (is_contiguous<T>::value)
{
UOPstream::write
(
UPstream::commsTypes::scheduled,
belowID,
reinterpret_cast<const char*>(&value),
sizeof(T),
tag,
comm
);
}
else
{
OPstream toBelow
(
UPstream::commsTypes::scheduled,
belowID,
0,
tag,
comm
);
toBelow << value;
}
}
}
else
{
// non-parallel: return own value
// TBD: only when UPstream::is_rank(comm) as well?
allValues.resize(1);
allValues[0] = localValue;
}
#endif
}
return allValues;
template<class T, class BinaryOp>
void Foam::Pstream::gather
(
T& value,
const BinaryOp& bop,
const int tag,
const label comm
)
{
Pstream::gather(UPstream::whichCommunication(comm), value, bop, tag, comm);
}
template<class T>
T Foam::Pstream::listScatterValues
(
const UList<T>& allValues,
const label comm,
const int tag
)
void Foam::Pstream::scatter(T& value, const int tag, const label comm)
{
// OR
// if (is_contiguous<T>::value)
// {
// return UPstream::listScatterValues(allValues, comm);
// }
T localValue{};
if (UPstream::is_parallel(comm))
{
const label numProc = UPstream::nProcs(comm);
if (UPstream::master(comm) && allValues.size() < numProc)
{
FatalErrorInFunction
<< "Attempting to send " << allValues.size()
<< " values to " << numProc << " processors" << endl
<< Foam::abort(FatalError);
}
if (is_contiguous<T>::value)
{
UPstream::mpiScatter
(
allValues.cdata_bytes(),
reinterpret_cast<char*>(&localValue),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
if (UPstream::master(comm))
{
const label startOfRequests = UPstream::nRequests();
List<DynamicList<char>> sendBuffers(numProc);
for (int proci = 1; proci < numProc; ++proci)
{
UOPstream toProc
(
UPstream::commsTypes::nonBlocking,
proci,
sendBuffers[proci],
tag,
comm
);
toProc << allValues[proci];
}
// Wait for outstanding requests
UPstream::waitRequests(startOfRequests);
return allValues[0];
}
else if (UPstream::is_rank(comm))
{
IPstream fromProc
(
UPstream::commsTypes::scheduled,
UPstream::masterNo(),
0, // bufsize
tag,
comm
);
fromProc >> localValue;
}
}
}
else
{
// non-parallel: return first value
// TBD: only when UPstream::is_rank(comm) as well?
if (!allValues.empty())
{
return allValues[0];
}
}
return localValue;
#ifndef Foam_Pstream_scatter_nobroadcast
Pstream::broadcast(value, comm);
#else
Pstream::scatter(UPstream::whichCommunication(comm), value, tag, comm);
#endif
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,7 @@ License
Description
Gather data from all processors onto single processor according to some
communication schedule (usually tree-to-master).
communication schedule (usually linear-to-master or tree-to-master).
The gathered data will be a list with element procID the data from processor
procID. Before calling every processor should insert its value into
values[UPstream::myProcNo(comm)].
@ -45,27 +45,24 @@ Description
template<class T>
void Foam::Pstream::gatherList
(
const UList<UPstream::commsStruct>& comms,
UList<T>& values,
const List<UPstream::commsStruct>& comms,
List<T>& values,
const int tag,
const label comm
)
{
if (!comms.empty() && UPstream::is_parallel(comm))
if (UPstream::is_parallel(comm))
{
const label myProci = UPstream::myProcNo(comm);
const label numProc = UPstream::nProcs(comm);
if (values.size() < numProc)
if (values.size() < UPstream::nProcs(comm))
{
FatalErrorInFunction
<< "List of values:" << values.size()
<< " < numProcs:" << numProc << nl
<< "List of values is too small:" << values.size()
<< " vs numProcs:" << UPstream::nProcs(comm) << nl
<< Foam::abort(FatalError);
}
// My communication order
const auto& myComm = comms[myProci];
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from my downstairs neighbours
for (const label belowID : myComm.below())
@ -130,21 +127,21 @@ void Foam::Pstream::gatherList
// Send up from values:
// - my own value first
// - all belowLeaves next
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
const labelList& belowLeaves = myComm.allBelow();
if (debug & 2)
{
Pout<< " sending to " << myComm.above()
<< " data from me:" << myProci
<< " data:" << values[myProci] << endl;
<< " data from me:" << UPstream::myProcNo(comm)
<< " data:" << values[UPstream::myProcNo(comm)] << endl;
}
if (is_contiguous<T>::value)
{
List<T> sending(belowLeaves.size() + 1);
sending[0] = values[myProci];
sending[0] = values[UPstream::myProcNo(comm)];
forAll(belowLeaves, leafI)
{
@ -171,7 +168,7 @@ void Foam::Pstream::gatherList
tag,
comm
);
toAbove << values[myProci];
toAbove << values[UPstream::myProcNo(comm)];
for (const label leafID : belowLeaves)
{
@ -192,8 +189,8 @@ void Foam::Pstream::gatherList
template<class T>
void Foam::Pstream::scatterList
(
const UList<UPstream::commsStruct>& comms,
UList<T>& values,
const List<UPstream::commsStruct>& comms,
List<T>& values,
const int tag,
const label comm
)
@ -202,24 +199,21 @@ void Foam::Pstream::scatterList
// between scatterList() and using broadcast(List<T>&) or a regular
// scatter(List<T>&) is that processor-local data is skipped.
if (!comms.empty() && UPstream::is_parallel(comm))
if (UPstream::is_parallel(comm))
{
const label myProci = UPstream::myProcNo(comm);
const label numProc = UPstream::nProcs(comm);
if (values.size() < numProc)
if (values.size() < UPstream::nProcs(comm))
{
FatalErrorInFunction
<< "List of values:" << values.size()
<< " < numProcs:" << numProc << nl
<< "List of values is too small:" << values.size()
<< " vs numProcs:" << UPstream::nProcs(comm) << nl
<< Foam::abort(FatalError);
}
// My communication order
const auto& myComm = comms[myProci];
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
// Receive from up
if (myComm.above() >= 0)
if (myComm.above() != -1)
{
const labelList& notBelowLeaves = myComm.allNotBelow();
@ -324,18 +318,12 @@ void Foam::Pstream::scatterList
template<class T>
void Foam::Pstream::gatherList
(
UList<T>& values,
List<T>& values,
const int tag,
const label comm
)
{
Pstream::gatherList
(
UPstream::whichCommunication(comm),
values,
tag,
comm
);
Pstream::gatherList(UPstream::whichCommunication(comm), values, tag, comm);
}
@ -343,25 +331,19 @@ void Foam::Pstream::gatherList
template<class T>
void Foam::Pstream::scatterList
(
UList<T>& values,
List<T>& values,
const int tag,
const label comm
)
{
Pstream::scatterList
(
UPstream::whichCommunication(comm),
values,
tag,
comm
);
Pstream::scatterList(UPstream::whichCommunication(comm), values, tag, comm);
}
template<class T>
void Foam::Pstream::allGatherList
(
UList<T>& values,
List<T>& values,
const int tag,
const label comm
)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -46,6 +46,28 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Reduce inplace (cf. MPI Allreduce)
//- using specified communication schedule.
template<class T, class BinaryOp>
void reduce
(
const List<UPstream::commsStruct>& comms,
T& value,
const BinaryOp& bop,
const int tag,
const label comm
)
{
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** reducing:" << value << " with comm:" << comm << endl;
error::printStack(Pout);
}
Pstream::gather(comms, value, bop, tag, comm);
Pstream::broadcast(value, comm);
}
//- Reduce inplace (cf. MPI Allreduce)
//- using linear/tree communication schedule
template<class T, class BinaryOp>
@ -59,13 +81,7 @@ void reduce
{
if (UPstream::is_parallel(comm))
{
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Pout<< "** reducing:" << value << " with comm:" << comm << endl;
error::printStack(Pout);
}
Pstream::gather(value, bop, tag, comm);
Pstream::broadcast(value, comm);
Foam::reduce(UPstream::whichCommunication(comm), value, bop, tag, comm);
}
}
@ -420,7 +436,8 @@ Pstream_SumReduce(double);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Convenience wrappers - defined after all specialisations are known
// Convenience wrappers for some reduction operations
// - defined after all specialisations are known
//- Perform reduction on a copy, using specified binary operation
// \return the resulting value

View File

@ -52,7 +52,6 @@ Foam::UPstream::commsTypeNames
({
{ commsTypes::blocking, "blocking" },
{ commsTypes::scheduled, "scheduled" },
// { commsTypes::nonBlocking, "non-blocking" },
{ commsTypes::nonBlocking, "nonBlocking" },
});

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -895,32 +895,21 @@ public:
);
//- Communication schedule for tree all-to-master (proc 0)
static const List<commsStruct>&
treeCommunication
static const List<commsStruct>& treeCommunication
(
const label communicator = worldComm
);
//- Communication schedule for all-to-master (proc 0) as
//- linear/tree/none with switching based on UPstream::nProcsSimpleSum
//- and the is_parallel() state
//- Communication schedule for linear/tree all-to-master (proc 0).
//- Chooses based on the value of UPstream::nProcsSimpleSum
static const List<commsStruct>& whichCommunication
(
const label communicator = worldComm
)
{
const label np
(
parRun_ && is_rank(communicator) // cf. is_parallel()
? nProcs(communicator)
: 0
);
return
(
np <= 1
? List<commsStruct>::null()
: np < nProcsSimpleSum
nProcs(communicator) < nProcsSimpleSum
? linearCommunication(communicator)
: treeCommunication(communicator)
);
@ -1149,7 +1138,7 @@ public:
// On master input list length == nProcs, ignored on other procs.
// \n
// For \b non-parallel :
// returns the first list element (or default initialized).
// returns the first list element (or zero).
template<class T>
static T listScatterValues
(
@ -1202,7 +1191,6 @@ public:
//- Process index of first sub-process
// \deprecated(2020-09) use subProcs() method instead
FOAM_DEPRECATED_FOR(2020-09, "subProcs() method")
static constexpr int firstSlave() noexcept
{
return 1;
@ -1210,7 +1198,6 @@ public:
//- Process index of last sub-process
// \deprecated(2020-09) use subProcs() method instead
FOAM_DEPRECATED_FOR(2020-09, "subProcs() or allProcs() method")
static int lastSlave(const label communicator = worldComm)
{
return nProcs(communicator) - 1;

View File

@ -34,6 +34,14 @@ Foam::List<T> Foam::UPstream::allGatherValues
const label comm
)
{
if (!is_contiguous<T>::value)
{
FatalErrorInFunction
<< "Cannot all-gather values for non-contiguous types" << endl
<< Foam::abort(FatalError);
}
List<T> allValues;
if (UPstream::is_parallel(comm))
@ -41,17 +49,7 @@ Foam::List<T> Foam::UPstream::allGatherValues
allValues.resize(UPstream::nProcs(comm));
allValues[UPstream::myProcNo(comm)] = localValue;
if (is_contiguous<T>::value)
{
UPstream::mpiAllGather(allValues.data_bytes(), sizeof(T), comm);
}
else
{
FatalErrorInFunction
<< "Cannot all-gather values for non-contiguous types"
" - consider Pstream variant instead" << endl
<< Foam::abort(FatalError);
}
UPstream::mpiAllGather(allValues.data_bytes(), sizeof(T), comm);
}
else
{
@ -72,6 +70,14 @@ Foam::List<T> Foam::UPstream::listGatherValues
const label comm
)
{
if (!is_contiguous<T>::value)
{
FatalErrorInFunction
<< "Cannot gather values for non-contiguous types" << endl
<< Foam::abort(FatalError);
}
List<T> allValues;
if (UPstream::is_parallel(comm))
@ -81,23 +87,13 @@ Foam::List<T> Foam::UPstream::listGatherValues
allValues.resize(UPstream::nProcs(comm));
}
if (is_contiguous<T>::value)
{
UPstream::mpiGather
(
reinterpret_cast<const char*>(&localValue),
allValues.data_bytes(),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
FatalErrorInFunction
<< "Cannot gather values for non-contiguous types"
" - consider Pstream variant instead" << endl
<< Foam::abort(FatalError);
}
UPstream::mpiGather
(
reinterpret_cast<const char*>(&localValue),
allValues.data_bytes(),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
@ -118,46 +114,47 @@ T Foam::UPstream::listScatterValues
const label comm
)
{
T localValue{};
if (!is_contiguous<T>::value)
{
FatalErrorInFunction
<< "Cannot scatter values for non-contiguous types" << endl
<< Foam::abort(FatalError);
}
T localValue;
if (UPstream::is_parallel(comm))
{
const label numProc = UPstream::nProcs(comm);
const label nproc = UPstream::nProcs(comm);
if (UPstream::master(comm) && allValues.size() < numProc)
if (UPstream::master(comm) && allValues.size() < nproc)
{
FatalErrorInFunction
<< "Attempting to send " << allValues.size()
<< " values to " << numProc << " processors" << endl
<< " values to " << nproc << " processors" << endl
<< Foam::abort(FatalError);
}
if (is_contiguous<T>::value)
{
UPstream::mpiScatter
(
allValues.cdata_bytes(),
reinterpret_cast<char*>(&localValue),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
FatalErrorInFunction
<< "Cannot scatter values for non-contiguous types"
" - consider Pstream variant instead" << endl
<< Foam::abort(FatalError);
}
UPstream::mpiScatter
(
allValues.cdata_bytes(),
reinterpret_cast<char*>(&localValue),
sizeof(T), // The send/recv size per rank
comm
);
}
else
{
// non-parallel: return first value
// TBD: only when UPstream::is_rank(comm) as well?
// non-parallel: return local value
if (!allValues.empty())
if (UPstream::is_rank(comm) && !allValues.empty())
{
return allValues[0];
localValue = allValues[0];
}
else
{
localValue = Zero;
}
}

View File

@ -59,10 +59,8 @@ class ISstream
{
// Private Data
//- The input stream path
fileName name_;
//- The input stream
std::istream& is_;
@ -131,8 +129,6 @@ public:
virtual const fileName& name() const override { return name_; }
//- The name of the input serial stream, for modification.
// Use with caution since some classes (eg, Fstream)
// also use this for filesystem information!
virtual fileName& name() { return name_; }

View File

@ -58,10 +58,8 @@ class OSstream
{
// Private Data
//- The output stream path
fileName name_;
//- The output stream
std::ostream& os_;
@ -121,11 +119,6 @@ public:
//- (eg, the name of the Fstream file name)
virtual const fileName& name() const override { return name_; }
//- The name of the output serial stream, for modification.
// Use with caution since some classes (eg, Fstream)
// also use this for filesystem information!
virtual fileName& name() { return name_; }
// STL stream

View File

@ -541,7 +541,7 @@ public:
// No character stripping
inline explicit token(tokenType typ, const std::string&, label line=0);
//- Move construct word/string token with the specified variant.
//- Copy construct word/string token with the specified variant.
// A invalid word/string variant type is silently treated as STRING.
// No character stripping
inline explicit token(tokenType typ, std::string&&, label line=0);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 Sergey Lesnik
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,7 +35,7 @@ namespace Foam
{
// Write tokens without keyword, suppress/ignore bad tokens.
// Mostly like primitiveEntry::write(os, true);
// Mostly like primitiveEntry::write(os, false);
static void writeTokens(Ostream& os, const tokenList& toks)
{
@ -56,11 +56,11 @@ static void writeTokens(Ostream& os, const tokenList& toks)
started = true;
}
// Token output via direct handling in Ostream(s),
// or normal '<<' output operator
// Output token with direct handling in Ostream(s),
// or use normal '<<' output operator
if (!os.write(tok))
{
os << tok;
os << tok;
}
if (tok.isCharData())
@ -73,10 +73,18 @@ static void writeTokens(Ostream& os, const tokenList& toks)
if (s.starts_with("//") && !s.ends_with('\n'))
{
os << '\n';
started = false; // Does not need further space separator
started = false; // already have newline as separator
}
}
}
// Always finish up with a newline?
// eg,
//
// if (started)
// {
// os << nl;
// }
}
} // End namespace Foam
@ -133,10 +141,7 @@ Foam::formattingEntry::formattingEntry
void Foam::formattingEntry::write(Ostream& os) const
{
if (active_)
{
writeTokens(os, *this);
}
writeTokens(os, *this);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2023 Sergey Lesnik
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,17 +51,12 @@ class formattingEntry
:
public primitiveEntry
{
// Private Data
//- The output visibility
bool active_ = true;
public:
// Static Member Functions
//- Generate an entry keyword: "__format-entry__NNN".
//- The generated names are unlikely to collide with user dictionaries
//- Generate a default entry keyword: "__format-entry__NNN"
// The generated names are unlikely to collide with user dictionaries
static keyType defaultName(label n)
{
return keyType
@ -104,12 +99,6 @@ public:
formattingEntry(defaultName(n), std::move(content))
{}
//- Construct with token data, using a generated keyword
formattingEntry(const label n, token&& tok, bool visible=true)
:
primitiveEntry(defaultName(n), std::move(tok)),
active_(visible)
{}
//- Clone the entry
virtual autoPtr<entry> clone(const dictionary&) const
@ -123,21 +112,6 @@ public:
// Member Functions
//- Set output visibility on/off.
// \return the previous value
bool active(bool on) noexcept
{
bool old(active_);
active_ = on;
return old;
}
//- Get the output visibility
bool active() const noexcept
{
return active_;
}
//- Write content without the keyword.
// Special properties:
// - ignores any bad tokens on output.

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2019 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -151,44 +151,6 @@ Foam::HashTable<Foam::wordHashSet> Foam::objectRegistry::classes() const
}
Foam::IOobject Foam::objectRegistry::newIOobject
(
const word& name,
IOobjectOption::readOption rOpt,
IOobjectOption::writeOption wOpt,
IOobjectOption::registerOption regOpt
) const
{
return IOobject
(
name,
time().timeName(), // instance
*this,
IOobjectOption(rOpt, wOpt, regOpt)
);
}
// FUTURE?
//
// Foam::IOobject Foam::objectRegistry::newIOobject_constant
// (
// const word& name,
// IOobjectOption::readOption rOpt,
// IOobjectOption::writeOption wOpt,
// IOobjectOption::registerOption regOpt
// ) const
// {
// return IOobject
// (
// name,
// time().constant(), // instance
// *this,
// IOobjectOption(rOpt, wOpt, regOpt)
// );
// }
Foam::label Foam::objectRegistry::count(const char* clsName) const
{
// No nullptr check - only called with string literals

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2019 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -239,23 +239,6 @@ public:
}
// Helper Functions
//- Create an IOobject at the current time instance (timeName).
// By default the object is NO_READ/NO_WRITE/NO_REGISTER
IOobject newIOobject
(
//! The object name
const word& name,
//! The read option (default: NO_READ)
IOobjectOption::readOption rOpt = IOobjectOption::NO_READ,
//! The write option (default: NO_WRITE)
IOobjectOption::writeOption wOpt = IOobjectOption::NO_WRITE,
//! The register option (default: NO_REGISTER)
IOobjectOption::registerOption regOpt = IOobjectOption::NO_REGISTER
) const;
// Summary of classes
//- A summary hash of classes used and their associated object names.

View File

@ -115,7 +115,7 @@ Type Foam::Function1Types::Function1Expression<Type>::integrate
) const
{
NotImplemented;
return Type();
return Zero;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020-2024 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,8 +65,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Foam_Function1Types_expression_H
#define Foam_Function1Types_expression_H
#ifndef Function1Types_expression_H
#define Function1Types_expression_H
#include "Function1.H"
#include "fieldExprDriver.H"
@ -124,10 +124,10 @@ public:
//- Copy construct
explicit Function1Expression(const Function1Expression<Type>& rhs);
//- Return a clone
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return Function1<Type>::Clone(*this);
return tmp<Function1<Type>>(new Function1Expression<Type>(*this));
}

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -163,7 +163,7 @@ operator_precedence()
svalue (lhs) ::= NUMBER (tok) . { lhs = (tok).scalarValue; } // scanToken
svalue (lhs) ::= ZERO . { lhs = Foam::zero{}; }
svalue (lhs) ::= ZERO . { lhs = Foam::Zero; }
svalue (lhs) ::= PI LPAREN RPAREN . { lhs = Foam::constant::mathematical::pi; }
svalue (lhs) ::= DEG_TO_RAD LPAREN RPAREN . { lhs = Foam::degToRad(); }
svalue (lhs) ::= RAD_TO_DEG LPAREN RPAREN . { lhs = Foam::radToDeg(); }

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -137,11 +137,8 @@ public:
// Static Member Functions
//- Return a null DimensionedField (reference to a nullObject).
static const DimensionedField<Type, GeoMesh>& null() noexcept
{
return NullObjectRef<DimensionedField<Type, GeoMesh>>();
}
//- Return a NullObjectRef DimensionedField
inline static const DimensionedField<Type, GeoMesh>& null();
// Constructors
@ -443,19 +440,8 @@ public:
const dimensioned<Type>& dt
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- retaining its instance/local.
// For LEGACY_REGISTER, registration is determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<DimensionedField<Type, GeoMesh>> New
(
const word& newName,
IOobjectOption::registerOption regOpt,
const tmp<DimensionedField<Type, GeoMesh>>& tfld
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- retaining its instance/local.
//- Return renamed tmp field (NO_READ, NO_WRITE).
//- [Takes current timeName from the mesh registry].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<DimensionedField<Type, GeoMesh>> New

View File

@ -28,6 +28,14 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class GeoMesh>
inline const Foam::DimensionedField<Type, GeoMesh>&
Foam::DimensionedField<Type, GeoMesh>::null()
{
return NullObjectRef<DimensionedField<Type, GeoMesh>>();
}
template<class Type, class GeoMesh>
inline const typename GeoMesh::Mesh&
Foam::DimensionedField<Type, GeoMesh>::mesh() const noexcept

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -40,7 +40,6 @@ Foam::DimensionedField<Type, GeoMesh>::New_impl
{
auto ptr = tmp<DimensionedField<Type, GeoMesh>>::New
(
// == mesh.thisDb().newIOobject(name)
IOobject
(
name,
@ -54,22 +53,19 @@ Foam::DimensionedField<Type, GeoMesh>::New_impl
std::forward<Args>(args)...
);
// Registration
if (IOobjectOption::REGISTER == regOpt)
{
if (IOobjectOption::REGISTER == regOpt)
{
ptr->checkIn();
}
else if
(
// LEGACY_REGISTER: detect if caching is desired
(IOobjectOption::LEGACY_REGISTER == regOpt)
&& ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr->checkIn();
}
else if
(
// LEGACY_REGISTER: detect if caching is desired
(IOobjectOption::LEGACY_REGISTER == regOpt)
&& ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}
@ -294,7 +290,6 @@ Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const tmp<DimensionedField<Type, GeoMesh>>& tfld
)
{
@ -313,44 +308,18 @@ Foam::DimensionedField<Type, GeoMesh>::New
tfld
);
// Registration
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
if (IOobjectOption::REGISTER == regOpt)
{
ptr->checkIn();
}
else if
(
// LEGACY_REGISTER: detect if caching is desired
(IOobjectOption::LEGACY_REGISTER == regOpt)
&& ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}
template<class Type, class GeoMesh>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
Foam::DimensionedField<Type, GeoMesh>::New
(
const word& name,
const tmp<DimensionedField<Type, GeoMesh>>& tfld
)
{
return DimensionedField<Type, GeoMesh>::New
(
name,
IOobjectOption::LEGACY_REGISTER,
tfld
);
}
template<class Type, class GeoMesh>
template<class AnyType>
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
@ -376,16 +345,13 @@ Foam::DimensionedField<Type, GeoMesh>::New
dims
);
// Registration
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}
@ -417,16 +383,13 @@ Foam::DimensionedField<Type, GeoMesh>::New
dt.dimensions()
);
// Registration
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}

View File

@ -85,7 +85,7 @@ public:
~SlicedDimensionedField()
{
// Set internalField to nullptr to avoid deletion of underlying field
UList<Type>::shallowCopy(nullptr);
UList<Type>::shallowCopy(UList<Type>());
}
};

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