Compare commits

..

24 Commits

Author SHA1 Message Date
39362aec25 CONFIG: bump patch level (240625) 2024-06-26 11:18:36 +02:00
fb365b6622 BUG: Nastran reading of free format truncates last field (fixes #3189)
- the old logic relied on the presence/absence of a comma to decide
  whether to parse as fixed or free format. This logic is faulty when
  handling the final (trailing) entry and will generally lead to the
  last field being truncated when read in.
  Now the caller decides on fixed vs free.

FIX: inconsistent Nastran surface output format

- use FREE format by default. Previously had an odd mix of SHORT
  format when created without options and LONG format (as default)
  when created with format options.
2024-06-26 11:06:05 +02:00
530a5192ca Merge branch 'fix-adjointRotatingWall-sens' into 'master'
BUG: adjointRotatingWallVelocity causes sensitivities to crash. Fixes #3180

Closes #3180

See merge request Development/openfoam!690
2024-06-11 10:39:58 +00:00
2ef96e9e43 BUG: adjointRotatingWallVelocity causes sensitivities to crash. Fixes #3180 2024-06-10 14:52:58 +03:00
51a34f5abc BUG: ThermoSurfaceFilm - corrected FA field caching for Cp. Fixes #3017 2024-06-07 20:47:35 +01:00
b2532e7769 BUG: extractEulerianParticles - corrected patch index. Fixes #2707 2024-06-07 12:26:03 +01:00
790de0f98e BUG: gltf corrections. Fixes #3179
- corrected scalar bounds (label->scalar), field limit initialisation
- corrected alpha field lookup
- updated header documentation
2024-06-07 12:25:32 +01:00
4510067e63 CONFIG: bump patch level 2024-05-22 16:26:39 +02:00
8cf757daf0 BUG: GAMG: processorAgglomeration not merging proc coeffs. Fixes #3172 2024-05-22 16:26:39 +02:00
6581c5792a BUG: STL: cannot handle files > 2Gb. Fixes #3171 2024-05-22 16:25:37 +02: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
d9c5a5d1a9 BUG: mapped: register to current, not other mesh. See #2723 2024-02-01 13:14:09 +00:00
ebe49d4cbd BUG: SlicedGeometricField, slices into field instead of shallow copy (#3080)
- regression introduced by e98acdc4fc

  Affected versions: (v2206, v2212, v2306, v2312)
2024-01-19 18:06:38 +01:00
62524b140c BUG: protected division - fixes #3084 2024-01-15 15:10:24 +00:00
a46b310fa4 COMP: g++11: suppress optimisation. See #3024 2024-01-08 14:30:06 +01:00
1dc216eb1f TUT: Corrected references to mut - related to #3057 2024-01-03 09:55:44 +00:00
c4328296b0 TUT: Corrected legacy muTilda -> nuTilda. Fixes 3057 2024-01-03 09:43:23 +00:00
52ab1fc06f TUT: changes in optimisation tutorials
- shape optimisation: SQP failed due to wrong divScheme for the adjoint
  equations
- shape optimisation: tutorials designed to show the impact of different flow
  conditions were actually using the same U
- topology optimisation: tutorials designed to show the impact of the
  flow rate distribution were actually using the same target
  fractions
- topology optimisation: updated old fvSolution syntax
2024-01-02 12:03:21 +00:00
670 changed files with 8810 additions and 7416 deletions

View File

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

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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -135,15 +135,23 @@ protected:
// Protected Member Functions
//- Read data (on master) and transmit.
//- Helper: determine number of processors whose recvSizes fits
//- into maxBufferSize
static label calcNumProcs
(
const label comm,
const off_t maxBufferSize,
const labelUList& recvSizes,
const label startProci
);
//- Read data into *this. ISstream is only valid on master.
static bool readBlocks
(
const label comm,
// [in] The input stream (only valid on master)
autoPtr<ISstream>& isPtr,
// [out] The processor local data
List<char>& localData,
const UPstream::commsTypes commsType /* unused */
List<char>& contentChars,
const UPstream::commsTypes commsType
);
//- Helper: skip a block of (binary) character data
@ -269,19 +277,6 @@ public:
}
//- Helper: write block of (binary) character content
// Housekeeping
static std::streamoff writeBlockEntry
(
OSstream& os,
const label blocki,
const stdFoam::span<char>& s
)
{
return writeBlockEntry(os, blocki, s.data(), s.size());
}
//- Helper: write block of (binary) character content
// Housekeeping
static std::streamoff writeBlockEntry
(
OSstream& os,
@ -312,136 +307,61 @@ public:
);
//- Read master header information (into headerIO) and return
//- data in stream.
//- data in stream. Note: isPtr is only valid on master.
static autoPtr<ISstream> readBlocks
(
const label comm,
const fileName& fName,
//! [in] The input stream (only valid on master)
autoPtr<ISstream>& isPtr,
//! [out] header information
IOobject& headerIO,
const UPstream::commsTypes commsType /* unused */
);
//- Helper: gather data from (subset of) sub-ranks.
// In non-blocking mode it sets up send/recv for non-empty content.
// In blocking/scheduled mode it uses MPI_Gatherv to collect data.
//
// Returns:
// - recvData : the received data
// - recvOffsets : offset in data. recvOffsets is nProcs+1
static void gatherProcData
(
const label comm,
const UList<char>& localData, //!< [in] required on all procs
const labelUList& recvSizes, //!< [in] only required on master
const labelRange& whichProcs, //!< [in] required on all procs
List<int>& recvOffsets, //!< [out] only relevant on master
DynamicList<char>& recvData, //!< [out] only relevant on master
const UPstream::commsTypes commsType
);
//- Helper: gather single label. Note: using native Pstream.
// datas sized with num procs but undefined contents on
// slaves
static void gather
(
const label comm,
const label data,
labelList& datas
);
//- Helper: gather data from (subset of) slaves.
//
// Returns:
// - recvData : received data
// - recvOffsets : offset in data. recvOffsets is nProcs+1
static void gatherSlaveData
(
const label comm,
const UList<char>& data,
const labelUList& recvSizes,
const labelRange& fromProcs,
List<int>& recvOffsets,
DynamicList<char>& recvData
);
//- Write *this. Ostream only valid on master.
// Returns offsets of processor blocks in blockOffset
static bool writeBlocks
(
const label comm,
//! [in] output stream (relevant on master)
autoPtr<OSstream>& osPtr,
//! [out] start offsets to each block (relevant on master),
//! ignored if List::null() type
List<std::streamoff>& blockOffset,
const UList<char>& localData, //!< [in] required on all procs
const labelUList& recvSizes, //!< [in] only required on master
const UList<char>& masterData,
//! Optional proc data (only written on master)
//! but \b must also be symmetrically defined (empty/non-empty)
//! on all ranks
const UList<stdFoam::span<char>>& procData,
const labelUList& recvSizes,
// Optional slave data (on master)
const UPtrList<SubList<char>>& slaveData,
const UPstream::commsTypes commsType,
const bool syncReturnState = true
);
// Housekeeping
//- Write *this. Ostream only valid on master.
// Returns offsets of processor blocks in blockOffset
FOAM_DEPRECATED_FOR(2023-09, "write with char span instead")
static bool writeBlocks
(
const label comm,
autoPtr<OSstream>& osPtr,
List<std::streamoff>& blockOffset,
const UList<char>& localData, // [in] required on all procs
const labelUList& recvSizes, // [in] only required on master
// Optional proc data (only written on master)
// but \b must also be symmetrically defined (empty/non-empty)
// on all ranks
const UPtrList<SubList<char>>& procData,
const UPstream::commsTypes commsType,
const bool syncReturnState = true
)
{
// Transcribe to span<char>
List<stdFoam::span<char>> spans(procData.size());
forAll(procData, proci)
{
if (procData.test(proci))
{
spans[proci] = stdFoam::span<char>
(
const_cast<char*>(procData[proci].cdata()),
procData[proci].size()
);
}
}
return decomposedBlockData::writeBlocks
(
comm,
osPtr,
blockOffset,
localData,
recvSizes,
spans,
commsType,
syncReturnState
);
}
//- Deprecated(2023-09) - consider UPstream::listGatherValue
// The only difference is that this gather also resizes the output
// on the non-master procs
// \deprecated(2023-09) - consider UPstream::listGatherValue
FOAM_DEPRECATED_FOR(2023-09, "consider UPstream::listGatherValue()")
static void gather
(
const label comm,
const label localValue,
labelList& allValues
)
{
allValues.resize_nocopy(UPstream::nProcs(comm));
UPstream::mpiGather
(
reinterpret_cast<const char*>(&localValue),
allValues.data_bytes(),
sizeof(label), // The send/recv size per rank
comm
);
}
};

View File

@ -29,7 +29,7 @@ License
#include "masterOFstream.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "Pstream.H"
#include "PstreamBuffers.H"
#include "masterUncollatedFileOperation.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -38,10 +38,10 @@ void Foam::masterOFstream::checkWrite
(
const fileName& fName,
const char* str,
const std::streamsize len
std::streamsize len
)
{
if (!str || !len)
if (!len)
{
// Can probably skip all of this if there is nothing to write
return;
@ -63,7 +63,9 @@ void Foam::masterOFstream::checkWrite
<< exit(FatalIOError);
}
// Write characters directly to std::ostream
// Use writeRaw() instead of writeQuoted(string,false) to output
// characters directly.
os.writeRaw(str, len);
if (!os.good())
@ -75,159 +77,97 @@ void Foam::masterOFstream::checkWrite
}
void Foam::masterOFstream::checkWrite
(
const fileName& fName,
const std::string& s
)
{
checkWrite(fName, s.data(), s.length());
}
void Foam::masterOFstream::commit()
{
// Take ownership of serialized content, without copying or reallocation
DynamicList<char> charData(OCharStream::release());
if (UPstream::parRun())
{
// Ignore content if not writing (reduces communication)
if (!writeOnProc_)
{
charData.clear();
}
List<fileName> filePaths(UPstream::nProcs(comm_));
filePaths[UPstream::myProcNo(comm_)] = pathName_;
Pstream::gatherList(filePaths, UPstream::msgType(), comm_);
// Test for identical output paths
bool uniform =
(
UPstream::master(comm_)
? fileOperation::uniformFile(filePaths)
: true
&& fileOperation::uniformFile(filePaths)
);
Pstream::broadcast(uniform, comm_);
if (uniform)
{
// Identical file paths - write on master
if (UPstream::master(comm_) && writeOnProc_)
{
checkWrite(pathName_, charData);
checkWrite(pathName_, this->str());
}
this->reset();
return;
}
// Different files
// ---------------
// Current strategy is to setup all non-blocking send/recv
// using the probed message size to establish the recv size
// (to avoid an additional communication of the sizes).
//
// For ranks with writeOnProc=false, the message size is 0.
PstreamBuffers pBufs(comm_, UPstream::commsTypes::nonBlocking);
// An alternative approach would be to gather recv sizes
// to avoid zero-sized messages and/or use double buffering
// to recv into a buffer and write.
//
// const labelList recvSizes
// (
// UPstream::listGatherValues<label>
// (
// (UPstream::is_subrank(comm_) ? charData.size() : label(0)),
// comm_
// )
// );
const label startOfRequests = UPstream::nRequests();
// Some unique tag for this read/write/probe grouping
const int messageTag = UPstream::msgType() + 256;
if (UPstream::is_subrank(comm_))
if (!UPstream::master(comm_))
{
// Send to master. When (!writeOnProc_) it is zero-sized.
UOPstream::write
(
UPstream::commsTypes::nonBlocking,
UPstream::masterNo(),
charData.cdata_bytes(),
charData.size_bytes(),
messageTag,
comm_
);
}
else if (UPstream::master(comm_))
{
// The receive slots
List<List<char>> procBuffers(UPstream::nProcs(comm_));
const auto recvProcs = UPstream::subProcs(comm_);
for (const int proci : recvProcs)
{
auto& procSlice = procBuffers[proci];
// Probe the message size
std::pair<int, int> probed =
UPstream::probeMessage
(
UPstream::commsTypes::blocking,
proci,
messageTag,
comm_
);
procSlice.resize_nocopy(probed.second);
// Receive content (can also be zero-sized)
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
procSlice.data_bytes(),
procSlice.size_bytes(),
messageTag,
comm_
);
}
if (writeOnProc_)
{
// Write non-empty master data
checkWrite(pathName_, charData);
// Send buffer to master
string s(this->str());
UOPstream os(UPstream::masterNo(), pBufs);
os.write(s.data(), s.length());
}
this->reset(); // Done with contents
}
// Poll for completed receive requests and dispatch
DynamicList<int> indices(recvProcs.size());
while
(
UPstream::waitSomeRequests
(
startOfRequests,
recvProcs.size(),
&indices
)
)
pBufs.finishedGathers();
if (UPstream::master(comm_))
{
if (writeOnProc_)
{
for (const int idx : indices)
// Write master data
checkWrite(filePaths[UPstream::masterNo()], this->str());
}
this->reset(); // Done with contents
// Allocate large enough to read without resizing
List<char> buf(pBufs.maxRecvCount());
for (const int proci : UPstream::subProcs(comm_))
{
const std::streamsize count(pBufs.recvDataCount(proci));
if (count)
{
const int proci = recvProcs[idx];
auto& procSlice = procBuffers[proci];
UIPstream is(proci, pBufs);
if (!procSlice.empty())
{
// Write non-empty sub-proc data
checkWrite(filePaths[proci], procSlice);
}
// Eager cleanup?
// TBD: procSlice.clear();
is.read(buf.data(), count);
checkWrite(filePaths[proci], buf.cdata(), count);
}
}
}
UPstream::waitRequests(startOfRequests);
}
else
{
// Write (non-empty) data
checkWrite(pathName_, charData);
checkWrite(pathName_, this->str());
this->reset();
}
// This method is only called once (internally)
// so no need to clear/flush old buffered data
}
@ -243,7 +183,7 @@ Foam::masterOFstream::masterOFstream
const bool writeOnProc
)
:
OCharStream(streamOpt),
OStringStream(streamOpt),
pathName_(pathName),
atomic_(atomic),
compression_(streamOpt.compression()),

View File

@ -41,7 +41,7 @@ SourceFiles
#ifndef Foam_masterOFstream_H
#define Foam_masterOFstream_H
#include "SpanStream.H"
#include "StringStream.H"
#include "UPstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ namespace Foam
class masterOFstream
:
public OCharStream
public OStringStream
{
// Private Data
@ -85,20 +85,13 @@ class masterOFstream
(
const fileName& fName,
const char* str,
const std::streamsize len
std::streamsize len
);
//- Open file with checking and write append contents
void checkWrite
(
const fileName& fName,
const UList<char>& charData
)
{
checkWrite(fName, charData.cdata(), charData.size_bytes());
}
void checkWrite(const fileName& fName, const std::string& s);
//- Commit buffered information, including communication as required
//- Commit buffered information, including parallel gather as required
void commit();

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

@ -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

@ -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

@ -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.
@ -440,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

@ -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

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017,2022 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -189,7 +189,7 @@ bool Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::checkConsistency
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
(
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
)
{
@ -210,9 +210,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
for (const entry& dEntry : dict)
{
const auto* subdict = dEntry.dictPtr();
if (subdict && dEntry.keyword().isLiteral())
if (dEntry.isDict() && dEntry.keyword().isLiteral())
{
const label patchi = bmesh_.findPatchID(dEntry.keyword());
@ -224,11 +222,11 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New
(
bmesh_[patchi],
iField,
*subdict
field,
dEntry.dict()
)
);
--nUnset;
nUnset--;
}
}
}
@ -247,9 +245,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
for (auto iter = dict.crbegin(); iter != dict.crend(); ++iter)
{
const entry& dEntry = *iter;
const auto* subdict = dEntry.dictPtr();
if (subdict && dEntry.keyword().isLiteral())
if (dEntry.isDict() && dEntry.keyword().isLiteral())
{
const labelList patchIds =
bmesh_.indices(dEntry.keyword(), true); // use patchGroups
@ -264,8 +261,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New
(
bmesh_[patchi],
iField,
*subdict
field,
dEntry.dict()
)
);
}
@ -288,15 +285,15 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
(
emptyPolyPatch::typeName,
bmesh_[patchi],
iField
field
)
);
}
else
{
const auto* subdict = dict.findDict(bmesh_[patchi].name());
bool found = dict.found(bmesh_[patchi].name());
if (subdict)
if (found)
{
this->set
(
@ -304,8 +301,8 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::readField
PatchField<Type>::New
(
bmesh_[patchi],
iField,
*subdict
field,
dict.subDict(bmesh_[patchi].name())
)
);
}
@ -356,7 +353,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const word& patchFieldType
)
:
@ -377,7 +374,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
patchFieldType,
bmesh_[patchi],
iField
field
)
);
}
@ -388,7 +385,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const wordList& patchFieldTypes,
const wordList& constraintTypes
)
@ -427,7 +424,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
patchFieldTypes[patchi],
constraintTypes[patchi],
bmesh_[patchi],
iField
field
)
);
}
@ -443,7 +440,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
patchFieldTypes[patchi],
bmesh_[patchi],
iField
field
)
);
}
@ -455,7 +452,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const PtrList<PatchField<Type>>& ptfl
)
:
@ -469,7 +466,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
forAll(bmesh_, patchi)
{
this->set(patchi, ptfl[patchi].clone(iField));
this->set(patchi, ptfl[patchi].clone(field));
}
}
@ -477,7 +474,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
)
:
@ -491,7 +488,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
forAll(bmesh_, patchi)
{
this->set(patchi, btf[patchi].clone(iField));
this->set(patchi, btf[patchi].clone(field));
}
}
@ -499,7 +496,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
const labelList& patchIDs,
const word& patchFieldType
@ -522,7 +519,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
patchFieldType,
bmesh_[patchi],
iField
field
)
);
}
@ -531,7 +528,7 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
{
if (!this->set(patchi))
{
this->set(patchi, btf[patchi].clone(iField));
this->set(patchi, btf[patchi].clone(field));
}
}
}
@ -557,14 +554,14 @@ template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
)
:
FieldField<PatchField, Type>(bmesh.size()),
bmesh_(bmesh)
{
readField(iField, dict);
readField(field, dict);
}
@ -838,24 +835,18 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::types() const
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>
Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::
boundaryInternalField() const
{
auto tresult = tmp<GeometricBoundaryField<Type, PatchField, GeoMesh>>::New
(
DimensionedField<Type, GeoMesh>::null(),
*this
);
auto& result = tresult;
GeometricBoundaryField<Type, PatchField, GeoMesh> result(*this);
forAll(result, patchi)
{
result[patchi] == this->operator[](patchi).patchInternalField();
}
return tresult;
return result;
}
@ -867,11 +858,13 @@ Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::interfaces() const
forAll(list, patchi)
{
list.set
(
patchi,
isA<LduInterfaceField<Type>>(this->operator[](patchi))
);
const auto* lduPtr =
isA<LduInterfaceField<Type>>(this->operator[](patchi));
if (lduPtr)
{
list.set(patchi, lduPtr);
}
}
return list;
@ -887,11 +880,13 @@ scalarInterfaces() const
forAll(list, patchi)
{
list.set
(
patchi,
isA<lduInterfaceField>(this->operator[](patchi))
);
const auto* lduPtr =
isA<lduInterfaceField>(this->operator[](patchi));
if (lduPtr)
{
list.set(patchi, lduPtr);
}
}
return list;

View File

@ -117,7 +117,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const word& patchFieldType = PatchField<Type>::calculatedType()
);
@ -127,7 +127,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const wordList& wantedPatchTypes,
const wordList& actualPatchTypes = wordList()
);
@ -137,14 +137,14 @@ public:
GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const PtrList<PatchField<Type>>& ptfl
);
//- Construct as copy, setting the reference to the internal field
GeometricBoundaryField
(
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
);
@ -152,7 +152,7 @@ public:
//- and resetting type of field for given patch IDs
GeometricBoundaryField
(
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf,
const labelList& patchIDs,
const word& patchFieldName
@ -169,7 +169,7 @@ public:
GeometricBoundaryField
(
const BoundaryMesh& bmesh,
const Internal& iField,
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
);
@ -177,7 +177,11 @@ public:
// Member Functions
//- Read the boundary field
void readField(const Internal& iField, const dictionary& dict);
void readField
(
const DimensionedField<Type, GeoMesh>& field,
const dictionary& dict
);
//- Update the boundary condition coefficients
void updateCoeffs();
@ -199,7 +203,7 @@ public:
wordList types() const;
//- Return boundary field of values neighbouring the boundary
tmp<GeometricBoundaryField> boundaryInternalField() const;
GeometricBoundaryField boundaryInternalField() const;
//- Return a list of pointers for each patch field with only those
//- pointing to interfaces being set

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.
@ -504,68 +504,6 @@ public:
const word& patchFieldType = PatchField<Type>::calculatedType()
);
//- Return tmp field (NO_READ, NO_WRITE)
//- from name, mesh, dimensions, copy of internal field contents
//- and patch list to clone.
//- [Takes current timeName from the mesh registry].
// For LEGACY_REGISTER, registration is determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& name,
IOobjectOption::registerOption regOpt,
const Mesh& mesh,
const dimensionSet& dims,
const Field<Type>& iField,
const PtrList<PatchField<Type>>& pflds
);
//- Return tmp field (NO_READ, NO_WRITE)
//- from name, mesh, dimensions, copy of internal field contents
//- and patch list to clone.
//- [Takes current timeName from the mesh registry].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensionSet& dims,
const Field<Type>& iField,
const PtrList<PatchField<Type>>& pflds
);
//- Return tmp field (NO_READ, NO_WRITE)
//- from name, mesh, dimensions, moved internal field contents
//- and patch list to clone.
//- [Takes current timeName from the mesh registry].
// For LEGACY_REGISTER, registration is determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& name,
IOobjectOption::registerOption regOpt,
const Mesh& mesh,
const dimensionSet& dims,
Field<Type>&& iField,
const PtrList<PatchField<Type>>& pflds
);
//- Return tmp field (NO_READ, NO_WRITE)
//- from name, mesh, dimensions, moved internal field contents
//- and patch list to clone.
//- [Takes current timeName from the mesh registry].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& name,
const Mesh& mesh,
const dimensionSet& dims,
Field<Type>&& iField,
const PtrList<PatchField<Type>>& pflds
);
//- Return tmp field (NO_READ, NO_WRITE)
//- from name, mesh, field value, dimensions and patch type.
//- [Takes current timeName from the mesh registry].
@ -683,70 +621,36 @@ public:
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- retaining its instance/local.
// For LEGACY_REGISTER, registration is determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- retaining its instance/local.
//- [Takes current timeName from the mesh registry].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- with reset patch field type, retaining its instance/local.
// For LEGACY_REGISTER, registration is determined by
//- with reset patch field type.
//- [Takes current timeName from the mesh registry].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
const word& patchFieldType
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- with reset patch field type, retaining its instance/local.
//- with reset patch field types.
//- [Takes instance from the field].
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const word& patchFieldType
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- with reset patch field types, retaining its instance/local.
// For LEGACY_REGISTER, registration is determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes = wordList()
);
//- Return renamed tmp field (NO_READ, NO_WRITE)
//- with reset patch field types, retaining its instance/local.
// Registration/persistence determined by
// objectRegistry::is_cacheTemporaryObject().
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
(
const word& newName,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes = wordList()
);
@ -962,6 +866,7 @@ public:
// Member Operators
//- Return a const-reference to the dimensioned internal field.
//- Same as internalField().
// Useful in the formulation of source-terms for FV equations
const Internal& operator()() const { return *this; }

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenFOAM Foundation
Copyright (C) 2019-2024 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,7 +41,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New_impl
{
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
(
// == mesh.thisDb().newIOobject(name)
IOobject
(
name,
@ -55,22 +54,19 @@ Foam::GeometricField<Type, PatchField, 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;
}
@ -215,100 +211,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const Mesh& mesh,
const dimensionSet& dims,
const Field<Type>& iField,
const PtrList<PatchField<Type>>& pflds
)
{
return GeometricField<Type, PatchField, GeoMesh>::New_impl
(
regOpt,
name,
mesh,
dims,
iField,
pflds
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensionSet& dims,
const Field<Type>& iField,
const PtrList<PatchField<Type>>& pflds
)
{
return GeometricField<Type, PatchField, GeoMesh>::New_impl
(
IOobjectOption::LEGACY_REGISTER,
name,
mesh,
dims,
iField,
pflds
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const Mesh& mesh,
const dimensionSet& dims,
Field<Type>&& iField,
const PtrList<PatchField<Type>>& pflds
)
{
return GeometricField<Type, PatchField, GeoMesh>::New_impl
(
regOpt,
name,
mesh,
dims,
std::move(iField),
pflds
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
const Mesh& mesh,
const dimensionSet& dims,
Field<Type>&& iField,
const PtrList<PatchField<Type>>& pflds
)
{
return GeometricField<Type, PatchField, GeoMesh>::New_impl
(
IOobjectOption::LEGACY_REGISTER,
name,
mesh,
dims,
std::move(iField),
pflds
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
@ -504,8 +406,8 @@ Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
const word& patchFieldType
)
{
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
@ -513,32 +415,24 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
IOobject
(
name,
tfld().instance(),
tfld().local(),
tfld().db(),
tgf().instance(),
tgf().local(),
tgf().db(),
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
),
tfld
tgf,
patchFieldType
);
// 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;
}
@ -549,26 +443,7 @@ Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld
)
{
return GeometricField<Type, PatchField, GeoMesh>::New
(
name,
IOobjectOption::LEGACY_REGISTER,
tfld
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const word& patchFieldType
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
)
{
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
@ -576,33 +451,23 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
IOobject
(
name,
tfld().instance(),
tfld().local(),
tfld().db(),
tgf().instance(),
tgf().local(),
tgf().db(),
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
),
tfld,
patchFieldType
tgf
);
// 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;
}
@ -613,27 +478,7 @@ Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const word& patchFieldType
)
{
return GeometricField<Type, PatchField, GeoMesh>::New
(
name,
IOobjectOption::LEGACY_REGISTER,
tfld,
patchFieldType
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
IOobjectOption::registerOption regOpt,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
@ -643,60 +488,30 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
IOobject
(
name,
tfld().instance(),
tfld().local(),
tfld().db(),
tgf().instance(),
tgf().local(),
tgf().db(),
IOobjectOption::NO_READ,
IOobjectOption::NO_WRITE,
IOobjectOption::NO_REGISTER
),
tfld,
tgf,
patchFieldTypes,
actualPatchTypes
);
// 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, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::New
(
const word& name,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tfld,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
{
return GeometricField<Type, PatchField, GeoMesh>::New
(
name,
IOobjectOption::LEGACY_REGISTER,
tfld,
patchFieldTypes,
actualPatchTypes
);
}
template<class Type, template<class> class PatchField, class GeoMesh>
template<class AnyType>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
@ -724,17 +539,13 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
patchFieldType
);
// Registration
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
if
(
// LEGACY_REGISTER: detect if caching is desired
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}
@ -768,17 +579,13 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
patchFieldType
);
// Registration
if
(
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
if
(
// LEGACY_REGISTER: detect if caching is desired
ptr->db().is_cacheTemporaryObject(ptr.get())
)
{
ptr.protect(true);
ptr->checkIn();
}
ptr.protect(true);
ptr->checkIn();
}
return ptr;
}

View File

@ -176,10 +176,11 @@ makeBoundary
new SlicedPatchField<Type>
(
p,
DimensionedField<Type, GeoMesh>::null(),
bField[patchi]
DimensionedField<Type, GeoMesh>::null()
)
);
bf[patchi].UList<Type>::shallowCopy(bField[patchi]);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -172,21 +172,6 @@ public:
{
return obr.lookupObject<IOField<Type>>(fieldName);
}
//- Lookup an IOField within object registry
// Fatal if not found or wrong type
//
// Note: const char signature to avoid spurious
// -Wdangling-reference with gcc-13
template<class Type>
static const IOField<Type>& lookupIOField
(
const char* fieldName,
const objectRegistry& obr
)
{
return obr.lookupObject<IOField<Type>>(word(fieldName));
}
};

View File

@ -83,6 +83,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new basicSymmetryPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
basicSymmetryPointPatchField
(
@ -90,35 +102,33 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new basicSymmetryPointPatchField<Type>
(
*this,
iF
)
);
}
// Member Functions
// Member functions
//- Update the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::commsTypes::blocking
);
// Evaluation functions
// Member Operators
//- Inherit assignment operators
using pointPatchField<Type>::operator=;
//- Update the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType =
Pstream::commsTypes::blocking
);
};

View File

@ -78,13 +78,14 @@ Foam::calculatedPointPatchField<Type>::calculatedPointPatchField
template<class Type>
template<class Type2>
Foam::autoPtr<Foam::pointPatchField<Type>>
Foam::pointPatchField<Type>::NewCalculatedType
(
const pointPatch& p
const pointPatchField<Type2>& pf
)
{
auto* patchTypeCtor = patchConstructorTable(p.type());
auto* patchTypeCtor = patchConstructorTable(pf.patch().type());
if (patchTypeCtor)
{
@ -92,8 +93,8 @@ Foam::pointPatchField<Type>::NewCalculatedType
(
patchTypeCtor
(
p,
DimensionedField<Type, pointMesh>::null()
pf.patch(),
Field<Type>::null()
)
);
}
@ -103,24 +104,12 @@ Foam::pointPatchField<Type>::NewCalculatedType
(
new calculatedPointPatchField<Type>
(
p,
DimensionedField<Type, pointMesh>::null()
pf.patch(),
Field<Type>::null()
)
);
}
}
template<class Type>
template<class AnyType>
Foam::autoPtr<Foam::pointPatchField<Type>>
Foam::pointPatchField<Type>::NewCalculatedType
(
const pointPatchField<AnyType>& pf
)
{
return NewCalculatedType(pf.patch());
}
// ************************************************************************* //

View File

@ -85,6 +85,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new calculatedPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
calculatedPointPatchField
(
@ -92,19 +104,18 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
virtual autoPtr<pointPatchField<Type>>
clone(const DimensionedField<Type, pointMesh>& iF) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new calculatedPointPatchField<Type>
(
*this,
iF
)
);
}
};

View File

@ -87,6 +87,9 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const = 0;
//- Construct as copy setting internal field reference
coupledPointPatchField
(
@ -94,9 +97,6 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const = 0;
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(

View File

@ -111,6 +111,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new fixedValuePointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
fixedValuePointPatchField
(
@ -118,19 +130,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new fixedValuePointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -237,8 +237,7 @@ void Foam::valuePointPatchField<Type>::operator=
const pointPatchField<Type>& ptf
)
{
// pointPatchField has no values to copy, assign internal values
this->extrapolateInternal();
Field<Type>::operator=(this->patchInternalField());
}
@ -278,8 +277,7 @@ void Foam::valuePointPatchField<Type>::operator==
const pointPatchField<Type>& ptf
)
{
// pointPatchField has no values to copy, assign internal values
this->extrapolateInternal();
Field<Type>::operator=(this->patchInternalField());
}

View File

@ -142,6 +142,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new valuePointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
valuePointPatchField
(
@ -149,19 +161,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new valuePointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -85,6 +85,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new zeroGradientPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
zeroGradientPointPatchField
(
@ -92,19 +104,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new zeroGradientPointPatchField<Type>
(
*this,
iF
)
);
}
};

View File

@ -92,6 +92,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new cyclicPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
cyclicPointPatchField
(
@ -99,19 +111,19 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new cyclicPointPatchField<Type>
(
*this, iF
)
);
}

View File

@ -87,6 +87,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new cyclicSlipPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
cyclicSlipPointPatchField
(
@ -94,19 +106,19 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new cyclicSlipPointPatchField<Type>
(
*this, iF
)
);
}

View File

@ -86,6 +86,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new emptyPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
emptyPointPatchField
(
@ -93,22 +105,22 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new emptyPointPatchField<Type>
(
*this,
iF
)
);
}
// Member functions
//- Constraint handling

View File

@ -87,6 +87,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new nonuniformTransformCyclicPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
nonuniformTransformCyclicPointPatchField
(
@ -94,19 +106,19 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new nonuniformTransformCyclicPointPatchField<Type>
(
*this, iF
)
);
}

View File

@ -91,6 +91,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new processorPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
processorPointPatchField
(
@ -98,19 +110,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new processorPointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -93,16 +93,15 @@ void Foam::processorCyclicPointPatchField<Type>::initSwapAddSeparated
Field<Type>& pField
) const
{
if (UPstream::parRun())
if (Pstream::parRun())
{
// Get internal field into correct order for opposite side. Note use
// of member data buffer since using non-blocking. Could be optimised
// out if not using non-blocking...
this->patchInternalField
sendBuf_ = this->patchInternalField
(
pField,
procPatch_.reverseMeshPoints(),
sendBuf_
procPatch_.reverseMeshPoints()
);
if (commsType == Pstream::commsTypes::nonBlocking)
@ -139,7 +138,7 @@ void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated
Field<Type>& pField
) const
{
if (UPstream::parRun())
if (Pstream::parRun())
{
// If nonblocking, data is already in receive buffer

View File

@ -99,6 +99,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new processorCyclicPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
processorCyclicPointPatchField
(
@ -106,19 +118,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new processorCyclicPointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -87,6 +87,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new symmetryPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
symmetryPointPatchField
(
@ -94,19 +106,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new symmetryPointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -92,6 +92,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new symmetryPlanePointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
symmetryPlanePointPatchField
(
@ -99,19 +111,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new symmetryPlanePointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -87,6 +87,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new wedgePointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
wedgePointPatchField
(
@ -94,19 +106,19 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new wedgePointPatchField<Type>
(
*this, iF
)
);
}

View File

@ -209,6 +209,15 @@ public:
const codedFixedValuePointPatchField<Type>&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new codedFixedValuePointPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
codedFixedValuePointPatchField
(
@ -216,19 +225,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new codedFixedValuePointPatchField<Type>
(
*this,
iF
)
);
}

View File

@ -104,6 +104,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new fixedNormalSlipPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
fixedNormalSlipPointPatchField
(
@ -111,22 +123,22 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new fixedNormalSlipPointPatchField<Type>
(
*this,
iF
)
);
}
// Member functions
//- Update the patch field

View File

@ -86,6 +86,18 @@ public:
const pointPatchFieldMapper&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new slipPointPatchField<Type>
(
*this
)
);
}
//- Construct as copy setting internal field reference
slipPointPatchField
(
@ -93,19 +105,20 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new slipPointPatchField<Type>
(
*this,
iF
)
);
}
};

View File

@ -101,6 +101,15 @@ public:
const timeVaryingUniformFixedValuePointPatchField<Type>&
);
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return autoPtr<pointPatchField<Type>>
(
new timeVaryingUniformFixedValuePointPatchField<Type>(*this)
);
}
//- Construct as copy setting internal field reference
timeVaryingUniformFixedValuePointPatchField
(
@ -108,19 +117,16 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Return a clone
virtual autoPtr<pointPatchField<Type>> clone() const
{
return pointPatchField<Type>::Clone(*this);
}
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const
{
return pointPatchField<Type>::Clone(*this, iF);
return autoPtr<pointPatchField<Type>>
(
new timeVaryingUniformFixedValuePointPatchField<Type>(*this, iF)
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2023 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -108,64 +108,6 @@ void Foam::pointPatchField<Type>::write(Ostream& os) const
}
template<class Type>
template<class Type1>
void Foam::pointPatchField<Type>::patchInternalField
(
const UList<Type1>& internalData,
const labelUList& addressing,
Field<Type1>& pfld
) const
{
// Check size
if (internalData.size() != primitiveField().size())
{
FatalErrorInFunction
<< "Internal field size: " << internalData.size()
<< " != mesh size: " << primitiveField().size() << nl
<< abort(FatalError);
}
const label len = this->size();
pfld.resize_nocopy(len);
for (label i = 0; i < len; ++i)
{
pfld[i] = internalData[addressing[i]];
}
}
template<class Type>
template<class Type1>
Foam::tmp<Foam::Field<Type1>>
Foam::pointPatchField<Type>::patchInternalField
(
const UList<Type1>& internalData,
const labelUList& addressing
) const
{
auto tpfld = tmp<Field<Type1>>::New();
this->patchInternalField(internalData, addressing, tpfld.ref());
return tpfld;
}
template<class Type>
template<class Type1>
Foam::tmp<Foam::Field<Type1>>
Foam::pointPatchField<Type>::patchInternalField
(
const UList<Type1>& internalData
) const
{
auto tpfld = tmp<Field<Type1>>::New();
this->patchInternalField(internalData, patch().meshPoints(), tpfld.ref());
return tpfld;
}
template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::pointPatchField<Type>::patchInternalField() const
@ -174,6 +116,41 @@ Foam::pointPatchField<Type>::patchInternalField() const
}
template<class Type>
template<class Type1>
Foam::tmp<Foam::Field<Type1>>
Foam::pointPatchField<Type>::patchInternalField
(
const Field<Type1>& iF,
const labelUList& meshPoints
) const
{
// Check size
if (iF.size() != primitiveField().size())
{
FatalErrorInFunction
<< "given internal field does not correspond to the mesh. "
<< "Field size: " << iF.size()
<< " mesh size: " << primitiveField().size()
<< abort(FatalError);
}
return tmp<Field<Type1>>::New(iF, meshPoints);
}
template<class Type>
template<class Type1>
Foam::tmp<Foam::Field<Type1>>
Foam::pointPatchField<Type>::patchInternalField
(
const Field<Type1>& iF
) const
{
return patchInternalField(iF, patch().meshPoints());
}
template<class Type>
template<class Type1>
void Foam::pointPatchField<Type>::addToInternalField
@ -186,16 +163,18 @@ void Foam::pointPatchField<Type>::addToInternalField
if (iF.size() != primitiveField().size())
{
FatalErrorInFunction
<< "Internal field size: " << iF.size()
<< " != mesh size: " << primitiveField().size() << nl
<< "given internal field does not correspond to the mesh. "
<< "Field size: " << iF.size()
<< " mesh size: " << primitiveField().size()
<< abort(FatalError);
}
if (pF.size() != size())
{
FatalErrorInFunction
<< "Patch field size: " << pF.size()
<< " != patch size: " << size() << nl
<< "given patch field does not correspond to the mesh. "
<< "Field size: " << pF.size()
<< " mesh size: " << size()
<< abort(FatalError);
}
@ -222,16 +201,18 @@ void Foam::pointPatchField<Type>::addToInternalField
if (iF.size() != primitiveField().size())
{
FatalErrorInFunction
<< "Internal field size: " << iF.size()
<< " != mesh size: " << primitiveField().size() << nl
<< "given internal field does not correspond to the mesh. "
<< "Field size: " << iF.size()
<< " mesh size: " << primitiveField().size()
<< abort(FatalError);
}
if (pF.size() != size())
{
FatalErrorInFunction
<< "Patch field size: " << pF.size()
<< " != patch size: " << size() << nl
<< "given patch field does not correspond to the mesh. "
<< "Field size: " << pF.size()
<< " mesh size: " << size()
<< abort(FatalError);
}
@ -259,16 +240,18 @@ void Foam::pointPatchField<Type>::setInInternalField
if (iF.size() != primitiveField().size())
{
FatalErrorInFunction
<< "Internal field size: " << iF.size()
<< " != mesh size: " << primitiveField().size() << nl
<< "given internal field does not correspond to the mesh. "
<< "Field size: " << iF.size()
<< " mesh size: " << primitiveField().size()
<< abort(FatalError);
}
if (pF.size() != meshPoints.size())
{
FatalErrorInFunction
<< "Patch field size: " << pF.size()
<< " != meshPoints size: " << meshPoints.size() << nl
<< "given patch field does not correspond to the meshPoints. "
<< "Field size: " << pF.size()
<< " meshPoints size: " << size()
<< abort(FatalError);
}

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.
@ -240,25 +240,6 @@ class pointPatchField
:
public pointPatchFieldBase
{
public:
// Public Data Types
//- The patch type for the patch field
typedef pointPatch Patch;
//- The value_type for the patch field
typedef Type value_type;
//- The internal field type associated with the patch field
typedef DimensionedField<Type, pointMesh> Internal;
//- Type for a \em calculated patch
typedef calculatedPointPatchField<Type> Calculated;
private:
// Private Data
//- Reference to internal field
@ -267,6 +248,19 @@ private:
public:
//- The Field value_type
typedef Type value_type;
//- The internal field type associated with the patch field
typedef DimensionedField<Type, pointMesh> Internal;
//- The patch type for the patch field
typedef pointPatch Patch;
//- Type for a \em calculated patch
typedef calculatedPointPatchField<Type> Calculated;
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
@ -345,31 +339,17 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Clone patch field with its own internal field reference
//- Construct and return a clone
virtual autoPtr<pointPatchField<Type>> clone() const = 0;
//- Clone patch field with an internal field reference
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type>> clone
(
const DimensionedField<Type, pointMesh>& iF
) const = 0;
// Factory Methods
//- Clone a patch field, optionally with internal field reference etc.
template<class DerivedPatchField, class... Args>
static autoPtr<pointPatchField<Type>> Clone
(
const DerivedPatchField& pf,
Args&&... args
)
{
return autoPtr<pointPatchField<Type>>
(
new DerivedPatchField(pf, std::forward<Args>(args)...)
);
}
// Selectors
//- Return a pointer to a new patchField created on freestore given
// patch and internal field
@ -414,19 +394,11 @@ public:
//- Return a pointer to a new calculatedPointPatchField created on
// freestore without setting patchField values
template<class Type2>
static autoPtr<pointPatchField<Type>>
NewCalculatedType
(
const pointPatch& p
);
//- Return a pointer to a new calculatedPointPatchField created on
// freestore without setting patchField values
template<class AnyType>
static autoPtr<pointPatchField<Type>>
NewCalculatedType
(
const pointPatchField<AnyType>& pf
const pointPatchField<Type2>&
);
@ -459,43 +431,26 @@ public:
// Evaluation Functions
//- Extract field using specified addressing
// \param internalData The internal field to extract from
// \param addressing Addressing (mesh-points) into internal field
// \param [out] pfld The extracted patch field.
// It is always resized according to the patch size(),
// which can be smaller than the addressing size
//- Return field created from appropriate internal field values
tmp<Field<Type>> patchInternalField() const;
//- Return field created from appropriate internal field values
//- given internal field reference
template<class Type1>
void patchInternalField
tmp<Field<Type1>> patchInternalField
(
const UList<Type1>& internalData,
const labelUList& addressing,
Field<Type1>& pfld
const Field<Type1>& iF
) const;
//- Return field created from selected internal field values
//- given internal field reference
// \param internalData The internal field to extract from
// \param addressing Addressing (mesh-points) into internal field
template<class Type1>
tmp<Field<Type1>> patchInternalField
(
const UList<Type1>& internalData,
const labelUList& addressing
const Field<Type1>& iF,
const labelUList& meshPoints
) const;
//- Return field created from appropriate internal field values
//- given internal field reference
template<class Type1>
tmp<Field<Type1>> patchInternalField
(
const UList<Type1>& internalData
) const;
//- Return field created from appropriate internal field values
tmp<Field<Type>> patchInternalField() const;
//- Given the internal field and a patch field,
//- add the patch field to the internal field
template<class Type1>

View File

@ -47,9 +47,9 @@ bool Foam::OFstreamCollator::writeFile
const label comm,
const word& objectType,
const fileName& fName,
const UList<char>& localData,
const string& masterData,
const labelUList& recvSizes,
const UList<stdFoam::span<char>>& procData, // optional proc data
const UPtrList<SubList<char>>& slaveData, // optional slave data
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
@ -58,14 +58,18 @@ bool Foam::OFstreamCollator::writeFile
{
if (debug)
{
Pout<< "OFstreamCollator : Writing local " << localData.size()
Pout<< "OFstreamCollator : Writing master " << label(masterData.size())
<< " bytes to " << fName << " using comm " << comm
<< " and " << procData.size() << " sub-ranks" << endl;
<< " and " << slaveData.size() << " sub-ranks" << endl;
forAll(procData, proci)
forAll(slaveData, proci)
{
Pout<< " " << proci << " size:"
<< label(procData[proci].size()) << nl;
if (slaveData.set(proci))
{
Pout<< " " << proci
<< " size:" << slaveData[proci].size()
<< endl;
}
}
}
@ -100,27 +104,32 @@ bool Foam::OFstreamCollator::writeFile
// for some mpi so default is non-blocking.
const UPstream::commsTypes myCommsType
(
mag
(
fileOperations::masterUncollatedFileOperation::
maxMasterFileBufferSize
) < 1
maxMasterFileBufferSize == 0
)
? UPstream::commsTypes::scheduled
: UPstream::commsTypes::nonBlocking
);
List<std::streamoff> blockOffsets; // Optional
UList<char> slice
(
const_cast<char*>(masterData.data()),
label(masterData.size())
);
List<std::streamoff> blockOffset;
decomposedBlockData::writeBlocks
(
comm,
osPtr,
blockOffsets, // or List<std::streamoff>::null()
localData,
blockOffset,
slice,
recvSizes,
procData,
slaveData,
myCommsType,
false // do not sync return state
false // do not reduce return state
);
if (osPtr && !osPtr->good())
@ -131,18 +140,17 @@ bool Foam::OFstreamCollator::writeFile
if (debug)
{
Pout<< "OFstreamCollator : Finished writing "
<< localData.size() << " bytes";
Pout<< "OFstreamCollator : Finished writing " << masterData.size()
<< " bytes";
if (UPstream::master(comm))
{
off_t total = 0;
off_t sum = 0;
for (const label recv : recvSizes)
{
total += recv;
sum += recv;
}
// Use std::to_string to display long int
Pout<< " (overall " << std::to_string(total) << ')';
Pout<< " (overall " << std::to_string(sum) << ')';
}
Pout<< " to " << fName
<< " using comm " << comm << endl;
@ -159,16 +167,13 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
// Consume stack
while (true)
{
std::unique_ptr<writeData> ptr;
writeData* ptr = nullptr;
{
std::lock_guard<std::mutex> guard(handler.mutex_);
if (handler.objects_.size())
{
// FIFO
ptr.reset(handler.objects_.front());
handler.objects_.pop_front();
ptr = handler.objects_.pop();
}
}
@ -176,39 +181,51 @@ void* Foam::OFstreamCollator::writeAll(void *threadarg)
{
break;
}
writeData& obj = *ptr;
// Obtain spans from storage
List<stdFoam::span<char>> procData(obj.procData_.size());
forAll(procData, proci)
else
{
procData[proci] = stdFoam::span<char>
// Convert storage to pointers
PtrList<SubList<char>> slaveData;
if (ptr->slaveData_.size())
{
slaveData.resize(ptr->slaveData_.size());
forAll(slaveData, proci)
{
if (ptr->slaveData_.set(proci))
{
slaveData.set
(
proci,
new SubList<char>
(
ptr->slaveData_[proci],
ptr->sizes_[proci]
)
);
}
}
}
bool ok = writeFile
(
const_cast<char*>(obj.procData_[proci].cdata()),
obj.procData_[proci].size()
ptr->comm_,
ptr->objectType_,
ptr->pathName_,
ptr->data_,
ptr->sizes_,
slaveData,
ptr->streamOpt_,
ptr->atomic_,
ptr->append_,
ptr->headerEntries_
);
}
if (!ok)
{
FatalIOErrorInFunction(ptr->pathName_)
<< "Failed writing " << ptr->pathName_
<< exit(FatalIOError);
}
bool ok = writeFile
(
obj.comm_,
obj.objectType_,
obj.pathName_,
obj.localData_,
obj.sizes_,
procData,
obj.streamOpt_,
obj.atomic_,
obj.append_,
obj.headerEntries_
);
if (!ok)
{
FatalIOErrorInFunction(obj.pathName_)
<< "Failed writing " << obj.pathName_
<< exit(FatalIOError);
delete ptr;
}
//sleep(1);
}
@ -231,14 +248,14 @@ void Foam::OFstreamCollator::waitForBufferSpace(const off_t wantedSize) const
{
while (true)
{
// The pending output size(s)
// Count files to be written
off_t totalSize = 0;
{
std::lock_guard<std::mutex> guard(mutex_);
for (const writeData* ptr : objects_)
forAllConstIters(objects_, iter)
{
if (ptr) totalSize += ptr->size();
totalSize += iter()->size();
}
}
@ -270,7 +287,17 @@ void Foam::OFstreamCollator::waitForBufferSpace(const off_t wantedSize) const
Foam::OFstreamCollator::OFstreamCollator(const off_t maxBufferSize)
:
OFstreamCollator(maxBufferSize, UPstream::worldComm)
maxBufferSize_(maxBufferSize),
threadRunning_(false),
localComm_(UPstream::worldComm),
threadComm_
(
UPstream::allocateCommunicator
(
localComm_,
labelRange(UPstream::nProcs(localComm_))
)
)
{}
@ -285,7 +312,6 @@ Foam::OFstreamCollator::OFstreamCollator
localComm_(comm),
threadComm_
(
// dupComm
UPstream::allocateCommunicator
(
localComm_,
@ -319,7 +345,7 @@ bool Foam::OFstreamCollator::write
(
const word& objectType,
const fileName& fName,
DynamicList<char>&& localData,
const string& data,
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
@ -329,109 +355,78 @@ bool Foam::OFstreamCollator::write
{
// Determine (on master) sizes to receive. Note: do NOT use thread
// communicator
const labelList recvSizes
(
UPstream::listGatherValues<label>(localData.size(), localComm_)
);
labelList recvSizes;
decomposedBlockData::gather(localComm_, label(data.size()), recvSizes);
off_t totalSize = 0;
label maxLocalSize = 0;
if (UPstream::master(localComm_))
{
for (const label recvSize : recvSizes)
if (UPstream::master(localComm_))
{
totalSize += recvSize;
maxLocalSize = max(maxLocalSize, recvSize);
for (const label recvSize : recvSizes)
{
totalSize += recvSize;
maxLocalSize = max(maxLocalSize, recvSize);
}
}
Pstream::broadcasts(localComm_, totalSize, maxLocalSize);
}
Pstream::broadcasts(localComm_, totalSize, maxLocalSize);
// Determine how things will be gathered and written...
enum class dispatchModes { GATHER_WRITE, PREFETCH_THREADED, FULL_THREADED };
dispatchModes dispatch(dispatchModes::GATHER_WRITE);
if (!useThread || maxBufferSize_ == 0 || maxLocalSize > maxBufferSize_)
{
dispatch = dispatchModes::GATHER_WRITE;
}
else if (totalSize <= maxBufferSize_)
{
// Total size can be stored locally
// - gather all data now and only do the writing in the thread
dispatch = dispatchModes::PREFETCH_THREADED;
}
else
{
// Gather data and write in the thread
dispatch = dispatchModes::FULL_THREADED;
if (!UPstream::haveThreads())
{
WarningInFunction
<< "MPI not initialized with thread support." << nl
<< " maxThreadFileBufferSize = 0 to disable threading" << nl
<< " or maxThreadFileBufferSize > " << totalSize
<< " to collate before threaded writing." << nl << nl;
dispatch = dispatchModes::GATHER_WRITE;
}
}
// -----------
// Dispatching
// -----------
if (dispatch == dispatchModes::GATHER_WRITE)
{
if (debug)
{
Pout<< "OFstreamCollator : non-thread gather/write "
<< "(local comm: " << localComm_ << ") of "
<< fName << endl;
Pout<< "OFstreamCollator : non-thread gather and write of " << fName
<< " using local comm " << localComm_ << endl;
}
// Direct collating and writing (so master blocks until all written!)
const PtrList<SubList<char>> dummySlaveData;
return writeFile
(
localComm_,
objectType,
fName,
localData,
data,
recvSizes,
UList<stdFoam::span<char>>(), // dummy proc data
dummySlaveData,
streamOpt,
atomic,
append,
headerEntries
);
}
else if (dispatch == dispatchModes::PREFETCH_THREADED)
else if (totalSize <= maxBufferSize_)
{
// Total size can be stored locally so receive all data now and only
// do the writing in the thread
if (debug)
{
Pout<< "OFstreamCollator : non-thread gather; thread write of "
<< fName << endl;
}
if (UPstream::master(localComm_))
if (Pstream::master(localComm_))
{
waitForBufferSpace(totalSize);
}
std::unique_ptr<writeData> fileAndDataPtr
// Receive in chunks of labelMax (2^31-1) since this is the maximum
// size that a List can be
autoPtr<writeData> fileAndDataPtr
(
new writeData
(
threadComm_, // Note: comm not actually used anymore
objectType,
fName,
(
Pstream::master(localComm_)
? data // Only used on master
: string::null
),
recvSizes,
streamOpt,
atomic,
@ -439,81 +434,63 @@ bool Foam::OFstreamCollator::write
headerEntries
)
);
auto& fileAndData = *fileAndDataPtr;
writeData& fileAndData = fileAndDataPtr();
List<List<char>>& procData = fileAndData.procData_;
if (UPstream::master(localComm_))
{
// Move in local data (master only!)
fileAndData.transfer(localData);
PtrList<List<char>>& slaveData = fileAndData.slaveData_;
// Storage for receive data
procData.resize(UPstream::nProcs(localComm_));
for (const int proci : UPstream::subProcs(localComm_))
{
procData[proci].resize(recvSizes[proci]);
}
}
else if (UPstream::is_subrank(localComm_))
{
// Requires a size for decomposedBlockData::writeBlocks() logic
procData.resize(UPstream::nProcs(localComm_));
}
UList<char> slice(const_cast<char*>(data.data()), label(data.size()));
slaveData.setSize(recvSizes.size());
// Gather all data onto master. Is done in local communicator since
// not in write thread.
// not in write thread. Note that we do not store in contiguous
// buffer since that would limit to 2G chars.
const label startOfRequests = UPstream::nRequests();
if (UPstream::master(localComm_))
if (Pstream::master(localComm_))
{
for (const int proci : UPstream::subProcs(localComm_))
for (label proci = 1; proci < slaveData.size(); proci++)
{
List<char>& procSlice = procData[proci];
if (procSlice.empty()) continue;
slaveData.set(proci, new List<char>(recvSizes[proci]));
UIPstream::read
(
UPstream::commsTypes::nonBlocking,
proci,
procSlice.data_bytes(),
procSlice.size_bytes(),
UPstream::msgType(),
slaveData[proci].data(),
slaveData[proci].size_bytes(),
Pstream::msgType(),
localComm_
);
}
}
else if (UPstream::is_subrank(localComm_) && !localData.empty())
else
{
if
(
!UOPstream::write
(
UPstream::commsTypes::nonBlocking,
UPstream::masterNo(),
localData.cdata_bytes(),
localData.size_bytes(),
UPstream::msgType(),
0,
slice.cdata(),
slice.size_bytes(),
Pstream::msgType(),
localComm_
)
)
{
FatalErrorInFunction
<< "Cannot send outgoing message (size: "
<< localData.size() << ") to master" << nl
<< "Cannot send outgoing message. "
<< "to:" << 0 << " nBytes:"
<< label(slice.size_bytes())
<< Foam::abort(FatalError);
}
}
UPstream::waitRequests(startOfRequests);
// The localData has been moved (master) or communicated
localData.clearStorage();
{
std::lock_guard<std::mutex> guard(mutex_);
// Append to thread buffer (as FIFO), take ownership
objects_.push_back(fileAndDataPtr.release());
// Append to thread buffer
objects_.push(fileAndDataPtr.ptr());
// Start thread if not running
if (!threadRunning_)
@ -540,46 +517,49 @@ bool Foam::OFstreamCollator::write
return true;
}
else if (dispatch == dispatchModes::FULL_THREADED)
else
{
if (debug)
{
Pout<< "OFstreamCollator : thread gather and write "
<< "(thread comm: " << threadComm_
<< ") of " << fName << endl;
Pout<< "OFstreamCollator : thread gather and write of " << fName
<< " using communicator " << threadComm_ << endl;
}
if (UPstream::master(localComm_))
if (!UPstream::haveThreads())
{
waitForBufferSpace(localData.size());
FatalErrorInFunction
<< "mpi does not seem to have thread support."
<< " Make sure to set buffer size 'maxThreadFileBufferSize'"
<< " to at least " << totalSize
<< " to be able to do the collating before threading."
<< exit(FatalError);
}
std::unique_ptr<writeData> fileAndDataPtr
(
new writeData
(
threadComm_,
objectType,
fName,
recvSizes,
streamOpt,
atomic,
append,
headerEntries
)
);
// Move in local data (all procs)
fileAndDataPtr->transfer(localData);
if (Pstream::master(localComm_))
{
waitForBufferSpace(data.size());
}
{
std::lock_guard<std::mutex> guard(mutex_);
// Append to thread buffer (as FIFO), take ownership
objects_.push_back(fileAndDataPtr.release());
// Note: no proc data provided
// Push all file info on buffer. Note that no slave data provided
// so it will trigger communication inside the thread
objects_.push
(
new writeData
(
threadComm_,
objectType,
fName,
data,
recvSizes,
streamOpt,
atomic,
append,
headerEntries
)
);
if (!threadRunning_)
{
@ -604,12 +584,6 @@ bool Foam::OFstreamCollator::write
return true;
}
FatalErrorInFunction
<< "Unknown dispatch mode: " << int(dispatch)
<< " - programming error?" << abort(FatalError);
return false;
}
@ -617,7 +591,7 @@ void Foam::OFstreamCollator::waitAll()
{
// Wait for all buffer space to be available i.e. wait for all jobs
// to finish
if (UPstream::master(localComm_))
if (Pstream::master(localComm_))
{
if (debug)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -51,13 +51,13 @@ SourceFiles
#ifndef Foam_OFstreamCollator_H
#define Foam_OFstreamCollator_H
#include "IOstream.H"
#include "List.H"
#include "CircularBuffer.H" // As FIFO
#include "dictionary.H"
#include <mutex>
#include <thread>
#include <mutex>
#include "IOstream.H"
#include "labelList.H"
#include "FIFOStack.H"
#include "SubList.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -72,33 +72,26 @@ class OFstreamCollator
{
// Private Class
//- Holds data to be written
struct writeData
{
const label comm_;
const word objectType_;
const fileName pathName_;
DynamicList<char> localData_;
const string data_;
const labelList sizes_;
List<List<char>> procData_;
PtrList<List<char>> slaveData_;
const IOstreamOption streamOpt_;
IOstreamOption::atomicType atomic_;
IOstreamOption::appendType append_;
const dictionary headerEntries_;
writeData() = delete; // No default construct
writeData(const writeData&) = delete; // No copy construct
writeData(writeData&&) = delete; // No move construct
void operator=(const writeData&) = delete; // No copy assign
void operator=(writeData&&) = delete; // No move assign
//- Construct without local data
writeData
(
const label comm,
const word& objectType,
const fileName& pathName,
const labelUList& sizes,
const string& data,
const labelList& sizes,
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
@ -108,30 +101,27 @@ class OFstreamCollator
comm_(comm),
objectType_(objectType),
pathName_(pathName),
localData_(),
data_(data),
sizes_(sizes),
procData_(),
slaveData_(),
streamOpt_(streamOpt),
atomic_(atomic),
append_(append),
headerEntries_(headerEntries)
{}
//- Move reset local data
void transfer(DynamicList<char>& localData)
{
localData_.transfer(localData);
}
//- The (approximate) size of local + any optional proc data
//- The (approximate) size of master + any optional slave data
off_t size() const
{
off_t total = localData_.size();
for (const auto& data : procData_)
off_t totalSize = data_.size();
forAll(slaveData_, i)
{
total += data.size();
if (slaveData_.set(i))
{
totalSize += slaveData_[i].size();
}
}
return total;
return totalSize;
}
};
@ -145,8 +135,8 @@ class OFstreamCollator
std::unique_ptr<std::thread> thread_;
//- FIFO of files to write and their contents
CircularBuffer<writeData*> objects_;
//- Stack of files to write + contents
FIFOStack<writeData*> objects_;
//- Whether thread is running (and not exited)
bool threadRunning_;
@ -166,9 +156,9 @@ class OFstreamCollator
const label comm,
const word& objectType,
const fileName& fName,
const UList<char>& localData,
const string& masterData,
const labelUList& recvSizes,
const UList<stdFoam::span<char>>& procData,
const UPtrList<SubList<char>>& slaveData,
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
@ -191,8 +181,7 @@ public:
// Constructors
//- Construct from buffer size (0 = do not use thread)
//- and with worldComm
//- Construct from buffer size. 0 = do not use thread
explicit OFstreamCollator(const off_t maxBufferSize);
//- Construct from buffer size (0 = do not use thread)
@ -206,15 +195,14 @@ public:
// Member Functions
//- Write file with contents, possibly taking ownership of the
//- content.
// Blocks until write-thread has space available
//- Write file with contents.
// Blocks until writethread has space available
// (total file sizes < maxBufferSize)
bool write
(
const word& objectType,
const fileName& fName,
DynamicList<char>&& localData,
const fileName&,
const string& data,
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
@ -222,37 +210,6 @@ public:
const dictionary& headerEntries = dictionary::null
);
//- Write file with contents.
FOAM_DEPRECATED_FOR(2023-09, "use write with movable content")
bool write
(
const word& objectType,
const fileName& fName,
const std::string& s,
IOstreamOption streamOpt,
IOstreamOption::atomicType atomic,
IOstreamOption::appendType append,
const bool useThread = true,
const dictionary& headerEntries = dictionary::null
)
{
DynamicList<char> charData;
charData.setCapacity(s.size());
std::copy(s.begin(), s.end(), charData.begin());
return write
(
objectType,
fName,
std::move(charData),
streamOpt,
atomic,
append,
useThread,
headerEntries
);
}
//- Wait for all thread actions to have finished
void waitAll();
};

View File

@ -59,7 +59,7 @@ namespace fileOperations
float collatedFileOperation::maxThreadFileBufferSize
(
debug::floatOptimisationSwitch("maxThreadFileBufferSize", 0)
debug::floatOptimisationSwitch("maxThreadFileBufferSize", 1e9)
);
registerOptSwitch
(
@ -90,40 +90,25 @@ void Foam::fileOperations::collatedFileOperation::printBanner
DetailInfo
<< "I/O : " << this->type();
if (mag(maxThreadFileBufferSize) > 1)
if (maxThreadFileBufferSize == 0)
{
// FUTURE: deprecate or remove threading?
DetailInfo
<< " [threaded] (maxThreadFileBufferSize = "
<< maxThreadFileBufferSize << ")." << nl
<< " Requires buffer large enough to collect all data"
" or MPI thread support." << nl
<< " To avoid MPI threading [slow], set"
" (maxThreadFileBufferSize = 0) in" << nl
<< " OpenFOAM etc/controlDict" << endl;
<< " [unthreaded] (maxThreadFileBufferSize = 0)." << nl
<< " Writing may be slow for large file sizes."
<< endl;
}
else
{
DetailInfo
<< " [unthreaded] (maxThreadFileBufferSize = 0)." << nl;
if (mag(maxMasterFileBufferSize) < 1)
{
DetailInfo
<< " With scheduled transfer" << nl;
}
else if (maxMasterFileBufferSize >= 1)
{
DetailInfo
<< " With non-blocking transfer,"
" buffer-size = " << maxMasterFileBufferSize << nl;
}
else
{
DetailInfo
<< " With non-blocking transfer,"
" minimal buffer size" << nl;
}
<< " [threaded] (maxThreadFileBufferSize = "
<< maxThreadFileBufferSize << ")." << nl
<< " Requires buffer large enough to collect all data"
" or thread support" << nl
<< " enabled in MPI. If MPI thread support cannot be"
" enabled, deactivate" << nl
<< " threading by setting maxThreadFileBufferSize"
" to 0 in" << nl
<< " OpenFOAM etc/controlDict" << endl;
}
if (withRanks)
@ -470,7 +455,7 @@ bool Foam::fileOperations::collatedFileOperation::writeObject
{
// Re-check static maxThreadFileBufferSize variable to see
// if needs to use threading
const bool useThread = (mag(maxThreadFileBufferSize) > 1);
const bool useThread = (maxThreadFileBufferSize != 0);
if (debug)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2020-2023 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,7 +41,7 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
const bool useThread
)
:
OCharStream(streamOpt),
OStringStream(streamOpt),
writer_(writer),
pathName_(pathName),
atomic_(atomic),
@ -74,22 +74,11 @@ Foam::threadedCollatedOFstream::threadedCollatedOFstream
Foam::threadedCollatedOFstream::~threadedCollatedOFstream()
{
commit();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::threadedCollatedOFstream::commit()
{
// Take ownership of serialized content, without copying or reallocation
DynamicList<char> charData(OCharStream::release());
writer_.write
(
decomposedBlockData::typeName,
pathName_,
std::move(charData),
str(),
IOstreamOption(IOstreamOption::BINARY, version(), compression_),
atomic_,
IOstreamOption::NON_APPEND,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2021-2023 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,7 +39,7 @@ SourceFiles
#define Foam_threadedCollatedOFstream_H
#include "dictionary.H"
#include "SpanStream.H"
#include "StringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +55,7 @@ class OFstreamCollator;
class threadedCollatedOFstream
:
public OCharStream
public OStringStream
{
// Private Data
@ -78,11 +78,6 @@ class threadedCollatedOFstream
dictionary headerEntries_;
// Private Member Functions
//- Commit buffered information
void commit();
public:
// Constructors
@ -107,14 +102,12 @@ public:
);
//- Destructor - commits buffered information to file
//- Destructor
~threadedCollatedOFstream();
// Member Functions
// -> using OCharStream::rewind
//- Define the header entries for the data block(s)
void setHeaderEntries(const dictionary& dict);
};

View File

@ -127,7 +127,7 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
const lduAddressing& addr = mesh.lduAddr();
lduInterfacePtrsList interfaces = mesh.interfaces();
const label myProci = UPstream::myProcNo(mesh.comm());
const label myProcID = UPstream::myProcNo(mesh.comm());
const globalIndex globalNumbering
(
@ -138,7 +138,11 @@ Foam::labelListList Foam::GAMGProcAgglomeration::globalCellCells
const labelList globalIndices
(
Foam::identity(globalNumbering.range(myProci))
identity
(
globalNumbering.localSize(myProcID),
globalNumbering.localStart(myProcID)
)
);
// Get the interface cells

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2023 OpenCFD Ltd.
Copyright (C) 2023-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -310,13 +310,7 @@ void Foam::GAMGSolver::gatherMatrices
const auto& boundaryMap = agglomeration_.boundaryMap(destLevel);
// Use PstreamBuffers
PstreamBuffers pBufs
(
UPstream::commsTypes::nonBlocking,
UPstream::msgType(),
comm
);
PstreamBuffers pBufs(comm);
// Send to master
if (!UPstream::master(comm))
@ -332,35 +326,49 @@ void Foam::GAMGSolver::gatherMatrices
const label proci = UPstream::myProcNo(comm);
labelList validInterface(interfaces.size(), -1);
// All interfaceBouCoeffs need to be sent across
bitSet validCoeffs(interfaces.size());
forAll(interfaceBouCoeffs, intI)
{
if (interfaceBouCoeffs.set(intI))
{
validCoeffs.set(intI);
}
}
// Only preserved interfaces need to be sent across
bitSet validInterface(interfaces.size());
forAll(interfaces, intI)
{
const label allIntI = boundaryMap[proci][intI];
if (interfaces.set(intI) && allIntI != -1)
{
validInterface[intI] = intI;
validInterface.set(intI);
}
}
UOPstream toMaster(UPstream::masterNo(), pBufs);
toMaster<< mat << token::SPACE << validInterface;
toMaster
<< mat
<< token::SPACE << validCoeffs
<< token::SPACE << validInterface;
forAll(validInterface, intI)
for (const label intI : validCoeffs)
{
if (validInterface[intI] != -1)
{
const auto& interface = refCast<const GAMGInterfaceField>
(
interfaces[intI]
);
toMaster
<< interfaceBouCoeffs[intI]
<< interfaceIntCoeffs[intI];
}
for (const label intI : validInterface)
{
const auto& interface = refCast<const GAMGInterfaceField>
(
interfaces[intI]
);
toMaster
<< interfaceBouCoeffs[intI]
<< interfaceIntCoeffs[intI]
<< interface.type();
interface.write(toMaster);
}
toMaster << interface.type();
interface.write(toMaster);
}
}
@ -376,10 +384,10 @@ void Foam::GAMGSolver::gatherMatrices
lduInterfacePtrsList destInterfaces = destMesh.interfaces();
// Master.
otherMats.setSize(nProcs-1);
otherBouCoeffs.setSize(nProcs-1);
otherIntCoeffs.setSize(nProcs-1);
otherInterfaces.setSize(nProcs-1);
otherMats.resize(nProcs-1);
otherBouCoeffs.resize(nProcs-1);
otherIntCoeffs.resize(nProcs-1);
otherInterfaces.resize(nProcs-1);
for (const int proci : UPstream::subProcs(comm))
{
@ -389,60 +397,41 @@ void Foam::GAMGSolver::gatherMatrices
otherMats.set(otherI, new lduMatrix(destMesh, fromProc));
// Receive number of/valid interfaces
// >= 0 : remote interface index
// -1 : invalid interface
const labelList validInterface(fromProc);
// Receive bit-sets of valid interfaceCoeffs/interfaces
const bitSet validCoeffs(fromProc);
const bitSet validInterface(fromProc);
otherBouCoeffs.set
(
otherI,
new FieldField<Field, scalar>(validInterface.size())
);
otherIntCoeffs.set
(
otherI,
new FieldField<Field, scalar>(validInterface.size())
);
otherInterfaces.set
(
otherI,
new PtrList<lduInterfaceField>(validInterface.size())
);
otherBouCoeffs.emplace_set(otherI, validCoeffs.size());
otherIntCoeffs.emplace_set(otherI, validCoeffs.size());
otherInterfaces.emplace_set(otherI, validInterface.size());
forAll(validInterface, intI)
// Receive individual interface contributions
for (const label intI : validCoeffs)
{
if (validInterface[intI] != -1)
{
otherBouCoeffs[otherI].set
(
intI,
new scalarField(fromProc)
);
otherIntCoeffs[otherI].set
(
intI,
new scalarField(fromProc)
);
otherBouCoeffs[otherI].emplace_set(intI, fromProc);
otherIntCoeffs[otherI].emplace_set(intI, fromProc);
}
const word coupleType(fromProc);
// Receive individual interface contributions
for (const label intI : validInterface)
{
const word coupleType(fromProc);
const label allIntI = boundaryMap[proci][intI];
const label allIntI = boundaryMap[proci][intI];
otherInterfaces[otherI].set
otherInterfaces[otherI].set
(
intI,
GAMGInterfaceField::New
(
intI,
GAMGInterfaceField::New
coupleType,
refCast<const GAMGInterface>
(
coupleType,
refCast<const GAMGInterface>
(
destInterfaces[allIntI]
),
fromProc
).release()
);
}
destInterfaces[allIntI]
),
fromProc
).release()
);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -133,7 +133,7 @@ Foam::schemesLookup::schemesLookup
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
IOobjectOption::NO_WRITE
),
fallback
),
@ -153,18 +153,23 @@ Foam::schemesLookup::schemesLookup
fluxRequiredDefault_(false),
steady_(false)
{
// Treat as MUST_READ_IF_MODIFIED whenever possible
// Treat as READ_MODIFIED whenever possible
if
(
readOpt() == IOobject::MUST_READ
readOpt() == IOobjectOption::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readOpt(IOobject::MUST_READ_IF_MODIFIED);
readOpt(IOobjectOption::READ_MODIFIED);
addWatch();
}
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
// Update: from values read or copied in
if
(
readOpt() == IOobjectOption::READ_MODIFIED
|| !dictionary::empty()
)
{
read(selectedDict());
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -174,7 +174,7 @@ Foam::solution::solution
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
IOobjectOption::NO_WRITE
),
fallback
),
@ -184,18 +184,23 @@ Foam::solution::solution
eqnRelaxDict_(),
solvers_()
{
// Treat as MUST_READ_IF_MODIFIED whenever possible
// Treat as READ_MODIFIED whenever possible
if
(
readOpt() == IOobject::MUST_READ
readOpt() == IOobjectOption::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readOpt(IOobject::MUST_READ_IF_MODIFIED);
readOpt(IOobjectOption::READ_MODIFIED);
addWatch();
}
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
// Update: from values read or copied in
if
(
readOpt() == IOobjectOption::READ_MODIFIED
|| !dictionary::empty()
)
{
read(selectedDict());
}

View File

@ -105,14 +105,12 @@ Foam::labelListList Foam::lduPrimitiveMesh::globalCellCells
const lduAddressing& addr = mesh.lduAddr();
lduInterfacePtrsList interfaces = mesh.interfaces();
const label myProci = UPstream::myProcNo(mesh.comm());
const labelList globalIndices
(
Foam::identity
identity
(
addr.size(),
globalNumbering.localStart(myProci)
globalNumbering.localStart(UPstream::myProcNo(mesh.comm()))
)
);

View File

@ -123,13 +123,13 @@ bool Foam::polyMesh::checkFaceOrthogonality
reduce(severeNonOrth, sumOp<label>());
reduce(errorNonOrth, sumOp<label>());
const scalar maxNonOrth = radToDeg(::acos(clamp(minDDotS, -1, 1)));
const scalar aveNonOrth = radToDeg(::acos(clamp(sumDDotS/nSummed, -1, 1)));
dictionary& meshDict = const_cast<dictionary&>(data().meshDict());
if (nSummed > 0)
{
scalar maxNonOrth = radToDeg(::acos(clamp(minDDotS, -1, 1)));
scalar aveNonOrth = radToDeg(::acos(clamp(sumDDotS/nSummed, -1, 1)));
meshDict.set("maxNonOrth", maxNonOrth);
meshDict.set("aveNonOrth", aveNonOrth);

View File

@ -289,12 +289,10 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs)
label vertI = 0;
const vectorField::subField ownFaceCentres = faceCentres();
forAll(ownFaceCentres, facej)
forAll(faceCentres(), facej)
{
const point& c0 = neighbFaceCentres_[facej];
const point& c1 = ownFaceCentres[facej];
const point& c1 = faceCentres()[facej];
writeOBJ(ccStr, c0, c1, vertI);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -133,7 +133,9 @@ public:
//- Return clone
autoPtr<coordinateRotation> clone() const
{
return coordinateRotation::Clone(*this);
return
autoPtr<coordinateRotation>::NewFrom
<coordinateRotations::euler>(*this);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -115,7 +115,9 @@ public:
//- Return clone
autoPtr<coordinateRotation> clone() const
{
return coordinateRotation::Clone(*this);
return
autoPtr<coordinateRotation>::NewFrom
<coordinateRotations::starcd>(*this);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -144,7 +144,9 @@ public:
//- Return clone
autoPtr<coordinateRotation> clone() const
{
return coordinateRotation::Clone(*this);
return
autoPtr<coordinateRotation>::NewFrom
<coordinateRotations::axes>(*this);
}

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