Compare commits

..

6 Commits

Author SHA1 Message Date
1307c4eb2e ENH: Propagated AMI API code changes across dependant code 2024-05-03 17:26:00 +01:00
de8dd7a5cf WIP: AMI - knock out connections with invalid interpolated delta vectors 2024-05-03 17:13:23 +01:00
a083ebb7bf ENH: AMI - propagate lowWeightOption 2024-05-03 17:08:01 +01:00
279abca7fa ENH: cyclicAMI - enable user to select low-weight correction
Example

    lowWeightOption assign;

Options:

- none   : no-op
- assign : set value when sum of weights < threshold (same as v2312) [DEFAULT]
- blend  : linear blend of AMI interpolated value plus (1 - sum_of_weights)
           times (supplied) default value
2024-05-03 16:37:33 +01:00
8c89c8f417 ENH: Refactored low-level AMI code to use new field-based ops 2024-05-03 16:10:52 +01:00
e44184e626 ENH: AMI - added new set of field-based AMI operations 2024-05-03 16:06:22 +01:00
786 changed files with 7334 additions and 11103 deletions

View File

@ -1,2 +1,2 @@
api=2402
api=2401
patch=240220

View File

@ -7,6 +7,7 @@ wclean libso surfaceTensionModels
wclean libso VoFphaseCompressibleTurbulenceModels
wclean
wclean compressibleInterDyMFoam
wclean compressibleInterFilmFoam
wclean compressibleInterIsoFoam

View File

@ -8,6 +8,7 @@ wmake $targetType surfaceTensionModels
wmake $targetType VoFphaseCompressibleTurbulenceModels
wmake $targetType
wmake $targetType compressibleInterDyMFoam
wmake $targetType compressibleInterFilmFoam
wmake $targetType compressibleInterIsoFoam
wmake $targetType overCompressibleInterDyMFoam

View File

@ -1,25 +1,21 @@
EXE_INC = \
-I../VoF \
-ItwoPhaseMixtureThermo \
-IVoFphaseCompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-IVoFphaseCompressibleTurbulenceModels/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \

View File

@ -0,0 +1,3 @@
compressibleInterDyMFoam.C
EXE = $(FOAM_APPBIN)/compressibleInterDyMFoam

View File

@ -0,0 +1,35 @@
EXE_INC = \
-I.. \
-I../../VoF \
-I../twoPhaseMixtureThermo \
-I../VoFphaseCompressibleTurbulenceModels/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
-I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicFvMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-ltwoPhaseMixture \
-ltwoPhaseProperties \
-linterfaceProperties \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lthermoTools \
-lVoFphaseCompressibleTurbulenceModels \
-ldynamicMesh \
-ldynamicFvMesh

View File

@ -0,0 +1,43 @@
volScalarField::Internal Sp
(
IOobject
(
"Sp",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
volScalarField::Internal Su
(
IOobject
(
"Su",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar(dgdt.dimensions(), Zero)
);
forAll(dgdt, celli)
{
if (dgdt[celli] > 0.0 && alpha1[celli] > 0.0)
{
Sp[celli] -= dgdt[celli]*alpha1[celli];
Su[celli] += dgdt[celli]*alpha1[celli];
}
else if (dgdt[celli] < 0.0 && alpha1[celli] < 1.0)
{
Sp[celli] += dgdt[celli]*(1.0 - alpha1[celli]);
}
}
volScalarField::Internal divU
(
mesh.moving()
? fvc::div(phiCN() + mesh.phi())
: fvc::div(phiCN())
);

View File

@ -0,0 +1,190 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 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
compressibleInterDyMFoam
Description
Solver for two compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
#include "CrankNicolsonDdtScheme.H"
#include "subCycle.H"
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Solver for two compressible, non-isothermal immiscible fluids"
" using VOF phase-fraction based interface capturing.\n"
"With optional mesh motion and mesh topology changes including"
" adaptive re-meshing."
);
#include "postProcess.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createFields.H"
#include "createUf.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readDyMControls.H"
// Store divU and divUp from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
volScalarField divUp("divUp", fvc::div(fvc::absolute(phi, U), p));
if (LTS)
{
#include "setRDeltaT.H"
}
else
{
#include "CourantNo.H"
#include "alphaCourantNo.H"
#include "setDeltaT.H"
}
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
mesh.update();
if (mesh.changing())
{
MRF.update();
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
}
if ((mesh.changing() && correctPhi))
{
// Calculate absolute flux from the mapped surface velocity
phi = mesh.Sf() & Uf;
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct();
}
if (mesh.changing() && checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"
turbulence.correctPhasePhi();
#include "UEqn.H"
#include "TEqn.H"
// --- Pressure corrector loop
while (pimple.correct())
{
#include "pEqn.H"
}
if (pimple.turbCorr())
{
turbulence.correct();
}
}
rho = alpha1*rho1 + alpha2*rho2;
// Correct p_rgh for consistency with p and the updated densities
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
runTime.write();
runTime.printExecutionTime(Info);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -8,4 +8,6 @@ CorrectPhi
pimple
);
//***HGW phi.oldTime() = phi;
#include "continuityErrs.H"

View File

@ -0,0 +1,145 @@
{
volScalarField rAU("rAU", 1.0/UEqn.A());
surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU));
volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh));
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf))
);
MRF.makeRelative(phiHbyA);
surfaceScalarField phig
(
(
mixture.surfaceTensionForce()
- ghf*fvc::snGrad(rho)
)*rAUf*mesh.magSf()
);
phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phiHbyA, U);
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
if (pimple.transonic())
{
#include "rhofs.H"
surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi);
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
p_rghEqnComp1 =
pos(alpha1)
*(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
)/rho1
- fvc::ddt(alpha1) - fvc::div(alphaPhi1)
+ (alpha1/rho1)
*correction
(
psi1*fvm::ddt(p_rgh)
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
)
);
p_rghEqnComp1.ref().relax();
p_rghEqnComp2 =
pos(alpha2)
*(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
)/rho2
- fvc::ddt(alpha2) - fvc::div(alphaPhi2)
+ (alpha2/rho2)
*correction
(
psi2*fvm::ddt(p_rgh)
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
p_rghEqnComp1 =
fvc::ddt(rho1) + psi1*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho1) - fvc::Sp(fvc::div(phi), rho1);
p_rghEqnComp2 =
fvc::ddt(rho2) + psi2*correction(fvm::ddt(p_rgh))
+ fvc::div(phi, rho2) - fvc::Sp(fvc::div(phi), rho2);
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
while (pimple.correctNonOrthogonal())
{
fvScalarMatrix p_rghEqnIncomp
(
fvc::div(phiHbyA)
- fvm::laplacian(rAUf, p_rgh)
);
solve
(
(
(max(alpha1, scalar(0))/rho1)*p_rghEqnComp1()
+ (max(alpha2, scalar(0))/rho2)*p_rghEqnComp2()
)
+ p_rghEqnIncomp,
p_rgh.select(pimple.finalInnerIter())
);
if (pimple.finalNonOrthogonalIter())
{
p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin);
p_rgh = p - (alpha1*rho1 + alpha2*rho2)*gh;
dgdt =
(
pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2
- pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1
);
phi = phiHbyA + p_rghEqnIncomp.flux();
U = HbyA
+ rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf);
U.correctBoundaryConditions();
fvOptions.correct(U);
}
}
{
Uf = fvc::interpolate(U);
surfaceVectorField n(mesh.Sf()/mesh.magSf());
Uf += n*(fvc::absolute(phi, U)/mesh.magSf() - (n & Uf));
}
// Update densities from change in p_rgh
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));
rho = alpha1*rho1 + alpha2*rho2;
// Correct p_rgh for consistency with p and the updated densities
p = max(p_rgh + rho*gh, pMin);
p_rgh = p - rho*gh;
p_rgh.correctBoundaryConditions();
K = 0.5*magSqr(U);
}

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2024 OpenCFD Ltd.
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) OpenCFD OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,9 +32,7 @@ Group
Description
Solver for two compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach,
with optional mesh motion and mesh topology changes including adaptive
re-meshing.
(volume of fluid) phase-fraction based interface capturing approach.
The momentum and other fluid properties are of the "mixture" and a single
momentum equation is solved.
@ -47,7 +45,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
@ -56,7 +53,6 @@ Description
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,31 +70,30 @@ int main(int argc, char *argv[])
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "createFields.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
#include "createUfIfPresent.H"
volScalarField& p = mixture.p();
volScalarField& T = mixture.T();
const volScalarField& psi1 = mixture.thermo1().psi();
const volScalarField& psi2 = mixture.thermo2().psi();
if (!LTS)
{
#include "readTimeControls.H"
#include "CourantNo.H"
#include "setInitialDeltaT.H"
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
#include "readDyMControls.H"
// Store divU from the previous mesh so that it can be mapped
// and used in correctPhi to ensure the corrected phi has the
// same divergence
volScalarField divU("divU0", fvc::div(fvc::absolute(phi, U)));
#include "readTimeControls.H"
if (LTS)
{
@ -118,44 +113,6 @@ int main(int argc, char *argv[])
// --- Pressure-velocity PIMPLE corrector loop
while (pimple.loop())
{
if (pimple.firstIter() || moveMeshOuterCorrectors)
{
scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime();
mesh.update();
if (mesh.changing())
{
MRF.update();
Info<< "Execution time for mesh.update() = "
<< runTime.elapsedCpuTime() - timeBeforeMeshUpdate
<< " s" << endl;
gh = (g & mesh.C()) - ghRef;
ghf = (g & mesh.Cf()) - ghRef;
if (correctPhi)
{
// Calculate absolute flux
// from the mapped surface velocity
phi = mesh.Sf() & Uf();
#include "correctPhi.H"
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phi, U);
mixture.correct();
}
if (checkMeshCourantNo)
{
#include "meshCourantNo.H"
}
}
}
#include "alphaControls.H"
#include "compressibleAlphaEqnSubCycle.H"

View File

@ -6,7 +6,7 @@
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi, Uf))
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi))
);
MRF.makeRelative(phiHbyA);
@ -23,9 +23,6 @@
// Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
// Make the fluxes relative to the mesh motion
fvc::makeRelative(phiHbyA, U);
tmp<fvScalarMatrix> p_rghEqnComp1;
tmp<fvScalarMatrix> p_rghEqnComp2;
@ -37,7 +34,8 @@
surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi);
p_rghEqnComp1 =
(
pos(alpha1)
*(
(
fvc::ddt(alpha1, rho1) + fvc::div(alphaPhi1*rho1f)
- (fvOptions(alpha1, mixture.thermo1().rho())&rho1)
@ -50,9 +48,11 @@
+ fvm::div(phid1, p_rgh) - fvm::Sp(fvc::div(phid1), p_rgh)
)
);
p_rghEqnComp1.ref().relax();
p_rghEqnComp2 =
(
pos(alpha2)
*(
(
fvc::ddt(alpha2, rho2) + fvc::div(alphaPhi2*rho2f)
- (fvOptions(alpha2, mixture.thermo2().rho())&rho2)
@ -65,6 +65,7 @@
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
@ -93,21 +94,6 @@
);
}
if (mesh.moving())
{
p_rghEqnComp1.ref() += fvc::div(mesh.phi())*alpha1;
p_rghEqnComp2.ref() += fvc::div(mesh.phi())*alpha2;
}
p_rghEqnComp1.ref() *= pos(alpha1);
p_rghEqnComp2.ref() *= pos(alpha2);
if (pimple.transonic())
{
p_rghEqnComp1.ref().relax();
p_rghEqnComp2.ref().relax();
}
// Cache p_rgh prior to solve for density update
volScalarField p_rgh_0(p_rgh);
@ -145,9 +131,6 @@
}
}
// Correct Uf if the mesh is moving
fvc::correctUf(Uf, U, fvc::absolute(phi, U));
// Update densities from change in p_rgh
mixture.thermo1().correctRho(psi1*(p_rgh - p_rgh_0));
mixture.thermo2().correctRho(psi2*(p_rgh - p_rgh_0));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -62,7 +62,7 @@ scalar sumReduce
scalar procValue;
UIPstream::read
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
proci,
reinterpret_cast<char*>(&procValue),
sizeof(scalar),
@ -79,7 +79,7 @@ scalar sumReduce
{
UOPstream::write
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
proci,
reinterpret_cast<const char*>(&sum),
sizeof(scalar),
@ -93,7 +93,7 @@ scalar sumReduce
{
UOPstream::write
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
UPstream::masterNo(),
reinterpret_cast<const char*>(&localValue),
sizeof(scalar),
@ -105,7 +105,7 @@ scalar sumReduce
{
UIPstream::read
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
UPstream::masterNo(),
reinterpret_cast<char*>(&sum),
sizeof(scalar),

View File

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

View File

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

View File

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

View File

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

View File

@ -131,7 +131,7 @@ void testTransfer(const T& input)
for (const int proci : UPstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::buffered, proci);
OPstream os(UPstream::commsTypes::blocking, proci);
os << data;
}
}
@ -139,7 +139,7 @@ void testTransfer(const T& input)
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
os << data;
}
@ -169,7 +169,7 @@ void testTokenized(const T& data)
for (const int proci : UPstream::subProcs())
{
Perr<< "master sending to proc:" << proci << endl;
OPstream os(UPstream::commsTypes::buffered, proci);
OPstream os(UPstream::commsTypes::blocking, proci);
os << tok;
}
}
@ -177,7 +177,7 @@ void testTokenized(const T& data)
{
{
Perr<< "proc sending to master" << endl;
OPstream os(UPstream::commsTypes::buffered, UPstream::masterNo());
OPstream os(UPstream::commsTypes::blocking, UPstream::masterNo());
os << tok;
}

View File

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

View File

@ -44,7 +44,7 @@ Description
Format options:
\table
Property | Description | Required | Default
commsType | scheduled/nonBlocking/buffered | no | scheduled
commsType | blocking/nonBlocking/scheduled | no | scheduled
merge | Enable geometry/field merging | no | true
write | Write file(s) | no | false
narrow | Communicate with narrowed values | no | false

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,9 +35,6 @@ Description
#include "labelList.H"
#include "scalarList.H"
#include "DynamicList.H"
#include "labelField.H"
#include "scalarField.H"
#include "SubField.H"
#include "SpanStream.H"
#include "formattingEntry.H"
@ -93,7 +90,7 @@ int main(int argc, char *argv[])
{
// This also works, but not actually using the autoPtr directly
autoPtr<token::compound> ptr
autoPtr<token::Compound<labelList>> ptr
(
new token::Compound<labelList>(identity(10, -9))
);
@ -134,50 +131,44 @@ int main(int argc, char *argv[])
Info<< "resized: "
<< ctok1.info() << nl << ctok1 << endl;
const scalarList* listptr = ctok1.compoundToken().isA<scalarList>();
if (listptr)
{
// Using isA<> on compoundToken()
const auto* listptr = ctok1.compoundToken().isA<scalarList>();
if (listptr)
for (scalar& val : const_cast<scalarList&>(*listptr))
{
// sneaky, SubField bypasses const!
scalarField::subField fld(*listptr);
fld *= 5;
Info<< "multiplied List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
val *= 5;
}
Info<< "multiplied List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
}
listptr = ctok1.isCompound<scalarList>();
if (listptr)
{
// Using isCompound<...> - combined check
const auto* listptr = ctok1.isCompound<scalarList>();
if (listptr)
for (scalar& val : const_cast<scalarList&>(*listptr))
{
scalarField::subField fld(*listptr);
fld /= 2;
Info<< "divided List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
val /= 2;
}
Info<< "divided List<scalar>: "
<< ctok1.info() << nl << ctok1 << endl;
}
const labelList* listptr2 = ctok1.isCompound<labelList>();
if (listptr2)
{
// Using isCompound<...> - combined check
const auto* listptr = ctok1.isCompound<labelList>();
if (listptr)
for (label& val : const_cast<labelList&>(*listptr2))
{
labelField::subField fld(*listptr);
fld /= 2;
val /= 2;
}
Info<< "divided List<label>: "
<< ctok1.info() << nl << ctok1 << endl;
}
else
{
Info<< "compound is not List<label>" << nl;
}
Info<< "divided List<label>: "
<< ctok1.info() << nl << ctok1 << endl;
}
else
{
Info<< "compound is not List<label>" << nl;
}
Info<< "Before fill_zero: " << ctok1 << endl;
@ -192,33 +183,57 @@ int main(int argc, char *argv[])
auto& ct = ctok1.refCompoundToken();
ct.resize(20);
bool handled = false;
bool handled = true;
switch (ct.typeCode())
{
#undef doLocalCode
#define doLocalCode(TokenType, cmptType, cmptValue) \
\
case TokenType : \
{ \
UList<cmptType> cmpts \
( \
reinterpret_cast<cmptType*>(ct.data_bytes()), \
label(ct.size_bytes() / sizeof(cmptType)) \
); \
cmpts = cmptValue; \
handled = true; \
break; \
case token::tokenType::BOOL :
{
UList<bool> cmpts
(
reinterpret_cast<bool*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(bool))
);
cmpts = false;
}
break;
doLocalCode(token::tokenType::BOOL, bool, false);
doLocalCode(token::tokenType::LABEL, label, 123);
doLocalCode(token::tokenType::FLOAT, float, 2.7);
doLocalCode(token::tokenType::DOUBLE, double, 3.1415);
case token::tokenType::LABEL :
{
UList<label> cmpts
(
reinterpret_cast<label*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(label))
);
cmpts = 123;
}
break;
#undef doLocalCode
case token::tokenType::FLOAT :
{
UList<float> cmpts
(
reinterpret_cast<float*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(float))
);
cmpts = 2.7;
}
break;
default : break;
case token::tokenType::DOUBLE :
{
UList<double> cmpts
(
reinterpret_cast<double*>(ct.data_bytes()),
label(ct.size_bytes() / sizeof(double))
);
cmpts = 3.1415;
}
break;
default:
handled = false;
break;
}
@ -226,10 +241,6 @@ int main(int argc, char *argv[])
{
Info<< "assigned: " << ctok1 << nl;
}
else
{
Info<< "Warning: not handled!" << nl;
}
}
}
@ -316,65 +327,6 @@ int main(int argc, char *argv[])
Info<< "content" << nl << entry3 << nl;
}
{
primitiveEntry entry0("entry");
Info<< "empty: " << entry0 << nl;
// populate
{
tokenList& toks = entry0.stream();
toks.resize(2);
toks[0] = word("nonuniform");
toks[1] = token::Compound<scalarList>::New(10, scalar(1));
}
Info<< entry0 << nl;
// Modify contents
for (auto& tok : entry0.stream())
{
if (tok.isCompound<scalarList>())
{
tok.refCompoundToken<scalarList>() = 2;
}
}
Info<< entry0 << nl;
// Find and 'capture' contents
{
typedef List<scalar> ListType;
auto* inputDataPtr =
const_cast<ListType*>(entry0.stream().findCompound<ListType>());
if (inputDataPtr)
{
Info<< "found input data" << nl;
Info<< entry0 << nl;
ListType inputData(std::move(*inputDataPtr));
Info<< "input data, after move" << nl;
Info<< entry0 << nl;
ListType replaceData(5, scalar(3.145));
// some manipulation
replaceData.back() = scalar(1.414);
inputDataPtr->swap(replaceData);
Info<< "with replaced values" << nl;
}
}
Info<< entry0 << nl;
}
return 0;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2023 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,7 +77,6 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
@ -91,7 +90,8 @@ int main(int argc, char *argv[])
faMesh::geometryOrder(geometryOrder);
}
#include "createNamedFaMesh.H"
// Create
faMesh aMesh(mesh);
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -55,7 +55,7 @@ do
bitSet haveMeshOnProc;
std::unique_ptr<faMeshSubset> subsetter;
IOobjectList objects;
IOobjectList objects(0);
refPtr<fileOperation> newHandler(fileOperation::NewUncollated());
@ -70,13 +70,7 @@ do
const bool oldParRun = UPstream::parRun(false);
objects = IOobjectList
(
serialMesh.time(),
runTime.timeName(),
serialMesh.dbDir(),
IOobjectOption::NO_REGISTER
);
objects = IOobjectList(serialMesh.time(), runTime.timeName());
UPstream::parRun(oldParRun);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -18,8 +18,7 @@ Required Classes
- Foam::IOdictionary
Required Variables
- regionName [word] (the polyMesh region)
- areaRegionName [word] (the areaMesh region)
- regionName [word]
- args [argList]
- runTime [Time]
@ -36,7 +35,6 @@ autoPtr<IOdictionary> meshDictPtr;
{
fileName dictPath;
const word& regionDir = Foam::polyMesh::regionName(regionName);
const word& areaRegionDir = Foam::polyMesh::regionName(areaRegionName);
if (args.readIfPresent("dict", dictPath))
{
@ -49,30 +47,38 @@ autoPtr<IOdictionary> meshDictPtr;
}
else if
(
// Dictionary under system/faMeshDefinition ?
// (v2312 and earlier)
areaRegionDir.empty()
&& exists
// Check global location
exists
(
runTime.path()/runTime.caseSystem()
runTime.path()/runTime.caseConstant()
/ regionDir/faMesh::meshSubDir/dictName
)
)
{
// Dictionary present directly in system/ (v2312 and earlier)
dictPath = runTime.system()/regionDir/dictName;
}
else
{
// Use system/finite-area/ directory, with region qualifications
// Dictionary present in constant faMesh directory (old-style)
dictPath =
(
runTime.system()/regionDir
/ faMesh::prefix()/areaRegionDir/dictName
runTime.constant()
/ regionDir/faMesh::meshSubDir/dictName
);
// Warn that constant/faMesh/faMeshDefinition was used
// instead of system/faMeshDefinition
#if 0
WarningIn(args.executable())
<< "Using the old faMeshDefinition location: "
<< dictPath << nl
<< " instead of default location: "
<< runTime.system()/regionDir/dictName << nl
<< endl;
#endif
}
else
{
// Assume dictionary is in the system directory
dictPath = runTime.system()/regionDir/dictName;
}
IOobject meshDictIO

View File

@ -104,13 +104,10 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "addFaRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedPolyMesh.H"
#include "getFaRegionOption.H"
const bool doDecompose = !args.found("no-decompose");
const bool doDecompFields = !args.found("no-fields");
@ -136,15 +133,8 @@ int main(int argc, char *argv[])
// Preliminary checks
#include "checkPatchTopology.H"
Info << "Create areaMesh";
if (!Foam::polyMesh::regionName(areaRegionName).empty())
{
Foam::Info << ' ' << areaRegionName;
}
Info << " for polyMesh at time = " << runTime.timeName() << nl;
// Create
faMesh aMesh(areaRegionName, mesh, meshDefDict);
faMesh aMesh(mesh, meshDefDict);
// Mesh information (less verbose)
faMeshTools::printMeshChecks(aMesh, 0);

View File

@ -618,7 +618,7 @@ void Foam::conformalVoronoiMesh::reorderProcessorPatches
labelList rotation(faces.size(), Zero);
labelList faceMap(faces.size(), label(-1));
PstreamBuffers pBufs;
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send ordering
forAll(sortMesh.boundaryMesh(), patchi)

View File

@ -568,9 +568,10 @@ void syncPoints
}
}
// buffered send
OPstream toNbr
(
UPstream::commsTypes::buffered,
UPstream::commsTypes::blocking,
procPatch.neighbProcNo()
);
toNbr << patchInfo;

View File

@ -145,7 +145,6 @@ Usage
#include "hexRef8Data.H"
#include "regionProperties.H"
#include "polyMeshTools.H"
#include "subsetAdjacency.H"
using namespace Foam;
@ -195,56 +194,21 @@ tmp<volScalarField> createScalarField
}
// Calculate band of mesh
// label getBand(const labelUList& owner, const labelUList& neighbour)
// {
// label bandwidth = 0;
//
// forAll(neighbour, facei)
// {
// const label width = neighbour[facei] - owner[facei];
//
// if (bandwidth < width)
// {
// bandwidth = width;
// }
// }
// return bandwidth;
// }
// Calculate band and profile of matrix. Profile is scalar to avoid overflow
Tuple2<label, scalar> getBand
(
const CompactListList<label>& mat
)
// Calculate band of matrix
label getBand(const labelList& owner, const labelList& neighbour)
{
Tuple2<label, scalar> metrics(0, 0);
label band = 0;
auto& bandwidth = metrics.first();
auto& profile = metrics.second();
forAll(mat, celli)
forAll(neighbour, facei)
{
const auto& neighbours = mat[celli];
label diff = neighbour[facei] - owner[facei];
const label nNbr = neighbours.size();
if (nNbr)
if (diff > band)
{
// Max distance
const label width = (neighbours[nNbr-1] - celli);
if (bandwidth < width)
{
bandwidth = width;
}
profile += scalar(width);
band = diff;
}
}
return metrics;
return band;
}
@ -253,36 +217,28 @@ void getBand
(
const bool calculateIntersect,
const label nCells,
const labelUList& owner,
const labelUList& neighbour,
const labelList& owner,
const labelList& neighbour,
label& bandwidth,
scalar& profile, // scalar to avoid overflow
scalar& sumSqrIntersect // scalar to avoid overflow
)
{
labelList cellBandwidth(nCells, Foam::zero{});
bandwidth = 0;
scalarField nIntersect(nCells, Foam::zero{});
forAll(neighbour, facei)
{
const label own = owner[facei];
const label nei = neighbour[facei];
label own = owner[facei];
label nei = neighbour[facei];
// Note: mag not necessary for correct (upper-triangular) ordering.
const label width = nei - own;
if (cellBandwidth[nei] < width)
{
cellBandwidth[nei] = width;
if (bandwidth < width)
{
bandwidth = width;
}
}
label diff = nei-own;
cellBandwidth[nei] = max(cellBandwidth[nei], diff);
}
bandwidth = max(cellBandwidth);
// Do not use field algebra because of conversion label to scalar
profile = 0;
for (const label width : cellBandwidth)
@ -290,16 +246,14 @@ void getBand
profile += scalar(width);
}
sumSqrIntersect = 0;
sumSqrIntersect = 0.0;
if (calculateIntersect)
{
scalarField nIntersect(nCells, Foam::zero{});
forAll(nIntersect, celli)
{
for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
{
nIntersect[colI] += scalar(1);
nIntersect[colI] += 1.0;
}
}
@ -721,8 +675,9 @@ CompactListList<label> regionRenumber
forAll(regionCellOrder, regioni)
{
// Info<< " region " << regioni << " starts at "
// << regionCellOrder.localStart(regioni) << nl;
// Info<< " region " << regioni
// << " starts at " << regionCellOrder.localStart(regioni)
// << nl;
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
@ -748,42 +703,27 @@ CompactListList<label> regionRenumber
{
timer.resetTimeIncrement();
// Create adjacency matrix of the full mesh and subset subsequently.
// This is more efficient than creating adjacency matrices of
// sub-meshes.
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
// The local connectivity of the full (non-subsetted) mesh
CompactListList<label> meshCellCells;
globalMeshData::calcCellCells(mesh, meshCellCells);
UPstream::parRun(oldParRun); // Restore parallel state
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
// For the respective subMesh selections
bitSet subsetCells(mesh.nCells());
forAll(regionCellOrder, regioni)
{
// Info<< " region " << regioni << " starts at "
// << regionCellOrder.localStart(regioni) << nl;
subsetCells = false;
subsetCells.set(regionCellOrder[regioni]);
// Connectivity of local sub-mesh
labelList cellMap;
CompactListList<label> subCellCells =
subsetAdjacency(subsetCells, meshCellCells, cellMap);
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
// Info<< " region " << regioni
// << " starts at " << regionCellOrder.localStart(regioni)
// << nl;
// No parallel communication
const bool oldParRun = UPstream::parRun(false);
labelList subCellOrder = method.renumber(subCellCells);
// Connectivity of local sub-mesh
CompactListList<label> cellCells;
labelList cellMap = globalMeshData::calcCellCells
(
mesh,
regionCellOrder[regioni],
cellCells
);
timings[TimingType::CELL_CELLS] += timer.timeIncrement();
labelList subCellOrder = method.renumber(cellCells);
UPstream::parRun(oldParRun); // Restore parallel state
@ -895,10 +835,10 @@ int main(int argc, char *argv[])
const bool dryrun = args.dryRun();
const bool readDict = args.found("dict");
const bool doDecompose = args.found("decompose");
const bool doFrontWidth = args.found("frontWidth");
const bool overwrite = args.found("overwrite");
const bool doFields = !args.found("no-fields");
const bool doFrontWidth = args.found("frontWidth") && !doDecompose;
const bool doDecompose = args.found("decompose");
word renumberMethodName;
args.readIfPresent("renumber-method", renumberMethodName);
@ -906,7 +846,8 @@ int main(int argc, char *argv[])
if (doDecompose && UPstream::parRun())
{
FatalErrorIn(args.executable())
<< "Cannot use -decompose option in parallel ... giving up" << nl
<< "Cannot use -decompose option in parallel"
<< " ... giving up" << nl
<< exit(FatalError);
}
@ -967,21 +908,21 @@ int main(int argc, char *argv[])
reduce(band, maxOp<label>());
reduce(profile, sumOp<scalar>());
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< "Mesh " << mesh.name()
<< " size: " << mesh.globalData().nTotalCells() << nl
<< "Before renumbering" << nl
<< "Before renumbering :" << nl
<< " band : " << band << nl
<< " profile : " << profile << nl;
if (doFrontWidth)
{
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
}
@ -1150,7 +1091,10 @@ int main(int argc, char *argv[])
);
// List of stored objects to clear from mesh (after reading)
// List of objects read from time directory
// List of stored objects to clear from mesh
IOobjectList objects;
DynamicList<regIOobject*> storedObjects;
if (!dryrun && doFields)
@ -1159,60 +1103,55 @@ int main(int argc, char *argv[])
timer.resetTimeIncrement();
IOobjectList objects(mesh, runTime.timeName());
objects = IOobjectList(mesh, runTime.timeName());
storedObjects.reserve(objects.size());
const predicates::always nameMatcher;
// Read GeometricFields
#undef doLocalCode
#define doLocalCode(FieldType) \
#undef ReadFields
#define ReadFields(FieldType) \
readFields<FieldType>(mesh, objects, nameMatcher, storedObjects);
// Read volume fields
doLocalCode(volScalarField);
doLocalCode(volVectorField);
doLocalCode(volSphericalTensorField);
doLocalCode(volSymmTensorField);
doLocalCode(volTensorField);
ReadFields(volScalarField);
ReadFields(volVectorField);
ReadFields(volSphericalTensorField);
ReadFields(volSymmTensorField);
ReadFields(volTensorField);
// Read internal fields
doLocalCode(volScalarField::Internal);
doLocalCode(volVectorField::Internal);
doLocalCode(volSphericalTensorField::Internal);
doLocalCode(volSymmTensorField::Internal);
doLocalCode(volTensorField::Internal);
ReadFields(volScalarField::Internal);
ReadFields(volVectorField::Internal);
ReadFields(volSphericalTensorField::Internal);
ReadFields(volSymmTensorField::Internal);
ReadFields(volTensorField::Internal);
// Read surface fields
doLocalCode(surfaceScalarField);
doLocalCode(surfaceVectorField);
doLocalCode(surfaceSphericalTensorField);
doLocalCode(surfaceSymmTensorField);
doLocalCode(surfaceTensorField);
ReadFields(surfaceScalarField);
ReadFields(surfaceVectorField);
ReadFields(surfaceSphericalTensorField);
ReadFields(surfaceSymmTensorField);
ReadFields(surfaceTensorField);
// Read point fields
const pointMesh& pMesh = pointMesh::New(mesh);
#undef doLocalCode
#define doLocalCode(FieldType) \
#undef ReadPointFields
#define ReadPointFields(FieldType) \
readFields<FieldType>(pMesh, objects, nameMatcher, storedObjects);
doLocalCode(pointScalarField);
doLocalCode(pointVectorField);
doLocalCode(pointSphericalTensorField);
doLocalCode(pointSymmTensorField);
doLocalCode(pointTensorField);
ReadPointFields(pointScalarField);
ReadPointFields(pointVectorField);
ReadPointFields(pointSphericalTensorField);
ReadPointFields(pointSymmTensorField);
ReadPointFields(pointTensorField);
#undef doLocalCode
#undef ReadFields
#undef ReadPointFields
timings[TimingType::READ_FIELDS] += timer.timeIncrement();
// Write loaded fields when mesh.write() is called
for (auto* fldptr : storedObjects)
{
fldptr->writeOpt(IOobject::AUTO_WRITE);
}
}
@ -1285,13 +1224,7 @@ int main(int argc, char *argv[])
CompactListList<label> regionCellOrder =
regionRenumber
(
renumberPtr(),
mesh,
cellToRegion,
decomposePtr().nDomains()
);
regionRenumber(renumberPtr(), mesh, cellToRegion);
cellOrder = regionCellOrder.values();
@ -1653,25 +1586,19 @@ int main(int argc, char *argv[])
);
reduce(band, maxOp<label>());
reduce(profile, sumOp<scalar>());
reduce(sumSqrIntersect, sumOp<scalar>());
Info<< "After renumbering";
if (doDecompose)
{
Info<< " [values are misleading with -decompose option]";
}
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< nl
Info<< "After renumbering :" << nl
<< " band : " << band << nl
<< " profile : " << profile << nl;
if (doFrontWidth)
{
reduce(sumSqrIntersect, sumOp<scalar>());
scalar rmsFrontwidth = Foam::sqrt
(
sumSqrIntersect/mesh.globalData().nTotalCells()
);
Info<< " rms frontwidth : " << rmsFrontwidth << nl;
}

View File

@ -1,168 +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, distributed under GPL-3.0-or-later.
Description
Subsetting of an adjacency matrix (as CompactListList).
Can be relocated elsewhere.
\*---------------------------------------------------------------------------*/
#include "CompactListList.H"
#include "bitSet.H"
#include "ListOps.H"
#include "Map.H"
namespace Foam
{
// Perform a subset of the adjacency matrix
CompactListList<label> subsetAdjacency
(
const bitSet& select, // could also be labelHashSet
const CompactListList<label>& input,
labelList& subMap
)
{
// Corresponds to cellMap etc (the original selection)
subMap = select.sortedToc();
// Ensure that the subMap corresponds to a valid subset
{
label validSize = 0;
const label nTotal = input.size();
forAllReverse(subMap, i)
{
if (subMap[i] < nTotal)
{
validSize = i + 1;
break;
}
}
subMap.resize(validSize);
}
// Assumed to be sparse - use Map for reverse lookup
const Map<label> reverseMap(invertToMap(subMap));
// Pass 1: determine the selected sub-sizes
labelList sizes(subMap.size(), Foam::zero{});
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if
(
select.test(nbr)
&& reverseMap.contains(nbr) // extra consistency (paranoid)
)
{
++sizes[idx];
}
}
}
CompactListList<label> output(sizes);
// Reuse sizes as output offset into output.values()
sizes = labelList::subList(output.offsets(), output.size());
labelList& values = output.values();
// Pass 2: extract sub-adjacent matrix
label newNbr = -1;
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if
(
select.test(nbr)
&& (newNbr = reverseMap.lookup(nbr, -1)) >= 0
)
{
values[sizes[idx]++] = newNbr;
}
}
}
return output;
}
// Perform a subset of the adjacency matrix
CompactListList<label> subsetAdjacency
(
const labelRange& slice,
const CompactListList<label>& input,
labelList& subMap
)
{
// Ensure that the selection corresponds to a valid subset
const labelRange select = slice.subset0(input.size());
// Corresponds to cellMap etc (the original selection)
subMap = Foam::identity(select);
// Pass 1: determine the selected sub-sizes
labelList sizes(subMap.size(), Foam::zero{});
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if (select.contains(nbr))
{
++sizes[idx];
}
}
}
CompactListList<label> output(sizes);
// Reuse sizes as output offset into output.values()
sizes = labelList::subList(output.offsets(), output.size());
labelList& values = output.values();
// Pass 2: extract sub-adjacent matrix
const label localOffset = select.start();
forAll(subMap, idx)
{
for (const label nbr : input[subMap[idx]])
{
if (select.contains(nbr))
{
values[sizes[idx]++] = nbr - localOffset;
}
}
}
return output;
}
} // End namespace Foam
// ************************************************************************* //

View File

@ -173,7 +173,7 @@ namespace Foam
// Uses polyMesh/fvMesh meshSubDir by default
autoPtr<labelIOList> procAddressing
(
const objectRegistry& procRegistry,
const fvMesh& procMesh,
const word& name,
const word& instance,
const word& local = fvMesh::meshSubDir
@ -186,7 +186,7 @@ autoPtr<labelIOList> procAddressing
name,
instance,
local,
procRegistry,
procMesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
@ -199,13 +199,13 @@ autoPtr<labelIOList> procAddressing
// Uses the finiteArea meshSubDir
autoPtr<labelIOList> faProcAddressing
(
const objectRegistry& procRegistry,
const fvMesh& procMesh,
const word& name,
const word& instance,
const word& local = faMesh::meshSubDir
)
{
return procAddressing(procRegistry, name, instance, local);
return procAddressing(procMesh, name, instance, local);
}
@ -797,22 +797,11 @@ int main(int argc, char *argv[])
// Field objects at this time
IOobjectList objects;
IOobjectList faObjects;
if (doDecompFields)
{
// List of volume mesh objects for this instance
objects = IOobjectList(mesh, runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
runTime.timeName(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
// Ignore generated fields: (cellDist)
objects.remove("cellDist");
}
@ -821,15 +810,12 @@ int main(int argc, char *argv[])
autoPtr<faMeshDecomposition> faMeshDecompPtr;
if (doFiniteArea)
{
const word boundaryInst =
mesh.time().findInstance(mesh.meshDir(), "boundary");
IOobject io
(
"faBoundary",
boundaryInst,
faMesh::meshDir(mesh, word::null),
mesh.time(),
mesh.time().findInstance(mesh.meshDir(), "boundary"),
faMesh::meshSubDir,
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
IOobject::NO_REGISTER
@ -1239,7 +1225,7 @@ int main(int argc, char *argv[])
if (doDecompFields)
{
areaFieldCache.readAllFields(aMesh, faObjects);
areaFieldCache.readAllFields(aMesh, objects);
}
const label nAreaFields = areaFieldCache.size();
@ -1307,7 +1293,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tfaceProcAddr =
faProcAddressing
(
procMesh,
procFvMesh,
"faceProcAddressing",
runTime.constant()
);
@ -1316,7 +1302,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tboundaryProcAddr =
faProcAddressing
(
procMesh,
procFvMesh,
"boundaryProcAddressing",
runTime.constant()
);
@ -1325,7 +1311,7 @@ int main(int argc, char *argv[])
autoPtr<labelIOList> tedgeProcAddr =
faProcAddressing
(
procMesh,
procFvMesh,
"edgeProcAddressing",
runTime.constant()
);

View File

@ -132,6 +132,9 @@ class domainDecomposition
labelList& elementToZone
);
//- Append single element to list
static void append(labelList&, const label);
//- Add face to inter-processor patch
void addInterProcFace
(

View File

@ -39,6 +39,14 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::domainDecomposition::append(labelList& lst, const label elem)
{
label sz = lst.size();
lst.setSize(sz+1);
lst[sz] = elem;
}
void Foam::domainDecomposition::addInterProcFace
(
const label facei,
@ -346,8 +354,9 @@ void Foam::domainDecomposition::decomposeMesh()
procFaceAddressing_[proci].size();
// Add size as last element to substarts and transfer
subPatchStarts[proci][interPatch].append
append
(
subPatchStarts[proci][interPatch],
curInterPatchFaces[interPatch].size()
);
procProcessorPatchSubPatchIDs_[proci][i].transfer

View File

@ -103,8 +103,8 @@ void Foam::domainDecomposition::processInterCyclics
if (interPatchFaces[proci][interI].size() > oldSz)
{
// Added faces to this interface. Add an entry
subPatchIDs[proci][interI].append(patchi);
subPatchStarts[proci][interI].append(oldSz);
append(subPatchIDs[proci][interI], patchi);
append(subPatchStarts[proci][interI], oldSz);
}
}
}

View File

@ -382,25 +382,9 @@ int main(int argc, char *argv[])
IOobjectList objects
(
procMeshes.meshes()[0],
databases[0].timeName(),
IOobjectOption::NO_REGISTER
databases[0].timeName()
);
IOobjectList faObjects;
if (doFiniteArea && doFields)
{
// List of area mesh objects (assuming single region)
// - scan on processor0
faObjects = IOobjectList
(
procMeshes.meshes()[0],
databases[0].timeName(),
faMesh::dbDir(word::null), // local relative to mesh
IOobjectOption::NO_REGISTER
);
}
if (doFields)
{
// If there are any FV fields, reconstruct them
@ -561,12 +545,12 @@ int main(int argc, char *argv[])
}
else if
(
faObjects.count<areaScalarField>()
|| faObjects.count<areaVectorField>()
|| faObjects.count<areaSphericalTensorField>()
|| faObjects.count<areaSymmTensorField>()
|| faObjects.count<areaTensorField>()
|| faObjects.count<edgeScalarField>()
objects.count<areaScalarField>()
|| objects.count<areaVectorField>()
|| objects.count<areaSphericalTensorField>()
|| objects.count<areaSymmTensorField>()
|| objects.count<areaTensorField>()
|| objects.count<edgeScalarField>()
)
{
Info << "Reconstructing FA fields" << nl << endl;
@ -584,7 +568,7 @@ int main(int argc, char *argv[])
procFaMeshes.boundaryProcAddressing()
);
reconstructor.reconstructAllFields(faObjects);
reconstructor.reconstructAllFields(objects);
}
else
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -314,7 +314,11 @@ boundBox procBounds
{
fileName pointsInstance
(
procDb.findInstance(polyMesh::meshDir(regionName), "points")
procDb.findInstance
(
polyMesh::meshDir(regionName),
"points"
)
);
if (pointsInstance != procDb.timeName())
@ -339,7 +343,11 @@ boundBox procBounds
IOobject
(
"points",
pointsInstance,
procDb.findInstance
(
polyMesh::meshDir(regionName),
"points"
),
polyMesh::meshDir(regionName),
procDb,
IOobject::MUST_READ,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,6 @@ License
#include "Pstream.H"
#include "OSspecific.H"
#include "decomposedBlockData.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
@ -162,54 +161,19 @@ Foam::boolList Foam::haveMeshFile
(
handler.filePath(runTime.path()/meshPath/meshFile)
);
bool found = handler.isFile(fName);
if (returnReduceAnd(found)) // worldComm
{
// Bit tricky: avoid having all slaves open file since this involves
// reading it on master and broadcasting it. This fails if file > 2G.
// So instead only read on master
bool isCollated = false;
// Note: can test only world-master. Since even host-collated will have
// same file format type for all processors
if (UPstream::master(UPstream::worldComm))
autoPtr<ISstream> isPtr(fileHandler().NewIFstream(fName));
if (isPtr && isPtr->good())
{
const bool oldParRun = UPstream::parRun(false);
auto& is = *isPtr;
IFstream is(fName);
if (is.good())
{
IOobject io(meshFile, meshPath, runTime);
io.readHeader(is);
IOobject io(meshFile, meshPath, runTime);
io.readHeader(is);
isCollated = decomposedBlockData::isCollatedType(io);
}
UPstream::parRun(oldParRun);
}
Pstream::broadcast(isCollated); //UPstream::worldComm
// Collect block-number in individual filenames (might differ
// on different processors)
if (isCollated)
{
const label nProcs = UPstream::nProcs(fileHandler().comm());
const label myProcNo = UPstream::myProcNo(fileHandler().comm());
// Collect file names on master of local communicator
const fileNameList fNames
(
Pstream::listGatherValues
(
fName,
fileHandler().comm(),
UPstream::msgType()
)
);
// Collect local block number
label myBlockNumber = -1;
if (decomposedBlockData::isCollatedType(io))
{
fileName path, pDir, local;
procRangeType group;
@ -224,6 +188,7 @@ Foam::boolList Foam::haveMeshFile
numProcs
);
label myBlockNumber = 0;
if (proci == -1 && group.empty())
{
// 'processorsXXX' format so contains all ranks
@ -234,53 +199,12 @@ Foam::boolList Foam::haveMeshFile
{
// 'processorsXXX_n-m' format so check for the
// relative rank
myBlockNumber = myProcNo;
myBlockNumber = UPstream::myProcNo(fileHandler().comm());
}
// Check if block for the local rank is inside file
found = decomposedBlockData::hasBlock(is, myBlockNumber);
}
const labelList myBlockNumbers
(
Pstream::listGatherValues
(
myBlockNumber,
fileHandler().comm(),
UPstream::msgType()
)
);
// Determine for all whether the filename exists in the collated
// file.
boolList allFound(nProcs, false);
if (UPstream::master(fileHandler().comm()))
{
// Store nBlocks and index of file that was used for nBlocks
label nBlocks = -1;
label blockRanki = -1;
forAll(fNames, ranki)
{
if
(
blockRanki == -1
|| (fNames[ranki] != fNames[blockRanki])
)
{
blockRanki = ranki;
IFstream is(fNames[ranki]);
nBlocks = decomposedBlockData::getNumBlocks(is);
}
allFound[ranki] = (myBlockNumbers[ranki] < nBlocks);
}
}
found = Pstream::listScatterValues
(
allFound,
fileHandler().comm(),
UPstream::msgType()
);
}
}
#endif

View File

@ -184,7 +184,7 @@ Foam::parLagrangianDistributor::distributeLagrangianPositions
labelListList sendMap;
// Transfer buffers
PstreamBuffers pBufs;
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
{
// List of lists of particles to be transferred for all of the

View File

@ -102,7 +102,6 @@ Usage
#include "faMeshSubset.H"
#include "faMeshTools.H"
#include "faMeshDistributor.H"
#include "faMeshesRegistry.H"
#include "parFaFieldDistributorCache.H"
#include "redistributeLagrangian.H"
@ -907,26 +906,12 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
}
// If faMeshesRegistry exists, it is also owned by the polyMesh and will
// be destroyed by clearGeom() in fvMeshDistribute::distribute()
//
// Rescue faMeshesRegistry from destruction by temporarily moving
// it to be locally owned.
std::unique_ptr<faMeshesRegistry> faMeshesRegistry_saved
(
faMeshesRegistry::Release(mesh)
);
// Mesh distribution engine
fvMeshDistribute distributor(mesh);
// Do all the distribution of mesh and fields
autoPtr<mapDistributePolyMesh> distMap = distributor.distribute(decomp);
// Restore ownership onto the polyMesh
faMeshesRegistry::Store(std::move(faMeshesRegistry_saved));
// Print some statistics
InfoOrPout<< "After distribution:" << endl;
printMeshData(mesh);
@ -1613,8 +1598,7 @@ int main(int argc, char *argv[])
);
const fileName areaMeshSubDir
(
// Assume single-region area mesh
faMesh::meshDir(regionName, word::null)
polyMesh::regionName(regionName) / faMesh::meshSubDir
);
InfoOrPout
@ -2517,8 +2501,7 @@ int main(int argc, char *argv[])
);
const fileName areaMeshSubDir
(
// Assume single-region area mesh
faMesh::meshDir(regionName, word::null)
polyMesh::regionName(regionName) / faMesh::meshSubDir
);
InfoOrPout

View File

@ -21,38 +21,29 @@ Requires
// Initially all possible objects that are available at the final time
List<wordHashSet> availableRegionObjectNames(meshes.size());
List<wordHashSet> availableFaRegionObjectNames(meshes.size());
forAll(meshes, regioni)
{
const auto& mesh = meshes[regioni];
IOobjectList objects;
IOobjectList faObjects;
IOobjectList objects(0);
if (doConvertFields && !timeDirs.empty())
{
// List of volume mesh objects for this instance
objects = IOobjectList(mesh, timeDirs.back().name());
// List of area mesh objects (assuming single region)
faObjects = IOobjectList
(
mesh.time(),
timeDirs.back().name(),
faMesh::dbDir(mesh, word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
faObjects.filterObjects(fieldSelector());
}
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
}
// Remove "*_0" restart fields
objects.prune_0();
faObjects.prune_0();
if (!doPointValues)
{
@ -68,38 +59,12 @@ forAll(meshes, regioni)
}
}
// Volume fields
if (!objects.empty())
{
wordList objectNames(objects.sortedNames());
wordList objectNames(objects.sortedNames());
// Check availability for all times...
checkData
(
mesh.thisDb(),
timeDirs,
objectNames
);
// Check availability for all times...
checkData(mesh, timeDirs, objectNames);
availableRegionObjectNames[regioni] = objectNames;
}
// Area fields
if (!faObjects.empty())
{
wordList objectNames(faObjects.sortedNames());
// Check availability for all times... (assuming single region)
checkData
(
mesh.time(),
timeDirs,
objectNames,
faMesh::dbDir(mesh, word::null)
);
availableFaRegionObjectNames[regioni] = objectNames;
}
availableRegionObjectNames[regioni] = objectNames;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2023 OpenCFD Ltd.
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -14,8 +14,6 @@ Description
Code chunk for converting area fields
included by foamToEnsight.
Possible objects to convert are given in faObjects
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -25,7 +23,7 @@ if (doFiniteArea && ensFaCasePtr && ensFaMeshPtr)
{
Info<< " area field (";
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, faObjects);
writeAllAreaFields(*ensFaCasePtr, *ensFaMeshPtr, objects);
Info<< " )" << nl;
}

View File

@ -577,20 +577,6 @@ int main(int argc, char *argv[])
// Volume, internal, point fields
#include "convertVolumeFields.H"
// The finite-area objects at this time
IOobjectList faObjects;
if (ensFaMeshPtr)
{
faObjects =
IOobjectList(ensFaMeshPtr->mesh(), runTime.timeName());
faObjects.filterObjects
(
availableFaRegionObjectNames[regioni]
);
}
// The finiteArea fields
#include "convertAreaFields.H"

View File

@ -55,7 +55,7 @@ label timeIndex = 0;
else
{
goodTimeIndex = false;
Info<< "skip ... missing file: " << io.objectRelPath() << endl;
Info<< "skip ... missing entry " << io.objectPath() << endl;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2023 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,10 +32,9 @@ License
Foam::label Foam::checkData
(
const objectRegistry& obr,
const fvMesh& mesh,
const instantList& timeDirs,
wordList& objectNames,
const fileName& local
wordList& objectNames
)
{
// Assume prune_0() was used prior to calling this
@ -44,9 +43,6 @@ Foam::label Foam::checkData
for (const word& fieldName : objectNames)
{
// // If prune_0() not previously used...
// if (objectNames.ends_with("_0")) continue;
bool good = false;
for (const instant& inst : timeDirs)
@ -56,8 +52,7 @@ Foam::label Foam::checkData
(
fieldName,
inst.name(),
local,
obr,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
IOobject::NO_REGISTER

View File

@ -164,10 +164,9 @@ tmp<VolumeField<Type>> makeZeroGradientField
// ignore fields that are not available for all time-steps
label checkData
(
const objectRegistry& obr,
const fvMesh& mesh,
const instantList& timeDirs,
wordList& objectNames,
const fileName& local = fileName::null
wordList& objectNames
);

View File

@ -29,7 +29,7 @@ if (doFiniteArea)
autoPtr<faMesh> faMeshPtr;
const label nAreaFields =
faObjects.count(stringListOps::foundOp<word>(fieldTypes::area));
objects.count(stringListOps::foundOp<word>(fieldTypes::area));
if (nAreaFields || withMeshIds)
{
@ -40,7 +40,7 @@ if (doFiniteArea)
{
const faMesh& areaMesh = faMeshPtr();
reportFields::area(Info, faObjects);
reportFields::area(Info, objects);
const auto& pp = faMeshPtr->patch();
@ -97,7 +97,7 @@ if (doFiniteArea)
(
writer,
areaMesh,
faObjects,
objects,
true // syncPar
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -141,7 +141,7 @@ Note
#include "pointSet.H"
#include "HashOps.H"
#include "regionProperties.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "stringListOps.H"
#include "Cloud.H"
#include "readFields.H"
@ -780,34 +780,21 @@ int main(int argc, char *argv[])
}
}
IOobjectList objects;
IOobjectList faObjects;
IOobjectList objects(0);
if (doConvertFields)
{
// List of volume mesh objects for this instance
// List of objects for this time
objects =
IOobjectList(meshProxy.baseMesh(), runTime.timeName());
// List of area mesh objects (assuming single region)
faObjects =
IOobjectList
(
runTime,
runTime.timeName(),
faMesh::dbDir(meshProxy.baseMesh(), word::null),
IOobjectOption::NO_REGISTER
);
if (fieldSelector && !fieldSelector().empty())
{
objects.filterObjects(fieldSelector());
faObjects.filterObjects(fieldSelector());
}
// Remove "*_0" restart fields
objects.prune_0();
faObjects.prune_0();
if (!doPointValues)
{

View File

@ -80,6 +80,7 @@ Usage
#include "IOobjectList.H"
#include "IOPtrList.H"
#include "volFields.H"
#include "stringListOps.H"
#include "timeSelector.H"
using namespace Foam;
@ -188,7 +189,7 @@ labelList findMatches
const HashTable<wordList>& shortcuts,
const wordList& shortcutNames,
const wordList& thisKeys,
const wordRe& key
const keyType& key
)
{
labelList matches;
@ -196,20 +197,20 @@ labelList findMatches
if (key.isPattern())
{
// Wildcard match
matches = wordRes::matching(key, thisKeys);
matches = findStrings(key, thisKeys);
}
else if (shortcuts.size())
{
// See if patchGroups expand to valid thisKeys
labelList indices = wordRes::matching(key, shortcutNames);
labelList indices = findStrings(key, shortcutNames);
for (const label idx : indices)
{
const word& name = shortcutNames[idx];
const wordList& keys = shortcuts[name];
for (const word& k : keys)
forAll(keys, j)
{
const label index = thisKeys.find(k);
const label index = thisKeys.find(keys[j]);
if (index != -1)
{
matches.append(index);

View File

@ -48,7 +48,7 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
if
(
commsType == UPstream::commsTypes::buffered
commsType == UPstream::commsTypes::blocking
|| commsType == UPstream::commsTypes::nonBlocking
)
{

View File

@ -51,7 +51,6 @@ Description
#include "emptyPolyPatch.H"
#include "processorPolyPatch.H"
#include "ListListOps.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "indirectPrimitivePatch.H"
#include "globalMeshData.H"
#include "globalIndex.H"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2014 OpenFOAM Foundation
Copyright (C) 2020-2024 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -294,7 +294,7 @@ bool Foam::searchableSurfaceModifiers::cut::modify
// Find the surfaces to cut with
for (const wordRe& cutterName : cutterNames_)
{
labelList geomIDs = wordRes::matching(cutterName, geometry_.names());
labelList geomIDs = findStrings(cutterName, geometry_.names());
for (const label geomI : geomIDs)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -130,14 +130,9 @@ int main(int argc, char *argv[])
for (const entry& e : regionsDict)
{
const wordRe regionName(e.keyword());
const keyType& regionName = e.keyword();
const dictionary& regionDict = e.dict();
labelList regionIDs
(
wordRes::matching(regionName, surf.regions())
);
autoPtr<searchableSurfaceModifier> modifier
(
searchableSurfaceModifier::New
@ -148,6 +143,9 @@ int main(int argc, char *argv[])
)
);
labelList regionIDs =
findStrings(regionName, surf.regions());
if (modifier().modify(regionIDs, surf))
{
changed = true;

View File

@ -56,7 +56,7 @@ Usage
#include "argList.H"
#include "MeshedSurfaces.H"
#include "stringListOps.H" // For stringListOps::findMatching()
#include "stringListOps.H"
#include "geometricSurfacePatch.H"
using namespace Foam;

View File

@ -1,322 +0,0 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2023-2024 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamUpgradeFiniteArea
#
# Description
# Relocate finite-area files to new sub-directory locations
#
#------------------------------------------------------------------------------
printHelp() {
cat <<USAGE
Usage: ${0##*/} [OPTION]
options:
-case=DIR Specify starting directory, default is cwd
-dry-run | -n Test without performing actions
-verbose | -v Additional verbosity
-force (currently ignored)
-link-back Link back from new finite-area/ to old locations
-no-mesh Do not move system/faMeshDefinition
-git Use 'git mv' when making changes
-help Print help and exit
Relocate finite-area files to new sub-directory locations
Equivalent options:
| -case=DIR | -case DIR |
USAGE
exit 0 # A clean exit
}
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
#------------------------------------------------------------------------------
# Parse options
unset caseDir optDryRun optGit optVerbose optLink optMeshDef hadError
while [ "$#" -gt 0 ]
do
case "$1" in
(- | --)
shift
break # Stop option parsing
;;
(-h | -help*) printHelp ;;
(-n | -dry-run) optDryRun="(dry-run) " ;;
(-v | -verbose) optVerbose=true ;;
(-f | -force) echo "Ignored option: ${1%%=*}" 1>&2 ;;
(-link-back) optLink=back ;;
# (-link-only) optLink=forward ;;
(-no-mesh) optMeshDef=false ;;
(-git) optGit=true ;;
(-case=*)
caseDir="${1#*=}"
;;
(-case)
caseDir="$2"
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
shift
;;
(-*) die "unknown option: $1" ;;
(*) die "unknown argument: $1" ;;
esac
shift
done
if [ -n "$caseDir" ]
then
cd "$caseDir" 2>/dev/null || {
echo "${0##*/}: No such directory $caseDir" 1>&2
exit 2
}
fi
#------------------------------------------------------------------------------
# Proper umask
umask 022
# The commands
copy_cmd="cp -a${optVerbose:+ -v}"
move_cmd="mv${optVerbose:+ -v}"
link_cmd="ln -sf${optVerbose:+ -v}"
mkdir_cmd="mkdir -p"
if [ -n "$optDryRun" ]
then
if [ -n "$optVerbose" ]
then
copy_cmd="echo cp -a"
move_cmd="echo mv"
link_cmd="echo ln -sf"
mkdir_cmd="echo mkdir -p"
else
copy_cmd=true
move_cmd=true
link_cmd=true
mkdir_cmd=true
fi
elif [ -n "$optGit" ]
then
move_cmd="git mv"
link_cmd="echo no symlink for git:"
fi
regionDir="finite-area"
#------------------------------------------------------------------------------
# Various script parts
#
# awk : scan file for FoamFile { ... class NAME; }
read -d '' getClass_awk << 'AWK_CONTENT'
BEGIN { state = 0 } # 0=begin, 1=header, 2=done
/FoamFile/ { if (!state) { state = 1; next; } exit; }
# FoamFile begin contents
/\{/ { if (state == 1) state = 2; next; }
# FoamFile end contents
/\}/ { if (state == 2) exit; next; }
/^[ ]*class[ ]/ {
if (state == 2)
{
sub("^[ ]*class[ ]+", "")
sub("[ ;]*$", "")
print
exit
}
next
}
AWK_CONTENT
# Check for FoamFile and return extracted 'class'
getFoamFile_class()
{
local file="$1"
local class
if grep -q FoamFile "$file" 2>/dev/null
then
# class="$(foamDictionary -disableFunctionEntries -entry FoamFile/class -value "$file" 2> stderr)"
class="$(awk -- "$getClass_awk" "$file")"
fi
echo "$class"
}
# Check if class corresponds to an finite-area field
# eg, areaScalarField, ... edgeVectorField
isAreaFieldClass()
{
case "$1" in
(area*Field | edge*Field) return 0 ;;
esac
return 1
}
#------------------------------------------------------------------------------
#Debug# getFoamFile_class "system/faSchemes"
#------------------------------------------------------------------------------
# Link back from the local finite-area/ directory to the current directory
# variables
# - regionDir = "finite-area"
#
performLinkBack()
{
local file
if [ -d "$regionDir" ]
then
find "$regionDir" -maxdepth 1 -type f 2>/dev/null | while read file
do
file="${file#*/}"
if [ -f "$regionDir/$file" ] && [ ! -f "$file" ]
then
echo "${optDryRun} ln -s $regionDir/$file $file" 1>&2
$link_cmd "$regionDir/$file" "$file"
fi
done
fi
}
# Move from current directory to local finite-area/ directory
# variables
# - regionDir = "finite-area"
#
performMove()
{
local file="$1"
if [ -f "$regionDir/$file" ]
then
echo "${optDryRun} already: $regionDir/$file" 1>&2
elif [ -f "$file" ]
then
$mkdir_cmd "$regionDir"
echo "${optDryRun} mv $file -> $regionDir/" 1>&2
$move_cmd "$file" "$regionDir/$file"
elif [ -n "$file" ]
then
echo "${optDryRun} no $file" 1>&2
fi
}
#------------------------------------------------------------------------------
# system
# ----
if [ -d system ]
then
(
cd system || exit
currDir="system"
echo "${optDryRun}Examining files in $currDir/" 1>&2
performMove faSchemes
performMove faSolution
if [ "$optMeshDef" = false ]
then
echo "${optDryRun} ignore: faMeshDefinition" 1>&2
else
performMove faMeshDefinition
fi
if [ -d "$regionDir" ] && [ "$optLink" = back ]
then
performLinkBack
fi
)
else
echo "${optDryRun}No system/ directory..." 1>&2
fi
#------------------------------------------------------------------------------
# time dirs (initial conditions)
# ----
for timeDir in 0 0.orig
do
if [ -d "$timeDir" ]
then
(
cd "$timeDir" || exit
currDir="$timeDir"
echo "${optDryRun}Examining $currDir/" 1>&2
find . -maxdepth 1 -type f | while read file
do
file="${file#*/}"
case "$file" in
(*.gz)
echo "${optDryRun} ignoring compressed file: $file" 1>&2
continue
;;
esac
className="$(getFoamFile_class "$file")"
if isAreaFieldClass "$className"
then
performMove "$file"
fi
done
if [ -d "$regionDir" ] && [ "$optLink" = back ]
then
performLinkBack
fi
)
else
echo "${optDryRun}No $timeDir/ directory..." 1>&2
fi
done
#------------------------------------------------------------------------------

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, distributed under GPL-3.0-or-later.
@ -501,9 +501,9 @@ cloneParallelCase()
}
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
# * -processor : copy into processor directories instead
# * -all : copy into serial and processor directories
# Overwrite 0/ with the contents of 0.orig/ if it exists.
# The -processor option to do the processor directories instead
#
restore0Dir()
{
if [ ! -d 0.orig ]
@ -513,27 +513,35 @@ restore0Dir()
fi
case "$1" in
(-all | -proc | -processor*)
if [ "$1" = "-all" ]
then
echo "Restore 0/ from 0.orig/ [serial/processor dirs]" 1>&2
\rm -rf 0
\cp -r 0.orig 0 2>/dev/null
else
echo "Restore 0/ from 0.orig/ [processor dirs]" 1>&2
fi
-proc | -processor | -processors)
echo "Restore 0/ from 0.orig/ [processor directories]"
\ls -d processor* | xargs -I {} \rm -rf ./{}/0
\ls -d processor* | xargs -I {} \cp -r 0.orig ./{}/0 > /dev/null 2>&1
# Remove '#include' directives from field dictionaries
# for collated format
if [ "$1" = "-processors" ]
then
(
echo "Filter #include directives in processors/0:"
\cd processors/0 2>/dev/null || exit 0
for file in $(grep -l "#include" * 2>/dev/null)
do
foamDictionary "$file" > "$file.$$." && mv "$file.$$." "$file"
echo " $file"
done | tr -d '\n'
echo
)
fi
;;
(*)
echo "Restore 0/ from 0.orig/" 1>&2
*)
echo "Restore 0/ from 0.orig/"
\rm -rf 0
\cp -r 0.orig 0 2>/dev/null
;;
esac
return 0
}

View File

@ -43,10 +43,6 @@ cellSet_doc
sets (c1 c2);
// or
set c1;
// or
zones (c1Zone c2Zone);
// or
zone c1Zone;
}
@ -66,10 +62,6 @@ cellSet_doc
sets (f0 f1);
// or
set f0; // Name of faceSet
// or
zones (f0Zone f1Zone);
// or
zone f0Zone;
//- selection option (mandatory)
option any; // cell with any face in faceSet
@ -135,10 +127,6 @@ cellSet_doc
sets (p0 p1);
// or
sets p0;
// or
zones (p0Zone p1Zone);
// or
zone p0Zone;
option any; // cell with any point in pointSet
//option edge; // cell with an edge with both points in pointSet
@ -266,10 +254,6 @@ faceSet_doc
sets (c0 c1);
// or
set c0; // Name of cellSet
// or
zones (c0Zone c1Zone);
// or
zone c0Zone;
option all; // All faces of cells
//option both; // Only faces with owner+neighbour in cellSet
@ -326,10 +310,6 @@ faceSet_doc
sets (p0 p1);
// or
set p0; // Name of pointSet
// or
zones (p0Zone p1Zone);
// or
zone p0Zone;
option any; // Faces using any point in pointSet
//option all // Faces with all points in pointSet
@ -419,10 +399,6 @@ pointSet_doc
sets (c1 c2);
// or
set c1;
// or
zones (c1Zone c2Zone);
// or
zone c1Zone;
option all; // all points of cell
}
@ -445,10 +421,6 @@ pointSet_doc
sets (f1 f2);
// or
set f1;
// or
zones (f1Zone f2Zone);
// or
zone f1Zone;
option all; // all points of face
}
@ -474,10 +446,6 @@ pointSet_doc
sets (p1 p2);
// or
set p1;
// or
zones (p1Zone p2Zone);
// or
zone p1Zone;
}

View File

@ -132,7 +132,7 @@ OptimisationSwitches
// MPI/Parallel settings
// =====================
// Default communication type (nonBlocking | scheduled | buffered)
// Default communication type (nonBlocking | scheduled | blocking);
commsType nonBlocking;
// Transfer double as float for processor boundaries. Mostly defunct.

View File

@ -83,9 +83,8 @@ See also
Foam::DynamicList
SourceFiles
PackedList.C
PackedListCore.C
PackedListI.H
PackedList.C
PackedListIO.C
\*---------------------------------------------------------------------------*/
@ -93,11 +92,11 @@ SourceFiles
#ifndef Foam_PackedList_H
#define Foam_PackedList_H
#include "className.H"
#include "BitOps.H"
#include "labelList.H"
#include "IndirectListBase.H"
#include "InfoProxy.H"
#include "PackedListCore.H"
#include <type_traits>
@ -120,23 +119,6 @@ template<unsigned Width>
Ostream& operator<<(Ostream& os, const InfoProxy<PackedList<Width>>& info);
/*---------------------------------------------------------------------------*\
Class Detail::PackedListCore Declaration
\*---------------------------------------------------------------------------*/
namespace Detail
{
//- Template-invariant parts for PackedList
struct PackedListCore
{
//- Define template name
ClassNameNoDebug("PackedList");
};
} // End namespace Detail
/*---------------------------------------------------------------------------*\
Class PackedList Declaration
\*---------------------------------------------------------------------------*/

View File

@ -25,7 +25,7 @@ License
\*---------------------------------------------------------------------------*/
#include "PackedList.H"
#include "PackedListCore.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -1 +1,69 @@
#warning File removed - left for old dependency check only
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 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/>.
Class
Foam::Detail::PackedListCore
Description
Implementation of template-invariant details for Foam::PackedList
SourceFiles
PackedListCore.C
\*---------------------------------------------------------------------------*/
#ifndef PackedListCore_H
#define PackedListCore_H
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class Detail::PackedListCore Declaration
\*---------------------------------------------------------------------------*/
//- Template-invariant parts for PackedList
struct PackedListCore
{
//- Define template name
ClassNameNoDebug("PackedList");
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Detail
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -115,7 +115,7 @@ void Foam::ParSortableList<Type>::checkAndSend
}
{
OPstream toProc(UPstream::commsTypes::buffered, destProci);
OPstream toProc(UPstream::commsTypes::blocking, destProci);
toProc << values << indices;
}
}
@ -309,7 +309,7 @@ void Foam::ParSortableList<Type>::sort()
Pout<< "Receiving from " << proci << endl;
}
IPstream fromProc(UPstream::commsTypes::buffered, proci);
IPstream fromProc(UPstream::commsTypes::blocking, proci);
fromProc >> recValues >> recIndices;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -228,9 +228,6 @@ public:
// Basic methods
//- Move insert IOobject into the list
inline bool add(std::unique_ptr<IOobject>&& objectPtr);
//- Move insert IOobject into the list
inline bool add(autoPtr<IOobject>& objectPtr);

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.
@ -109,17 +109,6 @@ inline Foam::IOobjectList::IOobjectList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::IOobjectList::add(std::unique_ptr<IOobject>&& objectPtr)
{
if (objectPtr)
{
return insert(objectPtr->name(), std::move(objectPtr));
}
return false;
}
inline bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
{
if (objectPtr)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,26 +32,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class BaseType>
bool Foam::CompactIOField<T, BaseType>::readIOcontents(bool readOnProc)
void Foam::CompactIOField<T, BaseType>::readFromStream(const bool readOnProc)
{
if (readOpt() == IOobject::MUST_READ)
{
// Reading
}
else if (isReadOptional())
{
if (!headerOk())
{
readOnProc = false;
}
}
else
{
return false;
}
// Do reading
Istream& is = readStream(word::null, readOnProc);
if (readOnProc)
@ -76,8 +58,23 @@ bool Foam::CompactIOField<T, BaseType>::readIOcontents(bool readOnProc)
<< exit(FatalIOError);
}
}
}
return true;
template<class T, class BaseType>
bool Foam::CompactIOField<T, BaseType>::readContents()
{
if
(
readOpt() == IOobject::MUST_READ
|| (isReadOptional() && headerOk())
)
{
readFromStream();
return true;
}
return false;
}
@ -88,7 +85,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField(const IOobject& io)
:
regIOobject(io)
{
readIOcontents();
readContents();
}
@ -101,7 +98,15 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
readIOcontents(readOnProc);
if (readOpt() == IOobject::MUST_READ)
{
readFromStream(readOnProc);
}
else if (isReadOptional())
{
const bool haveFile = headerOk();
readFromStream(readOnProc && haveFile);
}
}
@ -114,7 +119,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
readIOcontents();
readContents();
}
@ -127,7 +132,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
Field<T>::resize(len);
}
@ -143,7 +148,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
Field<T>::operator=(content);
}
@ -161,7 +166,7 @@ Foam::CompactIOField<T, BaseType>::CompactIOField
{
Field<T>::transfer(content);
readIOcontents();
readContents();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2024 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,10 +76,13 @@ class CompactIOField
{
// Private Member Functions
//- Read if IOobject flags set and 'on-proc' is true.
//- Reads according to the header type.
// Return true if read (only accurate when readOnProc == true).
bool readIOcontents(bool readOnProc = true);
//- Read according to header type, with optional 'on-proc' value
void readFromStream(const bool readOnProc = true);
//- Read if IOobject flags set. Return true if read.
// Reads according to the header type
bool readContents();
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2024 OpenCFD Ltd.
Copyright (C) 2015-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,34 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::readIOcontents()
void Foam::CompactIOList<T, BaseType>::readFromStream()
{
Istream& is = readStream(word::null);
if (headerClassName() == IOList<T>::typeName)
{
is >> static_cast<List<T>&>(*this);
close();
}
else if (headerClassName() == typeName)
{
is >> *this;
close();
}
else
{
FatalIOErrorInFunction(is)
<< "unexpected class name " << headerClassName()
<< " expected " << typeName
<< " or " << IOList<T>::typeName << endl
<< " while reading object " << name()
<< exit(FatalIOError);
}
}
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::readContents()
{
if
(
@ -40,28 +67,7 @@ bool Foam::CompactIOList<T, BaseType>::readIOcontents()
|| (isReadOptional() && headerOk())
)
{
Istream& is = readStream(word::null);
if (headerClassName() == IOList<T>::typeName)
{
is >> static_cast<List<T>&>(*this);
close();
}
else if (headerClassName() == typeName)
{
is >> *this;
close();
}
else
{
FatalIOErrorInFunction(is)
<< "Unexpected class name " << headerClassName()
<< " expected " << typeName
<< " or " << IOList<T>::typeName << endl
<< " while reading object " << name()
<< exit(FatalIOError);
}
readFromStream();
return true;
}
@ -72,14 +78,12 @@ bool Foam::CompactIOList<T, BaseType>::readIOcontents()
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::overflows() const
{
const List<T>& lists = *this;
label total = 0;
for (const auto& sublist : lists)
label size = 0;
forAll(*this, i)
{
const label prev = total;
total += sublist.size();
if (total < prev)
const label oldSize = size;
size += this->operator[](i).size();
if (size < oldSize)
{
return true;
}
@ -95,7 +99,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList(const IOobject& io)
:
regIOobject(io)
{
readIOcontents();
readContents();
}
@ -108,7 +112,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
readIOcontents();
readContents();
}
@ -121,7 +125,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
List<T>::resize(len);
}
@ -137,7 +141,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
List<T>::operator=(content);
}
@ -155,7 +159,7 @@ Foam::CompactIOList<T, BaseType>::CompactIOList
{
List<T>::transfer(content);
readIOcontents();
readContents();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,6 +43,7 @@ SourceFiles
#define Foam_CompactIOList_H
#include "IOList.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -75,10 +76,12 @@ class CompactIOList
{
// Private Member Functions
//- Read according to header type
void readFromStream();
//- Read if IOobject flags set. Return true if read.
//- Reads according to the header type.
// Return true if read.
bool readIOcontents();
// Reads according to the header type
bool readContents();
//- Has too many elements in it?
bool overflows() const;
@ -127,7 +130,7 @@ public:
const bool writeOnProc
) const;
virtual bool writeData(Ostream& os) const;
virtual bool writeData(Ostream&) const;
// Member Operators
@ -137,6 +140,23 @@ public:
//- Copy or move assignment of entries
using List<T>::operator=;
// IOstream operators
//- Read List from Istream, discarding contents of existing List.
friend Istream& operator>> <T, BaseType>
(
Istream&,
CompactIOList<T, BaseType>&
);
// Write List to Ostream.
friend Ostream& operator<< <T, BaseType>
(
Ostream&,
const CompactIOList<T, BaseType>&
);
};

View File

@ -91,14 +91,14 @@ public:
// Member Functions
//- This object is global
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
//- either in the case/processor or case otherwise null
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath(type());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,26 +31,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
bool Foam::IOField<Type>::readIOcontents(bool readOnProc)
void Foam::IOField<Type>::readFromStream(const bool readOnProc)
{
if (isReadRequired())
{
// Reading
}
else if (isReadOptional())
{
if (!headerOk())
{
readOnProc = false;
}
}
else
{
return false;
}
// Do reading
Istream& is = readStream(typeName, readOnProc);
if (readOnProc)
@ -58,7 +40,19 @@ bool Foam::IOField<Type>::readIOcontents(bool readOnProc)
is >> *this;
}
close();
return true;
}
template<class Type>
bool Foam::IOField<Type>::readContents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
readFromStream();
return true;
}
return false;
}
@ -72,7 +66,7 @@ Foam::IOField<Type>::IOField(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
readIOcontents();
readContents();
}
@ -84,7 +78,15 @@ Foam::IOField<Type>::IOField(const IOobject& io, const bool readOnProc)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
readIOcontents(readOnProc);
if (isReadRequired())
{
readFromStream(readOnProc);
}
else if (isReadOptional())
{
const bool haveFile = headerOk();
readFromStream(readOnProc && haveFile);
}
}
@ -96,7 +98,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Foam::zero)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
readIOcontents();
readContents();
}
@ -108,7 +110,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const label len)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
if (!readIOcontents())
if (!readContents())
{
Field<Type>::resize(len);
}
@ -123,7 +125,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const UList<Type>& content)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOField<Type>>();
if (!readIOcontents())
if (!readContents())
{
Field<Type>::operator=(content);
}
@ -140,7 +142,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, Field<Type>&& content)
Field<Type>::transfer(content);
readIOcontents();
readContents();
}
@ -156,7 +158,7 @@ Foam::IOField<Type>::IOField(const IOobject& io, const tmp<Field<Type>>& tfld)
Field<Type>::transfer(tfld.ref());
}
if (!readIOcontents() && !reuse)
if (!readContents() && !reuse)
{
Field<Type>::operator=(tfld());
}
@ -183,7 +185,7 @@ template<class Type>
Foam::Field<Type> Foam::IOField<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,9 +58,11 @@ class IOField
{
// Private Member Functions
//- Read if IOobject flags set and 'on-proc' is true.
// Return true if read (only accurate when readOnProc == true).
bool readIOcontents(bool readOnProc = true);
//- Read with optional 'on-proc' value
void readFromStream(const bool readOnProc = true);
//- Read if IOobject flags set. Return true if read.
bool readContents();
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
bool Foam::IOList<T>::readIOcontents()
bool Foam::IOList<T>::readContents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
@ -54,7 +54,7 @@ Foam::IOList<T>::IOList(const IOobject& io)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
readIOcontents();
readContents();
}
@ -66,7 +66,7 @@ Foam::IOList<T>::IOList(const IOobject& io, Foam::zero)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
readIOcontents();
readContents();
}
@ -78,7 +78,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const label len)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
if (!readIOcontents())
if (!readContents())
{
List<T>::resize(len);
}
@ -93,7 +93,7 @@ Foam::IOList<T>::IOList(const IOobject& io, const UList<T>& content)
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<IOList<T>>();
if (!readIOcontents())
if (!readContents())
{
List<T>::operator=(content);
}
@ -110,7 +110,7 @@ Foam::IOList<T>::IOList(const IOobject& io, List<T>&& content)
List<T>::transfer(content);
readIOcontents();
readContents();
}
@ -132,7 +132,7 @@ template<class T>
Foam::List<T> Foam::IOList<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ class IOList
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readIOcontents();
bool readContents();
public:

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
bool Foam::IOMap<T>::readIOcontents()
bool Foam::IOMap<T>::readContents()
{
if (isReadRequired() || (isReadOptional() && headerOk()))
{
@ -55,7 +55,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io)
:
regIOobject(io)
{
readIOcontents();
readContents();
}
@ -64,7 +64,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const label size)
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
Map<T>::resize(size);
}
@ -76,7 +76,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, const Map<T>& content)
:
regIOobject(io)
{
if (!readIOcontents())
if (!readContents())
{
Map<T>::operator=(content);
}
@ -90,7 +90,7 @@ Foam::IOMap<T>::IOMap(const IOobject& io, Map<T>&& content)
{
Map<T>::transfer(content);
readIOcontents();
readContents();
}
@ -100,7 +100,7 @@ template<class T>
Foam::Map<T> Foam::IOMap<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,7 +60,7 @@ class IOMap
// Private Member Functions
//- Read if IOobject flags set. Return true if read.
bool readIOcontents();
bool readContents();
public:

View File

@ -122,7 +122,7 @@ template<class T>
Foam::PtrList<T> Foam::IOPtrList<T>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -96,7 +96,7 @@ Foam::IOdictionary::IOdictionary
Foam::dictionary Foam::IOdictionary::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -93,7 +93,7 @@ Foam::localIOdictionary::localIOdictionary
Foam::dictionary Foam::localIOdictionary::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -97,7 +97,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f)
{
label index = -1;
if (readOpt() == IOobjectOption::READ_MODIFIED)
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
index = files_.find(f);
@ -113,7 +113,7 @@ Foam::label Foam::unwatchedIOdictionary::addWatch(const fileName& f)
void Foam::unwatchedIOdictionary::addWatch()
{
if (readOpt() == IOobjectOption::READ_MODIFIED)
if (readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
fileName f = filePath();
if (f.empty())

View File

@ -545,7 +545,7 @@ bool Foam::decomposedBlockData::readBlocks
}
else
{
PstreamBuffers pBufs(comm);
PstreamBuffers pBufs(comm, UPstream::commsTypes::nonBlocking);
if (UPstream::master(comm))
{
@ -667,7 +667,7 @@ Foam::autoPtr<Foam::ISstream> Foam::decomposedBlockData::readBlocks
}
else
{
PstreamBuffers pBufs(comm);
PstreamBuffers pBufs(comm, UPstream::commsTypes::nonBlocking);
if (UPstream::master(comm))
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::rawIOField<Type>::readIOcontents
void Foam::rawIOField<Type>::readContents
(
Istream& is,
IOobjectOption::readOption readAverage
@ -65,7 +65,7 @@ void Foam::rawIOField<Type>::readIOcontents
template<class Type>
bool Foam::rawIOField<Type>::readIOcontents
bool Foam::rawIOField<Type>::readContents
(
IOobjectOption::readOption readAverage
)
@ -111,7 +111,7 @@ bool Foam::rawIOField<Type>::readIOcontents
if (is.good())
{
readIOcontents(is, readAverage);
readContents(is, readAverage);
close();
}
}
@ -122,7 +122,7 @@ bool Foam::rawIOField<Type>::readIOcontents
if (isPtr && isPtr->good())
{
readIOcontents(*isPtr, readAverage);
readContents(*isPtr, readAverage);
}
else
{
@ -165,7 +165,7 @@ Foam::rawIOField<Type>::rawIOField
// Check for MUST_READ_IF_MODIFIED
warnNoRereading<rawIOField<Type>>();
readIOcontents(readAverage);
readContents(readAverage);
}
@ -194,7 +194,7 @@ template<class Type>
Foam::Field<Type> Foam::rawIOField<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
if (rio.readOpt() == IOobjectOption::MUST_READ_IF_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}

View File

@ -67,10 +67,10 @@ class rawIOField
// Private Member Functions
//- Read contents and average
void readIOcontents(Istream&, IOobjectOption::readOption readAverage);
void readContents(Istream&, IOobjectOption::readOption readAverage);
//- Read if IOobject flags set. Return true if read.
bool readIOcontents(IOobjectOption::readOption readAverage);
bool readContents(IOobjectOption::readOption readAverage);
public:

View File

@ -115,7 +115,7 @@ void Foam::masterOFstream::commit()
}
// Different files
PstreamBuffers pBufs(comm_);
PstreamBuffers pBufs(comm_, UPstream::commsTypes::nonBlocking);
if (!UPstream::master(comm_))
{

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,7 @@ License
Foam::UIPBstream::UIPBstream
(
const UPstream::commsTypes commsType,
const int rootProcNo,
const int fromProcNo,
DynamicList<char>& receiveBuf,
label& receiveBufPosition,
const int tag,
@ -45,11 +45,11 @@ Foam::UIPBstream::UIPBstream
:
UIPstreamBase
(
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
commsType,
fromProcNo,
receiveBuf,
receiveBufPosition,
tag, // irrelevant
tag,
comm,
clearAtEnd,
fmt
@ -62,7 +62,7 @@ Foam::UIPBstream::UIPBstream
Foam::IPBstream::IPBstream
(
const UPstream::commsTypes commsType,
const int rootProcNo,
const int fromProcNo,
const label bufSize,
const int tag,
const label comm,
@ -72,11 +72,11 @@ Foam::IPBstream::IPBstream
Pstream(commsType, bufSize),
UIPBstream
(
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
commsType,
fromProcNo,
Pstream::transferBuf_,
UIPstreamBase::storedRecvBufPos_, // Internal only
tag, // irrelevant
tag,
comm,
false, // Do not clear Pstream::transferBuf_ if at end
fmt
@ -86,7 +86,7 @@ Foam::IPBstream::IPBstream
Foam::IPBstream::IPBstream
(
const int rootProcNo,
const int fromProcNo,
const label comm,
IOstreamOption::streamFormat fmt
)
@ -94,25 +94,7 @@ Foam::IPBstream::IPBstream
IPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
rootProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,
fmt
)
{}
Foam::IPBstream::IPBstream
(
const label comm,
IOstreamOption::streamFormat fmt
)
:
IPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
UPstream::masterNo(), // rootProcNo
fromProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,

View File

@ -127,40 +127,14 @@ public:
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct for broadcast root and communicator,
//- with optional read format
IPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct with optional communicator and read format.
//- Uses UPstream::masterNo() root
//- Construct for broadcast root with optional communicator,
//- write format
explicit IPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Receive (from broadcast, root == UPstream::masterNo())
//- and deserialize a value.
//- Uses \c operator>> for de-serialization
template<class Type>
static void recv
(
Type& value,
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
IPBstream is(comm, fmt);
is >> value;
}
};

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.
@ -34,7 +34,7 @@ License
Foam::UOPBstream::UOPBstream
(
const UPstream::commsTypes commsType,
const int rootProcNo,
const int toProcNo,
DynamicList<char>& sendBuf,
const int tag,
const label comm,
@ -42,23 +42,14 @@ Foam::UOPBstream::UOPBstream
IOstreamOption::streamFormat fmt
)
:
UOPstreamBase
(
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
sendBuf,
tag, // irrelevant
comm,
sendAtDestruct,
fmt
)
UOPstreamBase(commsType, toProcNo, sendBuf, tag, comm, sendAtDestruct, fmt)
{}
Foam::OPBstream::OPBstream
(
const UPstream::commsTypes commsType,
const int rootProcNo,
const int toProcNo,
const label bufSize,
const int tag,
const label comm,
@ -68,10 +59,10 @@ Foam::OPBstream::OPBstream
Pstream(commsType, bufSize),
UOPBstream
(
commsType, // irrelevant
rootProcNo, // normally UPstream::masterNo()
commsType,
toProcNo,
Pstream::transferBuf_,
tag, // irrelevant
tag,
comm,
true, // sendAtDestruct
fmt
@ -81,7 +72,7 @@ Foam::OPBstream::OPBstream
Foam::OPBstream::OPBstream
(
const int rootProcNo,
const int toProcNo,
const label comm,
IOstreamOption::streamFormat fmt
)
@ -89,25 +80,7 @@ Foam::OPBstream::OPBstream
OPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
rootProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,
fmt
)
{}
Foam::OPBstream::OPBstream
(
const label comm,
IOstreamOption::streamFormat fmt
)
:
OPBstream
(
UPstream::commsTypes::scheduled, // irrelevant
UPstream::masterNo(), // rootProcNo
toProcNo,
label(0), // bufSize
UPstream::msgType(), // irrelevant
comm,

View File

@ -144,39 +144,14 @@ public:
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct for broadcast root and communicator,
//- with optional write format
OPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
//- Construct with optional communicator and write format.
//- Uses UPstream::masterNo() root
//- Construct for broadcast root with optional communicator,
//- write format
explicit OPBstream
(
const int rootProcNo, //!< normally UPstream::masterNo()
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
);
// Static Functions
//- Serialize a value and broadcast (root == UPstream::masterNo()).
//- Uses \c operator<< for serialization
template<class Type>
static void send
(
const Type& value,
const label comm = UPstream::worldComm,
IOstreamOption::streamFormat fmt = IOstreamOption::BINARY
)
{
OPBstream os(comm, fmt);
os << value;
}
};

View File

@ -101,12 +101,6 @@ Foam::UOPstream::~UOPstream()
{
if (sendAtDestruct_)
{
// Note: sendAtDestruct_ and nonBlocking is a questionable combination
// since the transfer buffer will be destroyed before
// the non-blocking send completes!
//
// Could flag as an error, but not actually used anywhere.
if (!bufferIPCsend())
{
FatalErrorInFunction

View File

@ -41,19 +41,20 @@ void Foam::Pstream::broadcast(Type& value, const label comm)
(
reinterpret_cast<char*>(&value),
sizeof(Type),
comm
comm,
UPstream::masterNo()
);
}
else if (UPstream::is_parallel(comm))
{
if (UPstream::master(comm))
{
OPBstream os(comm);
OPBstream os(UPstream::masterNo(), comm);
os << value;
}
else // UPstream::is_subrank(comm)
{
IPBstream is(comm);
IPBstream is(UPstream::masterNo(), comm);
is >> value;
}
}
@ -67,12 +68,12 @@ void Foam::Pstream::broadcasts(const label comm, Type& arg1, Args&&... args)
{
if (UPstream::master(comm))
{
OPBstream os(comm);
OPBstream os(UPstream::masterNo(), comm);
Detail::outputLoop(os, arg1, std::forward<Args>(args)...);
}
else // UPstream::is_subrank(comm)
{
IPBstream is(comm);
IPBstream is(UPstream::masterNo(), comm);
Detail::inputLoop(is, arg1, std::forward<Args>(args)...);
}
}
@ -97,7 +98,8 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
(
reinterpret_cast<char*>(&len),
sizeof(label),
comm
comm,
UPstream::masterNo()
);
if (UPstream::is_subrank(comm))
@ -111,7 +113,8 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
(
list.data_bytes(),
list.size_bytes(),
comm
comm,
UPstream::masterNo()
);
}
}
@ -122,12 +125,12 @@ void Foam::Pstream::broadcastList(ListType& list, const label comm)
if (UPstream::master(comm))
{
OPBstream os(comm);
OPBstream os(UPstream::masterNo(), comm);
os << list;
}
else // UPstream::is_subrank(comm)
{
IPBstream is(comm);
IPBstream is(UPstream::masterNo(), comm);
is >> list;
}
}

View File

@ -32,13 +32,13 @@ Description
Use UOPstream to stream data into buffers, call finishedSends() to
notify that data is in buffers and then use IUPstream to get data out
of received buffers. Works with both buffered and non-blocking. Does
of received buffers. Works with both blocking and non-blocking. Does
not make much sense with scheduled since there you would not need these
explicit buffers.
Example usage:
\code
PstreamBuffers pBufs;
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
for (const int proci : UPstream::allProcs())
{
@ -51,7 +51,7 @@ Description
}
}
pBufs.finishedSends(); // no-op for buffered
pBufs.finishedSends(); // no-op for blocking
for (const int proci : UPstream::allProcs())
{
@ -68,7 +68,7 @@ Description
one-to-all and all-to-one communication patterns.
For example,
\code
PstreamBuffers pBufs;
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
if (UPstream::master())
{
@ -96,7 +96,7 @@ Description
For example,
\code
PstreamBuffers pBufs;
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
pBufs.initRegisterSend();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,7 +96,7 @@ protected:
const int comm_;
//- The message size, read on bufferIPCrecv or set directly
label messageSize_;
int messageSize_;
//- Receive position in buffer data, if ony
//- If there is no external location for recvBufPos_
@ -279,8 +279,8 @@ public:
// Static Functions
//- Read buffer contents from given processor.
// \return the message size (bytes read). May change in the future
static std::streamsize read
// \return the message size (bytes read)
static label read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -293,8 +293,8 @@ public:
);
//- Read buffer contents (non-blocking) from given processor.
// \return the message size (bytes read). May change in the future
inline static std::streamsize read
// \return the message size (bytes read)
inline static label read
(
//! [out] request information
UPstream::Request& req,
@ -321,7 +321,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static std::streamsize read
inline static label read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -348,7 +348,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static std::streamsize read
inline static label read
(
const UPstream::commsTypes commsType,
const int fromProcNo,
@ -375,7 +375,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static std::streamsize read
inline static label read
(
//! [out] request information
UPstream::Request& req,
@ -401,7 +401,7 @@ public:
// Only valid for contiguous data types.
// \return the message size (bytes read). May change in the future
template<class Type>
inline static std::streamsize read
inline static label read
(
//! [out] request information
UPstream::Request& req,
@ -474,8 +474,8 @@ public:
// Static Functions
//- Wrapped version of UPstream::broadcast
// \return the message size (bytes read). May change in the future
static std::streamsize read
// \return the message size (bytes read)
static label read
(
const int rootProcNo, //!< normally UPstream::masterNo()
char* buf,

View File

@ -50,11 +50,9 @@ const Foam::Enum
>
Foam::UPstream::commsTypeNames
({
{ commsTypes::buffered, "buffered" }, // "buffered"
{ commsTypes::blocking, "blocking" }, // "buffered"
{ commsTypes::scheduled, "scheduled" },
{ commsTypes::nonBlocking, "nonBlocking" }, // "immediate"
// compatibility names
{ commsTypes::buffered, "blocking" },
});

View File

@ -56,9 +56,6 @@ namespace Foam
//- Implementation details for UPstream/Pstream/MPI etc.
namespace PstreamDetail {}
//- Interface handling for UPstream/Pstream/MPI etc.
namespace PstreamUtils {}
/*---------------------------------------------------------------------------*\
Class UPstream Declaration
\*---------------------------------------------------------------------------*/
@ -73,17 +70,15 @@ public:
//- Communications types
enum class commsTypes : char
{
buffered, //!< "buffered" : (MPI_Bsend, MPI_Recv)
blocking, //!< "blocking" (buffered) : (MPI_Bsend, MPI_Recv)
scheduled, //!< "scheduled" (MPI standard) : (MPI_Send, MPI_Recv)
nonBlocking, //!< "nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
// Aliases
blocking = buffered //!< compatibility name for buffered
nonBlocking //!< "nonBlocking" (immediate) : (MPI_Isend, MPI_Irecv)
};
//- Enumerated names for the communication types
static const Enum<commsTypes> commsTypeNames;
//- Different MPI-send modes (ignored for commsTypes::buffered)
//- Different MPI-send modes (ignored for commsTypes::blocking)
enum class sendModes : char
{
normal, //!< (MPI_Send, MPI_Isend)
@ -93,9 +88,6 @@ public:
// Public Classes
//- Wrapper for MPI_Comm
class Communicator; // Forward Declaration
//- Wrapper for MPI_Request
class Request; // Forward Declaration
@ -1226,119 +1218,12 @@ public:
};
/*---------------------------------------------------------------------------*\
Class UPstream::Communicator Declaration
\*---------------------------------------------------------------------------*/
//- An opaque wrapper for MPI_Comm with a vendor-independent
//- representation without any \c <mpi.h> header.
// The MPI standard states that MPI_Comm is always an opaque object.
// Generally it is either an integer (eg, mpich) or a pointer (eg, openmpi).
class UPstream::Communicator
{
public:
// Public Types
//- Storage for MPI_Comm (as integer or pointer)
typedef std::intptr_t value_type;
private:
// Private Data
//- The MPI_Comm (as wrapped value)
value_type value_;
public:
// Generated Methods
//- Copy construct
Communicator(const Communicator&) noexcept = default;
//- Move construct
Communicator(Communicator&&) noexcept = default;
//- Copy assignment
Communicator& operator=(const Communicator&) noexcept = default;
//- Move assignment
Communicator& operator=(Communicator&&) noexcept = default;
// Member Operators
//- Test for equality
bool operator==(const Communicator& rhs) const noexcept
{
return (value_ == rhs.value_);
}
//- Test for inequality
bool operator!=(const Communicator& rhs) const noexcept
{
return (value_ != rhs.value_);
}
// Constructors
//- Default construct as MPI_COMM_NULL
Communicator() noexcept;
//- Construct from MPI_Comm (as pointer type)
explicit Communicator(const void* p) noexcept
:
value_(reinterpret_cast<value_type>(p))
{}
//- Construct from MPI_Comm (as integer type)
explicit Communicator(value_type val) noexcept
:
value_(val)
{}
// Factory Methods
//- Transcribe internally indexed communicator to wrapped value.
// Example,
// \code
// PstreamUtils::Cast::to_mpi
// (
// UPstream::Communicator::lookup(UPstream::commWorld())
// )
// \endcode
static Communicator lookup(const label comm);
// Member Functions
//- Return raw value
value_type value() const noexcept { return value_; }
//- Return as pointer value
const void* pointer() const noexcept
{
return reinterpret_cast<const void*>(value_);
}
//- True if not equal to MPI_COMM_NULL
bool good() const noexcept;
//- Reset to default constructed value (MPI_COMM_NULL)
void reset() noexcept;
};
/*---------------------------------------------------------------------------*\
Class UPstream::Request Declaration
\*---------------------------------------------------------------------------*/
//- An opaque wrapper for MPI_Request with a vendor-independent
//- representation without any \c <mpi.h> header.
//- representation independent of any \c <mpi.h> header
// The MPI standard states that MPI_Request is always an opaque object.
// Generally it is either an integer (eg, mpich) or a pointer (eg, openmpi).
class UPstream::Request

View File

@ -348,13 +348,6 @@ public:
// Token Access
//- The token contents (read-only access)
const tokenList& tokens() const noexcept { return *this; }
//- The token contents (read/write access)
tokenList& tokens() noexcept { return *this; }
//- True if putback token is in use
bool hasPutback() const noexcept { return Istream::hasPutback(); }
@ -433,7 +426,7 @@ public:
using tokenList::find;
//- Find range containing matching delimiter pair, starting at the
//- specified position. The position -1 indicates to continue
//- the specified position. The position -1 indicates to continue
//- from the present tokenIndex() position.
labelRange find
(
@ -442,13 +435,6 @@ public:
label pos = 0
) const;
//- Find compoundToken of specified Type, starting at the
//- specified position. The position -1 indicates to continue
//- from the present tokenIndex() position.
// \return nullptr if not found
template<class Type>
const Type* findCompound(label pos = 0) const;
// Token list modification
@ -643,10 +629,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "ITstreamI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

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