Compare commits

..

1 Commits

Author SHA1 Message Date
54dcde5f9a INT: compressibleInterFoam: assimilate DyM solver
Based on changes from openfoam.org
2024-05-01 16:44:42 +01:00
374 changed files with 3713 additions and 9549 deletions

View File

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

View File

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

View File

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

View File

@ -1,21 +1,25 @@
EXE_INC = \
-I../VoF \
-ItwoPhaseMixtureThermo \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-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)/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 \
-IVoFphaseCompressibleTurbulenceModels/lnInclude
-I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvOptions \
-lmeshTools \
-ldynamicMesh \
-ldynamicFvMesh \
-ltwoPhaseMixtureThermo \
-ltwoPhaseSurfaceTension \
-lcompressibleTransportModels \

View File

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

View File

@ -1,35 +0,0 @@
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

@ -1,43 +0,0 @@
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

@ -1,190 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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

@ -1,145 +0,0 @@
{
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-2017 OpenFOAM Foundation
Copyright (C) OpenCFD OpenCFD Ltd.
Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,7 +32,9 @@ Group
Description
Solver for two compressible, non-isothermal immiscible fluids using a VOF
(volume of fluid) phase-fraction based interface capturing approach.
(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.
@ -45,6 +47,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "dynamicFvMesh.H"
#include "CMULES.H"
#include "EulerDdtScheme.H"
#include "localEulerDdtScheme.H"
@ -53,6 +56,7 @@ Description
#include "compressibleInterPhaseTransportModel.H"
#include "pimpleControl.H"
#include "fvOptions.H"
#include "CorrectPhi.H"
#include "fvcSmooth.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,30 +74,31 @@ int main(int argc, char *argv[])
#include "addCheckCaseOptions.H"
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
#include "createControl.H"
#include "createTimeControls.H"
#include "createDynamicFvMesh.H"
#include "initContinuityErrs.H"
#include "createDyMControls.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 "readTimeControls.H"
#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)));
if (LTS)
{
@ -113,6 +118,44 @@ 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

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

View File

@ -6,7 +6,7 @@
(
"phiHbyA",
fvc::flux(HbyA)
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi))
+ MRF.zeroFilter(fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi, Uf))
);
MRF.makeRelative(phiHbyA);
@ -23,6 +23,9 @@
// 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;
@ -34,8 +37,7 @@
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)
@ -48,11 +50,9 @@
+ 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,7 +65,6 @@
+ fvm::div(phid2, p_rgh) - fvm::Sp(fvc::div(phid2), p_rgh)
)
);
p_rghEqnComp2.ref().relax();
}
else
{
@ -94,6 +93,21 @@
);
}
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);
@ -131,6 +145,9 @@
}
}
// 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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -123,7 +123,7 @@ int main(int argc, char *argv[])
);
Info<< testInput << nl;
auto args = stringOps::splitSpace(testInput);
SubStrings<string> args = stringOps::splitSpace(testInput);
Info<< "split into " << args.size() << " args" << nl;
CStringList inC(args);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,137 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-ensightFile
Description
check cleanup of ensight file and variable names
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "ensightFile.H"
#include "ensightGeoFile.H"
#include "Switch.H"
#include "IOstreams.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::addBoolOption("ascii", "open as ascii instead of binary");
argList::addBoolOption("binary", "(default)");
argList::addBoolOption("clear", "force clear of time-steps");
argList::addBoolOption("no-end", "skip use of endTimeStep");
argList::addBoolOption("append", "open in append mode");
argList::addOption("geom", "geometry file");
argList::addOption("field", "field file");
#include "setRootCase.H"
const bool with_ascii = args.found("ascii") && !args.found("binary");
// const bool with_binary = args.found("binary");
const bool with_append = args.found("append");
const bool with_clear = args.found("clear");
const bool without_end = args.found("no-end");
const IOstreamOption::streamFormat fmt =
(
with_ascii
? IOstreamOption::ASCII
: IOstreamOption::BINARY
);
const IOstreamOption::appendType append =
(
with_append
? IOstreamOption::APPEND_ATE
: IOstreamOption::NO_APPEND
);
fileName file;
if (args.readIfPresent("geom", file))
{
Info<< "Open " << file << " as geometry "
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
<< " append:" << Switch::name(with_append) << nl;
ensightGeoFile ensFile(append, file, fmt);
if (append)
{
ensFile.beginTimeStep();
// At the moment need to pair begin/end time-step calls
if (!without_end)
{
ensFile.endTimeStep();
}
}
if (with_clear)
{
ensFile.clearTimeSteps();
}
}
if (args.readIfPresent("field", file))
{
Info<< "Open " << file << " as field"
<< " format:" << (with_ascii ? "ASCII" : "BINARY")
<< " append:" << Switch::name(with_append) << nl;
ensightFile ensFile(append, file, fmt);
if (append)
{
ensFile.beginTimeStep();
// At the moment need to pair begin/end time-step calls
if (!without_end)
{
ensFile.endTimeStep();
}
}
if (with_clear)
{
ensFile.clearTimeSteps();
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -148,7 +148,7 @@ int main(int argc, char *argv[])
Info<< "input: " << input << nl
<< "expand: " << output << nl
<< "split: " << stringOps::split(output, '/') << nl << nl;
<< "split: " << stringOps::split(output, "/") << nl << nl;
}
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,6 @@ Description
#include "argList.H"
#include "fileName.H"
#include "stringOps.H"
#include "Switch.H"
using namespace Foam;
@ -66,9 +65,6 @@ int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noMandatoryArgs();
argList::addArgument("string .. stringN");
argList::addOption
(
"any",
@ -93,12 +89,6 @@ int main(int argc, char *argv[])
"int",
"test split on fixed width"
);
argList::addOption
(
"begin",
"int",
"begin offset for splits"
);
argList::addBoolOption
(
"slash",
@ -114,25 +104,18 @@ int main(int argc, char *argv[])
"empty",
"preserve empty strings in split"
);
argList args(argc, argv);
argList args(argc, argv, false, true);
if (args.size() <= 1 && args.options().empty())
{
args.printUsage();
}
const label beginOffset = args.getOrDefault<label>("begin", 0);
const bool keepEmpty = args.found("empty");
Info<< "begin offset: " << beginOffset << nl;
Info<< "keep empty : " << Switch::name(keepEmpty) << nl;
const label nopts =
args.count({"any", "slash", "space", "sub", "fixed", "char"});
if (args.found("any"))
{
const std::string& str = args["any"];
@ -142,7 +125,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split = stringOps::splitAny(args[argi], str, beginOffset);
const auto split = stringOps::splitAny(args[argi], str);
printSubStrings(args[argi], split);
}
@ -161,7 +144,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split = stringOps::split(args[argi], str, beginOffset);
const auto split = stringOps::split(args[argi], str);
printSubStrings(args[argi], split);
}
@ -178,11 +161,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split = stringOps::splitSpace(args[argi], beginOffset);
printSubStrings(args[argi], split);
Info<< "pop_front(2)" << nl;
split.pop_front(2);
const auto split = stringOps::splitSpace(args[argi]);
printSubStrings(args[argi], split);
}
@ -201,8 +180,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split =
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
const auto split = stringOps::split(args[argi], delim, keepEmpty);
printSubStrings(args[argi], split);
}
@ -221,7 +199,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split = stringOps::splitFixed(args[argi], width, beginOffset);
const auto split = stringOps::splitFixed(args[argi], width);
printSubStrings(args[argi], split);
}
@ -241,8 +219,7 @@ int main(int argc, char *argv[])
for (label argi=1; argi < args.size(); ++argi)
{
auto split =
stringOps::split(args[argi], delim, beginOffset, keepEmpty);
const auto split = stringOps::split(args[argi], delim, keepEmpty);
printSubStrings(args[argi], split);
}
}

View File

@ -157,7 +157,7 @@ int main(int argc, char *argv[])
// // skip over time=0, unless some other time option has been specified
// if
// (
// !args.found("noZero")
// !args.found("zeroTime")
// && !args.found("time")
// && !args.found("latestTime")
// && Times.size() > 2

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.
@ -93,34 +93,29 @@ void Foam::fileFormats::ensightMeshReader::readIDs
(
ensightReadFile& is,
const bool doRead,
const label elemCount,
const label nShapes,
labelList& foamToElem,
Map<label>& elemToFoam
) const
{
const label begElem = foamToElem.size();
const label endElem = begElem + elemCount;
foamToElem.resize(foamToElem.size()+elemCount);
const label sz = foamToElem.size();
foamToElem.resize(sz+nShapes);
if (doRead)
{
elemToFoam.reserve(elemToFoam.size()+elemCount);
for (label elemi = begElem; elemi < endElem; ++elemi)
elemToFoam.reserve(elemToFoam.size()+nShapes);
for (label shapei = 0; shapei < nShapes; shapei++)
{
label id;
is.read(id);
foamToElem[elemi] = id;
elemToFoam.insert(id, elemi);
label elemi;
is.read(elemi);
foamToElem[sz+shapei] = elemi;
elemToFoam.insert(elemi, sz+shapei);
}
}
else
{
// identity
for (label elemi = begElem; elemi < endElem; ++elemi)
for (label shapei = 0; shapei < nShapes; shapei++)
{
foamToElem[elemi] = elemi;
foamToElem[sz+shapei] = sz+shapei;
}
}
}
@ -214,54 +209,37 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
// Work
DynamicList<label> verts;
string buffer;
string line;
while (is.good())
{
do
{
// Get entire line/string
is.read(buffer);
is.readKeyword(line);
}
while (buffer.empty() && is.good());
while (line.empty() && is.good());
if (!is.good())
{
break;
}
else if (buffer.contains("BEGIN TIME STEP"))
{
// Graciously handle a miscued start
continue;
}
else if (buffer.contains("END TIME STEP"))
{
// END TIME STEP is a valid means to terminate input
break;
}
const auto split = stringOps::splitSpace(buffer);
const auto split = stringOps::splitSpace(line);
if (split.empty())
if (split.size() == 0)
{
continue;
}
const auto keyword(split[0].str());
if (keyword == "part")
if (split[0] == "part")
{
return false;
}
else if (keyword == "node_ids")
else if (split[0] == "node_ids")
{
const label nPoints = points.size();
// Ignore point ids
for (label pointi = 0; pointi < nPoints; ++pointi)
// Ignore for now
for (label i = 0; i < nPoints; i++)
{
label id;
is.read(id);
label index;
is.read(index);
}
}
else if (keyword == "coordinates")
else if (split[0] == "coordinates")
{
label nPoints;
is.read(nPoints);
@ -279,205 +257,207 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
nodeIdToPoints
);
points.setSize(nPoints);
is.readPoints(nPoints, points);
for (label pointi = 0; pointi < nPoints; pointi++)
{
is.read(points[pointi].x());
}
for (label pointi = 0; pointi < nPoints; pointi++)
{
is.read(points[pointi].y());
}
for (label pointi = 0; pointi < nPoints; pointi++)
{
is.read(points[pointi].z());
}
}
else if (keyword == "tetra4")
else if (split[0] == "tetra4")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent<< "tetra4 " << elemCount
Pout<< indent<< "tetra4 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label celli = cells.size();
cells.resize(celli+nShapes);
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
cellToElemIds,
elemIdToCells
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
cells.resize(startElemi+elemCount);
faceListList::subList myElements = cells.slice(startElemi);
const auto& model = cellModel::ref(cellModel::TET);
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
readVerts(is, 4, nodeIdToPoints, verts);
if (setHandedness_)
{
setHandedness(model, verts, points);
}
cellFaces = cellShape(model, verts).faces();
const cellShape cellVerts(model, verts);
cells[celli+shapei] = cellVerts.faces();
}
}
else if (keyword == "pyramid5")
else if (split[0] == "pyramid5")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent<< "pyramid5 " << elemCount
Pout<< indent<< "pyramid5 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label celli = cells.size();
cells.resize(celli+nShapes);
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
cellToElemIds,
elemIdToCells
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
cells.resize(startElemi+elemCount);
faceListList::subList myElements = cells.slice(startElemi);
const auto& model = cellModel::ref(cellModel::PYR);
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
readVerts(is, 5, nodeIdToPoints, verts);
if (setHandedness_)
{
setHandedness(model, verts, points);
}
cellFaces = cellShape(model, verts).faces();
const cellShape cellVerts(model, verts);
cells[celli+shapei] = cellVerts.faces();
}
}
else if (keyword == "penta6")
else if (split[0] == "penta6")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent<< "penta6 " << elemCount
Pout<< indent<< "penta6 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label celli = cells.size();
cells.resize(celli+nShapes);
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
cellToElemIds,
elemIdToCells
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
cells.resize(startElemi+elemCount);
faceListList::subList myElements = cells.slice(startElemi);
const auto& model = cellModel::ref(cellModel::PRISM);
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
readVerts(is, 6, nodeIdToPoints, verts);
if (setHandedness_)
{
setHandedness(model, verts, points);
}
cellFaces = cellShape(model, verts).faces();
const cellShape cellVerts(model, verts);
cells[celli+shapei] = cellVerts.faces();
}
}
else if (keyword == "hexa8")
else if (split[0] == "hexa8")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent<< "hexa8 " << elemCount
Pout<< indent<< "hexa8 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label celli = cells.size();
cells.resize(celli+nShapes);
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
cellToElemIds,
elemIdToCells
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
cells.resize(startElemi+elemCount);
faceListList::subList myElements = cells.slice(startElemi);
const auto& model = cellModel::ref(cellModel::HEX);
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
readVerts(is, 8, nodeIdToPoints, verts);
if (setHandedness_)
{
setHandedness(model, verts, points);
}
cellFaces = cellShape(model, verts).faces();
const cellShape cellVerts(model, verts);
cells[celli+shapei] = cellVerts.faces();
}
}
else if (keyword == "nfaced")
else if (split[0] == "nfaced")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent<< "nfaced " << elemCount
Pout<< indent<< "nfaced " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label celli = cells.size();
cells.resize(celli+nShapes);
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
cellToElemIds,
elemIdToCells
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
cells.resize(startElemi+elemCount);
faceListList::subList myElements = cells.slice(startElemi);
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
label nFaces;
is.read(nFaces);
cellFaces.resize(nFaces);
faceList& cellFaces = cells[celli+shapei];
cellFaces.setSize(nFaces);
}
for (auto& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
for (face& f : cellFaces)
faceList& cellFaces = cells[celli+shapei];
forAll(cellFaces, cellFacei)
{
label nVerts;
is.read(nVerts);
f.resize(nVerts);
cellFaces[cellFacei].setSize(nVerts);
}
}
for (faceList& cellFaces : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
for (face& f : cellFaces)
faceList& cellFaces = cells[celli+shapei];
forAll(cellFaces, cellFacei)
{
face& f = cellFaces[cellFacei];
readVerts(is, f.size(), nodeIdToPoints, verts);
f.labelList::operator=(verts);
}
}
// Full check
forAll(myElements, elemi)
{
for (const face& f : myElements[elemi])
{
for (label pointi : f)
forAll(f, fp)
{
if (pointi < 0 || pointi >= points.size())
if (f[fp] < 0 || f[fp] >= points.size())
{
FatalErrorInFunction
<< "Face:" << elemi
FatalErrorInFunction<< "Face:" << shapei
<< " verts:" << f
<< " indexes outside points:" << points.size()
<< exit(FatalError);
@ -486,104 +466,107 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart
}
}
}
else if (keyword == "tria3")
else if (split[0] == "tria3")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent << "tria3 " << elemCount
Pout<< indent << "tria3 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label facei = faces.size();
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
faceToElemIDs,
elemIdToFaces
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
faces.resize(startElemi+elemCount, face(3)); // <- tria3
faceList::subList myElements = faces.slice(startElemi);
faces.setSize(facei+nShapes);
for (face& f : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
auto& f = faces[facei+shapei];
f.setSize(3);
readVerts(is, f.size(), nodeIdToPoints, verts);
f.labelList::operator=(verts);
}
}
else if (keyword == "quad4")
else if (split[0] == "quad4")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent << "quad4 " << elemCount
Pout<< indent << "quad4 " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label facei = faces.size();
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
faceToElemIDs,
elemIdToFaces
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
faces.resize(startElemi+elemCount, face(4)); // <- quad4
faceList::subList myElements = faces.slice(startElemi);
faces.setSize(facei+nShapes);
for (face& f : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
auto& f = faces[facei+shapei];
f.setSize(4);
readVerts(is, f.size(), nodeIdToPoints, verts);
f.labelList::operator=(verts);
}
}
else if (keyword == "nsided")
else if (split[0] == "nsided")
{
label elemCount;
is.read(elemCount);
label nShapes;
is.read(nShapes);
Pout<< indent << "nsided " << elemCount
Pout<< indent << "nsided " << nShapes
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
const label facei = faces.size();
readIDs
(
is,
read_elem_ids,
elemCount,
nShapes,
faceToElemIDs,
elemIdToFaces
);
// Extend and fill the new trailing portion
const label startElemi = cells.size();
faces.resize(startElemi+elemCount);
faceList::subList myElements = faces.slice(startElemi);
faces.setSize(facei+nShapes);
for (face& f : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
auto& f = faces[facei+shapei];
label nVerts;
is.read(nVerts);
f.resize(nVerts);
f.setSize(nVerts);
}
for (face& f : myElements)
for (label shapei = 0; shapei < nShapes; shapei++)
{
auto& f = faces[facei+shapei];
readVerts(is, f.size(), nodeIdToPoints, verts);
f.labelList::operator=(verts);
}
}
else
{
WarningInFunction << "Unhandled key " << keyword
<< " from line " << buffer
WarningInFunction << "Unhandled key " << string(split[0])
<< " from line " << line
<< " starting at line " << is.lineNumber()
<< " position " << is.stdStream().tellg() << endl;
}
@ -601,21 +584,16 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
const scalar scaleFactor
)
{
// Auto-detect ascii/binary format,
// skips any initial "BEGIN TIME STEP"
ensightReadFile is(geometryFile_);
// Skip 'binary' tag
is.readBinaryHeader();
string buffer;
// Ensight Geometry File
is.read(buffer);
Info<< "Ensight : " << buffer << nl;
// Description - 1
is.read(buffer);
Info<< "Ensight : " << buffer << nl;
string header;
is.read(header);
Info<< "Ensight : " << header << endl;
is.read(header);
Info<< "Ensight : " << header << endl;
bool read_node_ids = false;
@ -645,72 +623,61 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
// Parse all
SubStrings<string> split;
string line;
while (is.good())
{
do
{
// Get entire line/string
is.read(buffer);
is.readKeyword(line);
}
while (buffer.empty() && is.good());
if (buffer.contains("END TIME STEP"))
while (line.empty() && is.good());
const auto split = stringOps::splitSpace(line);
if (split[0] == "extents")
{
// END TIME STEP is a valid means to terminate input
break;
point min;
point max;
is.read(min.x());
is.read(max.x());
is.read(min.y());
is.read(max.y());
is.read(min.z());
is.read(max.z());
Pout<< indent
<< "Read extents " << boundBox(min, max)
<< endl;
}
split = stringOps::splitSpace(buffer);
if (split.empty())
else if (split[0] == "node")
{
continue;
}
const auto keyword(split[0].str());
if (keyword == "extents")
{
// Optional extents (xmin, xmax, ymin, ymax, zmin, zmax)
boundBox bb;
point& min = bb.min();
point& max = bb.max();
is.read(min.x()); is.read(max.x());
is.read(min.y()); is.read(max.y());
is.read(min.z()); is.read(max.z());
Pout<< indent << "Read extents " << bb << endl;
}
else if (keyword == "node")
{
// "node id (off|assign|given|ignore)"
std::string op(split[2]);
word id(split[1]);
word op(split[2]);
if (op == "given" || op == "ignore")
{
Pout<< indent << "Reading node ids" << endl;
read_node_ids = true;
}
}
else if (keyword == "element")
else if (split[0] == "element")
{
// "element id (off|assign|given|ignore)"
std::string op(split[2]);
word id(split[1]);
word op(split[2]);
if (op == "given" || op == "ignore")
{
Pout<< indent << "Reading element ids" << endl;
read_elem_ids = true;
}
}
else if (keyword == "part")
else if (split[0] == "part")
{
bool finished = false;
do
{
// Read part id and name
is.read(partIDs.emplace_back());
is.read(partNames.emplace_back());
// Make space
partIDs.emplace_back();
is.read(partIDs.back());
partNames.emplace_back();
is.read(partNames.back());
Pout<< indent
<< "Reading part " << partIDs.back()
@ -987,7 +954,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
const face& f = rotateFace(cFaces[cFacei], rotatedFace);
const auto fFnd = vertsToCell.find(f);
if (fFnd.good())
if (fFnd)
{
// Already inserted. Internal face.
vertsToCell.erase(fFnd);
@ -1059,12 +1026,7 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
)
);
if (cAndF.good())
{
partCellAndFace[patchFacei++] = cAndF.val();
vertsToCell.erase(cAndF);
}
else
if (!cAndF)
{
//WarningInFunction
// << "Did not find face " << facei
@ -1074,6 +1036,11 @@ bool Foam::fileFormats::ensightMeshReader::readGeometry
// << " in part " << parti
// << endl;
}
else
{
partCellAndFace[patchFacei++] = cAndF();
vertsToCell.erase(cAndF);
}
}
partCellAndFace.setSize(patchFacei);
}

View File

@ -1569,7 +1569,7 @@ int main(int argc, char *argv[])
//Get polyMesh to write to constant
runTime.setTime(instant(0, runTime.constant()), 0);
runTime.setTime(instant(runTime.constant()), 0);
repatcher.repatch();

View File

@ -803,10 +803,6 @@ CompactListList<label> regionRenumber
int main(int argc, char *argv[])
{
argList::noFunctionObjects(); // Never use function objects
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Renumber mesh cells to reduce the bandwidth. Use the -lib option or"
@ -867,8 +863,11 @@ int main(int argc, char *argv[])
"eg, 'reverse true;'"
);
argList::noFunctionObjects(); // Never use function objects
#include "addAllRegionOptions.H"
#include "addOverwriteOption.H"
#include "addTimeOptions.H"
// -------------------------
@ -927,15 +926,14 @@ int main(int argc, char *argv[])
// Get region names
#include "getAllRegionOptions.H"
// Set time from specified time options, or force start from Time=0
timeSelector::setTimeIfPresent(runTime, args, true);
// Get times list
instantList Times = runTime.times();
// Set startTime depending on -time and -latestTime options
#include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
// Capture current time information for non-overwrite
const Tuple2<instant, label> startTime
(
instant(runTime.value(), runTime.timeName()),
runTime.timeIndex()
);
// Start/reset all timings
timer.resetTime();
@ -949,10 +947,7 @@ int main(int argc, char *argv[])
for (fvMesh& mesh : meshes)
{
// Reset time in case of multiple meshes and not overwrite
if (!overwrite)
{
runTime.setTime(startTime.first(), startTime.second());
}
runTime.setTime(Times[startTime], startTime);
const word oldInstance = mesh.pointsInstance();

View File

@ -62,13 +62,12 @@ using namespace Foam;
int main(int argc, char *argv[])
{
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Add point/face/cell Zones from similarly named point/face/cell Sets"
);
timeSelector::addOptions(true, false); // constant(true), zero(false)
argList::addBoolOption
(
"noFlipMap",
@ -76,13 +75,14 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
const bool noFlipMap = args.found("noFlipMap");
// Allow override of time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
// Get times list
(void)timeSelector::selectIfPresent(runTime, args);
#include "createNamedPolyMesh.H"

View File

@ -240,9 +240,9 @@ int main(int argc, char *argv[])
// Read set construct info from dictionary
List<namedDictionary> actionEntries(topoSetDict.lookup("actions"));
forAll(timeDirs, timei)
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timei], timei);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;
// Optionally re-read mesh

View File

@ -549,17 +549,16 @@ int main(int argc, char *argv[])
{
Info<< finder.dict();
}
else if (finder.isStream())
else if (finder.ref().isStream())
{
bool separator = false;
bool addSep = false;
for (const token& tok : finder.stream())
const tokenList& tokens = finder.ref().stream();
for (const token& tok : tokens)
{
if (separator)
{
Info<< token::SPACE;
}
separator = true;
if (addSep) Info<< token::SPACE;
addSep = true;
Info<< tok;
}
Info<< endl;

View File

@ -554,8 +554,7 @@ int main(int argc, char *argv[])
{
autoPtr<ensightGeoFile> os =
ensCase.newGeometry(hasMovingMesh);
ensMesh.write(os.ref());
ensMesh.write(os);
}
// finite-area
@ -563,8 +562,7 @@ int main(int argc, char *argv[])
{
autoPtr<ensightGeoFile> os =
ensFaCasePtr->newGeometry(hasMovingMesh);
ensFaMeshPtr->write(os.ref());
ensFaMeshPtr->write(os);
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2023-2024 OpenCFD Ltd.
Copyright (C) 2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,7 +36,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "volFields.H"
#include "pointFields.H"
@ -146,22 +145,20 @@ void ReadAndMapFields
int main(int argc, char *argv[])
{
argList::noFunctionObjects(); // Never use function objects
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Convert polyMesh results to tetDualMesh"
);
#include "addOverwriteOption.H"
#include "addTimeOptions.H"
#include "setRootCase.H"
#include "createTime.H"
// Set time from specified time options, or force start from Time=0
timeSelector::setTimeIfPresent(runTime, args, true);
// Get times list
instantList Times = runTime.times();
#include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
// Read the mesh
#include "createNamedMesh.H"

View File

@ -353,7 +353,7 @@ int main(int argc, char *argv[])
#include "createTime.H"
runTime.setTime(instant(0, runTime.constant()), 0);
runTime.setTime(instant(runTime.constant()), 0);
#include "createNamedMesh.H"

View File

@ -106,7 +106,7 @@ int main(int argc, char *argv[])
}
runTime.setTime(instant(0, runTime.constant()), 0);
runTime.setTime(instant(runTime.constant()), 0);
#include "createNamedMesh.H"

View File

@ -26,8 +26,8 @@ License
\*---------------------------------------------------------------------------*/
#ifndef Foam_MapConsistentVolFields_H
#define Foam_MapConsistentVolFields_H
#ifndef MapConsistentVolFields_H
#define MapConsistentVolFields_H
#include "GeometricField.H"
#include "meshToMesh.H"
@ -41,9 +41,10 @@ namespace Foam
template<class Type>
void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
{
auto& bfld = fld.boundaryFieldRef();
auto& fldBf = fld.boundaryFieldRef();
const UPstream::commsTypes commsType = UPstream::defaultCommsType;
const label startOfRequests = UPstream::nRequests();
if
(
@ -51,32 +52,37 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
|| commsType == UPstream::commsTypes::nonBlocking
)
{
const label startOfRequests = UPstream::nRequests();
for (auto& pfld : bfld)
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
pfld.type() == pfld.patch().patch().type()
&& polyPatch::constraintType(pfld.patch().patch().type())
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
pfld.initEvaluate(commsType);
tgtField.initEvaluate(commsType);
}
}
// Wait for outstanding requests (non-blocking)
UPstream::waitRequests(startOfRequests);
for (auto& pfld : bfld)
// Wait for outstanding requests
if (commsType == UPstream::commsTypes::nonBlocking)
{
UPstream::waitRequests(startOfRequests);
}
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
pfld.type() == pfld.patch().patch().type()
&& polyPatch::constraintType(pfld.patch().patch().type())
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
pfld.evaluate(commsType);
tgtField.evaluate(commsType);
}
}
}
@ -88,21 +94,22 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
for (const auto& schedEval : patchSchedule)
{
const label patchi = schedEval.patch;
auto& pfld = bfld[patchi];
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
pfld.type() == pfld.patch().patch().type()
&& polyPatch::constraintType(pfld.patch().patch().type())
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
if (schedEval.init)
{
pfld.initEvaluate(commsType);
tgtField.initEvaluate(commsType);
}
else
{
pfld.evaluate(commsType);
tgtField.evaluate(commsType);
}
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2017 DHI
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
Copyright (C) 2017-2020 German Aerospace Center (DLR)
Copyright (C) 2020 Johan Roenby
-------------------------------------------------------------------------------
@ -39,7 +39,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "timeSelector.H"
#include "triSurface.H"
#include "triSurfaceTools.H"
@ -140,10 +139,6 @@ void setAlpha
int main(int argc, char *argv[])
{
argList::noFunctionObjects(); // Never use function objects
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Uses cutCellIso to create a volume fraction field from an "
@ -156,14 +151,9 @@ int main(int argc, char *argv[])
"file",
"Alternative setAlphaFieldDict dictionary"
);
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
// Set time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
#include "createNamedMesh.H"
const word dictName("setAlphaFieldDict");

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2022-2024 OpenCFD Ltd.
Copyright (C) 2022-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,7 +36,6 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "fvMesh.H"
#include "faMesh.H"
@ -657,10 +656,6 @@ struct setAreaField
int main(int argc, char *argv[])
{
argList::noFunctionObjects(); // Never use function objects
timeSelector::addOptions_singleTime(); // Single-time options
argList::addNote
(
"Set values on a selected set of cells/patch-faces via a dictionary"
@ -675,15 +670,8 @@ int main(int argc, char *argv[])
);
#include "addRegionOption.H"
// -------------------------
#include "setRootCase.H"
#include "createTime.H"
// Set time from specified time options, or no-op
timeSelector::setTimeIfPresent(runTime, args);
#include "createNamedMesh.H"
autoPtr<faMesh> faMeshPtr;

View File

@ -210,7 +210,7 @@ reportExecutable()
{
APP_NAME="$1"
APP_SPEC="$2"
APP_PATH="$(findExec "$PATH" "$1")"
APP_PATH="$(findExec $PATH $1)"
VERSION="unknown"
if [ -z "$APP_PATH" ]

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2406 |
| \\ / O peration | Version: v2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -146,18 +146,13 @@ OptimisationSwitches
// The default and minimum is (20000000).
mpiBufferSize 0;
// Optional max size (bytes) for unstructured data exchanges.
// In some phases of OpenFOAM it can send over very large data chunks
// Optional max size (bytes) for unstructured data exchanges. In some
// phases of OpenFOAM it can send over very large data chunks
// (e.g. in parallel load balancing) and some MPI implementations have
// problems with this.
//
// This tuning parameter specifies the max number of bytes before
// switching to a multi-pass send/recv
// (currently only affects PstreamBuffers exchanges).
//
// 0 : disabled
// >0 : limit exchanges to specified number of bytes
// <0 : limit exchanges to INT_MAX minus specified number of bytes
// problems with this. Setting this variable > 0 indicates that the
// data exchange needs to be done in multiple passes, each of maxCommsSize.
// This is not switched on by default since it requires an additional
// global reduction, even if multi-pass is not needed)
maxCommsSize 0;
// Optional (experimental) feature in lduMatrixUpdate

View File

@ -445,7 +445,6 @@ $(lduMatrix)/solvers/PBiCGStab/PBiCGStab.C
$(lduMatrix)/solvers/FPCG/FPCG.C
$(lduMatrix)/solvers/PPCG/PPCG.C
$(lduMatrix)/solvers/PPCR/PPCR.C
$(lduMatrix)/solvers/GMRES/gmresSolver.C
$(lduMatrix)/smoothers/GaussSeidel/GaussSeidelSmoother.C
$(lduMatrix)/smoothers/symGaussSeidel/symGaussSeidelSmoother.C

View File

@ -121,12 +121,6 @@ class IOobject;
template<>
Ostream& operator<<(Ostream&, const InfoProxy<IOobject>&);
// Traits
//- Trait for specifying global vs. local IOobject file types
template<class T>
struct is_globalIOobject : std::false_type {};
/*---------------------------------------------------------------------------*\
Class IOobject Declaration
@ -718,8 +712,6 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Specialization for \c void always returns true (no headerClassName check).
template<>
inline bool IOobject::isHeaderClass<void>() const
@ -728,6 +720,11 @@ inline bool IOobject::isHeaderClass<void>() const
}
//- Trait for specifying global vs. local file types
template<class T>
struct is_globalIOobject : std::false_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,26 +122,6 @@ Foam::GlobalIOField<Type>::GlobalIOField
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::Field<Type> Foam::GlobalIOField<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}
// The object is global
rio.globalObject(true);
GlobalIOField<Type> reader(rio);
return Field<Type>(std::move(static_cast<Field<Type>&>(reader)));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
@ -155,8 +135,7 @@ bool Foam::GlobalIOField<Type>::readData(Istream& is)
template<class Type>
bool Foam::GlobalIOField<Type>::writeData(Ostream& os) const
{
os << static_cast<const Field<Type>&>(*this);
return os.good();
return (os << static_cast<const Field<Type>&>(*this)).good();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,19 +85,13 @@ public:
GlobalIOField(const IOobject& io, const tmp<Field<Type>>& tfld);
// Factory Methods
//- Read and return contents. The IOobject is never registered
static Field<Type> readContents(const IOobject& io);
//- Destructor
virtual ~GlobalIOField() = default;
// Member Functions
//- The object is global
//- Is object global
virtual bool global() const
{
return true;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2024 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,26 +106,6 @@ Foam::GlobalIOList<Type>::GlobalIOList
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
Foam::List<Type> Foam::GlobalIOList<Type>::readContents(const IOobject& io)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
{
rio.readOpt(IOobjectOption::MUST_READ);
}
// The object is global
rio.globalObject(true);
GlobalIOList<Type> reader(rio);
return List<Type>(std::move(static_cast<List<Type>&>(reader)));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
@ -139,8 +119,7 @@ bool Foam::GlobalIOList<Type>::readData(Istream& is)
template<class Type>
bool Foam::GlobalIOList<Type>::writeData(Ostream& os) const
{
os << static_cast<const List<Type>&>(*this);
return os.good();
return (os << *this).good();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2018-2024 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,12 +85,6 @@ public:
GlobalIOList(const IOobject& io, List<Type>&& content);
// Factory Methods
//- Read and return contents. The IOobject is never registered
static List<Type> readContents(const IOobject& io);
//- Destructor
virtual ~GlobalIOList() = default;

View File

@ -105,9 +105,6 @@ Foam::Map<T> Foam::IOMap<T>::readContents(const IOobject& io)
rio.readOpt(IOobjectOption::MUST_READ);
}
// The object is global
rio.globalObject(true);
IOMap<T> reader(rio);
return Map<T>(std::move(static_cast<Map<T>&>(reader)));

View File

@ -101,7 +101,9 @@ public:
// Member Functions
//- This object is global
bool writeData(Ostream& os) const;
//- Is object global
virtual bool global() const
{
return true;
@ -114,9 +116,6 @@ public:
return globalFilePath(type());
}
//- The writeData method for regIOobject write operation
bool writeData(Ostream& os) const;
// Member Operators

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,16 +94,6 @@ Foam::IOdictionary::IOdictionary
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::dictionary Foam::IOdictionary::readContents(const IOobject& io)
{
return readContents(io, typeName);
}
Foam::dictionary Foam::IOdictionary::readContents
(
const IOobject& io,
const word& wantedType
)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
@ -111,14 +101,7 @@ Foam::dictionary Foam::IOdictionary::readContents
rio.readOpt(IOobjectOption::MUST_READ);
}
// The object is global
rio.globalObject(true);
IOdictionary reader
(
rio,
(wantedType.empty() ? typeName : wantedType)
);
IOdictionary reader(rio);
return dictionary(std::move(static_cast<dictionary&>(reader)));
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,18 +89,9 @@ public:
// Factory Methods
//- Read and return contents, testing for "dictionary" type.
//- The IOobject will not be registered
//- Read and return contents. The IOobject will not be registered
static dictionary readContents(const IOobject& io);
//- Read and return contents, testing for expected type.
//- The IOobject will not be registered
static dictionary readContents
(
const IOobject& io,
const word& wantedType
);
//- Destructor
virtual ~IOdictionary() = default;
@ -108,14 +99,14 @@ public:
// Member Functions
//- The 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

@ -92,7 +92,7 @@ bool Foam::baseIOdictionary::readData(Istream& is)
{
is >> *this;
if (writeDictionaries && UPstream::master() && !is.bad())
if (writeDictionaries && Pstream::master() && !is.bad())
{
Sout<< nl
<< "--- baseIOdictionary " << name()

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,16 +91,6 @@ Foam::localIOdictionary::localIOdictionary
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::dictionary Foam::localIOdictionary::readContents(const IOobject& io)
{
return readContents(io, typeName);
}
Foam::dictionary Foam::localIOdictionary::readContents
(
const IOobject& io,
const word& wantedType
)
{
IOobject rio(io, IOobjectOption::NO_REGISTER);
if (rio.readOpt() == IOobjectOption::READ_MODIFIED)
@ -108,11 +98,7 @@ Foam::dictionary Foam::localIOdictionary::readContents
rio.readOpt(IOobjectOption::MUST_READ);
}
localIOdictionary reader
(
rio,
(wantedType.empty() ? typeName : wantedType)
);
localIOdictionary reader(rio);
return dictionary(std::move(static_cast<dictionary&>(reader)));
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2021-2024 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -86,18 +86,9 @@ public:
// Factory Methods
//- Read and return contents, testing for "dictionary" type.
//- The IOobject will not be registered
//- Read and return contents. The IOobject will not be registered
static dictionary readContents(const IOobject& io);
//- Read and return contents, testing for expected type.
//- The IOobject will not be registered
static dictionary readContents
(
const IOobject& io,
const word& wantedType
);
//- Destructor
virtual ~localIOdictionary() = default;
@ -105,14 +96,14 @@ public:
// Member Functions
//- The object is not global
//- Is object global
virtual bool global() const
{
return false;
}
//- Return complete path + object name if the file exists
//- in the case otherwise null
// in the case otherwise null
virtual fileName filePath() const
{
// Use default (local only) search strategy

View File

@ -101,14 +101,14 @@ public:
// Member Functions
//- The 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

@ -28,8 +28,7 @@ Class
Foam::IFstream
Description
Input from file stream as an ISstream, normally using \c std::ifstream
for the actual input.
Input from file stream, using an ISstream
SourceFiles
IFstream.C

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -66,7 +66,7 @@ Foam::OFstream::OFstream
(
pathname,
streamOpt,
append,
(IOstreamOption::appendType::APPEND == append),
(IOstreamOption::atomicType::ATOMIC == atomic)
),
OSstream(*(ofstreamPointer::get()), pathname, streamOpt)

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2024 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,29 +28,7 @@ Class
Foam::OFstream
Description
Output to file stream as an OSstream, normally using \c std::ofstream
for the actual output.
Note
The atomic output works by creating an intermediate temporary file,
which is renamed as an atomic operation when closing. It is not
possible, or particularly desirable, to have an atomic in combination
with append behaviour. If both are specified, append has priority.
Note
An output file can be opened in two different \c append modes, both of
which preserve existing files:
-# A common append mode is APPEND_APP, which corresponds to the
\c std::ios_base::app flag.
A seek-to-end is performed at \em every write.
It is thus not possible to use any manual seeks to overwrite parts
of the file.
-# The other append mode is APPEND_ATE, which roughly corresponds to the
\c std::ios_base::ate flag behaviour.
A seek-to-end is performed immediately after opening,
but not subsequently.
Manual seeks can be used to overwrite parts of the file.
.
Output to file stream, using an OSstream
SourceFiles
OFstream.C
@ -86,55 +64,53 @@ public:
// Constructors
//- Construct a null output file stream that behaves like \c /dev/null
//- Construct a null output file stream.
// Behaves like \c /dev/null and is named accordingly
explicit OFstream(std::nullptr_t);
//- Construct with specified atomic behaviour
//- from pathname, stream option, optional append (see note).
//- from pathname, stream option, optional append
OFstream
(
IOstreamOption::atomicType atomic,
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
);
//- Construct from pathname and other specifications.
// See note on append mode.
//- Construct from pathname and other specifications
explicit OFstream
(
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
)
:
OFstream(IOstreamOption::NON_ATOMIC, pathname, streamOpt, append)
{}
//- Construct from pathname, format (uncompressed),
//- optional append (see note),
//- Construct from pathname, format (uncompressed), optional append,
//- atomic behaviour as per system default
OFstream
(
const fileName& pathname,
IOstreamOption::streamFormat fmt,
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
)
:
OFstream(pathname, IOstreamOption(fmt, cmp), append)
{}
//- Construct with specified atomic behaviour
//- from pathname, format (uncompressed),
//- optional append (see note).
//- from pathname, format (uncompressed), optional append
OFstream
(
IOstreamOption::atomicType atomic,
const fileName& pathname,
IOstreamOption::streamFormat fmt,
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
)
:
OFstream(atomic, pathname, IOstreamOption(fmt, cmp), append)
@ -165,21 +141,6 @@ public:
virtual void rewind();
// Output stream modes
//- True if opened in append mode \em and file already existed
bool is_appending() const noexcept
{
return ofstreamPointer::is_appending();
}
//- True if file creation behaves as atomic
bool is_atomic() const noexcept
{
return ofstreamPointer::is_atomic();
}
// Print
//- Print stream description
@ -197,7 +158,7 @@ public:
IOstreamOption::streamFormat fmt,
IOstreamOption::versionNumber ver,
IOstreamOption::compressionType cmp = IOstreamOption::UNCOMPRESSED,
IOstreamOption::appendType append = IOstreamOption::NO_APPEND
IOstreamOption::appendType append = IOstreamOption::NON_APPEND
)
:
OFstream(pathname, IOstreamOption(fmt, ver, cmp), append)

View File

@ -194,37 +194,20 @@ public:
class ofstreamPointer
{
// Private Data Types
//- The file open/creation type (bitmask)
enum modeType : char
{
NONE = 0, // Regular open (truncates existing)
ATOMIC = 0x1, // Atomic file creation
APPENDING = 0x2 // Is appending to an existing file
};
// Private Data
//- The stream pointer (ofstream | ogzstream | ocountstream, ...)
std::unique_ptr<std::ostream> ptr_;
//- File output/creation type (atomic, append etc)
char mode_;
// Private Member Functions
//- Clear any output mode information
void clear_mode() noexcept { mode_ = modeType::NONE; }
//- Atomic file creation
bool atomic_;
protected:
// Protected Member Functions
//- Reopen for compressed/non-compressed. Discards append status.
//- Reopen for compressed/non-compressed
void reopen(const std::string& pathname);
//- Close stream and rename file
@ -262,20 +245,16 @@ public:
//- Construct from pathname, option, append, file handling atomic
// \param pathname The file name to open for writing
// \param streamOpt Respects (UNCOMPRESSED | COMPRESSED)
// \param append Open in specified append mode
// \param append Open in append mode
// \param atomic Write into temporary file (not target file).
// This option should only be used with a stream wrapper
// (eg, OFstream) that handles the final renaming.
//
// \note
// There are two different append modes:
// append at every write, or only append after opening.
explicit ofstreamPointer
(
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
bool atomic = false
const bool append = false,
const bool atomic = false
);
//- Construct from pathname, compression, append, file handling atomic
@ -289,12 +268,12 @@ public:
(
const fileName& pathname,
IOstreamOption::compressionType comp,
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
bool atomic = false
const bool append = false,
const bool atomic = false
);
// Static Functions
// Member Functions
//- True if compiled with libz support
static bool supports_gz() noexcept;
@ -314,34 +293,14 @@ public:
//- Which compression type?
IOstreamOption::compressionType whichCompression() const;
//- True if opened in append mode \em and file already existed
bool is_appending() const noexcept
{
return (mode_ & modeType::APPENDING);
}
//- True if file creation behaves as atomic
bool is_atomic() const noexcept
{
return (mode_ & modeType::ATOMIC);
}
// Edit
//- Return managed pointer and release ownership.
std::ostream* release() noexcept
{
clear_mode();
return ptr_.release();
}
//- Return managed pointer and release ownership
std::ostream* release() noexcept { return ptr_.release(); }
//- Replace the managed pointer
void reset(std::ostream* ptr) noexcept
{
clear_mode();
ptr_.reset(ptr);
}
void reset(std::ostream* ptr) noexcept { ptr_.reset(ptr); }
// Operators

View File

@ -88,14 +88,14 @@ Foam::ifstreamPointer::ifstreamPointer
Foam::ofstreamPointer::ofstreamPointer() noexcept
:
ptr_(),
mode_(modeType::NONE)
atomic_(false)
{}
Foam::ofstreamPointer::ofstreamPointer(std::nullptr_t)
:
ptr_(new Foam::ocountstream),
mode_(modeType::NONE)
atomic_(false)
{}
@ -103,44 +103,27 @@ Foam::ofstreamPointer::ofstreamPointer
(
const fileName& pathname,
IOstreamOption streamOpt,
IOstreamOption::appendType append,
bool atomic
const bool append,
const bool atomic
)
:
ptr_(),
mode_(modeType::NONE)
atomic_(atomic)
{
// Leave std::ios_base::trunc implicitly handled to make things
// easier for append mode.
std::ios_base::openmode openmode
std::ios_base::openmode mode
(
std::ios_base::out | std::ios_base::binary
);
if (append == IOstreamOption::APPEND_APP)
if (append)
{
openmode |= std::ios_base::app;
mode |= std::ios_base::app;
// Cannot append to gzstream
streamOpt.compression(IOstreamOption::UNCOMPRESSED);
// Cannot use append + atomic operation, without lots of extra work
atomic = false;
}
else if (append == IOstreamOption::APPEND_ATE)
{
// Handle an "append-like" mode by opening "r+b" and NOT as "ab"
// - file already exists: Sets read position to start
// - file does not exist: Error
openmode |= std::ios_base::in; // [SIC] - use read bit, not append!
// Cannot append to gzstream
streamOpt.compression(IOstreamOption::UNCOMPRESSED);
// Cannot use append + atomic operation, without lots of extra work
atomic = false;
atomic_ = false;
}
@ -163,9 +146,9 @@ Foam::ofstreamPointer::ofstreamPointer
#ifdef HAVE_LIBZ
// TBD:
// atomic = true; // Always treat COMPRESSED like an atomic
// atomic_ = true; // Always treat COMPRESSED like an atomic
const fileName& target = (atomic ? pathname_tmp : pathname_gz);
const fileName& target = (atomic_ ? pathname_tmp : pathname_gz);
// Remove old uncompressed version (if any)
fType = Foam::type(pathname, false);
@ -175,7 +158,7 @@ Foam::ofstreamPointer::ofstreamPointer
}
// Avoid writing into symlinked files (non-append mode)
if (atomic || (append == IOstreamOption::NO_APPEND))
if (!append || atomic_)
{
fType = Foam::type(target, false);
if (fType == fileName::SYMLINK)
@ -184,7 +167,7 @@ Foam::ofstreamPointer::ofstreamPointer
}
}
ptr_.reset(new ogzstream(target, openmode));
ptr_.reset(new ogzstream(target, mode));
#else /* HAVE_LIBZ */
@ -201,7 +184,7 @@ Foam::ofstreamPointer::ofstreamPointer
if (IOstreamOption::COMPRESSED != streamOpt.compression())
{
const fileName& target = (atomic ? pathname_tmp : pathname);
const fileName& target = (atomic_ ? pathname_tmp : pathname);
// Remove old compressed version (if any)
fType = Foam::type(pathname_gz, false);
@ -211,7 +194,7 @@ Foam::ofstreamPointer::ofstreamPointer
}
// Avoid writing into symlinked files (non-append mode)
if (atomic || (append == IOstreamOption::NO_APPEND))
if (!append || atomic_)
{
fType = Foam::type(target, false);
if (fType == fileName::SYMLINK)
@ -220,75 +203,7 @@ Foam::ofstreamPointer::ofstreamPointer
}
}
// File pointer (std::ofstream)
auto filePtr = std::make_unique<std::ofstream>(target, openmode);
if (append == IOstreamOption::APPEND_APP)
{
// Final handling for append 'app' (always non-atomic)
// Set output position to the end (like std::ios_base::ate)
// but only to test if the file had a size.
// No real performance problem since any subsequent write
// will do the same anyhow.
filePtr->seekp(0, std::ios_base::end);
if (filePtr->tellp() <= 0)
{
// Did not open an existing file
append = IOstreamOption::NO_APPEND;
}
}
else if (append == IOstreamOption::APPEND_ATE)
{
// Final handling for append 'ate' (always non-atomic)
if (filePtr->good())
{
// Success if file already exists.
// Set output position to the end - like std::ios_base::ate
filePtr->seekp(0, std::ios_base::end);
if (filePtr->tellp() <= 0)
{
// Did not open an existing file
append = IOstreamOption::NO_APPEND;
}
}
else
{
// Error if file does not already exist.
// Reopen as regular output mode only.
// Did not open an existing file
append = IOstreamOption::NO_APPEND;
if (filePtr->is_open())
{
filePtr->close();
}
filePtr->clear();
filePtr->open
(
target,
(std::ios_base::out | std::ios_base::binary)
);
}
}
ptr_.reset(filePtr.release());
}
// Is appending to an existing file
if (append != IOstreamOption::NO_APPEND)
{
mode_ = modeType::APPENDING;
}
// An atomic output operation (normally not appending!)
if (atomic)
{
mode_ |= modeType::ATOMIC;
ptr_.reset(new std::ofstream(target, mode));
}
}
@ -297,8 +212,8 @@ Foam::ofstreamPointer::ofstreamPointer
(
const fileName& pathname,
IOstreamOption::compressionType comp,
IOstreamOption::appendType append,
bool atomic
const bool append,
const bool atomic
)
:
ofstreamPointer
@ -322,12 +237,12 @@ void Foam::ifstreamPointer::open
// Forcibly close old stream (if any)
ptr_.reset(nullptr);
const std::ios_base::openmode openmode
const std::ios_base::openmode mode
(
std::ios_base::in | std::ios_base::binary
);
ptr_.reset(new std::ifstream(pathname, openmode));
ptr_.reset(new std::ifstream(pathname, mode));
if (!ptr_->good())
{
@ -339,7 +254,7 @@ void Foam::ifstreamPointer::open
{
#ifdef HAVE_LIBZ
ptr_.reset(new igzstream(pathname_gz, openmode));
ptr_.reset(new igzstream(pathname_gz, mode));
#else /* HAVE_LIBZ */
@ -396,7 +311,7 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
gz->close();
gz->clear();
if (mode_ & modeType::ATOMIC)
if (atomic_)
{
gz->open
(
@ -426,11 +341,10 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
}
file->clear();
// Invalidate the appending into existing file information
// since rewind usually means overwrite
mode_ &= ~modeType::APPENDING;
// Don't need original request to append since rewind implies
// trashing that anyhow.
if (mode_ & modeType::ATOMIC)
if (atomic_)
{
file->open
(
@ -453,13 +367,7 @@ void Foam::ofstreamPointer::reopen(const std::string& pathname)
void Foam::ofstreamPointer::close(const std::string& pathname)
{
// Invalidate the appending into existing file information
mode_ &= ~modeType::APPENDING;
if (pathname.empty() || !(mode_ & modeType::ATOMIC))
{
return;
}
if (!atomic_ || pathname.empty()) return;
#ifdef HAVE_LIBZ
auto* gz = dynamic_cast<ogzstream*>(ptr_.get());

View File

@ -107,7 +107,7 @@ public:
const label comm,
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
const bool writeOnProc = true
);
@ -118,7 +118,7 @@ public:
const label comm,
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
const bool writeOnProc = true
)
:
@ -140,7 +140,7 @@ public:
IOstreamOption::atomicType atomic,
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
const bool writeOnProc = true
)
:
@ -161,7 +161,7 @@ public:
(
const fileName& pathname,
IOstreamOption streamOpt = IOstreamOption(),
IOstreamOption::appendType append = IOstreamOption::NO_APPEND,
IOstreamOption::appendType append = IOstreamOption::NON_APPEND,
const bool writeOnProc = true
)
:

View File

@ -166,9 +166,9 @@ inline Ostream& operator<<(Ostream& os, const Omanip<T>& m)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
inline Smanip<std::ios_base::fmtflags> setf(std::ios_base::fmtflags flags)
inline Smanip<ios_base::fmtflags> setf(const ios_base::fmtflags flags)
{
return Smanip<std::ios_base::fmtflags>(&IOstream::setf, flags);
return Smanip<ios_base::fmtflags>(&IOstream::setf, flags);
}

View File

@ -114,19 +114,23 @@ void Foam::IOstream::print(Ostream& os, const int streamState) const
{
if (streamState == std::ios_base::goodbit)
{
os << "goodbit set : the last operation on stream succeeded" << endl;
os << "ios_base::goodbit set : the last operation on stream succeeded"
<< endl;
}
else if (streamState & std::ios_base::badbit)
{
os << "badbit set : characters possibly lost" << endl;
os << "ios_base::badbit set : characters possibly lost"
<< endl;
}
else if (streamState & std::ios_base::failbit)
{
os << "failbit set : some type of formatting error" << endl;
os << "ios_base::failbit set : some type of formatting error"
<< endl;
}
else if (streamState & std::ios_base::eofbit)
{
os << "eofbit set : at end of stream" << endl;
os << "ios_base::eofbit set : at end of stream"
<< endl;
}
}

View File

@ -339,6 +339,9 @@ public:
return old;
}
//- Return flags of stream
virtual ios_base::fmtflags flags() const = 0;
//- Return the default precision
static unsigned int defaultPrecision() noexcept
{
@ -384,30 +387,27 @@ public:
ioState_ |= std::ios_base::badbit;
}
//- Return current stream flags
virtual std::ios_base::fmtflags flags() const = 0;
//- Set flags of stream
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) = 0;
//- Set stream flags, return old stream flags
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) = 0;
//- Set stream flag(s), return old stream flags
std::ios_base::fmtflags setf(std::ios_base::fmtflags f)
//- Set flags of stream
ios_base::fmtflags setf(const ios_base::fmtflags f)
{
return flags(flags() | f);
}
//- Set stream flag(s) with mask, return old stream flags
std::ios_base::fmtflags setf
//- Set flags of given field of stream
ios_base::fmtflags setf
(
const std::ios_base::fmtflags f,
const std::ios_base::fmtflags mask
const ios_base::fmtflags f,
const ios_base::fmtflags mask
)
{
return flags((flags() & ~mask) | (f & mask));
}
//- Unset flags of stream
void unsetf(std::ios_base::fmtflags f)
void unsetf(const ios_base::fmtflags f)
{
flags(flags() & ~f);
}

View File

@ -77,7 +77,7 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers)
if (debug)
{
Perr<< "UIPstream::UIPstream PstreamBuffers :"
Pout<< "UIPstream::UIPstream PstreamBuffers :"
<< " fromProcNo:" << fromProcNo_
<< " tag:" << tag_ << " comm:" << comm_
<< " receive buffer size:" << messageSize_

View File

@ -78,7 +78,7 @@ void Foam::Pstream::combineGather
if (debug & 2)
{
Perr<< " received from "
Pout<< " received from "
<< belowID << " data:" << received << endl;
}
@ -98,7 +98,7 @@ void Foam::Pstream::combineGather
if (debug & 2)
{
Perr<< " received from "
Pout<< " received from "
<< belowID << " data:" << received << endl;
}
@ -111,7 +111,7 @@ void Foam::Pstream::combineGather
{
if (debug & 2)
{
Perr<< " sending to " << myComm.above()
Pout<< " sending to " << myComm.above()
<< " data:" << value << endl;
}
@ -190,7 +190,7 @@ void Foam::Pstream::listCombineGather
if (debug & 2)
{
Perr<< " received from "
Pout<< " received from "
<< belowID << " data:" << received << endl;
}
@ -213,7 +213,7 @@ void Foam::Pstream::listCombineGather
if (debug & 2)
{
Perr<< " received from "
Pout<< " received from "
<< belowID << " data:" << received << endl;
}
@ -229,7 +229,7 @@ void Foam::Pstream::listCombineGather
{
if (debug & 2)
{
Perr<< " sending to " << myComm.above()
Pout<< " sending to " << myComm.above()
<< " data:" << values << endl;
}
@ -306,7 +306,7 @@ void Foam::Pstream::mapCombineGather
if (debug & 2)
{
Perr<< " received from "
Pout<< " received from "
<< belowID << " data:" << received << endl;
}
@ -337,7 +337,7 @@ void Foam::Pstream::mapCombineGather
{
if (debug & 2)
{
Perr<< " sending to " << myComm.above()
Pout<< " sending to " << myComm.above()
<< " data:" << values << endl;
}

File diff suppressed because it is too large Load Diff

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.
@ -82,7 +82,7 @@ void exchangeConsensus
{
buf.clear();
}
recvSizes = Foam::zero{};
recvSizes = Zero;
if (!UPstream::is_rank(comm))
{
@ -109,7 +109,7 @@ void exchangeConsensus
recvBufs[myProci] = sendBufs[myProci];
if (myProci < recvSizes.size())
{
recvSizes[myProci] = recvBufs[myProci].size();
recvSizes[myProci] = recvBufs.size();
}
}
@ -175,7 +175,7 @@ void exchangeConsensus
for (bool barrier_active = false, done = false; !done; /*nil*/)
{
std::pair<int, int64_t> probed =
std::pair<int, int> probed =
UPstream::probeMessage
(
UPstream::commsTypes::nonBlocking,
@ -189,8 +189,8 @@ void exchangeConsensus
// Message found and had size.
// - receive into dest buffer location
const label proci(probed.first);
const label count(probed.second / sizeof(Type));
const label proci = probed.first;
const label count = (probed.second / sizeof(Type));
auto& recvData = recvBufs[proci];
recvData.resize(count); // OK with resize() instead of _nocopy()
@ -254,10 +254,10 @@ void exchangeConsensus
{
static_assert(is_contiguous<Type>::value, "Contiguous data only!");
const bool initialBarrier = (UPstream::tuning_NBX_ > 0);
// TDB: const bool initialBarrier = (UPstream::tuning_NBX_ > 0);
const label myProci = UPstream::myProcNo(comm);
const label numProc = UPstream::nProcs(comm);
const label numProc = UPstream::myProcNo(comm);
// Initial: clear all receive locations
// Preferrable to clear out the map entries instead of the map itself
@ -300,12 +300,7 @@ void exchangeConsensus
// Setup sends
// ------------------------------------------------------------------------
// An initial barrier may help to avoid synchronisation problems
// caused elsewhere
if (initialBarrier)
{
UPstream::barrier(comm);
}
// TDB: initialBarrier ...
// Algorithm NBX: Nonblocking consensus with Map (HashTable) containers
@ -352,7 +347,7 @@ void exchangeConsensus
for (bool barrier_active = false, done = false; !done; /*nil*/)
{
std::pair<int, int64_t> probed =
std::pair<int, int> probed =
UPstream::probeMessage
(
UPstream::commsTypes::nonBlocking,
@ -366,8 +361,8 @@ void exchangeConsensus
// Message found and had size.
// - receive into dest buffer location
const label proci(probed.first);
const label count(probed.second / sizeof(Type));
const label proci = probed.first;
const label count = (probed.second / sizeof(Type));
auto& recvData = recvBufs(proci);
recvData.resize(count); // OK with resize() instead of _nocopy()

View File

@ -107,7 +107,7 @@ void Foam::Pstream::gatherList
if (debug & 2)
{
Perr<< " received through "
Pout<< " received through "
<< belowID << " data from:" << belowID
<< " data:" << values[belowID] << endl;
}
@ -119,7 +119,7 @@ void Foam::Pstream::gatherList
if (debug & 2)
{
Perr<< " received through "
Pout<< " received through "
<< belowID << " data from:" << leafID
<< " data:" << values[leafID] << endl;
}
@ -136,7 +136,7 @@ void Foam::Pstream::gatherList
if (debug & 2)
{
Perr<< " sending to " << myComm.above()
Pout<< " sending to " << myComm.above()
<< " data from me:" << myProci
<< " data:" << values[myProci] << endl;
}
@ -177,7 +177,7 @@ void Foam::Pstream::gatherList
{
if (debug & 2)
{
Perr<< " sending to "
Pout<< " sending to "
<< myComm.above() << " data from:" << leafID
<< " data:" << values[leafID] << endl;
}
@ -259,7 +259,7 @@ void Foam::Pstream::scatterList
if (debug & 2)
{
Perr<< " received through "
Pout<< " received through "
<< myComm.above() << " data for:" << leafID
<< " data:" << values[leafID] << endl;
}
@ -310,7 +310,7 @@ void Foam::Pstream::scatterList
if (debug & 2)
{
Perr<< " sent through "
Pout<< " sent through "
<< belowID << " data for:" << leafID
<< " data:" << values[leafID] << endl;
}

View File

@ -61,8 +61,8 @@ void reduce
{
if (UPstream::warnComm >= 0 && comm != UPstream::warnComm)
{
Perr<< "** reducing:" << value << " with comm:" << comm << endl;
error::printStack(Perr);
Pout<< "** reducing:" << value << " with comm:" << comm << endl;
error::printStack(Pout);
}
Pstream::gather(value, bop, tag, comm);
Pstream::broadcast(value, comm);

View File

@ -151,18 +151,16 @@ public:
// Stream State Functions
//- Return current stream flags.
//- Dummy for parallel stream, returns 0.
virtual std::ios_base::fmtflags flags() const override
//- Return stream flags
virtual ios_base::fmtflags flags() const override
{
return std::ios_base::fmtflags(0);
return ios_base::fmtflags(0);
}
//- Set stream flags, return old stream flags.
//- Dummy for parallel stream, returns 0.
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
//- Set flags of stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
{
return std::ios_base::fmtflags(0);
return ios_base::fmtflags(0);
}

View File

@ -257,7 +257,7 @@ Foam::UIPstreamBase::~UIPstreamBase()
{
if (debug)
{
Perr<< "UIPstreamBase Destructor : tag:" << tag_
Pout<< "UIPstreamBase Destructor : tag:" << tag_
<< " fromProcNo:" << fromProcNo_
<< " clearing receive buffer of size "
<< recvBuf_.size()

View File

@ -144,20 +144,12 @@ public:
// Member Functions
// Stream State Functions
// Inquiry
//- Return current stream flags.
//- Dummy for parallel stream, returns 0.
virtual std::ios_base::fmtflags flags() const override
//- Return flags of output stream
virtual ios_base::fmtflags flags() const override
{
return std::ios_base::fmtflags(0);
}
//- Set stream flags, return old stream flags.
//- Dummy for parallel stream, returns 0.
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags) override
{
return std::ios_base::fmtflags(0);
return ios_base::fmtflags(0);
}
@ -289,6 +281,15 @@ public:
virtual void rewind();
// Edit
//- Set flags of stream
virtual ios_base::fmtflags flags(const ios_base::fmtflags) override
{
return ios_base::fmtflags(0);
}
// Print
//- Print stream description to Ostream

View File

@ -221,7 +221,7 @@ void Foam::UPstream::setParRun(const label nProcs, const bool haveThreads)
if (debug)
{
Perr<< "UPstream::setParRun :"
Pout<< "UPstream::setParRun :"
<< " nProcs:" << nProcs
<< " haveThreads:" << haveThreads
<< endl;
@ -274,7 +274,7 @@ Foam::label Foam::UPstream::allocateCommunicator
if (debug)
{
Perr<< "Allocating communicator " << index << nl
Pout<< "Allocating communicator " << index << nl
<< " parent : " << parentIndex << nl
<< " procs : " << subRanks << nl
<< endl;
@ -335,7 +335,7 @@ Foam::label Foam::UPstream::allocateCommunicator
if (debug)
{
Perr<< "Allocating communicator " << index << nl
Pout<< "Allocating communicator " << index << nl
<< " parent : " << parentIndex << nl
<< " procs : " << flatOutput(subRanks) << nl
<< endl;
@ -492,7 +492,7 @@ bool Foam::UPstream::allocateHostCommunicatorPairs()
if (debug)
{
Perr<< "Allocating host communicators "
Pout<< "Allocating host communicators "
<< interHostComm_ << ", " << intraHostComm_ << nl
<< " parent : " << parentCommunicator << nl
<< endl;
@ -588,7 +588,7 @@ void Foam::UPstream::freeCommunicator
if (debug)
{
Perr<< "Communicators : Freeing communicator " << communicator
Pout<< "Communicators : Freeing communicator " << communicator
<< " parent: " << parentComm_[communicator]
<< " myProcNo: " << myProcNo_[communicator]
<< endl;

View File

@ -565,14 +565,14 @@ public:
//- Probe for an incoming message.
//
// \param commsType Non-blocking or not
// \param commsType Blocking or not
// \param fromProcNo The source rank (negative == ANY_SOURCE)
// \param tag The source message tag
// \param communicator The communicator index
//
// \returns source rank and message size (bytes)
// and (-1, 0) on failure
static std::pair<int,int64_t> probeMessage
static std::pair<int,int> probeMessage
(
const UPstream::commsTypes commsType,
const int fromProcNo,

View File

@ -147,17 +147,14 @@ public:
// Stream State
//- Return current stream flags
virtual std::ios_base::fmtflags flags() const override
//- Return flags of output stream
virtual ios_base::fmtflags flags() const override
{
return is_.flags();
}
//- Set stream flags, return old stream flags
virtual std::ios_base::fmtflags flags
(
std::ios_base::fmtflags f
) override
//- Set stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
{
return is_.flags(f);
}

View File

@ -138,17 +138,14 @@ public:
// Stream State
//- Get current stream flags
virtual std::ios_base::fmtflags flags() const override
//- Get stream flags
virtual ios_base::fmtflags flags() const override
{
return os_.flags();
}
//- Set stream flags, return old stream flags
virtual std::ios_base::fmtflags flags
(
std::ios_base::fmtflags f
) override
//- Set stream flags
virtual ios_base::fmtflags flags(const ios_base::fmtflags f) override
{
return os_.flags(f);
}

View File

@ -215,9 +215,6 @@ public:
// Member Functions
//- The number of bytes outputted
std::streamsize count() { return stream_.tellp(); }
//- Get the string.
//- As Foam::string instead of std::string (may change in future)
Foam::string str() const { return Foam::string(stream_.str()); }

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