Compare commits
23 Commits
issue-2966
...
feature-sr
| Author | SHA1 | Date | |
|---|---|---|---|
| a62529c0e9 | |||
| 9423976dda | |||
| 13152510b3 | |||
| 170d73f4ec | |||
| aa1e1eb15d | |||
| 8bda4fadbe | |||
| 2c7e95d2cb | |||
| 9b56c6b1ac | |||
| 64c6f350ae | |||
| 902f09b688 | |||
| 0d6de94e8e | |||
| d770ce7aa8 | |||
| 0e7a2d1529 | |||
| 648f0593c8 | |||
| 71812c21c5 | |||
| 80bb1b9f57 | |||
| d38a4a9177 | |||
| 5f805b0592 | |||
| 84a1452995 | |||
| c036d4207b | |||
| 542dae4a6d | |||
| f5e689c6a8 | |||
| 0723bcbf8a |
4
Allwmake
4
Allwmake
@ -73,10 +73,10 @@ echo
|
||||
applications/Allwmake $targetType $*
|
||||
|
||||
# Additional components/modules
|
||||
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
|
||||
if [ "$FOAM_MODULE_PREFIX" = false ]
|
||||
then
|
||||
echo "========================================"
|
||||
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
|
||||
echo "OpenFOAM modules disabled (prefix=false)"
|
||||
echo
|
||||
elif [ -d "$WM_PROJECT_DIR/modules" ]
|
||||
then
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
api=2012
|
||||
patch=220610
|
||||
patch=0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
{
|
||||
volScalarField& he = thermo.he();
|
||||
|
||||
fvScalarMatrix EEqn
|
||||
(
|
||||
fvm::div(phi, he)
|
||||
+ (
|
||||
he.name() == "e"
|
||||
? fvc::div(phi, volScalarField("Ekp", 0.5*magSqr(U) + p/rho))
|
||||
: fvc::div(phi, volScalarField("K", 0.5*magSqr(U)))
|
||||
)
|
||||
- fvm::laplacian(turbulence->alphaEff(), he)
|
||||
==
|
||||
fvOptions(rho, he)
|
||||
);
|
||||
|
||||
EEqn.relax();
|
||||
|
||||
fvOptions.constrain(EEqn);
|
||||
|
||||
EEqn.solve();
|
||||
|
||||
fvOptions.correct(he);
|
||||
|
||||
thermo.correct();
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
SRFrhoSimpleFoam.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/SRFrhoSimpleFoam
|
||||
@ -0,0 +1,21 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/cfdTools \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
||||
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfvOptions \
|
||||
-lmeshTools \
|
||||
-lsampling \
|
||||
-lcompressibleTransportModels \
|
||||
-lfluidThermophysicalModels \
|
||||
-lspecie \
|
||||
-lturbulenceModels \
|
||||
-lcompressibleTurbulenceModels \
|
||||
-latmosphericModels
|
||||
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
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
|
||||
SRFSimpleFoam
|
||||
|
||||
Group
|
||||
grpIncompressibleSolvers
|
||||
|
||||
Description
|
||||
Steady-state solver for incompressible, turbulent flow of non-Newtonian
|
||||
fluids in a single rotating frame.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvCFD.H"
|
||||
#include "fluidThermo.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "simpleControl.H"
|
||||
#include "pressureControl.H"
|
||||
#include "fvOptions.H"
|
||||
#include "SRFModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::addNote
|
||||
(
|
||||
"Steady-state solver for compressible, turbulent flow"
|
||||
" of non-Newtonian fluids in a single rotating frame."
|
||||
);
|
||||
|
||||
#include "postProcess.H"
|
||||
|
||||
#include "addCheckCaseOptions.H"
|
||||
#include "setRootCaseLists.H"
|
||||
#include "createTime.H"
|
||||
#include "createMesh.H"
|
||||
#include "createControl.H"
|
||||
#include "createFields.H"
|
||||
#include "createFieldRefs.H"
|
||||
#include "initContinuityErrs.H"
|
||||
|
||||
turbulence->validate();
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "\nStarting time loop\n" << endl;
|
||||
|
||||
while (simple.loop())
|
||||
{
|
||||
Info<< "Time = " << runTime.timeName() << nl << endl;
|
||||
|
||||
// --- Pressure-velocity SIMPLE corrector
|
||||
{
|
||||
#include "UrelEqn.H"
|
||||
#include "EEqn.H"
|
||||
#include "pEqn.H"
|
||||
}
|
||||
|
||||
U = Urel + SRF->U();
|
||||
|
||||
turbulence->correct();
|
||||
|
||||
runTime.write();
|
||||
|
||||
runTime.printExecutionTime(Info);
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,22 @@
|
||||
// Relative momentum predictor
|
||||
|
||||
tmp<fvVectorMatrix> tUrelEqn
|
||||
(
|
||||
fvm::div(phi, Urel)
|
||||
+ turbulence->divDevRhoReff(Urel)
|
||||
+ rho*SRF->Su()
|
||||
==
|
||||
fvOptions(rho, Urel)
|
||||
);
|
||||
fvVectorMatrix& UrelEqn = tUrelEqn.ref();
|
||||
|
||||
UrelEqn.relax();
|
||||
|
||||
fvOptions.constrain(UrelEqn);
|
||||
|
||||
if (simple.momentumPredictor())
|
||||
{
|
||||
solve(UrelEqn == -fvc::grad(p));
|
||||
|
||||
fvOptions.correct(Urel);
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
const volScalarField& psi = thermo.psi();
|
||||
@ -0,0 +1,89 @@
|
||||
Info<< "Reading thermophysical properties\n" << endl;
|
||||
|
||||
autoPtr<fluidThermo> pThermo
|
||||
(
|
||||
fluidThermo::New(mesh)
|
||||
);
|
||||
fluidThermo& thermo = pThermo();
|
||||
thermo.validate(args.executable(), "h", "e");
|
||||
|
||||
volScalarField& p = thermo.p();
|
||||
|
||||
volScalarField rho
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
thermo.rho()
|
||||
);
|
||||
|
||||
Info<< "Reading field Urel\n" << endl;
|
||||
volVectorField Urel
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Urel",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh
|
||||
);
|
||||
|
||||
Info<< "Reading/calculating face flux field phi\n" << endl;
|
||||
surfaceScalarField phi
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"phi",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
linearInterpolate(rho*Urel) & mesh.Sf()
|
||||
);
|
||||
|
||||
pressureControl pressureControl(p, rho, simple.dict());
|
||||
|
||||
mesh.setFluxRequired(p.name());
|
||||
|
||||
Info<< "Creating SRF model\n" << endl;
|
||||
autoPtr<SRF::SRFModel> SRF(SRF::SRFModel::New(Urel));
|
||||
|
||||
// Construct the absolute velocity
|
||||
volVectorField U
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"U",
|
||||
runTime.timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
Urel + SRF->U()
|
||||
);
|
||||
|
||||
|
||||
Info<< "Creating turbulence model\n" << endl;
|
||||
autoPtr<compressible::turbulenceModel> turbulence
|
||||
(
|
||||
compressible::turbulenceModel::New
|
||||
(
|
||||
rho,
|
||||
U,
|
||||
phi,
|
||||
thermo
|
||||
)
|
||||
);
|
||||
|
||||
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
|
||||
|
||||
#include "createFvOptions.H"
|
||||
@ -0,0 +1,109 @@
|
||||
volScalarField rAUrel(1.0/UrelEqn.A());
|
||||
surfaceScalarField rhorAUrelf("rhorAUf", fvc::interpolate(rho*rAUrel));
|
||||
volVectorField HbyA(constrainHbyA(rAUrel*UrelEqn.H(), Urel, p));
|
||||
tUrelEqn.clear();
|
||||
|
||||
bool closedVolume = false;
|
||||
|
||||
surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho)*fvc::flux(HbyA));
|
||||
|
||||
// Update the pressure BCs to ensure flux consistency
|
||||
constrainPressure(p, rho, Urel, phiHbyA, rhorAUrelf);
|
||||
|
||||
if (simple.transonic())
|
||||
{
|
||||
surfaceScalarField phid
|
||||
(
|
||||
"phid",
|
||||
(fvc::interpolate(psi)/fvc::interpolate(rho))*phiHbyA
|
||||
);
|
||||
|
||||
phiHbyA -= fvc::interpolate(psi*p)*phiHbyA/fvc::interpolate(rho);
|
||||
|
||||
while (simple.correctNonOrthogonal())
|
||||
{
|
||||
fvScalarMatrix pEqn
|
||||
(
|
||||
fvc::div(phiHbyA)
|
||||
+ fvm::div(phid, p)
|
||||
- fvm::laplacian(rhorAUrelf, p)
|
||||
==
|
||||
fvOptions(psi, p, rho.name())
|
||||
);
|
||||
|
||||
// Relax the pressure equation to ensure diagonal-dominance
|
||||
pEqn.relax();
|
||||
|
||||
pEqn.setReference
|
||||
(
|
||||
pressureControl.refCell(),
|
||||
pressureControl.refValue()
|
||||
);
|
||||
|
||||
pEqn.solve();
|
||||
|
||||
if (simple.finalNonOrthogonalIter())
|
||||
{
|
||||
phi = phiHbyA + pEqn.flux();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
closedVolume = adjustPhi(phiHbyA, Urel, p);
|
||||
|
||||
while (simple.correctNonOrthogonal())
|
||||
{
|
||||
fvScalarMatrix pEqn
|
||||
(
|
||||
fvc::div(phiHbyA)
|
||||
- fvm::laplacian(rhorAUrelf, p)
|
||||
==
|
||||
fvOptions(psi, p, rho.name())
|
||||
);
|
||||
|
||||
pEqn.setReference
|
||||
(
|
||||
pressureControl.refCell(),
|
||||
pressureControl.refValue()
|
||||
);
|
||||
|
||||
pEqn.solve();
|
||||
|
||||
if (simple.finalNonOrthogonalIter())
|
||||
{
|
||||
phi = phiHbyA + pEqn.flux();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "incompressible/continuityErrs.H"
|
||||
|
||||
// Explicitly relax pressure for momentum corrector
|
||||
p.relax();
|
||||
|
||||
Urel = HbyA - rAUrel*fvc::grad(p);
|
||||
Urel.correctBoundaryConditions();
|
||||
fvOptions.correct(Urel);
|
||||
|
||||
bool pLimited = pressureControl.limit(p);
|
||||
|
||||
// For closed-volume cases adjust the pressure and density levels
|
||||
// to obey overall mass continuity
|
||||
if (closedVolume)
|
||||
{
|
||||
p += (initialMass - fvc::domainIntegrate(psi*p))
|
||||
/fvc::domainIntegrate(psi);
|
||||
}
|
||||
|
||||
if (pLimited || closedVolume)
|
||||
{
|
||||
p.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
rho = thermo.rho();
|
||||
|
||||
if (!simple.transonic())
|
||||
{
|
||||
rho.relax();
|
||||
}
|
||||
@ -44,11 +44,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward Declarations
|
||||
class magnet;
|
||||
Istream& operator>>(Istream&, magnet&);
|
||||
Ostream& operator<<(Ostream&, const magnet&);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,6 +38,8 @@ Description
|
||||
#include "Time.H"
|
||||
#include "Random.H"
|
||||
#include "PackedList.H"
|
||||
#include "flipOp.H"
|
||||
#include "pointList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -223,8 +226,6 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
|
||||
fullData[meshPointi] = pt;
|
||||
}
|
||||
|
||||
//Pout<< "sparseData:" << sparseData << endl;
|
||||
|
||||
syncTools::syncPointMap
|
||||
(
|
||||
mesh,
|
||||
@ -309,8 +310,6 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
|
||||
fullData[meshEdgeI] = pt;
|
||||
}
|
||||
|
||||
//Pout<< "sparseData:" << sparseData << endl;
|
||||
|
||||
syncTools::syncEdgeMap
|
||||
(
|
||||
mesh,
|
||||
@ -408,7 +407,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen)
|
||||
{
|
||||
labelList nMasters(mesh.nPoints(), Zero);
|
||||
|
||||
bitSet isMasterPoint(syncTools::getMasterPoints(mesh));
|
||||
const bitSet isMasterPoint(syncTools::getMasterPoints(mesh));
|
||||
|
||||
forAll(isMasterPoint, pointi)
|
||||
{
|
||||
@ -484,7 +483,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
|
||||
{
|
||||
labelList nMasters(edges.size(), Zero);
|
||||
|
||||
bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
|
||||
const bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
|
||||
|
||||
forAll(isMasterEdge, edgeI)
|
||||
{
|
||||
@ -519,6 +518,310 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
|
||||
}
|
||||
|
||||
|
||||
typedef Pair<point> PointPair;
|
||||
class edgePointCombineOp
|
||||
{
|
||||
public:
|
||||
void operator()(PointPair& x, const PointPair& y) const
|
||||
{
|
||||
if
|
||||
(
|
||||
(y[0] < x[0])
|
||||
|| (y[0] == x[0] && y[1] < x[1])
|
||||
)
|
||||
{
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
};
|
||||
class edgePointTransformOp
|
||||
{
|
||||
public:
|
||||
void operator()
|
||||
(
|
||||
const vectorTensorTransform& vt,
|
||||
const bool forward,
|
||||
List<PointPair>& fld
|
||||
) const
|
||||
{
|
||||
pointField points0(fld.size());
|
||||
pointField points1(fld.size());
|
||||
forAll(fld, i)
|
||||
{
|
||||
points0[i] = fld[i].first();
|
||||
points1[i] = fld[i].second();
|
||||
}
|
||||
|
||||
pointField points0New;
|
||||
pointField points1New;
|
||||
if (forward)
|
||||
{
|
||||
points0New = vt.transformPosition(points0);
|
||||
points1New = vt.transformPosition(points1);
|
||||
}
|
||||
else
|
||||
{
|
||||
points0New = vt.invTransformPosition(points0);
|
||||
points1New = vt.invTransformPosition(points1);
|
||||
}
|
||||
|
||||
forAll(fld, i)
|
||||
{
|
||||
fld[i] = PointPair(points0New[i], points1New[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
class edgePointFlipOp
|
||||
{
|
||||
public:
|
||||
PointPair operator()(const PointPair& val) const
|
||||
{
|
||||
PointPair newVal(val);
|
||||
newVal.flip();
|
||||
return newVal;
|
||||
}
|
||||
};
|
||||
void testEdgeFlip2(const polyMesh& mesh, Random& rndGen)
|
||||
{
|
||||
Info<< nl << "Testing edge-wise (oriented) data synchronisation." << endl;
|
||||
|
||||
const edgeList& edges = mesh.edges();
|
||||
const pointField& points = mesh.points();
|
||||
|
||||
// Test position.
|
||||
|
||||
List<PointPair> synEdgeEnds(edges.size());
|
||||
{
|
||||
forAll(synEdgeEnds, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
synEdgeEnds[edgeI] = PointPair
|
||||
(
|
||||
points[e[0]],
|
||||
points[e[1]]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 1. Ignore flipping
|
||||
{
|
||||
List<PointPair> fld(synEdgeEnds);
|
||||
|
||||
syncTools::syncEdgeList
|
||||
(
|
||||
mesh,
|
||||
fld,
|
||||
edgePointCombineOp(),
|
||||
PointPair(point::max, point::max),
|
||||
edgePointTransformOp(),
|
||||
noOp()
|
||||
);
|
||||
|
||||
forAll(fld, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
const PointPair edgeEnd
|
||||
(
|
||||
points[e[0]],
|
||||
points[e[1]]
|
||||
);
|
||||
|
||||
const PointPair& sync = fld[edgeI];
|
||||
|
||||
if
|
||||
(
|
||||
(mag(edgeEnd[0] - sync[0]) > SMALL)
|
||||
|| (mag(edgeEnd[1] - sync[1]) > SMALL)
|
||||
)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Edge " << edgeI
|
||||
<< " original endpoints " << edgeEnd
|
||||
<< " synced endpoints " << sync
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Use flipping operator. Should produce no warnings
|
||||
{
|
||||
syncTools::syncEdgeList
|
||||
(
|
||||
mesh,
|
||||
synEdgeEnds,
|
||||
edgePointCombineOp(),
|
||||
PointPair(point::max, point::max),
|
||||
edgePointTransformOp(),
|
||||
edgePointFlipOp()
|
||||
);
|
||||
|
||||
forAll(synEdgeEnds, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
const PointPair edgeEnd
|
||||
(
|
||||
points[e[0]],
|
||||
points[e[1]]
|
||||
);
|
||||
|
||||
const PointPair& sync = synEdgeEnds[edgeI];
|
||||
|
||||
if
|
||||
(
|
||||
(mag(edgeEnd[0] - sync[0]) > SMALL)
|
||||
|| (mag(edgeEnd[1] - sync[1]) > SMALL)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Edge " << edgeI
|
||||
<< " original endpoints " << edgeEnd
|
||||
<< " synced endpoints " << sync
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void testEdgeFlip(const polyMesh& mesh, Random& rndGen)
|
||||
{
|
||||
Info<< nl << "Testing edge-wise (oriented) data synchronisation."
|
||||
<< endl;
|
||||
|
||||
const edgeList& edges = mesh.edges();
|
||||
const pointField& points = mesh.points();
|
||||
|
||||
// Test vector.
|
||||
|
||||
vectorField synEdgeVecs(edges.size());
|
||||
{
|
||||
forAll(synEdgeVecs, edgeI)
|
||||
{
|
||||
synEdgeVecs[edgeI] = edges[edgeI].unitVec(points);
|
||||
}
|
||||
}
|
||||
|
||||
// Without flipping (should produce warnings)
|
||||
{
|
||||
vectorField fld(synEdgeVecs);
|
||||
// Ignore flipping
|
||||
syncTools::syncEdgeList
|
||||
(
|
||||
mesh,
|
||||
fld,
|
||||
minEqOp<vector>(),
|
||||
point::max
|
||||
);
|
||||
|
||||
forAll(fld, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
const vector eVec(e.unitVec(points));
|
||||
|
||||
if ((eVec & fld[edgeI]) < (1-SMALL))
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Edge " << edgeI
|
||||
<< " at " << e.line(points)
|
||||
<< " original vector " << eVec
|
||||
<< " synced vector " << fld[edgeI]
|
||||
<< " diff:" << (eVec & fld[edgeI])
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// With consistent flipping. Should never produce difference
|
||||
{
|
||||
syncTools::syncEdgeList
|
||||
(
|
||||
mesh,
|
||||
synEdgeVecs,
|
||||
minMagSqrEqOp<vector>(),
|
||||
point::max,
|
||||
mapDistribute::transform(),
|
||||
flipOp()
|
||||
);
|
||||
|
||||
forAll(synEdgeVecs, edgeI)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
const vector eVec(e.unitVec(points));
|
||||
|
||||
if ((eVec & synEdgeVecs[edgeI]) < (1-SMALL))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Edge " << edgeI
|
||||
<< " at " << e.line(points)
|
||||
<< " original vector " << eVec
|
||||
<< " synced vector " << synEdgeVecs[edgeI]
|
||||
<< " diff:" << (eVec & synEdgeVecs[edgeI])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class pointListOps
|
||||
{
|
||||
public:
|
||||
|
||||
void operator()(pointList& lhs, const pointList& rhs) const
|
||||
{
|
||||
forAll(lhs, i)
|
||||
{
|
||||
point& l = lhs[i];
|
||||
const point& r = rhs[i];
|
||||
maxMagSqrEqOp<vector>()(l, r);
|
||||
}
|
||||
}
|
||||
|
||||
void operator()
|
||||
(
|
||||
const vectorTensorTransform& vt,
|
||||
const bool forward,
|
||||
List<pointList>& fld
|
||||
) const
|
||||
{
|
||||
if (forward)
|
||||
{
|
||||
for (auto& elems : fld)
|
||||
{
|
||||
for (auto& elem : elems)
|
||||
{
|
||||
elem = vt.transformPosition(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& elems : fld)
|
||||
{
|
||||
for (auto& elem : elems)
|
||||
{
|
||||
elem = vt.invTransformPosition(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- Transform patch-based field
|
||||
void operator()(const coupledPolyPatch& cpp, List<pointList>& fld) const
|
||||
{
|
||||
forAll(fld, facei)
|
||||
{
|
||||
pointList& pts = fld[facei];
|
||||
for (auto& pt : pts)
|
||||
{
|
||||
cpp.transformPosition(pt, facei);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void testFaceSync(const polyMesh& mesh, Random& rndGen)
|
||||
{
|
||||
Info<< nl << "Testing face-wise data synchronisation." << endl;
|
||||
@ -548,12 +851,58 @@ void testFaceSync(const polyMesh& mesh, Random& rndGen)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Test non-contiguous data (uses streaming)
|
||||
|
||||
{
|
||||
List<pointList> syncedFc(mesh.nFaces());
|
||||
|
||||
const pointField& fcs = mesh.faceCentres();
|
||||
forAll(fcs, facei)
|
||||
{
|
||||
const point& fc = fcs[facei];
|
||||
syncedFc[facei].setSize(2, fc);
|
||||
}
|
||||
|
||||
SubList<pointList> bndValues
|
||||
(
|
||||
syncedFc,
|
||||
mesh.nBoundaryFaces(),
|
||||
mesh.nInternalFaces()
|
||||
);
|
||||
syncTools::syncBoundaryFaceList
|
||||
(
|
||||
mesh,
|
||||
bndValues,
|
||||
pointListOps(), //does maxMagSqrEqOp<pointList>()
|
||||
pointListOps() //transforms all
|
||||
);
|
||||
|
||||
forAll(syncedFc, facei)
|
||||
{
|
||||
const point& fc = fcs[facei];
|
||||
const pointList& fld = syncedFc[facei];
|
||||
forAll(fld, i)
|
||||
{
|
||||
if (mag(fld[i] - fc) > SMALL)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Face " << facei
|
||||
<< " original centre " << fc
|
||||
<< " synced centre " << fld[i]
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Test masterFaces
|
||||
|
||||
{
|
||||
labelList nMasters(mesh.nFaces(), Zero);
|
||||
|
||||
bitSet isMasterFace(syncTools::getMasterFaces(mesh));
|
||||
const bitSet isMasterFace(syncTools::getMasterFaces(mesh));
|
||||
|
||||
forAll(isMasterFace, facei)
|
||||
{
|
||||
@ -604,6 +953,12 @@ int main(int argc, char *argv[])
|
||||
// Edge sync
|
||||
testEdgeSync(mesh, rndGen);
|
||||
|
||||
// Edge sync and flip
|
||||
testEdgeFlip(mesh, rndGen);
|
||||
|
||||
// Edge sync and flip of more complex structure
|
||||
testEdgeFlip2(mesh, rndGen);
|
||||
|
||||
// Point sync
|
||||
testPointSync(mesh, rndGen);
|
||||
|
||||
|
||||
17
applications/test/syncTools/block_2x2x1/Allrun
Executable file
17
applications/test/syncTools/block_2x2x1/Allrun
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
cd "${0%/*}" || exit # Run from this directory
|
||||
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
runApplication blockMesh
|
||||
runApplication decomposePar
|
||||
|
||||
# Swap point 2 and 6 in processor1
|
||||
( cd processor1/constant/polyMesh && \
|
||||
sed -i -e 's/(1 1 0)/point1/;s/(1 1 2)/(1 1 0)/;s/point1/(1 1 2)/' points && \
|
||||
sed -i -e 's/^4\([^2]*\)2/4\1TWO/;s/^4\([^6]*\)6/4\12/;s/TWO/6/' faces \
|
||||
)
|
||||
|
||||
runParallel Test-syncTools
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
7
applications/test/syncTools/block_2x2x1/README.txt
Normal file
7
applications/test/syncTools/block_2x2x1/README.txt
Normal file
@ -0,0 +1,7 @@
|
||||
- blockMesh
|
||||
- decomposePar
|
||||
- in processor1:
|
||||
- swap points 2 (1 1 0) and 6 (1 1 2) in polyMesh/points
|
||||
- swap indices 2 and 6 in polyMesh/faces
|
||||
|
||||
so now we have the same mesh but different edge orientation on processor1
|
||||
@ -0,0 +1,21 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "constant";
|
||||
object transportProperties;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
nu 0.01;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
103
applications/test/syncTools/block_2x2x1/system/blockMeshDict
Normal file
103
applications/test/syncTools/block_2x2x1/system/blockMeshDict
Normal file
@ -0,0 +1,103 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object blockMeshDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
scale 1;
|
||||
|
||||
vertices
|
||||
(
|
||||
//- Skewed hexes
|
||||
//(0 0 0)
|
||||
//(0.1 0 0)
|
||||
//(0.2 1 0)
|
||||
//(0.03 1 0)
|
||||
//(0 0 0.1)
|
||||
//(0.1 0 0.1)
|
||||
//(0.2 1 0.1)
|
||||
//(0.03 1 0.1)
|
||||
|
||||
////- Single block
|
||||
//(0 0 0)
|
||||
//(4 0 0)
|
||||
//(4.4 4 0)
|
||||
//(0.2 4 0)
|
||||
//(0 0 0.4)
|
||||
//(4 0 0.4)
|
||||
//(4.6 4 0.4)
|
||||
//(0.7 4 0.4)
|
||||
|
||||
//- Single block
|
||||
(0 0 0)
|
||||
(2 0 0)
|
||||
(2 2 0)
|
||||
(0 2 0)
|
||||
(0 0 2)
|
||||
(2 0 2)
|
||||
(2 2 2)
|
||||
(0 2 2)
|
||||
);
|
||||
|
||||
blocks
|
||||
(
|
||||
hex (0 1 2 3 4 5 6 7) (2 2 1) simpleGrading (1 1 1)
|
||||
);
|
||||
|
||||
edges
|
||||
(
|
||||
);
|
||||
|
||||
boundary
|
||||
(
|
||||
topWall
|
||||
{
|
||||
type wall;
|
||||
faces
|
||||
(
|
||||
(3 7 6 2)
|
||||
);
|
||||
}
|
||||
bottomWall
|
||||
{
|
||||
type wall;
|
||||
faces
|
||||
(
|
||||
(1 5 4 0)
|
||||
);
|
||||
}
|
||||
fixedWalls
|
||||
{
|
||||
type wall;
|
||||
faces
|
||||
(
|
||||
(0 4 7 3)
|
||||
(2 6 5 1)
|
||||
);
|
||||
}
|
||||
frontAndBack
|
||||
{
|
||||
type patch;
|
||||
faces
|
||||
(
|
||||
(0 3 2 1)
|
||||
(4 5 6 7)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
mergePatchPairs
|
||||
(
|
||||
);
|
||||
|
||||
// ************************************************************************* //
|
||||
48
applications/test/syncTools/block_2x2x1/system/controlDict
Normal file
48
applications/test/syncTools/block_2x2x1/system/controlDict
Normal file
@ -0,0 +1,48 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application icoFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.5;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 20;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 16;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,26 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1806 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
note "mesh decomposition control dictionary";
|
||||
object decomposeParDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- The total number of domains (mandatory)
|
||||
numberOfSubdomains 4;
|
||||
|
||||
//- The decomposition method (mandatory)
|
||||
method hierarchical;
|
||||
|
||||
n (2 2 1);
|
||||
|
||||
// ************************************************************************* //
|
||||
51
applications/test/syncTools/block_2x2x1/system/fvSchemes
Normal file
51
applications/test/syncTools/block_2x2x1/system/fvSchemes
Normal file
@ -0,0 +1,51 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object fvSchemes;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
ddtSchemes
|
||||
{
|
||||
default Euler;
|
||||
}
|
||||
|
||||
gradSchemes
|
||||
{
|
||||
default Gauss linear;
|
||||
grad(p) Gauss linear;
|
||||
}
|
||||
|
||||
divSchemes
|
||||
{
|
||||
default none;
|
||||
div(phi,U) Gauss linear;
|
||||
}
|
||||
|
||||
laplacianSchemes
|
||||
{
|
||||
default Gauss linear orthogonal;
|
||||
}
|
||||
|
||||
interpolationSchemes
|
||||
{
|
||||
default linear;
|
||||
}
|
||||
|
||||
snGradSchemes
|
||||
{
|
||||
default orthogonal;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
52
applications/test/syncTools/block_2x2x1/system/fvSolution
Normal file
52
applications/test/syncTools/block_2x2x1/system/fvSolution
Normal file
@ -0,0 +1,52 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v1812 |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
location "system";
|
||||
object fvSolution;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
solvers
|
||||
{
|
||||
p
|
||||
{
|
||||
solver PCG;
|
||||
preconditioner DIC;
|
||||
tolerance 1e-06;
|
||||
relTol 0.05;
|
||||
}
|
||||
|
||||
pFinal
|
||||
{
|
||||
$p;
|
||||
relTol 0;
|
||||
}
|
||||
|
||||
U
|
||||
{
|
||||
solver smoothSolver;
|
||||
smoother symGaussSeidel;
|
||||
tolerance 1e-05;
|
||||
relTol 0;
|
||||
}
|
||||
}
|
||||
|
||||
PISO
|
||||
{
|
||||
nCorrectors 2;
|
||||
nNonOrthogonalCorrectors 0;
|
||||
pRefCell 0;
|
||||
pRefValue 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -39,7 +39,7 @@ Description
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "Fstream.H"
|
||||
#include "pointField.H"
|
||||
#include "polyMesh.H"
|
||||
#include "unitConversion.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -76,8 +76,7 @@ int main(int argc, char *argv[])
|
||||
word block;
|
||||
string zoneName;
|
||||
token punctuation;
|
||||
label iPoints;
|
||||
label jPoints;
|
||||
label iPoints, jPoints;
|
||||
|
||||
Istring >> block;
|
||||
Istring >> block;
|
||||
@ -117,11 +116,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// correct error in biconic meshes
|
||||
forAll(points, i)
|
||||
for (point& p : points)
|
||||
{
|
||||
if (points[i][1] < 1e-07)
|
||||
if (p.y() < 1e-07)
|
||||
{
|
||||
points[i][1] = 0.0;
|
||||
p.y() = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,18 +145,30 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
}
|
||||
|
||||
const fileName polyMeshPath(runTime.constantPath()/"polyMesh");
|
||||
const fileName pointsFile(polyMeshPath/"points");
|
||||
OFstream pFile(pointsFile);
|
||||
if (!exists(polyMeshPath)) mkDir(polyMeshPath);
|
||||
// Write (overwrite) points
|
||||
{
|
||||
IOobject iopoints
|
||||
(
|
||||
"points",
|
||||
runTime.constant(), // instance
|
||||
polyMesh::meshSubDir, // local
|
||||
runTime
|
||||
);
|
||||
|
||||
Info<< "Writing points to: " << nl
|
||||
<< " " << pointsFile << endl;
|
||||
if (!exists(iopoints.path()))
|
||||
{
|
||||
mkDir(iopoints.path());
|
||||
}
|
||||
|
||||
runTime.writeHeader(pFile, "vectorField");
|
||||
pFile << pointsWedge;
|
||||
runTime.writeEndDivider(pFile);
|
||||
OFstream os(iopoints.objectPath(), runTime.writeStreamOption());
|
||||
|
||||
Info<< "Writing points to: " << nl
|
||||
<< " " << os.name() << endl;
|
||||
|
||||
iopoints.writeHeader(os, vectorIOField::typeName);
|
||||
os << pointsWedge;
|
||||
IOobject::writeEndDivider(os);
|
||||
}
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
|
||||
@ -53,8 +53,8 @@ Usage
|
||||
-rotate-angle (vector angle)
|
||||
Rotate angle degrees about vector axis.
|
||||
|
||||
or -yawPitchRoll : (yaw pitch roll) degrees
|
||||
or -rollPitchYaw : (roll pitch yaw) degrees
|
||||
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
|
||||
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
|
||||
|
||||
-scale scalar|vector
|
||||
Scale the points by the given scalar or vector on output.
|
||||
@ -251,18 +251,15 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"auto-centre",
|
||||
"Use bounding box centre as centre for rotations"
|
||||
"auto-origin",
|
||||
"Use bounding box centre as origin for rotations"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"centre",
|
||||
"origin",
|
||||
"point",
|
||||
"Use specified <point> as centre for rotations"
|
||||
"Use specified <point> as origin for rotations"
|
||||
);
|
||||
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
|
||||
argList::addOptionCompat("centre", {"origin", 2206});
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"rotate",
|
||||
@ -393,18 +390,18 @@ int main(int argc, char *argv[])
|
||||
points += v;
|
||||
}
|
||||
|
||||
vector rotationCentre;
|
||||
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
|
||||
if (args.found("auto-centre") && !useRotationCentre)
|
||||
vector origin;
|
||||
bool useOrigin = args.readIfPresent("origin", origin);
|
||||
if (args.found("auto-origin") && !useOrigin)
|
||||
{
|
||||
useRotationCentre = true;
|
||||
rotationCentre = boundBox(points).centre();
|
||||
useOrigin = true;
|
||||
origin = boundBox(points).centre();
|
||||
}
|
||||
|
||||
if (useRotationCentre)
|
||||
if (useOrigin)
|
||||
{
|
||||
Info<< "Set centre of rotation to " << rotationCentre << endl;
|
||||
points -= rotationCentre;
|
||||
Info<< "Set origin for rotations to " << origin << endl;
|
||||
points -= origin;
|
||||
}
|
||||
|
||||
if (args.found("rotate"))
|
||||
@ -485,15 +482,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (useRotationCentre)
|
||||
{
|
||||
Info<< "Unset centre of rotation from " << rotationCentre << endl;
|
||||
points += rotationCentre;
|
||||
}
|
||||
|
||||
// Output scaling
|
||||
applyScaling(points, getScalingOpt("scale", args));
|
||||
|
||||
if (useOrigin)
|
||||
{
|
||||
Info<< "Unset origin for rotations from " << origin << endl;
|
||||
points += origin;
|
||||
}
|
||||
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||
|
||||
@ -675,7 +675,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
for
|
||||
(
|
||||
const char * const opt
|
||||
const word& opt
|
||||
: { "cellSet", "cellZone", "faceSet", "pointSet" }
|
||||
)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
|
||||
expressions::exprString
|
||||
expression
|
||||
(
|
||||
args["expression"],
|
||||
args[expression],
|
||||
dictionary::null
|
||||
);
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ bool setCellFieldType
|
||||
|
||||
fieldType field(fieldHeader, mesh, false);
|
||||
|
||||
const Type value = pTraits<Type>(fieldValueStream);
|
||||
const Type& value = pTraits<Type>(fieldValueStream);
|
||||
|
||||
if (selectedCells.size() == field.size())
|
||||
{
|
||||
@ -244,7 +244,7 @@ bool setFaceFieldType
|
||||
|
||||
fieldType field(fieldHeader, mesh);
|
||||
|
||||
const Type value = pTraits<Type>(fieldValueStream);
|
||||
const Type& value = pTraits<Type>(fieldValueStream);
|
||||
|
||||
// Create flat list of selected faces and their value.
|
||||
Field<Type> allBoundaryValues(mesh.nBoundaryFaces());
|
||||
|
||||
@ -188,18 +188,15 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
argList::addBoolOption
|
||||
(
|
||||
"auto-centre",
|
||||
"Use bounding box centre as centre for rotations"
|
||||
"auto-origin",
|
||||
"Use bounding box centre as origin for rotations"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"centre",
|
||||
"origin",
|
||||
"point",
|
||||
"Use specified <point> as centre for rotations"
|
||||
"Use specified <point> as origin for rotations"
|
||||
);
|
||||
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
|
||||
argList::addOptionCompat("centre", {"origin", 2206});
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"rotate",
|
||||
@ -337,18 +334,18 @@ int main(int argc, char *argv[])
|
||||
points += v;
|
||||
}
|
||||
|
||||
vector rotationCentre;
|
||||
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
|
||||
if (args.found("auto-centre") && !useRotationCentre)
|
||||
vector origin;
|
||||
bool useOrigin = args.readIfPresent("origin", origin);
|
||||
if (args.found("auto-origin") && !useOrigin)
|
||||
{
|
||||
useRotationCentre = true;
|
||||
rotationCentre = boundBox(points).centre();
|
||||
useOrigin = true;
|
||||
origin = boundBox(points).centre();
|
||||
}
|
||||
|
||||
if (useRotationCentre)
|
||||
if (useOrigin)
|
||||
{
|
||||
Info<< "Set centre of rotation to " << rotationCentre << endl;
|
||||
points -= rotationCentre;
|
||||
Info<< "Set origin for rotations to " << origin << endl;
|
||||
points -= origin;
|
||||
}
|
||||
|
||||
if (args.found("rotate"))
|
||||
@ -409,15 +406,15 @@ int main(int argc, char *argv[])
|
||||
points = transform(rot, points);
|
||||
}
|
||||
|
||||
if (useRotationCentre)
|
||||
{
|
||||
Info<< "Unset centre of rotation from " << rotationCentre << endl;
|
||||
points += rotationCentre;
|
||||
}
|
||||
|
||||
// Output scaling
|
||||
applyScaling(points, getScalingOpt("write-scale", args));
|
||||
|
||||
if (useOrigin)
|
||||
{
|
||||
Info<< "Unset origin for rotations from " << origin << endl;
|
||||
points += origin;
|
||||
}
|
||||
|
||||
surf1.movePoints(points);
|
||||
surf1.write(exportName, writeFileType);
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -140,8 +140,8 @@ do
|
||||
esac
|
||||
else
|
||||
echo "Ignore bad/invalid plugin-path: $pluginPath" 1>&2
|
||||
unset pluginPath
|
||||
fi
|
||||
unset pluginPath
|
||||
;;
|
||||
|
||||
-block*) # Silently accepts -blockMesh
|
||||
@ -238,11 +238,8 @@ then
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$pluginError" ]
|
||||
if [ -n "$pluginError" ]
|
||||
then
|
||||
# Ensure plugin is also in the lib-path
|
||||
LD_LIBRARY_PATH="${PV_PLUGIN_PATH}:$LD_LIBRARY_PATH"
|
||||
else
|
||||
cat<< NO_PLUGIN 1>&2
|
||||
$pluginError
|
||||
See '${0##*/} -help-build' for more information
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -55,8 +55,6 @@ Equivalent options:
|
||||
-scotch-path --scotchArchPath | -scotchArchPath
|
||||
-system-compiler -system
|
||||
-third-compiler -third
|
||||
-openmpi-system -sys-openmpi
|
||||
-openmpi-third -openmpi
|
||||
|
||||
HELP_COMPAT
|
||||
exit 0 # A clean exit
|
||||
@ -91,9 +89,10 @@ Compiler
|
||||
mpc-VERSION For ThirdParty gcc (mpc-system for system library)
|
||||
|
||||
MPI
|
||||
-mpi=NAME Specify 'WM_MPLIB' type (eg, INTELMPI, etc)
|
||||
-openmpi[=VER] Use ThirdParty openmpi, with version for 'FOAM_MPI'
|
||||
-sys-openmpi[=MAJ] Use system openmpi, with specified major version
|
||||
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
|
||||
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
|
||||
-openmpi-system use system openmpi
|
||||
-openmpi-third use ThirdParty openmpi (using default version)
|
||||
|
||||
Components versions (ThirdParty)
|
||||
-adios VER specify 'adios2_version'
|
||||
@ -213,13 +212,12 @@ _inlineSed()
|
||||
# Local filename (for reporting)
|
||||
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
|
||||
|
||||
if grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file"
|
||||
then
|
||||
[ -n "$msg" ] && echo " $msg ($localFile)"
|
||||
else
|
||||
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
|
||||
echo "Failed: ${msg:-replacement} in $localFile"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
[ -n "$msg" ] && echo " $msg ($localFile)"
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -280,8 +278,8 @@ replaceEtc()
|
||||
local file="$1"
|
||||
shift
|
||||
|
||||
file="$(_foamEtc "$file")"
|
||||
replace "$file" "$@"
|
||||
file=$(_foamEtc "$file")
|
||||
replace $file "$@"
|
||||
}
|
||||
|
||||
|
||||
@ -291,36 +289,24 @@ replaceEtcCsh()
|
||||
local file="$1"
|
||||
shift
|
||||
|
||||
file="$(_foamEtc "$file")"
|
||||
replaceCsh "$file" "$@"
|
||||
file=$(_foamEtc "$file")
|
||||
replaceCsh $file "$@"
|
||||
}
|
||||
|
||||
|
||||
# Get the option's value (argument), or die on missing or empty argument
|
||||
# $1 option
|
||||
# $2 value
|
||||
|
||||
# Returns values via optValue, nOptArgs variables!!
|
||||
optValue=""
|
||||
nOptArgs=0 # The number of args to shift
|
||||
|
||||
getOptionValue()
|
||||
{
|
||||
optValue="${1#*=}"
|
||||
if [ "$optValue" = "$1" ]
|
||||
then
|
||||
# Eg, -option value
|
||||
optValue="$2"
|
||||
[ -n "$optValue" ] || die "'$1' option requires an argument"
|
||||
nOptArgs=1
|
||||
else
|
||||
# Eg, -option=value
|
||||
nOptArgs=0
|
||||
fi
|
||||
local value="$2"
|
||||
[ -n "$value" ] || die "'$1' option requires an argument"
|
||||
|
||||
# Remove any surrounding double quotes
|
||||
optValue="${optValue%\"}"
|
||||
optValue="${optValue#\"}"
|
||||
value="${value%\"}"
|
||||
value="${value#\"}"
|
||||
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
|
||||
@ -380,7 +366,7 @@ removeCshMagic()
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
unset adjusted
|
||||
unset adjusted optMpi
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
@ -435,37 +421,26 @@ CONFIG_CSH
|
||||
[ -n "$FOAM_CONFIG_ETC" ] || unset FOAM_CONFIG_ETC
|
||||
;;
|
||||
|
||||
-project-path=* | -project-path)
|
||||
-project-path)
|
||||
# Replace WM_PROJECT_DIR=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\""
|
||||
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\""
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc WM_PROJECT_DIR "\"$optValue\""
|
||||
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optValue\""
|
||||
removeBashMagic $(_foamEtc bashrc)
|
||||
removeCshMagic $(_foamEtc cshrc)
|
||||
|
||||
removeBashMagic "$(_foamEtc bashrc)"
|
||||
removeCshMagic "$(_foamEtc cshrc)"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-version=* | -version | -foamVersion | --projectVersion)
|
||||
-version | -foamVersion | --projectVersion)
|
||||
# Replace WM_PROJECT_VERSION=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc WM_PROJECT_VERSION "$optValue"
|
||||
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc bashrc WM_PROJECT_VERSION "$optionValue"
|
||||
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-sp | -SP | -float32)
|
||||
@ -491,169 +466,132 @@ CONFIG_CSH
|
||||
|
||||
-int32 | -int64)
|
||||
# Replace WM_LABEL_SIZE=...
|
||||
optValue="${1#-int}"
|
||||
replaceEtc bashrc WM_LABEL_SIZE "$optValue"
|
||||
replaceEtcCsh cshrc WM_LABEL_SIZE "$optValue"
|
||||
optionValue="${1#-int}"
|
||||
replaceEtc bashrc WM_LABEL_SIZE "$optionValue"
|
||||
replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue"
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
|
||||
## Compiler ##
|
||||
|
||||
-clang=* | -clang)
|
||||
-clang)
|
||||
# Replace default_clang_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/compiler default_clang_version "$optValue"
|
||||
replaceEtc config.csh/compiler default_clang_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/compiler default_clang_version "$optionValue"
|
||||
replaceEtc config.csh/compiler default_clang_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-gcc=* | -gcc)
|
||||
-gcc)
|
||||
# Replace default_gcc_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/compiler default_gcc_version "$optValue"
|
||||
replaceEtc config.csh/compiler default_gcc_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/compiler default_gcc_version "$optionValue"
|
||||
replaceEtc config.csh/compiler default_gcc_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-system-compiler | -system)
|
||||
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc \
|
||||
WM_COMPILER_TYPE system \
|
||||
WM_COMPILER "$optValue"
|
||||
replaceEtcCsh cshrc \
|
||||
WM_COMPILER_TYPE system \
|
||||
WM_COMPILER "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc bashrc \
|
||||
WM_COMPILER_TYPE system \
|
||||
WM_COMPILER "$optionValue"
|
||||
replaceEtcCsh cshrc \
|
||||
WM_COMPILER_TYPE system \
|
||||
WM_COMPILER "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-third-compiler | -third | -ThirdParty)
|
||||
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc \
|
||||
WM_COMPILER_TYPE ThirdParty \
|
||||
WM_COMPILER "$optValue"
|
||||
replaceEtcCsh cshrc \
|
||||
WM_COMPILER_TYPE ThirdParty \
|
||||
WM_COMPILER "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc bashrc \
|
||||
WM_COMPILER_TYPE ThirdParty \
|
||||
WM_COMPILER "$optionValue"
|
||||
replaceEtcCsh cshrc \
|
||||
WM_COMPILER_TYPE ThirdParty \
|
||||
WM_COMPILER "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
gmp-[4-9]* | gmp-system)
|
||||
# gcc-related package
|
||||
optValue="${1#-}"
|
||||
replaceEtc config.sh/compiler default_gmp_version "$optValue"
|
||||
replaceEtc config.csh/compiler default_gmp_version "$optValue"
|
||||
replaceEtc config.sh/compiler default_gmp_version "$1"
|
||||
replaceEtc config.csh/compiler default_gmp_version "$1"
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
mpfr-[2-9]* | mpfr-system)
|
||||
# gcc-related package
|
||||
optValue="${1#-}"
|
||||
replaceEtc config.sh/compiler default_mpfr_version "$optValue"
|
||||
replaceEtc config.csh/compiler default_mpfr_version "$optValue"
|
||||
replaceEtc config.sh/compiler default_mpfr_version "$1"
|
||||
replaceEtc config.csh/compiler default_mpfr_version "$1"
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
mpc-[0-9]* | mpc-system)
|
||||
# gcc-related package
|
||||
optValue="${1#-}"
|
||||
replaceEtc config.sh/compiler default_mpc_version "$optValue"
|
||||
replaceEtc config.csh/compiler default_mpc_version "$optValue"
|
||||
replaceEtc config.sh/compiler default_mpc_version "$1"
|
||||
replaceEtc config.csh/compiler default_mpc_version "$1"
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
|
||||
## MPI ##
|
||||
|
||||
-mpi=* | -mpi)
|
||||
-mpi)
|
||||
# Explicitly set WM_MPLIB=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc WM_MPLIB "$optValue"
|
||||
replaceEtcCsh cshrc WM_MPLIB "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc bashrc WM_MPLIB "$optionValue"
|
||||
replaceEtcCsh cshrc WM_MPLIB "$optionValue"
|
||||
optMpi=system
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-sys-openmpi=* | -sys-openmpi | -openmpi-system)
|
||||
optValue="$(echo "$1" | sed -ne 's/^.*mpi=\([1-9][0-9]*\).*/\1/p')"
|
||||
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI"$optValue"
|
||||
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI"$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
;;
|
||||
|
||||
-openmpi=* | -openmpi | -openmpi-third)
|
||||
# Explicitly set WM_MPLIB=OPENMPI
|
||||
# - use default setting for openmpi, or
|
||||
# replace FOAM_MPI=openmpi-<digits>..
|
||||
-openmpi)
|
||||
# Replace FOAM_MPI=openmpi-<digits>.. and set to use third-party
|
||||
# The edit is slightly fragile, but works
|
||||
|
||||
expected="openmpi-[1-9][.0-9]*"
|
||||
optValue="$(echo "$1" | sed -ne 's/^.*mpi=//p')"
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
if [ "${optValue#openmpi-}" = "$optValue" ]
|
||||
then
|
||||
optValue="openmpi-$optValue"
|
||||
fi
|
||||
optMpi=$(getOptionValue "$@")
|
||||
|
||||
_matches "$optValue" "$expected" || \
|
||||
die "'${1%=*}' has bad value: '$optValue'"
|
||||
_matches "$optMpi" "$expected" || \
|
||||
die "'$1' has bad value: '$optMpi'"
|
||||
|
||||
_inlineSed "$(_foamEtc config.sh/mpi)" \
|
||||
"FOAM_MPI=$expected" \
|
||||
"FOAM_MPI=$optValue" \
|
||||
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optValue'"
|
||||
_inlineSed $(_foamEtc config.sh/mpi) \
|
||||
"FOAM_MPI=$expected" \
|
||||
"FOAM_MPI=$optMpi" \
|
||||
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
|
||||
|
||||
_inlineSed $(_foamEtc config.csh/mpi) \
|
||||
"FOAM_MPI $expected" \
|
||||
"FOAM_MPI $optMpi" \
|
||||
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
|
||||
|
||||
_inlineSed "$(_foamEtc config.csh/mpi)" \
|
||||
"FOAM_MPI=$expected" \
|
||||
"FOAM_MPI=$optValue" \
|
||||
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optValue'"
|
||||
fi
|
||||
replaceEtc bashrc WM_MPLIB OPENMPI
|
||||
replaceEtcCsh cshrc WM_MPLIB OPENMPI
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-openmpi-system)
|
||||
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
|
||||
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI
|
||||
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI
|
||||
optMpi=system
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
-openmpi-third)
|
||||
# Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
|
||||
replaceEtc bashrc WM_MPLIB OPENMPI
|
||||
replaceEtcCsh cshrc WM_MPLIB OPENMPI
|
||||
optMpi=third
|
||||
adjusted=true
|
||||
;;
|
||||
|
||||
|
||||
@ -661,242 +599,146 @@ CONFIG_CSH
|
||||
|
||||
-adios | -adios2)
|
||||
# Replace adios2_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/adios2 adios2_version "$optValue"
|
||||
replaceEtc config.csh/adios2 adios2_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/adios2 adios2_version "$optionValue"
|
||||
replaceEtc config.csh/adios2 adios2_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-adios-path | -adios2-path)
|
||||
# Replace ADIOS2_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
|
||||
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
|
||||
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-boost)
|
||||
# Replace boost_version=... (config is cgal or CGAL)
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" boost_version "$optValue"
|
||||
replaceEtc config.csh/"$cfgName" boost_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" boost_version "$optionValue"
|
||||
replaceEtc config.csh/"$cfgName" boost_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-boost-path)
|
||||
# Replace BOOST_ARCH_PATH=... (config is cgal or CGAL)
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
|
||||
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
|
||||
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-cgal)
|
||||
# Replace cgal_version=... (config is cgal or CGAL)
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" cgal_version "$optValue"
|
||||
replaceEtc config.csh/"$cfgName" cgal_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" cgal_version "$optionValue"
|
||||
replaceEtc config.csh/"$cfgName" cgal_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-cgal-path)
|
||||
# Replace CGAL_ARCH_PATH=... (config is cgal or CGAL)
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optValue"
|
||||
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
|
||||
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-fftw)
|
||||
# Replace fftw_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
# config.sh/fftw or config.sh/FFTW
|
||||
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" fftw_version "$optValue"
|
||||
replaceEtc config.csh/"$cfgName" fftw_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" fftw_version "$optionValue"
|
||||
replaceEtc config.csh/"$cfgName" fftw_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-fftw-path)
|
||||
# Replace FFTW_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
optionValue=$(getOptionValue "$@")
|
||||
# config.sh/fftw or config.sh/FFTW
|
||||
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
|
||||
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
|
||||
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-cmake)
|
||||
# Replace cmake_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/cmake cmake_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/cmake cmake_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-cmake-path)
|
||||
# Replace CMAKE_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-kahip)
|
||||
# Replace KAHIP_VERSION=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/kahip KAHIP_VERSION "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-kahip-path)
|
||||
# Replace KAHIP_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-metis)
|
||||
# Replace METIS_VERSION=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/metis METIS_VERSION "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/metis METIS_VERSION "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-metis-path)
|
||||
# Replace METIS_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-scotch | -scotchVersion | --scotchVersion)
|
||||
# Replace SCOTCH_VERSION=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/scotch SCOTCH_VERSION "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-scotch-path | -scotchArchPath | --scotchArchPath)
|
||||
# Replace SCOTCH_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
@ -905,156 +747,107 @@ CONFIG_CSH
|
||||
-paraview | -paraviewVersion | --paraviewVersion)
|
||||
# Replace ParaView_VERSION=...
|
||||
expected="[5-9][.0-9]*" # but also accept system
|
||||
getOptionValue "$@"
|
||||
_matches "$optValue" "$expected" || \
|
||||
[ "$optValue" != "${optValue%system}" ] || \
|
||||
die "'${1%=*}' has bad value: '$optValue'"
|
||||
|
||||
shift "${nOptArgs:-0}"
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/paraview ParaView_VERSION "$optValue"
|
||||
replaceEtc config.csh/paraview ParaView_VERSION "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
_matches "$optionValue" "$expected" || \
|
||||
[ "$optionValue" != "${optionValue%system}" ] || \
|
||||
die "'$1' has bad value: '$optionValue'"
|
||||
replaceEtc config.sh/paraview ParaView_VERSION "$optionValue"
|
||||
replaceEtc config.csh/paraview ParaView_VERSION "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-paraview-qt)
|
||||
# Replace ParaView_QT=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/paraview ParaView_QT "$optValue"
|
||||
replaceEtc config.csh/paraview ParaView_QT "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/paraview ParaView_QT "$optionValue"
|
||||
replaceEtc config.csh/paraview ParaView_QT "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-paraview-path | -paraviewInstall | --paraviewInstall)
|
||||
# Replace ParaView_DIR=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/paraview ParaView_DIR \""$optValue\""
|
||||
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\""
|
||||
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-llvm)
|
||||
# Replace mesa_llvm=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk mesa_llvm "$optValue"
|
||||
replaceEtc config.csh/vtk mesa_llvm "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
|
||||
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-mesa)
|
||||
# Replace mesa_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk mesa_version "$optValue"
|
||||
replaceEtc config.csh/vtk mesa_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk mesa_version "$optionValue"
|
||||
replaceEtc config.csh/vtk mesa_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-vtk)
|
||||
# Replace vtk_version=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk vtk_version "$optValue"
|
||||
replaceEtc config.csh/vtk vtk_version "$optValue"
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk vtk_version "$optionValue"
|
||||
replaceEtc config.csh/vtk vtk_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-llvm-path)
|
||||
# Replace LLVM_ARCH_PATH=...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optValue\""
|
||||
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-mesa-path)
|
||||
# Replace MESA_ARCH_PATH...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optValue\""
|
||||
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-vtk-path)
|
||||
# Replace VTK_DIR...
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
|
||||
if [ -n "$optValue" ]
|
||||
then
|
||||
replaceEtc config.sh/vtk VTK_DIR \""$optValue\""
|
||||
replaceEtcCsh config.csh/vtk VTK_DIR \""$optValue\""
|
||||
adjusted=true
|
||||
else
|
||||
: "${adjusted:=empty}"
|
||||
fi
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
## Misc ##
|
||||
|
||||
# Obsolete flags
|
||||
-sigfpe | -no-sigfpe)
|
||||
echo "Enable/disable FOAM_SIGFPE now via controlDict" 1>&2
|
||||
;;
|
||||
|
||||
# Obsolete options
|
||||
-archOption | --archOption | \
|
||||
-archOption | --archOption)
|
||||
# Replace WM_ARCH_OPTION=...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
echo "Ignoring $1 option: no longer supported" 1>&2
|
||||
shift
|
||||
;;
|
||||
|
||||
-foamInstall | --foamInstall | -projectName | --projectName)
|
||||
echo "Ignoring obsolete option: $1" 1>&2
|
||||
getOptionValue "$@"
|
||||
shift "${nOptArgs:-0}"
|
||||
# Removed for 1812
|
||||
optionValue=$(getOptionValue "$@")
|
||||
echo "Ignoring $1 option: obsolete" 1>&2
|
||||
shift
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -32,8 +32,9 @@
|
||||
#
|
||||
# Debian-style without OpenFOAM sub-directory
|
||||
#
|
||||
# foamPackRelease -name=openfoam2002_200129.orig -no-prefix origin/develop
|
||||
# foamPackRelease -debian origin/develop
|
||||
# foamPackRelease -debian=openfoam2002_200129 origin/develop
|
||||
# foamPackRelease -name=openfoam2002_200129.orig -no-prefix origin/develop
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
Script="${0##*/}"
|
||||
@ -55,7 +56,8 @@ options:
|
||||
-sep=SEP Change version/patch separator from '_' to SEP
|
||||
-gitbase=DIR Alternative repository location
|
||||
-with-api=NUM Specify alternative api value for packaging
|
||||
-tgz, -xz Alias for -compress=tgz, -compress=xz
|
||||
-tgz, -xz, -zstd Alias for -compress=tgz, -compress=xz, -compress=zstd
|
||||
-debian Auto (debian) naming with -no-prefix, -xz
|
||||
-debian=NAME Short-cut for -name=NAME.orig, -no-prefix, -xz
|
||||
-help Print help
|
||||
|
||||
@ -116,6 +118,11 @@ do
|
||||
-h | -help*)
|
||||
printHelp
|
||||
;;
|
||||
-debian)
|
||||
tarName="debian" # Special placeholder
|
||||
prefixDir=false # No prefix directory
|
||||
: "${compress:=xz}" # Default 'xz' compression
|
||||
;;
|
||||
-debian=*)
|
||||
tarName="${1#*=}"
|
||||
cleanTarName
|
||||
@ -166,7 +173,7 @@ do
|
||||
-with-api=*)
|
||||
packageApi="${1#*=}"
|
||||
;;
|
||||
-tgz | -xz)
|
||||
-tgz | -xz | -zst | -zstd)
|
||||
compress="${1#*-}"
|
||||
;;
|
||||
--)
|
||||
@ -259,10 +266,11 @@ sha1=$(git --git-dir="$gitbase/.git" ls-tree "$head" META-INFO/api-info | \
|
||||
[ -n "$sha1" ] || die "Could locate git content for META-INFO/api-info"
|
||||
|
||||
# The api and patch
|
||||
api="$(git --git-dir="$gitbase/.git" show "$sha1" | sed -ne s/api=//p)"
|
||||
patch="$(git --git-dir="$gitbase/.git" show "$sha1" | sed -ne s/patch=//p)"
|
||||
api="$(git --git-dir="$gitbase/.git" show "$sha1" | sed -ne s/^api=//p)"
|
||||
patch="$(git --git-dir="$gitbase/.git" show "$sha1" | sed -ne s/^patch=//p)"
|
||||
|
||||
[ -n "$api" ] || die "Could resolve api value"
|
||||
: "${patch:=0}" # Treat missing patch number as '0'
|
||||
|
||||
# Determine the BUILD information from git, as per `wmake -build-info`
|
||||
build="$(git --git-dir="$gitbase/.git" log -1 --date=short --format='%h=%ad' 2>/dev/null|sed 's/-//g;s/=/-/')"
|
||||
@ -290,8 +298,25 @@ then
|
||||
unset prefixDir
|
||||
fi
|
||||
|
||||
if [ -z "$tarName" ]
|
||||
then
|
||||
case "$tarName" in
|
||||
(debian)
|
||||
tarName="openfoam${packageApi}"
|
||||
|
||||
if [ "$withPatchNum" = false ]
|
||||
then
|
||||
echo "Ignoring patch number for output name" 1>&2
|
||||
else
|
||||
# Start debian with patch=1, not patch=0
|
||||
if [ "$patch" = 0 ]
|
||||
then
|
||||
patch=1
|
||||
fi
|
||||
tarName="${tarName}${versionSeparator}${patch}"
|
||||
fi
|
||||
tarName="${tarName}.orig" # Append .orig
|
||||
;;
|
||||
|
||||
('')
|
||||
tarName="OpenFOAM-v${packageApi}"
|
||||
if [ "$withSource" = false ]
|
||||
then
|
||||
@ -301,11 +326,12 @@ then
|
||||
if [ "$withPatchNum" = false ]
|
||||
then
|
||||
echo "Ignoring patch number for output name" 1>&2
|
||||
elif [ "${patch:-0}" -gt 0 ]
|
||||
elif [ "${patch:-0}" != 0 ]
|
||||
then
|
||||
tarName="${tarName}${versionSeparator}${patch}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo 1>&2
|
||||
echo "Tar-file name: $tarName.tar" 1>&2
|
||||
@ -444,7 +470,7 @@ case "$compress" in
|
||||
|
||||
(gz | gzip)
|
||||
echo "Using gzip compression" 1>&2
|
||||
echo 'gzip -f9 "$outputDir/$tarName.tar"'
|
||||
echo 'gzip -f -9 "$outputDir/$tarName.tar"'
|
||||
echo
|
||||
echo '# End of compression'
|
||||
;;
|
||||
@ -459,14 +485,21 @@ case "$compress" in
|
||||
|
||||
(bz | bzip | bzip2)
|
||||
echo "Using bzip2 compression" 1>&2
|
||||
echo 'bzip2 -f9 "$outputDir/$tarName.tar"'
|
||||
echo 'bzip2 -f -9 "$outputDir/$tarName.tar"'
|
||||
echo
|
||||
echo '# End of compression'
|
||||
;;
|
||||
|
||||
(xz)
|
||||
echo "Using xz compression" 1>&2
|
||||
echo 'xz -f9 "$outputDir/$tarName.tar"'
|
||||
echo 'xz -f -9 "$outputDir/$tarName.tar"'
|
||||
echo
|
||||
echo '# End of compression'
|
||||
;;
|
||||
|
||||
(zst | zstd)
|
||||
echo "Using zstd compression" 1>&2
|
||||
echo 'zstd --rm -f -9 "$outputDir/$tarName.tar"'
|
||||
echo
|
||||
echo '# End of compression'
|
||||
;;
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
# [WM_PROJECT_VERSION] - A human-readable version name
|
||||
# A development version is often named 'com' - as in www.openfoam.com
|
||||
export WM_PROJECT_VERSION=v2012
|
||||
export WM_PROJECT_VERSION=com
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Configuration environment variables.
|
||||
|
||||
@ -44,7 +44,7 @@ coldAndHot
|
||||
fire
|
||||
{
|
||||
// ParaView: Black-Body Radiation
|
||||
interpolate rgb;
|
||||
interpolate rbg;
|
||||
|
||||
table
|
||||
(
|
||||
@ -70,7 +70,7 @@ rainbow
|
||||
greyscale
|
||||
{
|
||||
// ParaView: grayscale
|
||||
interpolate rgb;
|
||||
interpolate rbg;
|
||||
|
||||
table
|
||||
(
|
||||
@ -82,7 +82,7 @@ greyscale
|
||||
xray
|
||||
{
|
||||
// ParaView: "X ray"
|
||||
interpolate rgb;
|
||||
interpolate rbg;
|
||||
|
||||
table
|
||||
(
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -174,13 +174,12 @@ _foamAddPath "${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN}"
|
||||
# Dummy versions of external libraries. To be found last in library path
|
||||
_foamAddLib "$FOAM_LIBBIN/dummy"
|
||||
|
||||
# External (ThirdParty) libraries:
|
||||
# - check if already compiled, or will be compiled.
|
||||
# can also be unset
|
||||
unsetenv FOAM_EXT_LIBBIN
|
||||
if ( -d "$WM_THIRD_PARTY_DIR/platforms" || -f "$WM_THIRD_PARTY_DIR/Allwmake" ) then
|
||||
# External (ThirdParty) libraries. Also allowed to be unset
|
||||
if ( -d "$WM_THIRD_PARTY_DIR" ) then
|
||||
setenv FOAM_EXT_LIBBIN "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib"
|
||||
_foamAddLib "$FOAM_EXT_LIBBIN"
|
||||
else
|
||||
unsetenv FOAM_EXT_LIBBIN
|
||||
endif
|
||||
|
||||
# OpenFOAM libraries (user, group, standard)
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
# Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -174,14 +174,13 @@ _foamAddPath "$FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN"
|
||||
# Dummy versions of external libraries. To be found last in library path
|
||||
_foamAddLib "$FOAM_LIBBIN/dummy"
|
||||
|
||||
# External (ThirdParty) libraries:
|
||||
# - check if already compiled, or will be compiled.
|
||||
# can also be unset
|
||||
unset FOAM_EXT_LIBBIN
|
||||
if [ -d "$WM_THIRD_PARTY_DIR/platforms" ] || [ -f "$WM_THIRD_PARTY_DIR/Allwmake" ]
|
||||
# External (ThirdParty) libraries. Also allowed to be unset
|
||||
if [ -d "$WM_THIRD_PARTY_DIR" ]
|
||||
then
|
||||
export FOAM_EXT_LIBBIN="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib"
|
||||
_foamAddLib "$FOAM_EXT_LIBBIN"
|
||||
else
|
||||
unset FOAM_EXT_LIBBIN
|
||||
fi
|
||||
|
||||
# OpenFOAM libraries (user, group, standard)
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
# [WM_PROJECT_VERSION] - A human-readable version name
|
||||
# A development version is often named 'com' - as in www.openfoam.com
|
||||
setenv WM_PROJECT_VERSION v2012
|
||||
setenv WM_PROJECT_VERSION com
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Configuration environment variables.
|
||||
|
||||
@ -12,13 +12,7 @@ targetType=libso
|
||||
export FOAM_MODULE_PREFIX
|
||||
|
||||
echo "========================================"
|
||||
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
|
||||
then
|
||||
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Compile OpenFOAM modules"
|
||||
echo "prefix = $FOAM_MODULE_PREFIX"
|
||||
echo
|
||||
echo " ignoring possible compilation errors"
|
||||
|
||||
@ -161,7 +161,7 @@ public:
|
||||
// + (numElem % elem_per_block) ? 1 : 0
|
||||
// \endcode
|
||||
// But avoiding the modulus operation
|
||||
static constexpr label num_blocks(label numElem)
|
||||
static constexpr label num_blocks(label numElem) noexcept
|
||||
{
|
||||
return ((numElem - 1 + elem_per_block) / elem_per_block);
|
||||
}
|
||||
@ -385,10 +385,6 @@ public:
|
||||
|
||||
// Low-level access
|
||||
|
||||
//- The number of bytes used in the underlying storage
|
||||
//- including any unused padding.
|
||||
inline std::streamsize byteSize() const;
|
||||
|
||||
//- The number of internal storage blocks
|
||||
inline label nBlocks() const;
|
||||
|
||||
@ -399,6 +395,16 @@ public:
|
||||
// Manipulate with utmost caution
|
||||
inline List<unsigned int>& storage();
|
||||
|
||||
//- A const pointer to the raw storage
|
||||
inline const unsigned int* cdata() const noexcept;
|
||||
|
||||
//- A pointer to the raw storage
|
||||
inline unsigned int* data() noexcept;
|
||||
|
||||
//- The number of bytes used in the raw storage
|
||||
//- including any unused padding.
|
||||
inline std::streamsize byteSize() const noexcept;
|
||||
|
||||
|
||||
// IO
|
||||
|
||||
@ -519,10 +525,7 @@ public:
|
||||
void assign(const PackedList<Width>& rhs) { (*this) = rhs; }
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label len, unsigned int val = 0u)
|
||||
{
|
||||
resize(len, val);
|
||||
}
|
||||
void setSize(const label n, unsigned int val = 0u) { resize(n, val); }
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -548,7 +548,21 @@ inline Foam::label Foam::PackedList<Width>::nBlocks() const
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline std::streamsize Foam::PackedList<Width>::byteSize() const
|
||||
inline const unsigned int* Foam::PackedList<Width>::cdata() const noexcept
|
||||
{
|
||||
return blocks_.cdata();
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline unsigned int* Foam::PackedList<Width>::data() noexcept
|
||||
{
|
||||
return blocks_.data();
|
||||
}
|
||||
|
||||
|
||||
template<unsigned Width>
|
||||
inline std::streamsize Foam::PackedList<Width>::byteSize() const noexcept
|
||||
{
|
||||
return num_blocks(size()) * sizeof(block_type);
|
||||
}
|
||||
@ -563,7 +577,7 @@ inline void Foam::PackedList<Width>::swap(PackedList<Width>& rhs)
|
||||
}
|
||||
|
||||
blocks_.swap(rhs.blocks_);
|
||||
Foam::Swap(size_, rhs.size_);
|
||||
std::swap(size_, rhs.size_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -127,7 +127,7 @@ Foam::Istream& Foam::PackedList<Width>::read(Istream& is)
|
||||
{
|
||||
is.read
|
||||
(
|
||||
reinterpret_cast<char*>(list.storage().data()),
|
||||
reinterpret_cast<char*>(list.data()),
|
||||
list.byteSize()
|
||||
);
|
||||
|
||||
@ -249,7 +249,7 @@ Foam::Ostream& Foam::PackedList<Width>::writeList
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(list.storage().cdata()),
|
||||
reinterpret_cast<const char*>(list.cdata()),
|
||||
list.byteSize()
|
||||
);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -87,7 +87,7 @@ Foam::Ostream& Foam::bitSet::writeList
|
||||
// write(...) includes surrounding start/end delimiters
|
||||
os.write
|
||||
(
|
||||
reinterpret_cast<const char*>(list.storage().cdata()),
|
||||
reinterpret_cast<const char*>(list.cdata()),
|
||||
list.byteSize()
|
||||
);
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ Foam::PtrListDictionary<T>::PtrListDictionary(const label size)
|
||||
:
|
||||
DictionaryBase<PtrList<T>, T>(2*size)
|
||||
{
|
||||
PtrList<T>::setSize(size);
|
||||
PtrList<T>::resize(size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -201,17 +201,17 @@ void Foam::CompactListList<T, Container>::clear()
|
||||
template<class T, class Container>
|
||||
void Foam::CompactListList<T, Container>::swap
|
||||
(
|
||||
CompactListList<T, Container>& lst
|
||||
CompactListList<T, Container>& other
|
||||
)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &other)
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
Foam::Swap(size_, lst.size_);
|
||||
offsets_.swap(lst.offsets_);
|
||||
m_.swap(lst.m_);
|
||||
std::swap(size_, other.size_);
|
||||
offsets_.swap(other.offsets_);
|
||||
m_.swap(other.m_);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -103,7 +103,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor.
|
||||
//- Default construct
|
||||
inline CompactListList();
|
||||
|
||||
//- Construct by converting given List<List<T>>
|
||||
@ -197,7 +197,7 @@ public:
|
||||
labelList sizes() const;
|
||||
|
||||
//- Swap contents
|
||||
void swap(CompactListList<T, Container>& lst);
|
||||
void swap(CompactListList<T, Container>& other);
|
||||
|
||||
//- Transfer contents into this and annul the argument
|
||||
void transfer(CompactListList<T, Container>& list);
|
||||
@ -261,13 +261,15 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Note: uses default Foam::Swap (move construct/assignment)
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "CompactListListI.H"
|
||||
#include "CompactListListI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,7 +38,7 @@ Foam::label Foam::DynamicList<T, SizeMin>::removeElements
|
||||
{
|
||||
if (!slice.size())
|
||||
{
|
||||
// Noop
|
||||
// No-op
|
||||
return 0;
|
||||
}
|
||||
else if (slice.after() >= this->size())
|
||||
@ -89,40 +88,4 @@ Foam::label Foam::DynamicList<T, SizeMin>::subsetElements
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
|
||||
:
|
||||
List<T>(is),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& lst
|
||||
)
|
||||
{
|
||||
os << static_cast<const List<T>&>(lst);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& lst
|
||||
)
|
||||
{
|
||||
is >> static_cast<List<T>&>(lst);
|
||||
lst.capacity_ = lst.List<T>::size();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,18 +56,10 @@ namespace Foam
|
||||
template<class T, int SizeMin> class DynamicList;
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& lst
|
||||
);
|
||||
inline Istream& operator>>(Istream&, DynamicList<T, SizeMin>&);
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& lst
|
||||
);
|
||||
inline Ostream& operator<<(Ostream&, const DynamicList<T, SizeMin>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -95,36 +87,25 @@ class DynamicList
|
||||
//- Subset elements in range
|
||||
label subsetElements(const labelRange& slice);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Copy assignment from another list
|
||||
template<class ListType>
|
||||
inline void assignDynList(const ListType& lst);
|
||||
inline void assignDynList(const ListType& list);
|
||||
|
||||
public:
|
||||
|
||||
// Related Types
|
||||
|
||||
//- Declare friendship with the List class
|
||||
friend class List<T>;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Default construct, an empty list without allocation.
|
||||
inline constexpr DynamicList() noexcept;
|
||||
|
||||
//- Construct an empty list with given reserve size.
|
||||
inline explicit DynamicList(const label nElem);
|
||||
inline explicit DynamicList(const label len);
|
||||
|
||||
//- Construct with given size and value for all elements.
|
||||
inline DynamicList(const label nElem, const T& val);
|
||||
inline DynamicList(const label len, const T& val);
|
||||
|
||||
//- Construct with given size initializing all elements to zero
|
||||
inline DynamicList(const label nElem, const Foam::zero);
|
||||
inline DynamicList(const label len, const Foam::zero);
|
||||
|
||||
//- Copy construct.
|
||||
inline DynamicList(const DynamicList<T, SizeMin>& lst);
|
||||
@ -181,64 +162,62 @@ public:
|
||||
inline label capacity() const noexcept;
|
||||
|
||||
|
||||
// Edit
|
||||
// Sizing
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
inline void setCapacity(const label nElem);
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
inline void setCapacity(const label newCapacity);
|
||||
|
||||
//- Alter addressable list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void setSize(const label nElem);
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label len);
|
||||
|
||||
//- Alter addressable list size and fill new space with constant.
|
||||
inline void setSize(const label nElem, const T& val);
|
||||
//- Alter addressable size.
|
||||
// New space will be allocated if required.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Alter addressable list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void resize(const label nElem);
|
||||
//- Alter addressable size and fill new space with constant value
|
||||
inline void resize(const label newLen, const T& val);
|
||||
|
||||
//- Alter addressable list size and fill new space with constant.
|
||||
inline void resize(const label nElem, const T& val);
|
||||
//- Alias for resize()
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label nElem);
|
||||
//- Alias for resize()
|
||||
void setSize(const label n, const T& val) { this->resize(n, val); }
|
||||
|
||||
//- Clear the addressed list, i.e. set the size to zero.
|
||||
// Allocated size does not change
|
||||
inline void clear();
|
||||
//- Clear the addressed list, i.e. set the size to zero.
|
||||
// Allocated size does not change
|
||||
inline void clear() noexcept;
|
||||
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
|
||||
//- Expand the addressable size to fit the allocated capacity.
|
||||
// Returns the previous addressable size.
|
||||
inline label expandStorage();
|
||||
//- Expand the addressable size to fit the allocated capacity.
|
||||
// Returns the previous addressable size.
|
||||
inline label expandStorage() noexcept;
|
||||
|
||||
//- Shrink the allocated space to the number of elements used.
|
||||
// Returns a reference to the DynamicList.
|
||||
inline DynamicList<T, SizeMin>& shrink();
|
||||
//- Shrink the allocated space to the number of elements used.
|
||||
// Returns a reference to the DynamicList.
|
||||
inline DynamicList<T, SizeMin>& shrink();
|
||||
|
||||
//- Swap content with any sized DynamicList
|
||||
|
||||
// Edit
|
||||
|
||||
//- Swap content, independent of sizing parameter
|
||||
template<int AnySizeMin>
|
||||
inline void swap(DynamicList<T, AnySizeMin>& lst);
|
||||
inline void swap(DynamicList<T, AnySizeMin>& other);
|
||||
|
||||
//- Transfer contents of the argument List into this.
|
||||
inline void transfer(List<T>& lst);
|
||||
inline void transfer(List<T>& list);
|
||||
|
||||
//- Transfer contents of any sized DynamicList into this.
|
||||
template<int AnySizeMin>
|
||||
inline void transfer(DynamicList<T, AnySizeMin>& lst);
|
||||
inline void transfer(DynamicList<T, AnySizeMin>& list);
|
||||
|
||||
//- Transfer contents of the argument SortableList into this.
|
||||
inline void transfer(SortableList<T>& lst);
|
||||
inline void transfer(SortableList<T>& list);
|
||||
|
||||
//- Append an element to the end of this list.
|
||||
inline DynamicList<T, SizeMin>& append(const T& val);
|
||||
@ -311,8 +290,7 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return non-const access to an element,
|
||||
//- resizing list if necessary
|
||||
//- Return non-const access to an element, resizing list if needed
|
||||
inline T& operator()(const label i);
|
||||
|
||||
//- Assignment of all addressed entries to the given value
|
||||
@ -356,29 +334,32 @@ public:
|
||||
inline void operator=(SortableList<T>&& lst);
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
// Write DynamicList to Ostream.
|
||||
friend Ostream& operator<< <T, SizeMin>
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& lst
|
||||
);
|
||||
//- Read from Istream, discarding existing contents
|
||||
friend Istream& operator>> <T, SizeMin>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& rhs
|
||||
);
|
||||
|
||||
//- Read from Istream, discarding contents of existing DynamicList.
|
||||
friend Istream& operator>> <T, SizeMin>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& lst
|
||||
);
|
||||
//- Write to Ostream
|
||||
friend Ostream& operator<< <T, SizeMin>
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& rhs
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// Global Functions
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Exchange contents of lists - see DynamicList::swap().
|
||||
template<class T, int SizeMin1, int SizeMin2>
|
||||
inline void Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b);
|
||||
template<class T, int SizeMinA, int SizeMinB>
|
||||
inline void Swap(DynamicList<T, SizeMinA>& a, DynamicList<T, SizeMinB>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,29 +28,29 @@ License
|
||||
|
||||
#include "FixedList.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<class ListType>
|
||||
inline void Foam::DynamicList<T, SizeMin>::assignDynList
|
||||
(
|
||||
const ListType& lst
|
||||
const ListType& list
|
||||
)
|
||||
{
|
||||
const label newSize = lst.size();
|
||||
const label newLen = list.size();
|
||||
|
||||
if (capacity_ >= newSize)
|
||||
if (newLen <= capacity_)
|
||||
{
|
||||
// Can copy w/o reallocating - adjust addressable size accordingly.
|
||||
List<T>::size(newSize);
|
||||
List<T>::operator=(lst);
|
||||
List<T>::setAddressableSize(newLen);
|
||||
List<T>::operator=(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure list size consistency prior to copying.
|
||||
List<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
List<T>::operator=(lst);
|
||||
List<T>::operator=(list);
|
||||
capacity_ = List<T>::size();
|
||||
}
|
||||
}
|
||||
@ -61,27 +61,29 @@ inline void Foam::DynamicList<T, SizeMin>::assignDynList
|
||||
template<class T, int SizeMin>
|
||||
inline constexpr Foam::DynamicList<T, SizeMin>::DynamicList() noexcept
|
||||
:
|
||||
List<T>(),
|
||||
capacity_(0)
|
||||
{}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList(const label nElem)
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList(const label len)
|
||||
:
|
||||
List<T>(),
|
||||
capacity_(0)
|
||||
{
|
||||
reserve(nElem);
|
||||
reserve(len);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const label nElem,
|
||||
const label len,
|
||||
const T& val
|
||||
)
|
||||
:
|
||||
List<T>(nElem, val),
|
||||
List<T>(len, val),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
@ -89,11 +91,11 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const label nElem,
|
||||
const label len,
|
||||
const Foam::zero
|
||||
)
|
||||
:
|
||||
List<T>(nElem, Zero),
|
||||
List<T>(len, Zero),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
@ -101,10 +103,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const DynamicList<T, SizeMin>& lst
|
||||
const DynamicList<T, SizeMin>& list
|
||||
)
|
||||
:
|
||||
List<T>(lst),
|
||||
List<T>(list),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
@ -113,10 +115,10 @@ template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const DynamicList<T, AnySizeMin>& lst
|
||||
const DynamicList<T, AnySizeMin>& list
|
||||
)
|
||||
:
|
||||
List<T>(lst),
|
||||
List<T>(list),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
@ -124,10 +126,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const UList<T>& lst
|
||||
const UList<T>& list
|
||||
)
|
||||
:
|
||||
List<T>(lst),
|
||||
List<T>(list),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
@ -136,12 +138,12 @@ template<class T, int SizeMin>
|
||||
template<unsigned N>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
(
|
||||
const FixedList<T, N>& lst
|
||||
const FixedList<T, N>& list
|
||||
)
|
||||
:
|
||||
capacity_(0)
|
||||
{
|
||||
this->operator=(lst);
|
||||
this->operator=(list);
|
||||
}
|
||||
|
||||
|
||||
@ -218,6 +220,14 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>::DynamicList(Istream& is)
|
||||
:
|
||||
List<T>(is),
|
||||
capacity_(List<T>::size())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
@ -230,124 +240,83 @@ inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const noexcept
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::setCapacity
|
||||
(
|
||||
const label nElem
|
||||
const label newCapacity
|
||||
)
|
||||
{
|
||||
label nextFree = List<T>::size();
|
||||
capacity_ = nElem;
|
||||
label currLen = List<T>::size();
|
||||
capacity_ = newCapacity;
|
||||
|
||||
if (nextFree > capacity_)
|
||||
if (currLen > capacity_)
|
||||
{
|
||||
// Truncate addressed sizes too
|
||||
nextFree = capacity_;
|
||||
currLen = capacity_;
|
||||
}
|
||||
|
||||
// We could also enforce sizing granularity
|
||||
|
||||
List<T>::setSize(capacity_);
|
||||
List<T>::size(nextFree);
|
||||
List<T>::resize(capacity_);
|
||||
List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::reserve
|
||||
(
|
||||
const label nElem
|
||||
const label len
|
||||
)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
if (nElem > capacity_)
|
||||
if (capacity_ < len)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
SizeMin,
|
||||
max
|
||||
(
|
||||
nElem,
|
||||
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
label(2 * capacity_)
|
||||
)
|
||||
);
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
|
||||
|
||||
// Adjust allocated size, leave addressed size untouched
|
||||
const label nextFree = List<T>::size();
|
||||
List<T>::setSize(capacity_);
|
||||
List<T>::size(nextFree);
|
||||
const label currLen = List<T>::size();
|
||||
List<T>::resize(capacity_);
|
||||
List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::setSize
|
||||
inline void Foam::DynamicList<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem
|
||||
const label newLen
|
||||
)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
if (nElem > capacity_)
|
||||
if (capacity_ < newLen)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
SizeMin,
|
||||
max
|
||||
(
|
||||
nElem,
|
||||
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
label(2 * capacity_)
|
||||
)
|
||||
);
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
|
||||
|
||||
List<T>::setSize(capacity_);
|
||||
List<T>::resize(capacity_);
|
||||
}
|
||||
|
||||
// Adjust addressed size
|
||||
List<T>::size(nElem);
|
||||
List<T>::setAddressableSize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::setSize
|
||||
inline void Foam::DynamicList<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const label newLen,
|
||||
const T& val
|
||||
)
|
||||
{
|
||||
label nextFree = List<T>::size();
|
||||
setSize(nElem);
|
||||
label currLen = List<T>::size();
|
||||
resize(newLen);
|
||||
|
||||
// Set new elements to constant value
|
||||
while (nextFree < nElem)
|
||||
// Fill newly exposed with constant value
|
||||
while (currLen < newLen)
|
||||
{
|
||||
this->operator[](nextFree++) = val;
|
||||
this->operator[](currLen++) = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem
|
||||
)
|
||||
inline void Foam::DynamicList<T, SizeMin>::clear() noexcept
|
||||
{
|
||||
this->setSize(nElem);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const T& val
|
||||
)
|
||||
{
|
||||
this->setSize(nElem, val);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::clear()
|
||||
{
|
||||
List<T>::size(0);
|
||||
List<T>::setAddressableSize(0);
|
||||
}
|
||||
|
||||
|
||||
@ -360,14 +329,14 @@ inline void Foam::DynamicList<T, SizeMin>::clearStorage()
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage()
|
||||
inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage() noexcept
|
||||
{
|
||||
const label nextFree = List<T>::size();
|
||||
const label currLen = List<T>::size();
|
||||
|
||||
// Allow addressing into the entire list
|
||||
List<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
return nextFree;
|
||||
return currLen;
|
||||
}
|
||||
|
||||
|
||||
@ -375,16 +344,16 @@ template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>&
|
||||
Foam::DynamicList<T, SizeMin>::shrink()
|
||||
{
|
||||
const label nextFree = List<T>::size();
|
||||
if (capacity_ > nextFree)
|
||||
const label currLen = List<T>::size();
|
||||
if (currLen < capacity_)
|
||||
{
|
||||
// Use the full list when resizing
|
||||
List<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
// The new size
|
||||
capacity_ = nextFree;
|
||||
List<T>::setSize(capacity_);
|
||||
List<T>::size(nextFree);
|
||||
// Capacity and size are identical
|
||||
capacity_ = currLen;
|
||||
List<T>::resize(currLen);
|
||||
// Redundant: List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -394,41 +363,30 @@ template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline void Foam::DynamicList<T, SizeMin>::swap
|
||||
(
|
||||
DynamicList<T, AnySizeMin>& lst
|
||||
DynamicList<T, AnySizeMin>& other
|
||||
)
|
||||
{
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == lst.cdata())
|
||||
if (this->cdata() == other.cdata())
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
DynamicList<T, SizeMin>& cur = *this;
|
||||
// Swap storage and addressable size
|
||||
UList<T>::swap(other);
|
||||
|
||||
// Make addressable size identical to the allocated capacity
|
||||
const label oldSize1 = cur.expandStorage();
|
||||
const label oldSize2 = lst.expandStorage();
|
||||
|
||||
// Swap storage
|
||||
UList<T>::swap(lst);
|
||||
|
||||
// Match capacity to the underlying allocated list size
|
||||
cur.setCapacity(cur.size());
|
||||
lst.setCapacity(lst.size());
|
||||
|
||||
// Set addressable size
|
||||
cur.setSize(oldSize2);
|
||||
lst.setSize(oldSize1);
|
||||
// Swap capacity
|
||||
std::swap(this->capacity_, other.capacity_);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void
|
||||
Foam::DynamicList<T, SizeMin>::transfer(List<T>& lst)
|
||||
Foam::DynamicList<T, SizeMin>::transfer(List<T>& list)
|
||||
{
|
||||
// Take over storage, clear addressing for lst.
|
||||
capacity_ = lst.size();
|
||||
List<T>::transfer(lst);
|
||||
// Take over storage, clear addressing for list
|
||||
capacity_ = list.size();
|
||||
List<T>::transfer(list);
|
||||
}
|
||||
|
||||
|
||||
@ -437,21 +395,21 @@ template<int AnySizeMin>
|
||||
inline void
|
||||
Foam::DynamicList<T, SizeMin>::transfer
|
||||
(
|
||||
DynamicList<T, AnySizeMin>& lst
|
||||
DynamicList<T, AnySizeMin>& list
|
||||
)
|
||||
{
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == lst.cdata())
|
||||
if (this->cdata() == list.cdata())
|
||||
{
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
// Take over storage as-is (without shrink, without using SizeMin)
|
||||
// clear addressing and storage for old lst.
|
||||
capacity_ = lst.capacity();
|
||||
capacity_ = list.capacity();
|
||||
|
||||
List<T>::transfer(static_cast<List<T>&>(lst));
|
||||
lst.clearStorage(); // Ensure capacity=0
|
||||
List<T>::transfer(static_cast<List<T>&>(list));
|
||||
list.clearStorage(); // Ensure capacity=0
|
||||
}
|
||||
|
||||
|
||||
@ -459,12 +417,12 @@ template<class T, int SizeMin>
|
||||
inline void
|
||||
Foam::DynamicList<T, SizeMin>::transfer
|
||||
(
|
||||
SortableList<T>& lst
|
||||
SortableList<T>& list
|
||||
)
|
||||
{
|
||||
lst.shrink(); // Shrink away sort indices
|
||||
capacity_ = lst.size(); // Capacity after transfer == list size
|
||||
List<T>::transfer(lst);
|
||||
list.shrink(); // Shrink away sort indices
|
||||
capacity_ = list.size(); // Capacity after transfer == list size
|
||||
List<T>::transfer(list);
|
||||
}
|
||||
|
||||
|
||||
@ -476,7 +434,7 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
const label idx = List<T>::size();
|
||||
setSize(idx + 1);
|
||||
resize(idx + 1);
|
||||
|
||||
this->operator[](idx) = val; // copy element
|
||||
return *this;
|
||||
@ -491,7 +449,7 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
const label idx = List<T>::size();
|
||||
setSize(idx + 1);
|
||||
resize(idx + 1);
|
||||
|
||||
this->operator[](idx) = std::move(val); // move assign element
|
||||
return *this;
|
||||
@ -508,12 +466,12 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
if (this == &lst)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self" << abort(FatalError);
|
||||
<< "Attempted appending to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
label idx = List<T>::size();
|
||||
|
||||
setSize(idx + lst.size());
|
||||
resize(idx + lst.size());
|
||||
|
||||
for (const T& val : lst)
|
||||
{
|
||||
@ -532,7 +490,7 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
label idx = List<T>::size();
|
||||
setSize(idx + lst.size());
|
||||
resize(idx + lst.size());
|
||||
|
||||
for (const T& val : lst)
|
||||
{
|
||||
@ -550,8 +508,7 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
label idx = List<T>::size();
|
||||
|
||||
setSize(idx + lst.size());
|
||||
resize(idx + lst.size());
|
||||
|
||||
for (const T& val : lst)
|
||||
{
|
||||
@ -572,7 +529,7 @@ Foam::DynamicList<T, SizeMin>::append
|
||||
label idx = List<T>::size();
|
||||
const label n = lst.size();
|
||||
|
||||
setSize(idx + n);
|
||||
resize(idx + n);
|
||||
|
||||
for (label i=0; i<n; ++i)
|
||||
{
|
||||
@ -586,25 +543,25 @@ template<class T, int SizeMin>
|
||||
inline Foam::DynamicList<T, SizeMin>&
|
||||
Foam::DynamicList<T, SizeMin>::append
|
||||
(
|
||||
List<T>&& lst
|
||||
List<T>&& list
|
||||
)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self" << abort(FatalError);
|
||||
<< "Attempted appending to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
label idx = List<T>::size();
|
||||
resize(idx + list.size());
|
||||
|
||||
setSize(idx + lst.size());
|
||||
|
||||
for (T& val : lst)
|
||||
for (T& val : list)
|
||||
{
|
||||
Foam::Swap(this->operator[](idx++), val); // moved content
|
||||
}
|
||||
|
||||
lst.clear();
|
||||
list.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -663,7 +620,7 @@ inline T Foam::DynamicList<T, SizeMin>::remove()
|
||||
|
||||
const T& val = List<T>::operator[](idx);
|
||||
|
||||
List<T>::size(idx);
|
||||
List<T>::setAddressableSize(idx);
|
||||
|
||||
return val;
|
||||
}
|
||||
@ -742,7 +699,7 @@ inline T& Foam::DynamicList<T, SizeMin>::operator()
|
||||
{
|
||||
if (i >= List<T>::size())
|
||||
{
|
||||
setSize(i + 1);
|
||||
resize(i + 1);
|
||||
}
|
||||
|
||||
return this->operator[](i);
|
||||
@ -788,7 +745,7 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||
{
|
||||
const label n = lst.size();
|
||||
|
||||
setSize(n);
|
||||
resize(n);
|
||||
|
||||
for (label i=0; i<n; ++i)
|
||||
{
|
||||
@ -906,16 +863,34 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin1, int SizeMin2>
|
||||
inline void Foam::Swap
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Istream& Foam::operator>>
|
||||
(
|
||||
DynamicList<T, SizeMin1>& a,
|
||||
DynamicList<T, SizeMin2>& b
|
||||
Istream& is,
|
||||
DynamicList<T, SizeMin>& rhs
|
||||
)
|
||||
{
|
||||
a.swap(b);
|
||||
// Use entire storage - ie, resize(capacity())
|
||||
(void) rhs.expandStorage();
|
||||
|
||||
is >> static_cast<List<T>&>(rhs);
|
||||
rhs.capacity_ = rhs.List<T>::size();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicList<T, SizeMin>& rhs
|
||||
)
|
||||
{
|
||||
os << static_cast<const List<T>&>(rhs);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,20 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
std::streamsize Foam::FixedList<T, N>::byteSize() const
|
||||
{
|
||||
if (!is_contiguous<T>::value)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Invalid for non-contiguous data types"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return N*sizeof(T);
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
Foam::label Foam::FixedList<T, N>::find(const T& val, label pos) const
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -216,6 +216,8 @@ public:
|
||||
//- The last element of the list, position [N-1]
|
||||
inline const T& last() const noexcept;
|
||||
|
||||
//- The number of bytes stored by the list data for contiguous types
|
||||
std::streamsize byteSize() const;
|
||||
|
||||
//- Return the forward circular index, i.e. next index
|
||||
//- which returns to the first at the end of the list
|
||||
@ -279,7 +281,7 @@ public:
|
||||
inline void resize(const label n);
|
||||
|
||||
//- Dummy function, to make FixedList consistent with List
|
||||
inline void setSize(const label n);
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Assign all entries to the given value
|
||||
inline void fill(const T& val);
|
||||
@ -340,25 +342,25 @@ public:
|
||||
// Random access iterator (non-const)
|
||||
|
||||
//- Return an iterator to begin traversing the FixedList
|
||||
inline iterator begin();
|
||||
inline iterator begin() noexcept;
|
||||
|
||||
//- Return an iterator to end traversing the FixedList
|
||||
inline iterator end();
|
||||
inline iterator end() noexcept;
|
||||
|
||||
|
||||
// Random access iterator (const)
|
||||
|
||||
//- Return const_iterator to begin traversing the constant FixedList
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing the constant FixedList
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- Return const_iterator to begin traversing the constant FixedList
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing the constant FixedList
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// Reverse iterator (non-const)
|
||||
@ -397,7 +399,7 @@ public:
|
||||
static constexpr unsigned max_size() noexcept { return N; }
|
||||
|
||||
//- Swap lists by swapping the content of the individual list elements
|
||||
inline void swap(FixedList<T, N>& list);
|
||||
inline void swap(FixedList<T, N>& other);
|
||||
|
||||
|
||||
// STL Member Operators
|
||||
@ -489,9 +491,12 @@ struct is_contiguous_scalar<FixedList<T, N>> : is_contiguous_scalar<T> {};
|
||||
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
|
||||
|
||||
//- Swap FixedList contents - see FixedList::swap().
|
||||
// Internally this actually swaps the individual list elements
|
||||
// Internally actually swaps the individual list elements
|
||||
template<class T, unsigned N>
|
||||
inline void Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs);
|
||||
inline void Swap(FixedList<T, N>& a, FixedList<T, N>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
//- Hashing for FixedList data, which uses Hasher for contiguous data and
|
||||
|
||||
@ -327,15 +327,6 @@ inline void Foam::FixedList<T, N>::resize(const label n)
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline void Foam::FixedList<T, N>::setSize(const label n)
|
||||
{
|
||||
#ifdef FULLDEBUG
|
||||
checkSize(n);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline void Foam::FixedList<T, N>::fill(const T& val)
|
||||
{
|
||||
@ -357,16 +348,16 @@ inline void Foam::FixedList<T, N>::fill(const Foam::zero)
|
||||
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline void Foam::FixedList<T, N>::swap(FixedList<T, N>& list)
|
||||
inline void Foam::FixedList<T, N>::swap(FixedList<T, N>& other)
|
||||
{
|
||||
if (this == &list)
|
||||
if (this == &other)
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
Foam::Swap(v_[i], list.v_[i]);
|
||||
Foam::Swap(v_[i], other.v_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -490,8 +481,6 @@ inline void Foam::FixedList<T, N>::operator=(FixedList<T, N>&& list)
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
// No significant speedup observed for copy assignment on simple types,
|
||||
// use move assignment for generality with more complex types
|
||||
for (unsigned i=0; i<N; ++i)
|
||||
{
|
||||
v_[i] = std::move(list.v_[i]);
|
||||
@ -503,7 +492,7 @@ inline void Foam::FixedList<T, N>::operator=(FixedList<T, N>&& list)
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::iterator
|
||||
Foam::FixedList<T, N>::begin()
|
||||
Foam::FixedList<T, N>::begin() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -511,7 +500,7 @@ Foam::FixedList<T, N>::begin()
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::const_iterator
|
||||
Foam::FixedList<T, N>::begin() const
|
||||
Foam::FixedList<T, N>::begin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -519,7 +508,7 @@ Foam::FixedList<T, N>::begin() const
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::const_iterator
|
||||
Foam::FixedList<T, N>::cbegin() const
|
||||
Foam::FixedList<T, N>::cbegin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -527,7 +516,7 @@ Foam::FixedList<T, N>::cbegin() const
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::iterator
|
||||
Foam::FixedList<T, N>::end()
|
||||
Foam::FixedList<T, N>::end() noexcept
|
||||
{
|
||||
return (v_ + N);
|
||||
}
|
||||
@ -535,7 +524,7 @@ Foam::FixedList<T, N>::end()
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::const_iterator
|
||||
Foam::FixedList<T, N>::end() const
|
||||
Foam::FixedList<T, N>::end() const noexcept
|
||||
{
|
||||
return (v_ + N);
|
||||
}
|
||||
@ -543,7 +532,7 @@ Foam::FixedList<T, N>::end() const
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline typename Foam::FixedList<T, N>::const_iterator
|
||||
Foam::FixedList<T, N>::cend() const
|
||||
Foam::FixedList<T, N>::cend() const noexcept
|
||||
{
|
||||
return (v_ + N);
|
||||
}
|
||||
@ -597,13 +586,4 @@ Foam::FixedList<T, N>::crend() const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, unsigned N>
|
||||
inline void Foam::Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -50,7 +50,6 @@ void Foam::List<T>::doResize(const label newSize)
|
||||
{
|
||||
if (newSize > 0)
|
||||
{
|
||||
// With sign-check to avoid spurious -Walloc-size-larger-than
|
||||
T* nv = new T[newSize];
|
||||
|
||||
const label overlap = min(this->size_, newSize);
|
||||
|
||||
@ -93,7 +93,7 @@ class List
|
||||
template<class List2>
|
||||
inline void copyList(const List2& list);
|
||||
|
||||
//- Change allocation size of List. Backend for resize/setSize.
|
||||
//- Change allocation size - backend for resize.
|
||||
void doResize(const label newSize);
|
||||
|
||||
//- Construct given begin/end iterators and number of elements
|
||||
@ -123,7 +123,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor
|
||||
//- Default construct
|
||||
inline constexpr List() noexcept;
|
||||
|
||||
//- Construct with given size
|
||||
@ -208,24 +208,27 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Sizing
|
||||
|
||||
//- Clear the list, i.e. set size to zero
|
||||
inline void clear();
|
||||
|
||||
//- Adjust allocated size of list.
|
||||
// The boolList version fills new memory with false.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Adjust allocated size of list and set val for new elements
|
||||
void resize(const label newLen, const T& val);
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label n, const T& val) { this->resize(n, val); }
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Adjust allocated size of list.
|
||||
// The boolList version fills new memory with false.
|
||||
inline void resize(const label newSize);
|
||||
|
||||
//- Adjust allocated size of list and set val for new elements
|
||||
void resize(const label newSize, const T& val);
|
||||
|
||||
//- Alias for resize(const label)
|
||||
inline void setSize(const label newSize);
|
||||
|
||||
//- Alias for resize(const label, const T&)
|
||||
inline void setSize(const label newSize, const T& val);
|
||||
|
||||
//- Clear the list, i.e. set size to zero
|
||||
inline void clear();
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline void append(const T& val);
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,9 +31,8 @@ License
|
||||
template<class T>
|
||||
inline void Foam::List<T>::doAlloc()
|
||||
{
|
||||
if (this->size_ > 0)
|
||||
if (this->size_)
|
||||
{
|
||||
// With sign-check to avoid spurious -Walloc-size-larger-than
|
||||
this->v_ = new T[this->size_];
|
||||
}
|
||||
}
|
||||
@ -129,31 +128,17 @@ namespace Foam
|
||||
{
|
||||
// Template specialization for bool. Fills with false
|
||||
template<>
|
||||
inline void List<bool>::resize(const label newSize)
|
||||
inline void List<bool>::resize(const label newLen)
|
||||
{
|
||||
this->resize(newSize, false);
|
||||
this->resize(newLen, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::resize(const label len)
|
||||
inline void Foam::List<T>::resize(const label newLen)
|
||||
{
|
||||
this->doResize(len);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::setSize(const label len)
|
||||
{
|
||||
this->resize(len);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::List<T>::setSize(const label len, const T& val)
|
||||
{
|
||||
this->resize(len, val);
|
||||
this->doResize(newLen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -213,8 +213,8 @@ Foam::PackedList<Width> Foam::reorder
|
||||
}
|
||||
|
||||
// Verify addresses (for movable refs)
|
||||
// Info<< "reordered in " << name(input.storage().cdata()) << nl
|
||||
// << "reordered out " << name(output.storage().cdata()) << nl;
|
||||
// Info<< "reordered in " << name(input.cdata()) << nl
|
||||
// << "reordered out " << name(output.cdata()) << nl;
|
||||
|
||||
return output;
|
||||
}
|
||||
@ -231,7 +231,7 @@ void Foam::inplaceReorder
|
||||
input = reorder(oldToNew, input, prune);
|
||||
|
||||
// Verify address (for movable refs)
|
||||
// Info<< "now have " << name(input.storage().cdata()) << nl;
|
||||
// Info<< "now have " << name(input.cdata()) << nl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -195,15 +195,15 @@ void Foam::SortableList<T>::partialReverseSort(label n, label start)
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::SortableList<T>::swap(SortableList<T>& lst)
|
||||
void Foam::SortableList<T>::swap(SortableList<T>& other)
|
||||
{
|
||||
if (this == &lst)
|
||||
if (this == &other)
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
List<T>::swap(lst);
|
||||
indices_.swap(lst.indices_);
|
||||
List<T>::swap(other);
|
||||
indices_.swap(other.indices_);
|
||||
}
|
||||
|
||||
|
||||
@ -267,13 +267,4 @@ inline void Foam::SortableList<T>::operator=(std::initializer_list<T> lst)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::Swap(SortableList<T>& a, SortableList<T>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,7 +72,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor, sort later (eg, after assignment or transfer)
|
||||
//- Default construct
|
||||
inline constexpr SortableList() noexcept;
|
||||
|
||||
//- Construct given size, sort later.
|
||||
@ -143,7 +143,7 @@ public:
|
||||
void partialReverseSort(label n, label start=0);
|
||||
|
||||
//- Swap content with another SortableList in constant time
|
||||
inline void swap(SortableList<T>& lst);
|
||||
inline void swap(SortableList<T>& other);
|
||||
|
||||
|
||||
// Member Operators
|
||||
@ -160,20 +160,22 @@ public:
|
||||
//- Move assignment, removing indices. Takes linear time
|
||||
inline void operator=(List<T>&& lst);
|
||||
|
||||
//- Move operator. Takes linear time
|
||||
//- Move operator (constant time)
|
||||
inline void operator=(SortableList<T>&& lst);
|
||||
|
||||
//- Assignment to an initializer list
|
||||
void operator=(std::initializer_list<T> lst);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Global Functions
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Exchange contents of lists - see SortableList::swap().
|
||||
template<class T>
|
||||
inline void Swap(SortableList<T>& a, SortableList<T>& b);
|
||||
inline void Swap(SortableList<T>& a, SortableList<T>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -193,7 +193,7 @@ std::streamsize Foam::UList<T>::byteSize() const
|
||||
if (!is_contiguous<T>::value)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot return binary size of a list with non-primitive elements"
|
||||
<< "Invalid for non-contiguous data types"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -101,9 +101,13 @@ protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Override size to be inconsistent with allocated storage.
|
||||
//- Set addressed size to be inconsistent with allocated storage.
|
||||
// Use with care
|
||||
inline void size(const label n) noexcept;
|
||||
inline void setAddressableSize(const label n) noexcept;
|
||||
|
||||
//- Older name for setAddressableSize
|
||||
FOAM_DEPRECATED_FOR(2021-01, "setAddressableSize(label) method")
|
||||
void size(const label n) { this->setAddressableSize(n); }
|
||||
|
||||
//- Write the UList with its compound type
|
||||
void writeEntry(Ostream& os) const;
|
||||
@ -248,22 +252,15 @@ public:
|
||||
//- Return reverse circular value (ie, previous value in the list)
|
||||
inline T& rcValue(const label i);
|
||||
|
||||
//- Return the binary size in number of characters of the UList
|
||||
//- if the element is a primitive type
|
||||
// i.e. is_contiguous<T>::value == true.
|
||||
// Note that is of type streamsize since used in stream ops
|
||||
std::streamsize byteSize() const;
|
||||
|
||||
|
||||
//- Return a const pointer to the first data element.
|
||||
// Similar to the STL front() method and the string::data() method
|
||||
// This can be used (with caution) when interfacing with C code
|
||||
inline const T* cdata() const;
|
||||
inline const T* cdata() const noexcept;
|
||||
|
||||
//- Return a pointer to the first data element.
|
||||
// Similar to the STL front() method and the string::data() method
|
||||
// This can be used (with caution) when interfacing with C code
|
||||
inline T* data();
|
||||
inline T* data() noexcept;
|
||||
|
||||
//- Return the first element of the list
|
||||
inline T& first();
|
||||
@ -277,6 +274,10 @@ public:
|
||||
//- Return the last element of the list
|
||||
inline const T& last() const;
|
||||
|
||||
//- The number of bytes stored by the list data for contiguous types
|
||||
// \note is a std::streamsize since it is used in stream ops
|
||||
std::streamsize byteSize() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
@ -371,25 +372,25 @@ public:
|
||||
// Random access iterator (non-const)
|
||||
|
||||
//- Return an iterator to begin traversing the UList
|
||||
inline iterator begin();
|
||||
inline iterator begin() noexcept;
|
||||
|
||||
//- Return an iterator to end traversing the UList
|
||||
inline iterator end();
|
||||
inline iterator end() noexcept;
|
||||
|
||||
|
||||
// Random access iterator (const)
|
||||
|
||||
//- Return const_iterator to begin traversing the constant UList
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing the constant UList
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- Return const_iterator to begin traversing the constant UList
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing the constant UList
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// Reverse iterators (non-const)
|
||||
@ -582,9 +583,12 @@ inline void reverse(UList<T>& list, const label n);
|
||||
template<class T>
|
||||
inline void reverse(UList<T>& list);
|
||||
|
||||
// Exchange contents of lists - see UList::swap().
|
||||
//- Exchange contents of lists - see UList::swap().
|
||||
template<class T>
|
||||
inline void Swap(UList<T>& a, UList<T>& b);
|
||||
inline void Swap(UList<T>& a, UList<T>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
//- Hashing for UList data, which uses Hasher for contiguous data and
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,7 +28,6 @@ License
|
||||
|
||||
#include "error.H"
|
||||
#include "pTraits.H"
|
||||
#include "Swap.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -195,14 +194,14 @@ inline const T& Foam::UList<T>::last() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T* Foam::UList<T>::cdata() const
|
||||
inline const T* Foam::UList<T>::cdata() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T* Foam::UList<T>::data()
|
||||
inline T* Foam::UList<T>::data() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -273,42 +272,42 @@ inline Foam::UList<T>::operator const Foam::List<T>&() const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::iterator
|
||||
Foam::UList<T>::begin()
|
||||
Foam::UList<T>::begin() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::begin() const
|
||||
Foam::UList<T>::begin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::cbegin() const
|
||||
Foam::UList<T>::cbegin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::iterator
|
||||
Foam::UList<T>::end()
|
||||
Foam::UList<T>::end() noexcept
|
||||
{
|
||||
return (v_ + size_);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::end() const
|
||||
Foam::UList<T>::end() const noexcept
|
||||
{
|
||||
return (v_ + size_);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UList<T>::const_iterator
|
||||
Foam::UList<T>::cend() const
|
||||
Foam::UList<T>::cend() const noexcept
|
||||
{
|
||||
return (v_ + size_);
|
||||
}
|
||||
@ -357,7 +356,7 @@ Foam::UList<T>::crend() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UList<T>::size(const label n) noexcept
|
||||
inline void Foam::UList<T>::setAddressableSize(const label n) noexcept
|
||||
{
|
||||
size_ = n;
|
||||
}
|
||||
@ -385,8 +384,8 @@ inline void Foam::UList<T>::swap(UList<T>& list)
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
Foam::Swap(size_, list.size_);
|
||||
Foam::Swap(v_, list.v_);
|
||||
std::swap(size_, list.size_);
|
||||
std::swap(v_, list.v_);
|
||||
}
|
||||
|
||||
|
||||
@ -409,11 +408,4 @@ inline void Foam::reverse(UList<T>& list)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::Swap(UList<T>& a, UList<T>& b)
|
||||
{
|
||||
a.swap(b);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -71,17 +71,11 @@ class PtrDynList
|
||||
label capacity_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Adjust addressable size
|
||||
void setAddressableSize(const label len);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Default construct
|
||||
inline constexpr PtrDynList() noexcept;
|
||||
|
||||
//- Construct with given capacity.
|
||||
@ -118,23 +112,20 @@ public:
|
||||
const T* set(const label i) const { return this->get(i); }
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Delete the allocated entries, but retain the list size.
|
||||
using PtrList<T>::free;
|
||||
// Sizing
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
inline void setCapacity(const label nElem);
|
||||
inline void setCapacity(const label newCapacity);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label len);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Same as resize()
|
||||
inline void setSize(const label newLen);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label nElem);
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Clear the addressed list, i.e. set the size to zero.
|
||||
// Allocated size does not change
|
||||
@ -145,16 +136,26 @@ public:
|
||||
|
||||
//- Expand the addressable size to fit the allocated capacity.
|
||||
// Returns the previous addressable size.
|
||||
inline label expandStorage();
|
||||
inline label expandStorage() noexcept;
|
||||
|
||||
//- Shrink the allocated space to the number of elements used.
|
||||
inline void shrink();
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Delete the allocated entries, but retain the list size.
|
||||
using PtrList<T>::free;
|
||||
|
||||
//- Squeeze out intermediate nullptr entries in the list of pointers
|
||||
//- and adjust the addressable size accordingly.
|
||||
// \return the number of non-null entries
|
||||
inline label squeezeNull();
|
||||
|
||||
//- Swap content, independent of sizing parameter
|
||||
template<int AnySizeMin>
|
||||
inline void swap(PtrDynList<T, AnySizeMin>& other);
|
||||
|
||||
//- Construct and append an element to the end of the list
|
||||
template<class... Args>
|
||||
inline void emplace_append(Args&&... args);
|
||||
@ -234,7 +235,6 @@ public:
|
||||
//- Move assignment with different sizing parameters
|
||||
template<int AnySizeMin>
|
||||
inline void operator=(PtrDynList<T, AnySizeMin>&& list);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,15 +29,6 @@ License
|
||||
#include "refPtr.H"
|
||||
#include "tmp.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::setAddressableSize(const label len)
|
||||
{
|
||||
(this->ptrs_).setAddressableSize(len);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
@ -54,7 +45,7 @@ inline Foam::PtrDynList<T, SizeMin>::PtrDynList(const label len)
|
||||
PtrList<T>(len),
|
||||
capacity_(len)
|
||||
{
|
||||
setAddressableSize(0);
|
||||
PtrList<T>::setAddressableSize(0);
|
||||
}
|
||||
|
||||
|
||||
@ -107,35 +98,34 @@ inline const T* Foam::PtrDynList<T, SizeMin>::get(const label i) const
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::setCapacity(const label nElem)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::setCapacity(const label newCapacity)
|
||||
{
|
||||
label nextFree = PtrList<T>::size();
|
||||
capacity_ = nElem;
|
||||
label currLen = PtrList<T>::size();
|
||||
capacity_ = newCapacity;
|
||||
|
||||
if (nextFree > capacity_)
|
||||
if (currLen > capacity_)
|
||||
{
|
||||
// Truncate addressed sizes too
|
||||
nextFree = capacity_;
|
||||
currLen = capacity_;
|
||||
}
|
||||
|
||||
PtrList<T>::resize(capacity_);
|
||||
setAddressableSize(nextFree);
|
||||
PtrList<T>::setAddressableSize(currLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::reserve(const label nElem)
|
||||
inline void Foam::PtrDynList<T, SizeMin>::reserve(const label len)
|
||||
{
|
||||
if (nElem > capacity_)
|
||||
if (capacity_ < len)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
|
||||
capacity_ = max(SizeMin, max(nElem, label(2*capacity_)));
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
|
||||
|
||||
// Adjust allocated size, leave addressed size untouched
|
||||
const label nextFree = PtrList<T>::size();
|
||||
const label currLen = PtrList<T>::size();
|
||||
PtrList<T>::resize(capacity_);
|
||||
setAddressableSize(nextFree);
|
||||
PtrList<T>::setAddressableSize(currLen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,31 +137,25 @@ inline void Foam::PtrDynList<T, SizeMin>::resize(const label newLen)
|
||||
|
||||
const label oldLen = ptrs.size();
|
||||
|
||||
if (newLen > capacity_)
|
||||
if (capacity_ < newLen)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
capacity_ = max(SizeMin, max(newLen, label(2*capacity_)));
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
|
||||
|
||||
PtrList<T>::resize(capacity_);
|
||||
}
|
||||
else if (newLen != oldLen)
|
||||
{
|
||||
// Truncation frees old pointers
|
||||
for (label i=newLen; i<oldLen; ++i)
|
||||
for (label i = newLen; i < oldLen; ++i)
|
||||
{
|
||||
delete ptrs[i];
|
||||
ptrs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
setAddressableSize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::setSize(const label newLen)
|
||||
{
|
||||
this->resize(newLen);
|
||||
// Adjust addressed size
|
||||
PtrList<T>::setAddressableSize(newLen);
|
||||
}
|
||||
|
||||
|
||||
@ -179,7 +163,7 @@ template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::clear()
|
||||
{
|
||||
(this->ptrs_).free(); // free old pointers
|
||||
setAddressableSize(0);
|
||||
PtrList<T>::setAddressableSize(0);
|
||||
}
|
||||
|
||||
|
||||
@ -192,30 +176,30 @@ inline void Foam::PtrDynList<T, SizeMin>::clearStorage()
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::label Foam::PtrDynList<T, SizeMin>::expandStorage()
|
||||
inline Foam::label Foam::PtrDynList<T, SizeMin>::expandStorage() noexcept
|
||||
{
|
||||
const label nextFree = PtrList<T>::size();
|
||||
const label currLen = PtrList<T>::size();
|
||||
|
||||
// Allow addressing into the entire list
|
||||
setAddressableSize(capacity_);
|
||||
PtrList<T>::setAddressableSize(capacity_);
|
||||
|
||||
return nextFree;
|
||||
return currLen;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::shrink()
|
||||
{
|
||||
label nextFree = PtrList<T>::size();
|
||||
if (capacity_ > nextFree)
|
||||
const label currLen = PtrList<T>::size();
|
||||
if (currLen < capacity_)
|
||||
{
|
||||
// Use the full list when resizing
|
||||
setAddressableSize(capacity_);
|
||||
PtrList<T>::setAddressableSize(capacity_);
|
||||
|
||||
// The new size
|
||||
capacity_ = nextFree;
|
||||
PtrList<T>::resize(capacity_);
|
||||
setAddressableSize(nextFree);
|
||||
// Capacity and size are identical
|
||||
capacity_ = currLen;
|
||||
PtrList<T>::resize(currLen);
|
||||
// Redundant: PtrList<T>::setAddressableSize(currLen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,6 +213,27 @@ inline Foam::label Foam::PtrDynList<T, SizeMin>::squeezeNull()
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::swap
|
||||
(
|
||||
PtrDynList<T, AnySizeMin>& other
|
||||
)
|
||||
{
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == other.cdata())
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
// Swap storage and addressable size
|
||||
UPtrList<T>::swap(other);
|
||||
|
||||
// Swap capacity
|
||||
std::swap(this->capacity_, other.capacity_);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<class... Args>
|
||||
inline void Foam::PtrDynList<T, SizeMin>::emplace_append(Args&&... args)
|
||||
@ -332,7 +337,7 @@ inline Foam::autoPtr<T> Foam::PtrDynList<T, SizeMin>::remove()
|
||||
|
||||
autoPtr<T> old(this->ptrs_[idx]);
|
||||
this->ptrs_[idx] = nullptr;
|
||||
setAddressableSize(idx);
|
||||
PtrList<T>::setAddressableSize(idx);
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ public:
|
||||
void resize(const label newLen);
|
||||
|
||||
//- Same as resize()
|
||||
inline void setSize(const label newLen);
|
||||
void setSize(const label newLen) { this->resize(newLen); }
|
||||
|
||||
//- Construct and append an element to the end of the list
|
||||
template<class... Args>
|
||||
|
||||
@ -101,13 +101,6 @@ inline void Foam::PtrList<T>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::PtrList<T>::setSize(const label newLen)
|
||||
{
|
||||
this->resize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
template<class... Args>
|
||||
inline void Foam::PtrList<T>::emplace_append(Args&&... args)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,9 +106,9 @@ public:
|
||||
// New entries are initialized to nullptr.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Override size to be inconsistent with allocated storage.
|
||||
//- Set addressed size to be inconsistent with allocated storage.
|
||||
// Use with care
|
||||
inline void setAddressableSize(const label n);
|
||||
inline void setAddressableSize(const label n) noexcept;
|
||||
|
||||
//- Write output, optionally silently trimming nullptrs
|
||||
Ostream& write(Ostream& os, const bool trimNull=false) const;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,9 +85,12 @@ inline Foam::Detail::PtrListDetail<T>::PtrListDetail
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::Detail::PtrListDetail<T>::setAddressableSize(const label n)
|
||||
inline void Foam::Detail::PtrListDetail<T>::setAddressableSize
|
||||
(
|
||||
const label n
|
||||
) noexcept
|
||||
{
|
||||
List<T*>::size(n);
|
||||
List<T*>::setAddressableSize(n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,10 +78,16 @@ protected:
|
||||
Detail::PtrListDetail<T> ptrs_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Adjust addressable size
|
||||
inline void setAddressableSize(const label n) noexcept;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Low-level move construct
|
||||
inline UPtrList(Detail::PtrListDetail<T>&& ptrs);
|
||||
inline explicit UPtrList(Detail::PtrListDetail<T>&& ptrs);
|
||||
|
||||
|
||||
public:
|
||||
@ -158,15 +164,15 @@ public:
|
||||
inline const T& last() const;
|
||||
|
||||
//- Return pointer to element (can be nullptr),
|
||||
// without bounds checking.
|
||||
//- without bounds checking.
|
||||
inline T* get(const label i);
|
||||
|
||||
//- Return const pointer to element (can be nullptr),
|
||||
// without bounds checking.
|
||||
//- without bounds checking.
|
||||
inline const T* get(const label i) const;
|
||||
|
||||
//- Return const pointer to element (can be nullptr),
|
||||
// without bounds checking - same as get().
|
||||
//- without bounds checking - same as get().
|
||||
// The return value can also be tested as a bool.
|
||||
const T* set(const label i) const { return this->get(i); }
|
||||
|
||||
@ -176,12 +182,12 @@ public:
|
||||
//- Set list size to zero.
|
||||
inline void clear();
|
||||
|
||||
//- Reset size of list.
|
||||
//- Change the size of the list.
|
||||
// New entries are initialized to nullptr.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Same as resize()
|
||||
inline void setSize(const label newLen);
|
||||
//- Alias for resize()
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Squeeze out intermediate nullptr entries in the list of pointers
|
||||
// \return the number of non-null entries
|
||||
@ -235,6 +241,7 @@ public:
|
||||
//- Random-access iterator with non-const access
|
||||
class iterator
|
||||
{
|
||||
// Pointer to parent
|
||||
T** ptr_;
|
||||
|
||||
public:
|
||||
@ -247,51 +254,52 @@ public:
|
||||
friend class const_iterator;
|
||||
|
||||
//- Construct for a given entry
|
||||
inline iterator(T** ptr);
|
||||
inline iterator(T** ptr) noexcept;
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Return pointer, can be nullptr.
|
||||
inline pointer get() const;
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const iterator& iter) const;
|
||||
inline bool operator!=(const iterator& iter) const;
|
||||
// Member Operators
|
||||
|
||||
inline pointer operator->() const;
|
||||
inline reference operator*() const;
|
||||
|
||||
inline reference operator()() const;
|
||||
|
||||
// Forward iteration
|
||||
inline iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
|
||||
inline iterator& operator--();
|
||||
inline iterator operator--(int);
|
||||
|
||||
// Random-access
|
||||
inline iterator& operator+=(difference_type n);
|
||||
inline iterator& operator-=(difference_type n);
|
||||
inline iterator operator+(difference_type n) const;
|
||||
inline iterator operator-(difference_type n) const;
|
||||
|
||||
inline difference_type operator-(const iterator& iter) const;
|
||||
|
||||
reference operator()() const { return this->operator*(); }
|
||||
inline reference operator[](difference_type n) const;
|
||||
|
||||
inline bool operator<(const iterator& iter) const;
|
||||
inline bool operator>(const iterator& iter) const;
|
||||
// Forward iteration
|
||||
inline iterator& operator++() noexcept;
|
||||
inline iterator operator++(int) noexcept;
|
||||
|
||||
inline bool operator<=(const iterator& iter) const;
|
||||
inline bool operator>=(const iterator& iter) const;
|
||||
inline iterator& operator--() noexcept;
|
||||
inline iterator operator--(int) noexcept;
|
||||
|
||||
// Random-access
|
||||
inline iterator& operator+=(difference_type n) noexcept;
|
||||
inline iterator& operator-=(difference_type n) noexcept;
|
||||
inline iterator operator+(difference_type n) const noexcept;
|
||||
inline iterator operator-(difference_type n) const noexcept;
|
||||
|
||||
inline difference_type operator-(const iterator& iter)
|
||||
const noexcept;
|
||||
|
||||
inline bool operator==(const iterator& iter) const noexcept;
|
||||
inline bool operator!=(const iterator& iter) const noexcept;
|
||||
|
||||
inline bool operator<(const iterator& iter) const noexcept;
|
||||
inline bool operator>(const iterator& iter) const noexcept;
|
||||
|
||||
inline bool operator<=(const iterator& iter) const noexcept;
|
||||
inline bool operator>=(const iterator& iter) const noexcept;
|
||||
};
|
||||
|
||||
|
||||
//- Random-access iterator with const access
|
||||
class const_iterator
|
||||
{
|
||||
// Pointer to parent
|
||||
const T* const* ptr_;
|
||||
|
||||
public:
|
||||
@ -303,68 +311,68 @@ public:
|
||||
using reference = const T&;
|
||||
|
||||
//- Construct for a given entry
|
||||
inline const_iterator(const T* const* ptr);
|
||||
inline const_iterator(const T* const* ptr) noexcept;
|
||||
|
||||
//- Copy construct from non-const iterator
|
||||
inline const_iterator(const iterator& iter);
|
||||
inline const_iterator(const iterator& iter) noexcept;
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Return pointer, can be nullptr.
|
||||
inline pointer get() const;
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
// Member Operators
|
||||
|
||||
inline pointer operator->() const;
|
||||
inline reference operator*() const;
|
||||
|
||||
inline reference operator()() const;
|
||||
|
||||
// Forward iteration
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
|
||||
inline const_iterator& operator--();
|
||||
inline const_iterator operator--(int);
|
||||
|
||||
// Random-access
|
||||
inline const_iterator& operator+=(difference_type n);
|
||||
inline const_iterator& operator-=(difference_type n);
|
||||
inline const_iterator operator+(difference_type n) const;
|
||||
inline const_iterator operator-(difference_type n) const;
|
||||
|
||||
inline difference_type operator-(const const_iterator& iter) const;
|
||||
|
||||
reference operator()() const { return this->operator*(); }
|
||||
inline reference operator[](difference_type n) const;
|
||||
|
||||
inline bool operator<(const const_iterator& iter) const;
|
||||
inline bool operator>(const const_iterator& iter) const;
|
||||
// Forward iteration
|
||||
inline const_iterator& operator++() noexcept;
|
||||
inline const_iterator operator++(int) noexcept;
|
||||
|
||||
inline bool operator<=(const const_iterator& iter) const;
|
||||
inline bool operator>=(const const_iterator& iter) const;
|
||||
inline const_iterator& operator--() noexcept;
|
||||
inline const_iterator operator--(int) noexcept;
|
||||
|
||||
// Random-access
|
||||
inline const_iterator& operator+=(difference_type n) noexcept;
|
||||
inline const_iterator& operator-=(difference_type n) noexcept;
|
||||
inline const_iterator operator+(difference_type n) const noexcept;
|
||||
inline const_iterator operator-(difference_type n) const noexcept;
|
||||
|
||||
inline difference_type operator-(const const_iterator& iter)
|
||||
const noexcept;
|
||||
|
||||
inline bool operator==(const const_iterator& iter) const noexcept;
|
||||
inline bool operator!=(const const_iterator& iter) const noexcept;
|
||||
|
||||
inline bool operator<(const const_iterator& iter) const noexcept;
|
||||
inline bool operator>(const const_iterator& iter) const noexcept;
|
||||
|
||||
inline bool operator<=(const const_iterator& iter) const noexcept;
|
||||
inline bool operator>=(const const_iterator& iter) const noexcept;
|
||||
};
|
||||
|
||||
|
||||
//- Return an iterator to begin traversing the UPtrList
|
||||
inline iterator begin();
|
||||
inline iterator begin() noexcept;
|
||||
|
||||
//- Return an iterator to end traversing the UPtrList
|
||||
inline iterator end();
|
||||
inline iterator end() noexcept;
|
||||
|
||||
//- Return an const_iterator to begin traversing the UPtrList
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- Return an const_iterator to end traversing the UPtrList
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- Return an const_iterator to begin traversing the UPtrList
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- Return an const_iterator to end traversing the UPtrList
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// IOstream operator
|
||||
@ -375,7 +383,6 @@ public:
|
||||
Ostream& os,
|
||||
const UPtrList<T>& list
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,6 +26,15 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::setAddressableSize(const label n) noexcept
|
||||
{
|
||||
ptrs_.setAddressableSize(n);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
@ -177,13 +186,6 @@ inline void Foam::UPtrList<T>::resize(const label newLen)
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::setSize(const label newLen)
|
||||
{
|
||||
ptrs_.resize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void Foam::UPtrList<T>::append(T* ptr)
|
||||
{
|
||||
@ -252,7 +254,8 @@ inline const T* Foam::UPtrList<T>::operator()(const label i) const
|
||||
// * * * * * * * * * * * * * * * * iterator * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
|
||||
inline Foam::UPtrList<T>::iterator::
|
||||
iterator(T** ptr) noexcept
|
||||
:
|
||||
ptr_(ptr)
|
||||
{}
|
||||
@ -265,20 +268,6 @@ inline T* Foam::UPtrList<T>::iterator::get() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator!=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T* Foam::UPtrList<T>::iterator::operator->() const
|
||||
{
|
||||
@ -294,15 +283,14 @@ inline T& Foam::UPtrList<T>::iterator::operator*() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator()() const
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](label n) const
|
||||
{
|
||||
return **ptr_;
|
||||
return **(ptr_ + n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator++()
|
||||
Foam::UPtrList<T>::iterator::operator++() noexcept
|
||||
{
|
||||
++ptr_;
|
||||
return *this;
|
||||
@ -311,7 +299,7 @@ Foam::UPtrList<T>::iterator::operator++()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator++(int)
|
||||
Foam::UPtrList<T>::iterator::operator++(int) noexcept
|
||||
{
|
||||
iterator iter(*this);
|
||||
++ptr_;
|
||||
@ -321,7 +309,7 @@ Foam::UPtrList<T>::iterator::operator++(int)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator--()
|
||||
Foam::UPtrList<T>::iterator::operator--() noexcept
|
||||
{
|
||||
--ptr_;
|
||||
return *this;
|
||||
@ -330,7 +318,7 @@ Foam::UPtrList<T>::iterator::operator--()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator--(int)
|
||||
Foam::UPtrList<T>::iterator::operator--(int) noexcept
|
||||
{
|
||||
iterator iter(*this);
|
||||
--ptr_;
|
||||
@ -340,7 +328,7 @@ Foam::UPtrList<T>::iterator::operator--(int)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator+=(label n)
|
||||
Foam::UPtrList<T>::iterator::operator+=(label n) noexcept
|
||||
{
|
||||
ptr_ += n;
|
||||
return *this;
|
||||
@ -349,7 +337,7 @@ Foam::UPtrList<T>::iterator::operator+=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator&
|
||||
Foam::UPtrList<T>::iterator::operator-=(label n)
|
||||
Foam::UPtrList<T>::iterator::operator-=(label n) noexcept
|
||||
{
|
||||
ptr_ -= n;
|
||||
return *this;
|
||||
@ -358,7 +346,7 @@ Foam::UPtrList<T>::iterator::operator-=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator+(label n) const
|
||||
Foam::UPtrList<T>::iterator::operator+(label n) const noexcept
|
||||
{
|
||||
return iterator(ptr_ + n);
|
||||
}
|
||||
@ -366,7 +354,7 @@ Foam::UPtrList<T>::iterator::operator+(label n) const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator-(label n) const
|
||||
Foam::UPtrList<T>::iterator::operator-(label n) const noexcept
|
||||
{
|
||||
return iterator(ptr_ - n);
|
||||
}
|
||||
@ -374,42 +362,56 @@ Foam::UPtrList<T>::iterator::operator-(label n) const
|
||||
|
||||
template<class T>
|
||||
inline Foam::label
|
||||
Foam::UPtrList<T>::iterator::operator-(const iterator& iter) const
|
||||
Foam::UPtrList<T>::iterator::
|
||||
operator-(const iterator& iter) const noexcept
|
||||
{
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](label n) const
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator==(const iterator& iter) const noexcept
|
||||
{
|
||||
return *(*this + n);
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<(const iterator& iter) const
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator!=(const iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator<(const iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ < iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>(const iterator& iter) const
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator>(const iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ > iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<=(const iterator& iter) const
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator<=(const iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ <= iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||
inline bool Foam::UPtrList<T>::iterator::
|
||||
operator>=(const iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ >= iter.ptr_;
|
||||
}
|
||||
@ -418,14 +420,16 @@ inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||
// * * * * * * * * * * * * * * * const_iterator * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::const_iterator::const_iterator(const T* const* ptr)
|
||||
inline Foam::UPtrList<T>::const_iterator::
|
||||
const_iterator(const T* const* ptr) noexcept
|
||||
:
|
||||
ptr_(ptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::UPtrList<T>::const_iterator::const_iterator(const iterator& iter)
|
||||
inline Foam::UPtrList<T>::const_iterator::
|
||||
const_iterator(const iterator& iter) noexcept
|
||||
:
|
||||
ptr_(iter.ptr_)
|
||||
{}
|
||||
@ -438,26 +442,6 @@ inline const T* Foam::UPtrList<T>::const_iterator::get() const
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator==
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator!=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T* Foam::UPtrList<T>::const_iterator::operator->() const
|
||||
{
|
||||
@ -473,15 +457,16 @@ inline const T& Foam::UPtrList<T>::const_iterator::operator*() const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator()() const
|
||||
inline const T&
|
||||
Foam::UPtrList<T>::const_iterator::operator[](label n) const
|
||||
{
|
||||
return **ptr_;
|
||||
return **(ptr_ + n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator++()
|
||||
Foam::UPtrList<T>::const_iterator::operator++() noexcept
|
||||
{
|
||||
++ptr_;
|
||||
return *this;
|
||||
@ -490,7 +475,7 @@ Foam::UPtrList<T>::const_iterator::operator++()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator++(int)
|
||||
Foam::UPtrList<T>::const_iterator::operator++(int) noexcept
|
||||
{
|
||||
const_iterator iter(*this);
|
||||
++ptr_;
|
||||
@ -500,7 +485,7 @@ Foam::UPtrList<T>::const_iterator::operator++(int)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator--()
|
||||
Foam::UPtrList<T>::const_iterator::operator--() noexcept
|
||||
{
|
||||
--ptr_;
|
||||
return *this;
|
||||
@ -509,7 +494,7 @@ Foam::UPtrList<T>::const_iterator::operator--()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator--(int)
|
||||
Foam::UPtrList<T>::const_iterator::operator--(int) noexcept
|
||||
{
|
||||
const_iterator iter(*this);
|
||||
--ptr_;
|
||||
@ -519,7 +504,7 @@ Foam::UPtrList<T>::const_iterator::operator--(int)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator+=(label n) noexcept
|
||||
{
|
||||
ptr_ += n;
|
||||
return *this;
|
||||
@ -528,7 +513,7 @@ Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator&
|
||||
Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator-=(label n) noexcept
|
||||
{
|
||||
ptr_ -= n;
|
||||
return *this;
|
||||
@ -537,7 +522,7 @@ Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator+(label n) const
|
||||
Foam::UPtrList<T>::const_iterator::operator+(label n) const noexcept
|
||||
{
|
||||
return const_iterator(ptr_ + n);
|
||||
}
|
||||
@ -545,7 +530,7 @@ Foam::UPtrList<T>::const_iterator::operator+(label n) const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator-(label n) const
|
||||
Foam::UPtrList<T>::const_iterator::operator-(label n) const noexcept
|
||||
{
|
||||
return const_iterator(ptr_ - n);
|
||||
}
|
||||
@ -553,55 +538,56 @@ Foam::UPtrList<T>::const_iterator::operator-(label n) const
|
||||
|
||||
template<class T>
|
||||
inline Foam::label
|
||||
Foam::UPtrList<T>::const_iterator::operator-(const const_iterator& iter) const
|
||||
Foam::UPtrList<T>::const_iterator::
|
||||
operator-(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T&
|
||||
Foam::UPtrList<T>::const_iterator::operator[](label n) const
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator==(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return *(*this + n);
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator<
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator!=(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator<(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ < iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator>
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator>(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ > iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator<=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator<=(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ <= iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::const_iterator::operator>=
|
||||
(
|
||||
const const_iterator& iter
|
||||
) const
|
||||
inline bool Foam::UPtrList<T>::const_iterator::
|
||||
operator>=(const const_iterator& iter) const noexcept
|
||||
{
|
||||
return ptr_ >= iter.ptr_;
|
||||
}
|
||||
@ -611,7 +597,7 @@ inline bool Foam::UPtrList<T>::const_iterator::operator>=
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::begin()
|
||||
Foam::UPtrList<T>::begin() noexcept
|
||||
{
|
||||
return ptrs_.begin();
|
||||
}
|
||||
@ -619,7 +605,7 @@ Foam::UPtrList<T>::begin()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::end()
|
||||
Foam::UPtrList<T>::end() noexcept
|
||||
{
|
||||
return ptrs_.end();
|
||||
}
|
||||
@ -627,7 +613,7 @@ Foam::UPtrList<T>::end()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cbegin() const
|
||||
Foam::UPtrList<T>::cbegin() const noexcept
|
||||
{
|
||||
return ptrs_.cbegin();
|
||||
}
|
||||
@ -635,7 +621,7 @@ Foam::UPtrList<T>::cbegin() const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::cend() const
|
||||
Foam::UPtrList<T>::cend() const noexcept
|
||||
{
|
||||
return ptrs_.cend();
|
||||
}
|
||||
@ -643,7 +629,7 @@ Foam::UPtrList<T>::cend() const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::begin() const
|
||||
Foam::UPtrList<T>::begin() const noexcept
|
||||
{
|
||||
return ptrs_.begin();
|
||||
}
|
||||
@ -651,7 +637,7 @@ Foam::UPtrList<T>::begin() const
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::end() const
|
||||
Foam::UPtrList<T>::end() const noexcept
|
||||
{
|
||||
return ptrs_.end();
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -511,8 +511,8 @@ public:
|
||||
// Writing
|
||||
|
||||
//- Write the standard OpenFOAM file/dictionary banner
|
||||
// Optionally without -*- C++ -*- editor hint (eg, for logs)
|
||||
static Ostream& writeBanner(Ostream& os, bool noHint=false);
|
||||
// Optionally without editor syntax hint (eg, for logs)
|
||||
static Ostream& writeBanner(Ostream& os, const bool noSyntaxHint=false);
|
||||
|
||||
//- Write the standard file section divider
|
||||
static Ostream& writeDivider(Ostream& os);
|
||||
@ -520,11 +520,17 @@ public:
|
||||
//- Write the standard end file divider
|
||||
static Ostream& writeEndDivider(Ostream& os);
|
||||
|
||||
//- Write header
|
||||
//- Write header with current type() and arch information
|
||||
bool writeHeader(Ostream& os) const;
|
||||
|
||||
//- Write header. Allow override of type
|
||||
bool writeHeader(Ostream& os, const word& objectType) const;
|
||||
//- Write header with override of type and optionally without
|
||||
//- arch information in ASCII
|
||||
bool writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const word& objectType,
|
||||
const bool noArchAscii = false
|
||||
) const;
|
||||
|
||||
|
||||
// Error Handling
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,7 +42,8 @@ License
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint)
|
||||
Foam::Ostream&
|
||||
Foam::IOobject::writeBanner(Ostream& os, const bool noSyntaxHint)
|
||||
{
|
||||
// The version padded with spaces to fit after "Version: "
|
||||
// - initialized with zero-length string to detect if it has been populated
|
||||
@ -66,7 +67,7 @@ Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint)
|
||||
os <<
|
||||
"/*--------------------------------";
|
||||
|
||||
if (noHint)
|
||||
if (noSyntaxHint)
|
||||
{
|
||||
// Without syntax hint
|
||||
os << "---------";
|
||||
@ -116,7 +117,12 @@ Foam::Ostream& Foam::IOobject::writeEndDivider(Ostream& os)
|
||||
}
|
||||
|
||||
|
||||
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
||||
bool Foam::IOobject::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const word& objectType,
|
||||
const bool noArchAscii
|
||||
) const
|
||||
{
|
||||
if (!os.good())
|
||||
{
|
||||
@ -127,25 +133,37 @@ bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
|
||||
return false;
|
||||
}
|
||||
|
||||
writeBanner(os)
|
||||
<< "FoamFile\n{\n"
|
||||
<< " version " << os.version() << ";\n"
|
||||
<< " format " << os.format() << ";\n"
|
||||
<< " class " << type << ";\n";
|
||||
IOobject::writeBanner(os)
|
||||
<< "FoamFile" << nl
|
||||
<< '{' << nl
|
||||
<< " version " << os.version() << ';' << nl
|
||||
<< " format " << os.format() << ';' << nl;
|
||||
|
||||
if (os.format() == IOstream::BINARY)
|
||||
if (os.format() == IOstream::BINARY || !noArchAscii)
|
||||
{
|
||||
os << " arch " << foamVersion::buildArch << ";\n";
|
||||
// Arch information (BINARY: always, ASCII: can disable)
|
||||
os << " arch " << foamVersion::buildArch << ';' << nl;
|
||||
}
|
||||
|
||||
if (!note().empty())
|
||||
{
|
||||
os << " note " << note() << ";\n";
|
||||
os << " note " << note() << ';' << nl;
|
||||
}
|
||||
|
||||
os << " location " << instance()/db().dbDir()/local() << ";\n"
|
||||
<< " object " << name() << ";\n"
|
||||
<< "}" << nl;
|
||||
os << " class ";
|
||||
if (objectType.empty())
|
||||
{
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
os << "dictionary";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << objectType;
|
||||
}
|
||||
os << ';' << nl;
|
||||
|
||||
os << " location " << instance()/db().dbDir()/local() << ';' << nl
|
||||
<< " object " << name() << ';' << nl
|
||||
<< '}' << nl;
|
||||
|
||||
writeDivider(os) << nl;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -188,41 +188,47 @@ void Foam::decomposedBlockData::writeHeader
|
||||
Ostream& os,
|
||||
const IOstream::versionNumber version,
|
||||
const IOstream::streamFormat format,
|
||||
const word& type,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& name
|
||||
const word& objectName
|
||||
)
|
||||
{
|
||||
IOobject::writeBanner(os)
|
||||
<< "FoamFile\n{\n"
|
||||
<< " version " << version << ";\n"
|
||||
<< " format " << format << ";\n"
|
||||
<< " class " << type << ";\n";
|
||||
|
||||
// This may be useful to have as well
|
||||
if (os.format() == IOstream::BINARY)
|
||||
{
|
||||
os << " arch " << foamVersion::buildArch << ";\n";
|
||||
}
|
||||
<< "FoamFile" << nl
|
||||
<< '{' << nl
|
||||
<< " version " << version << ';' << nl
|
||||
<< " format " << format << ';' << nl
|
||||
<< " arch " << foamVersion::buildArch << ';' << nl;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
os << " blocks " << Pstream::nProcs() << ";\n";
|
||||
os << " blocks " << Pstream::nProcs() << ';' << nl;
|
||||
}
|
||||
|
||||
if (note.size())
|
||||
if (!note.empty())
|
||||
{
|
||||
os << " note " << note << ";\n";
|
||||
os << " note " << note << ';' << nl;
|
||||
}
|
||||
|
||||
if (location.size())
|
||||
os << " class ";
|
||||
if (objectType.empty())
|
||||
{
|
||||
os << " location " << location << ";\n";
|
||||
// Empty type not allowed - use 'dictionary' fallback
|
||||
os << "dictionary";
|
||||
}
|
||||
else
|
||||
{
|
||||
os << objectType;
|
||||
}
|
||||
os << ';' << nl;
|
||||
|
||||
if (!location.empty())
|
||||
{
|
||||
os << " location " << location << ';' << nl;
|
||||
}
|
||||
|
||||
os << " object " << name << ";\n"
|
||||
<< "}" << nl;
|
||||
os << " object " << objectName << ';' << nl
|
||||
<< '}' << nl;
|
||||
|
||||
IOobject::writeDivider(os) << nl;
|
||||
}
|
||||
@ -976,9 +982,8 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
// Scatter header information
|
||||
|
||||
string versionString(os.version().str());
|
||||
Pstream::scatter(versionString, Pstream::msgType(), comm_);
|
||||
|
||||
label formatValue(os.format());
|
||||
Pstream::scatter(versionString, Pstream::msgType(), comm_);
|
||||
Pstream::scatter(formatValue, Pstream::msgType(), comm_);
|
||||
|
||||
//word masterName(name());
|
||||
@ -997,8 +1002,8 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
|
||||
writeHeader
|
||||
(
|
||||
os,
|
||||
IOstream::versionNumber(versionString),
|
||||
IOstream::streamFormat(formatValue),
|
||||
IOstreamOption::versionNumber(versionString),
|
||||
IOstreamOption::streamFormat(formatValue),
|
||||
io.headerClassName(),
|
||||
io.note(),
|
||||
masterLocation,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -156,10 +156,10 @@ public:
|
||||
Ostream& os,
|
||||
const IOstream::versionNumber version,
|
||||
const IOstream::streamFormat format,
|
||||
const word& type,
|
||||
const word& objectType,
|
||||
const string& note,
|
||||
const fileName& location,
|
||||
const word& name
|
||||
const word& objectName
|
||||
);
|
||||
|
||||
//- Read selected block (non-seeking) + header information
|
||||
|
||||
@ -32,8 +32,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_OSHA1stream_H
|
||||
#define Foam_OSHA1stream_H
|
||||
#ifndef OSHA1stream_H
|
||||
#define OSHA1stream_H
|
||||
|
||||
#include "OSstream.H"
|
||||
#include "SHA1.H"
|
||||
@ -63,17 +63,10 @@ class osha1stream
|
||||
|
||||
protected:
|
||||
|
||||
//- Handle overflow
|
||||
virtual int overflow(int c = EOF)
|
||||
{
|
||||
if (c != EOF) sha1_.append(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
//- Put sequence of characters
|
||||
virtual std::streamsize xsputn(const char* s, std::streamsize n)
|
||||
{
|
||||
if (n) sha1_.append(s, n);
|
||||
sha1_.append(s, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@ -54,8 +54,8 @@ template<class Container, class Delimiters> class OutputAdaptor;
|
||||
template<class Container, class Delimiters>
|
||||
inline Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const FlatOutput::OutputAdaptor<Container, Delimiters>&
|
||||
Ostream& os,
|
||||
const FlatOutput::OutputAdaptor<Container, Delimiters>& adaptor
|
||||
);
|
||||
|
||||
|
||||
@ -187,8 +187,7 @@ public:
|
||||
// Operators
|
||||
|
||||
//- Ostream Operator
|
||||
inline friend Ostream&
|
||||
operator<<
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const OutputAdaptor<Container, Delimiters>& adaptor
|
||||
|
||||
@ -158,7 +158,7 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
|
||||
OTstream toks;
|
||||
result.writeValue(toks);
|
||||
|
||||
return tokenList(std::move(toks.tokens()));
|
||||
return std::move(toks);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -304,13 +304,13 @@ public:
|
||||
inline dimensionSet& dimensions();
|
||||
|
||||
//- Return oriented type
|
||||
inline const orientedType& oriented() const;
|
||||
inline const orientedType& oriented() const noexcept;
|
||||
|
||||
//- Return non-const access to the oriented type
|
||||
inline orientedType& oriented();
|
||||
inline orientedType& oriented() noexcept;
|
||||
|
||||
//- Set the oriented flag
|
||||
inline void setOriented(const bool oriented = true);
|
||||
inline void setOriented(const bool oriented = true) noexcept;
|
||||
|
||||
//- Return field
|
||||
inline const Field<Type>& field() const;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,14 +61,15 @@ inline Foam::dimensionSet& Foam::DimensionedField<Type, GeoMesh>::dimensions()
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
inline const Foam::orientedType&
|
||||
Foam::DimensionedField<Type, GeoMesh>::oriented() const
|
||||
Foam::DimensionedField<Type, GeoMesh>::oriented() const noexcept
|
||||
{
|
||||
return oriented_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class GeoMesh>
|
||||
inline Foam::orientedType& Foam::DimensionedField<Type, GeoMesh>::oriented()
|
||||
inline Foam::orientedType&
|
||||
Foam::DimensionedField<Type, GeoMesh>::oriented() noexcept
|
||||
{
|
||||
return oriented_;
|
||||
}
|
||||
@ -78,7 +79,7 @@ template<class Type, class GeoMesh>
|
||||
inline void Foam::DimensionedField<Type, GeoMesh>::setOriented
|
||||
(
|
||||
const bool oriented
|
||||
)
|
||||
) noexcept
|
||||
{
|
||||
oriented_.setOriented(oriented);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -120,9 +121,12 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
|
||||
) const
|
||||
{
|
||||
os.writeEntry("dimensions", dimensions());
|
||||
oriented_.writeEntry(os);
|
||||
os << nl;
|
||||
|
||||
os<< nl << nl;
|
||||
if (oriented_.writeEntry(os))
|
||||
{
|
||||
os << nl;
|
||||
}
|
||||
|
||||
Field<Type>::writeEntry(fieldDictEntry, os);
|
||||
|
||||
|
||||
@ -1,77 +1 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "DynamicField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::DynamicField<T, SizeMin>::DynamicField(Istream& is)
|
||||
:
|
||||
Field<T>(is),
|
||||
capacity_(Field<T>::size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::tmp<Foam::DynamicField<T, SizeMin>>
|
||||
Foam::DynamicField<T, SizeMin>::clone() const
|
||||
{
|
||||
return tmp<DynamicField<T, SizeMin>>::New(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicField<T, SizeMin>& lst
|
||||
)
|
||||
{
|
||||
os << static_cast<const Field<T>&>(lst);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicField<T, SizeMin>& lst
|
||||
)
|
||||
{
|
||||
is >> static_cast<Field<T>&>(lst);
|
||||
lst.capacity_ = lst.Field<T>::size();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
#warning File removed - left for old dependency check only
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -32,7 +32,6 @@ Description
|
||||
|
||||
SourceFiles
|
||||
DynamicFieldI.H
|
||||
DynamicField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -47,24 +46,14 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
// Forward Declarations
|
||||
template<class T, int SizeMin> class DynamicField;
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicField<T, SizeMin>& fld
|
||||
);
|
||||
inline Istream& operator>>(Istream&, DynamicField<T, SizeMin>&);
|
||||
|
||||
template<class T, int SizeMin>
|
||||
Istream& operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicField<T, SizeMin>& fld
|
||||
);
|
||||
|
||||
inline Ostream& operator<<(Ostream&, const DynamicField<T, SizeMin>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DynamicField Declaration
|
||||
@ -77,7 +66,7 @@ class DynamicField
|
||||
{
|
||||
static_assert(SizeMin > 0, "Invalid min size parameter");
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- The capacity (allocated size) of the underlying field.
|
||||
label capacity_;
|
||||
@ -87,7 +76,7 @@ class DynamicField
|
||||
|
||||
//- Copy assignment from another list
|
||||
template<class ListType>
|
||||
inline void assignDynField(const ListType& list);
|
||||
inline void assignDynList(const ListType& list);
|
||||
|
||||
public:
|
||||
|
||||
@ -102,7 +91,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
//- Default construct, an empty field without allocation.
|
||||
inline constexpr DynamicField() noexcept;
|
||||
|
||||
//- Construct empty field with given reserve size.
|
||||
@ -162,69 +151,69 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream. Size set to size of list read.
|
||||
explicit DynamicField(Istream& is);
|
||||
inline explicit DynamicField(Istream& is);
|
||||
|
||||
//- Clone
|
||||
tmp<DynamicField<T, SizeMin>> clone() const;
|
||||
inline tmp<DynamicField<T, SizeMin>> clone() const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Normal lower capacity limit - the SizeMin template parameter
|
||||
static constexpr label min_size() noexcept { return SizeMin; }
|
||||
|
||||
//- Size of the underlying storage.
|
||||
inline label capacity() const noexcept;
|
||||
|
||||
|
||||
// Edit
|
||||
// Sizing
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
// Use this or reserve() in combination with append().
|
||||
inline void setCapacity(const label nElem);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void setSize(const label nElem);
|
||||
|
||||
//- Alter the addressed list size and fill new space with a constant.
|
||||
inline void setSize(const label nElem, const T& val);
|
||||
|
||||
//- Alter the addressed list size.
|
||||
// New space will be allocated if required.
|
||||
// Use this to resize the list prior to using the operator[] for
|
||||
// setting values (as per List usage).
|
||||
inline void resize(const label nElem);
|
||||
|
||||
//- Alter the addressed list size and fill new space with a
|
||||
// constant.
|
||||
inline void resize(const label nElem, const T& val);
|
||||
inline void setCapacity(const label newCapacity);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size, use setCapacity() for that.
|
||||
inline void reserve(const label nElem);
|
||||
inline void reserve(const label len);
|
||||
|
||||
//- Alter addressable size.
|
||||
// New space will be allocated if required.
|
||||
inline void resize(const label newLen);
|
||||
|
||||
//- Alter addressable size and fill new space with constant value
|
||||
inline void resize(const label newLen, const T& val);
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label n) { this->resize(n); }
|
||||
|
||||
//- Alias for resize()
|
||||
void setSize(const label n, const T& val) { this->resize(n, val); }
|
||||
|
||||
//- Clear the addressed list, i.e. set the size to zero.
|
||||
// Allocated size does not change
|
||||
inline void clear();
|
||||
inline void clear() noexcept;
|
||||
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
|
||||
//- Expand the addressable size to fit the allocated capacity.
|
||||
// Returns the previous addressable size.
|
||||
inline label expandStorage();
|
||||
inline label expandStorage() noexcept;
|
||||
|
||||
//- Shrink the allocated space to the number of elements used.
|
||||
// Returns a reference to the DynamicField.
|
||||
inline DynamicField<T, SizeMin>& shrink();
|
||||
|
||||
//- Swap content with any sized DynamicField
|
||||
|
||||
// Edit
|
||||
|
||||
//- Swap content, independent of sizing parameter
|
||||
template<int AnySizeMin>
|
||||
inline void swap(DynamicField<T, AnySizeMin>& list);
|
||||
inline void swap(DynamicField<T, AnySizeMin>& other);
|
||||
|
||||
//- Transfer the parameter contents into this
|
||||
inline void transfer(List<T>& list);
|
||||
@ -237,10 +226,11 @@ public:
|
||||
template<int AnySizeMin>
|
||||
inline void transfer(DynamicField<T, AnySizeMin>& list);
|
||||
|
||||
|
||||
//- Append an element at the end of the list
|
||||
inline DynamicField<T, SizeMin>&
|
||||
append(const T& val);
|
||||
inline DynamicField<T, SizeMin>& append(const T& val);
|
||||
|
||||
//- Move append an element
|
||||
inline DynamicField<T, SizeMin>& append(T&& val);
|
||||
|
||||
//- Append a List at the end of this list
|
||||
inline DynamicField<T, SizeMin>&
|
||||
@ -252,12 +242,15 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return non-const access to an element, resizing list if necessary
|
||||
//- Return non-const access to an element, resizing list if needed
|
||||
inline T& operator()(const label i);
|
||||
|
||||
//- Assign addressed entries to the given value
|
||||
inline void operator=(const T& val);
|
||||
|
||||
//- Assign addressed entries to zero
|
||||
inline void operator=(const Foam::zero);
|
||||
|
||||
//- Copy assignment
|
||||
inline void operator=(const UList<T>& list);
|
||||
|
||||
@ -274,6 +267,22 @@ public:
|
||||
template<int AnySizeMin>
|
||||
inline void operator=(DynamicField<T, AnySizeMin>&& list);
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Read from Istream, discarding existing contents
|
||||
friend Istream& operator>> <T, SizeMin>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicField<T, SizeMin>& rhs
|
||||
);
|
||||
|
||||
//- Write to Ostream
|
||||
friend Ostream& operator<< <T, SizeMin>
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicField<T, SizeMin>& rhs
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -287,12 +296,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "DynamicField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,26 +30,26 @@ License
|
||||
|
||||
template<class T, int SizeMin>
|
||||
template<class ListType>
|
||||
inline void Foam::DynamicField<T, SizeMin>::assignDynField
|
||||
inline void Foam::DynamicField<T, SizeMin>::assignDynList
|
||||
(
|
||||
const ListType& list
|
||||
)
|
||||
{
|
||||
const label newSize = list.size();
|
||||
const label newLen = list.size();
|
||||
|
||||
if (capacity_ >= newSize)
|
||||
if (newLen <= capacity_)
|
||||
{
|
||||
// Can copy w/o reallocating - adjust addressable size accordingly.
|
||||
Field<T>::size(list.size());
|
||||
Field<T>::operator=(list);
|
||||
List<T>::setAddressableSize(newLen);
|
||||
List<T>::operator=(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ensure list size consistency prior to copying.
|
||||
Field<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
Field<T>::operator=(list);
|
||||
capacity_ = Field<T>::size();
|
||||
List<T>::operator=(list);
|
||||
capacity_ = List<T>::size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,10 +67,10 @@ inline constexpr Foam::DynamicField<T, SizeMin>::DynamicField() noexcept
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>::DynamicField(const label len)
|
||||
:
|
||||
Field<T>(len),
|
||||
capacity_(Field<T>::size())
|
||||
Field<T>(),
|
||||
capacity_(0)
|
||||
{
|
||||
Field<T>::size(0);
|
||||
reserve(len);
|
||||
}
|
||||
|
||||
|
||||
@ -207,7 +207,6 @@ inline Foam::DynamicField<T, SizeMin>::DynamicField
|
||||
{}
|
||||
|
||||
|
||||
//- Construct by mapping from the given field
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>::DynamicField
|
||||
(
|
||||
@ -220,6 +219,22 @@ inline Foam::DynamicField<T, SizeMin>::DynamicField
|
||||
{}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>::DynamicField(Istream& is)
|
||||
:
|
||||
Field<T>(is),
|
||||
capacity_(Field<T>::size())
|
||||
{}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::tmp<Foam::DynamicField<T, SizeMin>>
|
||||
Foam::DynamicField<T, SizeMin>::clone() const
|
||||
{
|
||||
return tmp<DynamicField<T, SizeMin>>::New(*this);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
@ -232,144 +247,103 @@ inline Foam::label Foam::DynamicField<T, SizeMin>::capacity() const noexcept
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::setCapacity
|
||||
(
|
||||
const label nElem
|
||||
const label newCapacity
|
||||
)
|
||||
{
|
||||
label nextFree = Field<T>::size();
|
||||
capacity_ = nElem;
|
||||
label currLen = List<T>::size();
|
||||
capacity_ = newCapacity;
|
||||
|
||||
if (nextFree > capacity_)
|
||||
if (currLen > capacity_)
|
||||
{
|
||||
// truncate addressed sizes too
|
||||
nextFree = capacity_;
|
||||
// Truncate addressed sizes too
|
||||
currLen = capacity_;
|
||||
}
|
||||
|
||||
// We could also enforce sizing granularity
|
||||
|
||||
Field<T>::setSize(capacity_);
|
||||
Field<T>::size(nextFree);
|
||||
List<T>::resize(capacity_);
|
||||
List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::reserve
|
||||
(
|
||||
const label nElem
|
||||
const label len
|
||||
)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
if (nElem > capacity_)
|
||||
if (capacity_ < len)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
SizeMin,
|
||||
max
|
||||
(
|
||||
nElem,
|
||||
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
label(2*capacity_)
|
||||
)
|
||||
);
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
|
||||
|
||||
// Adjust allocated size, leave addressed size untouched
|
||||
const label nextFree = Field<T>::size();
|
||||
Field<T>::setSize(capacity_);
|
||||
Field<T>::size(nextFree);
|
||||
const label currLen = List<T>::size();
|
||||
List<T>::resize(capacity_);
|
||||
List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::setSize
|
||||
inline void Foam::DynamicField<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem
|
||||
const label newLen
|
||||
)
|
||||
{
|
||||
// Allocate more capacity if necessary
|
||||
if (nElem > capacity_)
|
||||
if (capacity_ < newLen)
|
||||
{
|
||||
capacity_ = max
|
||||
(
|
||||
SizeMin,
|
||||
max
|
||||
(
|
||||
nElem,
|
||||
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
|
||||
label(2*capacity_)
|
||||
)
|
||||
);
|
||||
// Increase capacity (doubling)
|
||||
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
|
||||
|
||||
Field<T>::setSize(capacity_);
|
||||
List<T>::resize(capacity_);
|
||||
}
|
||||
|
||||
// Adjust addressed size
|
||||
Field<T>::size(nElem);
|
||||
List<T>::setAddressableSize(newLen);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::setSize
|
||||
inline void Foam::DynamicField<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const label newLen,
|
||||
const T& val
|
||||
)
|
||||
{
|
||||
label nextFree = Field<T>::size();
|
||||
setSize(nElem);
|
||||
label currLen = List<T>::size();
|
||||
resize(newLen);
|
||||
|
||||
// Set new elements to constant value
|
||||
while (nextFree < nElem)
|
||||
// Fill newly exposed with constant value
|
||||
while (currLen < newLen)
|
||||
{
|
||||
this->operator[](nextFree++) = val;
|
||||
this->operator[](currLen++) = val;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem
|
||||
)
|
||||
inline void Foam::DynamicField<T, SizeMin>::clear() noexcept
|
||||
{
|
||||
this->setSize(nElem);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::resize
|
||||
(
|
||||
const label nElem,
|
||||
const T& val
|
||||
)
|
||||
{
|
||||
this->setSize(nElem, val);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::clear()
|
||||
{
|
||||
Field<T>::size(0);
|
||||
List<T>::setAddressableSize(0);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::clearStorage()
|
||||
{
|
||||
Field<T>::clear();
|
||||
List<T>::clear();
|
||||
capacity_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage()
|
||||
inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage() noexcept
|
||||
{
|
||||
const label nextFree = Field<T>::size();
|
||||
const label currLen = List<T>::size();
|
||||
|
||||
// Allow addressing into the entire list
|
||||
Field<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
return nextFree;
|
||||
return currLen;
|
||||
}
|
||||
|
||||
|
||||
@ -377,16 +351,16 @@ template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>&
|
||||
Foam::DynamicField<T, SizeMin>::shrink()
|
||||
{
|
||||
label nextFree = Field<T>::size();
|
||||
if (capacity_ > nextFree)
|
||||
const label currLen = Field<T>::size();
|
||||
if (currLen < capacity_)
|
||||
{
|
||||
// Use the full list when resizing
|
||||
Field<T>::size(capacity_);
|
||||
List<T>::setAddressableSize(capacity_);
|
||||
|
||||
// The new size
|
||||
capacity_ = nextFree;
|
||||
Field<T>::setSize(capacity_);
|
||||
Field<T>::size(nextFree);
|
||||
// Capacity and size are identical
|
||||
capacity_ = currLen;
|
||||
List<T>::resize(currLen);
|
||||
// Redundant: List<T>::setAddressableSize(currLen);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@ -396,38 +370,27 @@ template<class T, int SizeMin>
|
||||
template<int AnySizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::swap
|
||||
(
|
||||
DynamicField<T, AnySizeMin>& lst
|
||||
DynamicField<T, AnySizeMin>& other
|
||||
)
|
||||
{
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == lst.cdata())
|
||||
if (this->cdata() == other.cdata())
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
}
|
||||
|
||||
DynamicField<T, SizeMin>& cur = *this;
|
||||
// Swap storage and addressable size
|
||||
UList<T>::swap(other);
|
||||
|
||||
// Make addressable size identical to the allocated capacity
|
||||
const label oldSize1 = cur.expandStorage();
|
||||
const label oldSize2 = lst.expandStorage();
|
||||
|
||||
// Swap storage
|
||||
Field<T>::swap(lst);
|
||||
|
||||
// Match capacity to the underlying allocated list size
|
||||
cur.setCapacity(cur.size());
|
||||
lst.setCapacity(lst.size());
|
||||
|
||||
// Set addressable size
|
||||
cur.setSize(oldSize2);
|
||||
lst.setSize(oldSize1);
|
||||
// Swap capacity
|
||||
std::swap(this->capacity_, other.capacity_);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::transfer(List<T>& list)
|
||||
{
|
||||
// Take over storage, clear addressing for list.
|
||||
// Take over storage, clear addressing for list
|
||||
capacity_ = list.size();
|
||||
Field<T>::transfer(list);
|
||||
}
|
||||
@ -443,7 +406,7 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == list.cdata())
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
// Take over storage as-is (without shrink, without using SizeMin)
|
||||
@ -465,7 +428,7 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
|
||||
// Cannot compare 'this' for different types, so use cdata()
|
||||
if (this->cdata() == list.cdata())
|
||||
{
|
||||
return; // Self-swap is a no-op
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
// Take over storage as-is (without shrink, without using SizeMin)
|
||||
@ -485,13 +448,28 @@ Foam::DynamicField<T, SizeMin>::append
|
||||
)
|
||||
{
|
||||
const label idx = List<T>::size();
|
||||
setSize(idx + 1);
|
||||
resize(idx + 1);
|
||||
|
||||
this->operator[](idx) = val; // copy element
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>&
|
||||
Foam::DynamicField<T, SizeMin>::append
|
||||
(
|
||||
T&& val
|
||||
)
|
||||
{
|
||||
const label idx = List<T>::size();
|
||||
resize(idx + 1);
|
||||
|
||||
this->operator[](idx) = std::move(val); // move assign element
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::DynamicField<T, SizeMin>&
|
||||
Foam::DynamicField<T, SizeMin>::append
|
||||
@ -502,11 +480,12 @@ Foam::DynamicField<T, SizeMin>::append
|
||||
if (this == &list)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Attempted appending to self" << abort(FatalError);
|
||||
<< "Attempted appending to self"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
label idx = List<T>::size();
|
||||
setSize(idx + list.size());
|
||||
resize(idx + list.size());
|
||||
|
||||
for (const T& val : list)
|
||||
{
|
||||
@ -530,7 +509,7 @@ inline T Foam::DynamicField<T, SizeMin>::remove()
|
||||
|
||||
const T& val = List<T>::operator[](idx);
|
||||
|
||||
List<T>::size(idx);
|
||||
List<T>::setAddressableSize(idx);
|
||||
|
||||
return val;
|
||||
}
|
||||
@ -546,7 +525,7 @@ inline T& Foam::DynamicField<T, SizeMin>::operator()
|
||||
{
|
||||
if (i >= Field<T>::size())
|
||||
{
|
||||
setSize(i + 1);
|
||||
resize(i + 1);
|
||||
}
|
||||
|
||||
return this->operator[](i);
|
||||
@ -563,13 +542,23 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::operator=
|
||||
(
|
||||
const Foam::zero
|
||||
)
|
||||
{
|
||||
UList<T>::operator=(Zero);
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline void Foam::DynamicField<T, SizeMin>::operator=
|
||||
(
|
||||
const UList<T>& list
|
||||
)
|
||||
{
|
||||
assignDynField(list);
|
||||
assignDynList(list);
|
||||
}
|
||||
|
||||
|
||||
@ -584,7 +573,7 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
|
||||
return; // Self-assignment is a no-op
|
||||
}
|
||||
|
||||
assignDynField(list);
|
||||
assignDynList(list);
|
||||
}
|
||||
|
||||
|
||||
@ -619,4 +608,35 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Istream& Foam::operator>>
|
||||
(
|
||||
Istream& is,
|
||||
DynamicField<T, SizeMin>& rhs
|
||||
)
|
||||
{
|
||||
// Use entire storage - ie, resize(capacity())
|
||||
(void) rhs.expandStorage();
|
||||
|
||||
is >> static_cast<Field<T>&>(rhs);
|
||||
rhs.capacity_ = rhs.Field<T>::size();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
template<class T, int SizeMin>
|
||||
inline Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const DynamicField<T, SizeMin>& rhs
|
||||
)
|
||||
{
|
||||
os << static_cast<const Field<T>&>(rhs);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,7 +26,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
@ -55,22 +55,20 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
|
||||
if
|
||||
(
|
||||
actualPatchType.empty()
|
||||
actualPatchType == word::null
|
||||
|| actualPatchType != p.type()
|
||||
)
|
||||
{
|
||||
if (pfPtr().constraintType() != p.constraintType())
|
||||
{
|
||||
// Incompatible (constraint-wise) with the patch type
|
||||
// - use default constraint type
|
||||
|
||||
// Use default constraint type
|
||||
auto patchTypeCstrIter =
|
||||
pointPatchConstructorTablePtr_->cfind(p.type());
|
||||
|
||||
if (!patchTypeCstrIter.found())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Inconsistent patch and patchField types for\n"
|
||||
<< "inconsistent patch and patchField types for \n"
|
||||
<< " patch type " << p.type()
|
||||
<< " and patchField type " << patchFieldType
|
||||
<< exit(FatalError);
|
||||
@ -140,17 +138,20 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
|
||||
if
|
||||
(
|
||||
!dict.found("patchType")
|
||||
!dict.found("patchType")
|
||||
|| dict.get<word>("patchType") != p.type()
|
||||
)
|
||||
{
|
||||
if (pfPtr().constraintType() != p.constraintType())
|
||||
if (pfPtr().constraintType() == p.constraintType())
|
||||
{
|
||||
// Incompatible (constraint-wise) with the patch type
|
||||
// - use default constraint type
|
||||
|
||||
auto patchTypeCstrIter =
|
||||
dictionaryConstructorTablePtr_->cfind(p.type());
|
||||
// Compatible (constraint-wise) with the patch type
|
||||
return pfPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use default constraint type
|
||||
auto patchTypeCstrIter
|
||||
= dictionaryConstructorTablePtr_->cfind(p.type());
|
||||
|
||||
if (!patchTypeCstrIter.found())
|
||||
{
|
||||
@ -165,7 +166,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
|
||||
}
|
||||
}
|
||||
|
||||
return pfPtr;
|
||||
return cstrIter()(p, iF, dict);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -1205,7 +1205,7 @@ void Foam::argList::parse
|
||||
{
|
||||
parRunControl_.distributed(true);
|
||||
source = "-roots";
|
||||
if (roots.size() > 1)
|
||||
if (roots.size() != 1)
|
||||
{
|
||||
dictNProcs = roots.size()+1;
|
||||
}
|
||||
@ -1214,7 +1214,6 @@ void Foam::argList::parse
|
||||
{
|
||||
roots.resize(Pstream::nProcs()-1, fileName::null);
|
||||
|
||||
parRunControl_.distributed(true);
|
||||
source = "-hostRoots";
|
||||
ITstream is(source, options_["hostRoots"]);
|
||||
|
||||
@ -1253,7 +1252,7 @@ void Foam::argList::parse
|
||||
}
|
||||
}
|
||||
|
||||
if (roots.size() > 1)
|
||||
if (roots.size() != 1)
|
||||
{
|
||||
dictNProcs = roots.size()+1;
|
||||
}
|
||||
@ -1297,12 +1296,6 @@ void Foam::argList::parse
|
||||
{
|
||||
parRunControl_.distributed(true);
|
||||
decompDict.readEntry("roots", roots);
|
||||
if (roots.empty())
|
||||
{
|
||||
DetailInfo
|
||||
<< "WARNING: running distributed"
|
||||
<< " but did not specify roots!" << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1370,8 +1363,8 @@ void Foam::argList::parse
|
||||
{
|
||||
options_.set("case", roots[slave-1]/globalCase_);
|
||||
|
||||
OPstream toProc(Pstream::commsTypes::scheduled, slave);
|
||||
toProc << args_ << options_ << parRunControl_.distributed();
|
||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
||||
toSlave << args_ << options_ << roots.size();
|
||||
}
|
||||
options_.erase("case");
|
||||
|
||||
@ -1417,24 +1410,24 @@ void Foam::argList::parse
|
||||
// Distribute the master's argument list (unaltered)
|
||||
for (const int slave : Pstream::subProcs())
|
||||
{
|
||||
OPstream toProc(Pstream::commsTypes::scheduled, slave);
|
||||
toProc << args_ << options_ << parRunControl_.distributed();
|
||||
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
|
||||
toSlave << args_ << options_ << roots.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Collect the master's argument list
|
||||
bool isDistributed;
|
||||
label nroots;
|
||||
|
||||
IPstream fromMaster
|
||||
(
|
||||
Pstream::commsTypes::scheduled,
|
||||
Pstream::masterNo()
|
||||
);
|
||||
fromMaster >> args_ >> options_ >> isDistributed;
|
||||
fromMaster >> args_ >> options_ >> nroots;
|
||||
|
||||
parRunControl_.distributed(isDistributed);
|
||||
parRunControl_.distributed(nroots);
|
||||
|
||||
// Establish rootPath_/globalCase_/case_ for slave
|
||||
setCasePaths();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -94,16 +94,15 @@ bool Foam::OFstreamCollator::writeFile
|
||||
// We don't have IOobject so cannot use IOobject::writeHeader
|
||||
if (!append)
|
||||
{
|
||||
OSstream& os = osPtr();
|
||||
decomposedBlockData::writeHeader
|
||||
(
|
||||
os,
|
||||
*osPtr,
|
||||
ver,
|
||||
fmt,
|
||||
typeName,
|
||||
"",
|
||||
fName,
|
||||
fName.name()
|
||||
"", // note
|
||||
fName, // location
|
||||
fName.name() // object name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,8 +202,7 @@ inline Foam::Matrix<Form, Type>::Matrix
|
||||
)
|
||||
:
|
||||
mRows_(Mb.m()),
|
||||
nCols_(Mb.n()),
|
||||
v_(nullptr)
|
||||
nCols_(Mb.n())
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
@ -225,8 +224,7 @@ inline Foam::Matrix<Form, Type>::Matrix
|
||||
)
|
||||
:
|
||||
mRows_(Mb.m()),
|
||||
nCols_(Mb.n()),
|
||||
v_(nullptr)
|
||||
nCols_(Mb.n())
|
||||
{
|
||||
doAlloc();
|
||||
|
||||
@ -462,6 +460,20 @@ Foam::scalar Foam::Matrix<Form, Type>::norm(const bool noSqrt) const
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Type>
|
||||
std::streamsize Foam::Matrix<Form, Type>::byteSize() const
|
||||
{
|
||||
if (!is_contiguous<Type>::value)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Invalid for non-contiguous data types"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
return mRows_*nCols_*sizeof(Type);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Form, class Type>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -123,8 +123,8 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline Matrix();
|
||||
//- Default construct (empty matrix)
|
||||
inline Matrix() noexcept;
|
||||
|
||||
//- Construct given number of rows/columns
|
||||
Matrix(const label m, const label n);
|
||||
@ -204,6 +204,9 @@ public:
|
||||
//- be used to address into Matrix contents
|
||||
inline Type* data() noexcept;
|
||||
|
||||
//- The number of bytes stored by the Matrix data for contiguous types
|
||||
std::streamsize byteSize() const;
|
||||
|
||||
//- Return const pointer to data in the specified row
|
||||
// Subscript checking only with FULLDEBUG
|
||||
inline const Type* rowData(const label irow) const;
|
||||
@ -444,25 +447,25 @@ public:
|
||||
// Random Access Iterator (non-const)
|
||||
|
||||
//- Return an iterator to begin traversing a Matrix
|
||||
inline iterator begin();
|
||||
inline iterator begin() noexcept;
|
||||
|
||||
//- Return an iterator to end traversing a Matrix
|
||||
inline iterator end();
|
||||
inline iterator end() noexcept;
|
||||
|
||||
|
||||
// Random Access Iterator (const)
|
||||
|
||||
//- Return const_iterator to begin traversing a constant Matrix
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing a constant Matrix
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- Return const_iterator to begin traversing a constant Matrix
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end traversing a constant Matrix
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// IO
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -35,9 +35,8 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
|
||||
{
|
||||
const label len = size();
|
||||
|
||||
if (len > 0)
|
||||
if (len)
|
||||
{
|
||||
// With sign-check to avoid spurious -Walloc-size-larger-than
|
||||
v_ = new Type[len];
|
||||
}
|
||||
}
|
||||
@ -46,7 +45,7 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Form, class Type>
|
||||
inline Foam::Matrix<Form, Type>::Matrix()
|
||||
inline Foam::Matrix<Form, Type>::Matrix() noexcept
|
||||
:
|
||||
mRows_(0),
|
||||
nCols_(0),
|
||||
@ -511,7 +510,7 @@ inline Foam::tmp<Foam::Field<Type>> Foam::Matrix<Form, Type>::Tmul
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::iterator
|
||||
Foam::Matrix<Form, Type>::begin()
|
||||
Foam::Matrix<Form, Type>::begin() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -519,7 +518,7 @@ Foam::Matrix<Form, Type>::begin()
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::iterator
|
||||
Foam::Matrix<Form, Type>::end()
|
||||
Foam::Matrix<Form, Type>::end() noexcept
|
||||
{
|
||||
return v_ + (mRows_ * nCols_);
|
||||
}
|
||||
@ -527,7 +526,7 @@ Foam::Matrix<Form, Type>::end()
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::const_iterator
|
||||
Foam::Matrix<Form, Type>::cbegin() const
|
||||
Foam::Matrix<Form, Type>::cbegin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -535,7 +534,7 @@ Foam::Matrix<Form, Type>::cbegin() const
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::const_iterator
|
||||
Foam::Matrix<Form, Type>::cend() const
|
||||
Foam::Matrix<Form, Type>::cend() const noexcept
|
||||
{
|
||||
return v_ + (mRows_ * nCols_);
|
||||
}
|
||||
@ -543,7 +542,7 @@ Foam::Matrix<Form, Type>::cend() const
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::const_iterator
|
||||
Foam::Matrix<Form, Type>::begin() const
|
||||
Foam::Matrix<Form, Type>::begin() const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
@ -551,7 +550,7 @@ Foam::Matrix<Form, Type>::begin() const
|
||||
|
||||
template<class Form, class Type>
|
||||
inline typename Foam::Matrix<Form, Type>::const_iterator
|
||||
Foam::Matrix<Form, Type>::end() const
|
||||
Foam::Matrix<Form, Type>::end() const noexcept
|
||||
{
|
||||
return v_ + (mRows_ * nCols_);
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
#warning File removed - left for old dependency check only
|
||||
@ -48,8 +48,8 @@ namespace Foam
|
||||
|
||||
// Forward Declarations
|
||||
class labelledTri;
|
||||
Istream& operator>>(Istream&, labelledTri&);
|
||||
Ostream& operator<<(Ostream&, const labelledTri&);
|
||||
inline Istream& operator>>(Istream&, labelledTri&);
|
||||
inline Ostream& operator<<(Ostream&, const labelledTri&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class labelledTri Declaration
|
||||
@ -119,8 +119,8 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
inline friend Istream& operator>>(Istream&, labelledTri&);
|
||||
inline friend Ostream& operator<<(Ostream&, const labelledTri&);
|
||||
friend Istream& operator>>(Istream&, labelledTri&);
|
||||
friend Ostream& operator<<(Ostream&, const labelledTri&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
|
||||
class objectMap;
|
||||
inline bool operator==(const objectMap& a, const objectMap& b);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -138,18 +138,19 @@ public:
|
||||
);
|
||||
|
||||
//- Synchronize values on all mesh edges.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
const TransformOp& top
|
||||
const TransformOp& top,
|
||||
const FlipOp& fop
|
||||
);
|
||||
|
||||
//- Synchronize values on selected mesh edges.
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -157,7 +158,8 @@ public:
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
const TransformOp& top
|
||||
const TransformOp& top,
|
||||
const FlipOp& fop
|
||||
);
|
||||
|
||||
//- Synchronize values on boundary faces only.
|
||||
@ -277,7 +279,8 @@ public:
|
||||
edgeValues,
|
||||
cop,
|
||||
nullValue,
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
noOp()
|
||||
);
|
||||
}
|
||||
|
||||
@ -297,7 +300,8 @@ public:
|
||||
positions,
|
||||
cop,
|
||||
nullValue,
|
||||
mapDistribute::transformPosition()
|
||||
mapDistribute::transformPosition(),
|
||||
noOp()
|
||||
);
|
||||
}
|
||||
|
||||
@ -319,7 +323,8 @@ public:
|
||||
edgeValues,
|
||||
cop,
|
||||
nullValue,
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
noOp()
|
||||
);
|
||||
}
|
||||
|
||||
@ -341,7 +346,8 @@ public:
|
||||
positions,
|
||||
cop,
|
||||
nullValue,
|
||||
mapDistribute::transformPosition()
|
||||
mapDistribute::transformPosition(),
|
||||
noOp()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -798,14 +798,15 @@ void Foam::syncTools::syncPointList
|
||||
}
|
||||
|
||||
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
void Foam::syncTools::syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
const TransformOp& top
|
||||
const TransformOp& top,
|
||||
const FlipOp& fop
|
||||
)
|
||||
{
|
||||
if (edgeValues.size() != mesh.nEdges())
|
||||
@ -816,12 +817,47 @@ void Foam::syncTools::syncEdgeList
|
||||
<< mesh.nEdges() << abort(FatalError);
|
||||
}
|
||||
|
||||
const edgeList& edges = mesh.edges();
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
const labelList& meshEdges = gd.coupledPatchMeshEdges();
|
||||
const indirectPrimitivePatch& cpp = gd.coupledPatch();
|
||||
const edgeList& cppEdges = cpp.edges();
|
||||
const labelList& mp = cpp.meshPoints();
|
||||
const globalIndexAndTransform& git = gd.globalTransforms();
|
||||
const mapDistribute& edgeMap = gd.globalEdgeSlavesMap();
|
||||
const bitSet& orientation = gd.globalEdgeOrientation();
|
||||
|
||||
List<T> cppFld(meshEdges.size());
|
||||
forAll(meshEdges, i)
|
||||
{
|
||||
const edge& cppE = cppEdges[i];
|
||||
const label meshEdgei = meshEdges[i];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
// 1. is cpp edge oriented as mesh edge
|
||||
// 2. is cpp edge oriented same as master edge
|
||||
|
||||
const int dir = edge::compare(meshE, edge(mp, cppE));
|
||||
if (dir == 0)
|
||||
{
|
||||
FatalErrorInFunction<< "Problem:"
|
||||
<< " mesh edge:" << meshE.line(mesh.points())
|
||||
<< " coupled edge:" << cppE.line(cpp.localPoints())
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const bool sameOrientation = ((dir == 1) == orientation[i]);
|
||||
|
||||
if (sameOrientation)
|
||||
{
|
||||
cppFld[i] = edgeValues[meshEdgei];
|
||||
}
|
||||
else
|
||||
{
|
||||
cppFld[i] = fop(edgeValues[meshEdgei]);
|
||||
}
|
||||
}
|
||||
|
||||
List<T> cppFld(UIndirectList<T>(edgeValues, meshEdges));
|
||||
|
||||
globalMeshData::syncData
|
||||
(
|
||||
@ -837,12 +873,29 @@ void Foam::syncTools::syncEdgeList
|
||||
// Extract back onto mesh
|
||||
forAll(meshEdges, i)
|
||||
{
|
||||
edgeValues[meshEdges[i]] = cppFld[i];
|
||||
const edge& cppE = cppEdges[i];
|
||||
const label meshEdgei = meshEdges[i];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
// 1. is cpp edge oriented as mesh edge
|
||||
// 2. is cpp edge oriented same as master edge
|
||||
|
||||
const int dir = edge::compare(meshE, edge(mp, cppE));
|
||||
const bool sameOrientation = ((dir == 1) == orientation[i]);
|
||||
|
||||
if (sameOrientation)
|
||||
{
|
||||
edgeValues[meshEdges[i]] = cppFld[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeValues[meshEdges[i]] = fop(cppFld[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class T, class CombineOp, class TransformOp>
|
||||
template<class T, class CombineOp, class TransformOp, class FlipOp>
|
||||
void Foam::syncTools::syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -850,7 +903,8 @@ void Foam::syncTools::syncEdgeList
|
||||
List<T>& edgeValues,
|
||||
const CombineOp& cop,
|
||||
const T& nullValue,
|
||||
const TransformOp& top
|
||||
const TransformOp& top,
|
||||
const FlipOp& fop
|
||||
)
|
||||
{
|
||||
if (edgeValues.size() != meshEdges.size())
|
||||
@ -860,19 +914,48 @@ void Foam::syncTools::syncEdgeList
|
||||
<< " is not equal to the number of meshEdges "
|
||||
<< meshEdges.size() << abort(FatalError);
|
||||
}
|
||||
const edgeList& edges = mesh.edges();
|
||||
const globalMeshData& gd = mesh.globalData();
|
||||
const indirectPrimitivePatch& cpp = gd.coupledPatch();
|
||||
const edgeList& cppEdges = cpp.edges();
|
||||
const labelList& mp = cpp.meshPoints();
|
||||
const Map<label>& mpm = gd.coupledPatchMeshEdgeMap();
|
||||
const bitSet& orientation = gd.globalEdgeOrientation();
|
||||
|
||||
List<T> cppFld(cpp.nEdges(), nullValue);
|
||||
|
||||
forAll(meshEdges, i)
|
||||
{
|
||||
const auto iter = mpm.cfind(meshEdges[i]);
|
||||
|
||||
const label meshEdgei = meshEdges[i];
|
||||
const auto iter = mpm.cfind(meshEdgei);
|
||||
if (iter.found())
|
||||
{
|
||||
cppFld[*iter] = edgeValues[i];
|
||||
const label cppEdgei = iter();
|
||||
const edge& cppE = cppEdges[cppEdgei];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
// 1. is cpp edge oriented as mesh edge
|
||||
// 2. is cpp edge oriented same as master edge
|
||||
|
||||
const int dir = edge::compare(meshE, edge(mp, cppE));
|
||||
if (dir == 0)
|
||||
{
|
||||
FatalErrorInFunction<< "Problem:"
|
||||
<< " mesh edge:" << meshE.line(mesh.points())
|
||||
<< " coupled edge:" << cppE.line(cpp.localPoints())
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const bool sameOrientation = ((dir == 1) == orientation[i]);
|
||||
|
||||
if (sameOrientation)
|
||||
{
|
||||
cppFld[cppEdgei] = edgeValues[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
cppFld[cppEdgei] = fop(edgeValues[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -889,11 +972,25 @@ void Foam::syncTools::syncEdgeList
|
||||
|
||||
forAll(meshEdges, i)
|
||||
{
|
||||
const auto iter = mpm.cfind(meshEdges[i]);
|
||||
|
||||
if (iter.found())
|
||||
label meshEdgei = meshEdges[i];
|
||||
Map<label>::const_iterator iter = mpm.find(meshEdgei);
|
||||
if (iter != mpm.end())
|
||||
{
|
||||
edgeValues[i] = cppFld[*iter];
|
||||
label cppEdgei = iter();
|
||||
const edge& cppE = cppEdges[cppEdgei];
|
||||
const edge& meshE = edges[meshEdgei];
|
||||
|
||||
const int dir = edge::compare(meshE, edge(mp, cppE));
|
||||
const bool sameOrientation = ((dir == 1) == orientation[i]);
|
||||
|
||||
if (sameOrientation)
|
||||
{
|
||||
edgeValues[i] = cppFld[cppEdgei];
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeValues[i] = fop(cppFld[cppEdgei]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -925,50 +1022,147 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
|
||||
if (parRun)
|
||||
{
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
if
|
||||
(
|
||||
is_contiguous<T>::value
|
||||
&& Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Receive buffer
|
||||
List<T> receivedValues(mesh.nBoundaryFaces());
|
||||
|
||||
// Set up reads
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
const label patchStart = procPatch.start()-boundaryOffset;
|
||||
SubList<T> fld
|
||||
(
|
||||
receivedValues,
|
||||
procPatch.size(),
|
||||
procPatch.offset()
|
||||
);
|
||||
|
||||
// Send slice of values on the patch
|
||||
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
|
||||
toNbr<< SubList<T>(faceValues, procPatch.size(), patchStart);
|
||||
IPstream::read
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
reinterpret_cast<char*>(fld.data()),
|
||||
fld.byteSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up writes
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
const SubList<T> fld
|
||||
(
|
||||
faceValues,
|
||||
procPatch.size(),
|
||||
procPatch.offset()
|
||||
);
|
||||
|
||||
OPstream::write
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
reinterpret_cast<const char*>(fld.cdata()),
|
||||
fld.byteSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all comms to finish
|
||||
Pstream::waitRequests(startRequest);
|
||||
|
||||
// Combine with existing data
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
SubList<T> recvFld
|
||||
(
|
||||
receivedValues,
|
||||
procPatch.size(),
|
||||
procPatch.offset()
|
||||
);
|
||||
const List<T>& fakeList = recvFld;
|
||||
top(procPatch, const_cast<List<T>&>(fakeList));
|
||||
|
||||
SubList<T> patchValues
|
||||
(
|
||||
faceValues,
|
||||
procPatch.size(),
|
||||
procPatch.offset()
|
||||
);
|
||||
forAll(patchValues, i)
|
||||
{
|
||||
cop(patchValues[i], recvFld[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
|
||||
// Receive and combine.
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
else
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
Field<T> nbrVals(procPatch.size());
|
||||
|
||||
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
|
||||
fromNbr >> nbrVals;
|
||||
|
||||
top(procPatch, nbrVals);
|
||||
|
||||
label bFacei = procPatch.start()-boundaryOffset;
|
||||
|
||||
for (T& nbrVal : nbrVals)
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
{
|
||||
cop(faceValues[bFacei++], nbrVal);
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
const label patchStart = procPatch.start()-boundaryOffset;
|
||||
|
||||
// Send slice of values on the patch
|
||||
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
|
||||
toNbr <<
|
||||
SubList<T>(faceValues, procPatch.size(), patchStart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
|
||||
// Receive and combine.
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
List<T> nbrVals(procPatch.size());
|
||||
|
||||
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
|
||||
fromNbr >> nbrVals;
|
||||
|
||||
top(procPatch, nbrVals);
|
||||
|
||||
label bFacei = procPatch.start()-boundaryOffset;
|
||||
|
||||
for (const T& nbrVal : nbrVals)
|
||||
{
|
||||
cop(faceValues[bFacei++], nbrVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -992,10 +1186,10 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
const label nbrStart = nbrPatch.start()-boundaryOffset;
|
||||
|
||||
// Transform (copy of) data on both sides
|
||||
Field<T> ownVals(SubList<T>(faceValues, patchSize, ownStart));
|
||||
List<T> ownVals(SubList<T>(faceValues, patchSize, ownStart));
|
||||
top(nbrPatch, ownVals);
|
||||
|
||||
Field<T> nbrVals(SubList<T>(faceValues, patchSize, nbrStart));
|
||||
List<T> nbrVals(SubList<T>(faceValues, patchSize, nbrStart));
|
||||
top(cycPatch, nbrVals);
|
||||
|
||||
label bFacei = ownStart;
|
||||
@ -1048,10 +1242,39 @@ void Foam::syncTools::syncFaceList
|
||||
|
||||
if (parRun)
|
||||
{
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
const label startRequest = UPstream::nRequests();
|
||||
|
||||
// Send
|
||||
// Receive buffers
|
||||
PtrList<PackedList<Width>> recvInfos(patches.size());
|
||||
|
||||
// Set up reads
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size())
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
const label patchSize = procPatch.size();
|
||||
const label patchi = procPatch.index();
|
||||
|
||||
recvInfos.set(patchi, new PackedList<Width>(patchSize));
|
||||
PackedList<Width>& recvInfo = recvInfos[patchi];
|
||||
|
||||
IPstream::read
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
reinterpret_cast<char*>(recvInfo.data()),
|
||||
recvInfo.byteSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Send buffers
|
||||
PtrList<PackedList<Width>> sendInfos(patches.size());
|
||||
|
||||
// Set up writes
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size())
|
||||
@ -1064,18 +1287,29 @@ void Foam::syncTools::syncFaceList
|
||||
procPatch.start()-boundaryOffset,
|
||||
procPatch.size()
|
||||
);
|
||||
const label patchi = procPatch.index();
|
||||
|
||||
// Send slice of values on the patch
|
||||
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
|
||||
toNbr<< PackedList<Width>(faceValues, range);
|
||||
sendInfos.set
|
||||
(
|
||||
patchi,
|
||||
new PackedList<Width>(faceValues, range)
|
||||
);
|
||||
PackedList<Width>& sendInfo = sendInfos[patchi];
|
||||
|
||||
OPstream::write
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
reinterpret_cast<const char*>(sendInfo.cdata()),
|
||||
sendInfo.byteSize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
|
||||
// Receive and combine.
|
||||
// Wait for all comms to finish
|
||||
Pstream::waitRequests(startRequest);
|
||||
|
||||
// Combine with existing data
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isA<processorPolyPatch>(pp) && pp.size())
|
||||
@ -1084,13 +1318,8 @@ void Foam::syncTools::syncFaceList
|
||||
refCast<const processorPolyPatch>(pp);
|
||||
|
||||
const label patchSize = procPatch.size();
|
||||
|
||||
// Recv slice of values on the patch
|
||||
PackedList<Width> recvInfo(patchSize);
|
||||
{
|
||||
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
|
||||
fromNbr >> recvInfo;
|
||||
}
|
||||
const label patchi = procPatch.index();
|
||||
const PackedList<Width>& recvInfo = recvInfos[patchi];
|
||||
|
||||
// Combine (bitwise)
|
||||
label bFacei = procPatch.start()-boundaryOffset;
|
||||
@ -1106,6 +1335,66 @@ void Foam::syncTools::syncFaceList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
//
|
||||
//// Send
|
||||
//
|
||||
//for (const polyPatch& pp : patches)
|
||||
//{
|
||||
// if (isA<processorPolyPatch>(pp) && pp.size())
|
||||
// {
|
||||
// const processorPolyPatch& procPatch =
|
||||
// refCast<const processorPolyPatch>(pp);
|
||||
//
|
||||
// const labelRange range
|
||||
// (
|
||||
// procPatch.start()-boundaryOffset,
|
||||
// procPatch.size()
|
||||
// );
|
||||
//
|
||||
// // Send slice of values on the patch
|
||||
// UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
|
||||
// toNbr<< PackedList<Width>(faceValues, range);
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//pBufs.finishedSends();
|
||||
//
|
||||
//
|
||||
//// Receive and combine.
|
||||
//
|
||||
//for (const polyPatch& pp : patches)
|
||||
//{
|
||||
// if (isA<processorPolyPatch>(pp) && pp.size())
|
||||
// {
|
||||
// const processorPolyPatch& procPatch =
|
||||
// refCast<const processorPolyPatch>(pp);
|
||||
//
|
||||
// const label patchSize = procPatch.size();
|
||||
//
|
||||
// // Recv slice of values on the patch
|
||||
// PackedList<Width> recvInfo(patchSize);
|
||||
// {
|
||||
// UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
|
||||
// fromNbr >> recvInfo;
|
||||
// }
|
||||
//
|
||||
// // Combine (bitwise)
|
||||
// label bFacei = procPatch.start()-boundaryOffset;
|
||||
// for (label i = 0; i < patchSize; ++i)
|
||||
// {
|
||||
// unsigned int recvVal = recvInfo[i];
|
||||
// unsigned int faceVal = faceValues[bFacei];
|
||||
//
|
||||
// cop(faceVal, recvVal);
|
||||
// faceValues.set(bFacei, faceVal);
|
||||
//
|
||||
// ++bFacei;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -49,13 +49,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
|
||||
class Istream;
|
||||
class Ostream;
|
||||
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward Declarations
|
||||
|
||||
template<class Point, class PointRef> class line;
|
||||
|
||||
|
||||
@ -280,13 +280,13 @@ public:
|
||||
{
|
||||
if (is.format() == IOstream::ASCII)
|
||||
{
|
||||
return is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
|
||||
is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO (2019-08-06):
|
||||
// cannot properly handle mixed-precision reading
|
||||
// owning to bool and Point type.
|
||||
// owing to bool and Point type.
|
||||
|
||||
is.read
|
||||
(
|
||||
|
||||
@ -57,11 +57,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
class Istream;
|
||||
class Ostream;
|
||||
class tetPoints;
|
||||
// Forward Declarations
|
||||
class plane;
|
||||
class tetPoints;
|
||||
|
||||
template<class Point, class PointRef> class tetrahedron;
|
||||
|
||||
@ -310,7 +308,7 @@ public:
|
||||
boundBox bounds() const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>> <Point, PointRef>
|
||||
(
|
||||
|
||||
@ -54,8 +54,6 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class Istream;
|
||||
class Ostream;
|
||||
class plane;
|
||||
class triPoints;
|
||||
|
||||
@ -355,7 +353,7 @@ public:
|
||||
) const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>> <Point, PointRef>
|
||||
(
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,6 +26,9 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "orientedType.H"
|
||||
#include "dictionary.H"
|
||||
#include "Istream.H"
|
||||
#include "Ostream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -35,12 +38,14 @@ const Foam::Enum
|
||||
>
|
||||
Foam::orientedType::orientedOptionNames
|
||||
({
|
||||
{ orientedOption::UNKNOWN, "unknown" },
|
||||
{ orientedOption::ORIENTED, "oriented" },
|
||||
{ orientedOption::UNORIENTED, "unoriented" },
|
||||
{ orientedOption::UNKNOWN, "unknown" },
|
||||
});
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::orientedType::checkType
|
||||
(
|
||||
const orientedType& ot1,
|
||||
@ -86,19 +91,19 @@ Foam::orientedType::orientedType(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::orientedType::orientedOption& Foam::orientedType::oriented()
|
||||
Foam::orientedType::orientedOption& Foam::orientedType::oriented() noexcept
|
||||
{
|
||||
return oriented_;
|
||||
}
|
||||
|
||||
|
||||
Foam::orientedType::orientedOption Foam::orientedType::oriented() const
|
||||
Foam::orientedType::orientedOption Foam::orientedType::oriented() const noexcept
|
||||
{
|
||||
return oriented_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::orientedType::setOriented(const bool oriented)
|
||||
void Foam::orientedType::setOriented(const bool oriented) noexcept
|
||||
{
|
||||
oriented_ = oriented ? ORIENTED : UNORIENTED;
|
||||
}
|
||||
@ -116,12 +121,16 @@ void Foam::orientedType::read(const dictionary& dict)
|
||||
}
|
||||
|
||||
|
||||
void Foam::orientedType::writeEntry(Ostream& os) const
|
||||
bool Foam::orientedType::writeEntry(Ostream& os) const
|
||||
{
|
||||
if (oriented_ == ORIENTED)
|
||||
const bool output = (oriented_ == ORIENTED);
|
||||
|
||||
if (output)
|
||||
{
|
||||
os.writeEntry("oriented", orientedOptionNames[oriented_]);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -37,9 +37,6 @@ SourceFiles
|
||||
#ifndef orientedType_H
|
||||
#define orientedType_H
|
||||
|
||||
#include "Istream.H"
|
||||
#include "Ostream.H"
|
||||
#include "dictionary.H"
|
||||
#include "Enum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -47,12 +44,10 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
// Forward Declarations
|
||||
class orientedType;
|
||||
|
||||
Istream& operator>>(Istream& is, orientedType& ot);
|
||||
|
||||
Ostream& operator<<(Ostream& os, const orientedType& ot);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -63,24 +58,25 @@ class orientedType
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
// Public Data Types
|
||||
|
||||
//- Enumeration defining the valid oriented flags
|
||||
//- Enumeration defining oriented flags
|
||||
enum orientedOption
|
||||
{
|
||||
ORIENTED,
|
||||
UNORIENTED,
|
||||
UNKNOWN
|
||||
UNKNOWN = 0,
|
||||
ORIENTED = 1,
|
||||
UNORIENTED = 2
|
||||
};
|
||||
|
||||
//- Named enumerations for oriented flags
|
||||
static const Enum<orientedOption> orientedOptionNames;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Oriented flag
|
||||
//- Oriented type
|
||||
orientedOption oriented_;
|
||||
|
||||
|
||||
@ -88,20 +84,20 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Null constructor - flag initialised to false
|
||||
//- Default construct as "UNKNOWN"
|
||||
orientedType();
|
||||
|
||||
//- Copy constructor
|
||||
//- Copy construct
|
||||
orientedType(const orientedType& ot);
|
||||
|
||||
//- Construct from bool
|
||||
orientedType(const bool oriented);
|
||||
explicit orientedType(const bool oriented);
|
||||
|
||||
//- Construct from Istream
|
||||
orientedType(Istream& is);
|
||||
explicit orientedType(Istream& is);
|
||||
|
||||
|
||||
// Member functions
|
||||
// Member Functions
|
||||
|
||||
//- Return true if can operate on this pair of oriented types
|
||||
static bool checkType
|
||||
@ -111,22 +107,23 @@ public:
|
||||
);
|
||||
|
||||
//- Return non-const reference to the oriented flag
|
||||
orientedOption& oriented();
|
||||
orientedOption& oriented() noexcept;
|
||||
|
||||
//- Return const reference to the oriented flag
|
||||
orientedOption oriented() const;
|
||||
//- Return the oriented flag
|
||||
orientedOption oriented() const noexcept;
|
||||
|
||||
//- Set the oriented flag
|
||||
void setOriented(const bool oriented = true);
|
||||
void setOriented(const bool oriented = true) noexcept;
|
||||
|
||||
//- Read the oriented state from dictionary
|
||||
//- Read the "oriented" state from dictionary
|
||||
void read(const dictionary& dict);
|
||||
|
||||
//- Write the oriented flag entry
|
||||
void writeEntry(Ostream& os) const;
|
||||
//- Write the "oriented" flag entry (if ORIENTED)
|
||||
// \return True if entry was written
|
||||
bool writeEntry(Ostream& os) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member Operators
|
||||
|
||||
void operator=(const orientedType& ot);
|
||||
|
||||
@ -139,10 +136,9 @@ public:
|
||||
bool operator()() const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream& is, orientedType& ot);
|
||||
|
||||
friend Ostream& operator<<(Ostream& os, const orientedType& ot);
|
||||
};
|
||||
|
||||
|
||||
@ -45,9 +45,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "mathematicalConstants.H"
|
||||
#include "error.H"
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
using namespace Foam::constant::mathematical;
|
||||
|
||||
|
||||
@ -43,10 +43,6 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "mathematicalConstants.H"
|
||||
#include "error.H"
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
using namespace Foam::constant::mathematical;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -513,10 +513,6 @@ inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::T() const
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Foam::Tensor<Cmpt>
|
||||
Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
|
||||
{
|
||||
@ -540,10 +536,6 @@ Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
|
||||
|
||||
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Foam::Tensor<Cmpt>
|
||||
Foam::Tensor<Cmpt>::schur(const Tensor<Cmpt>& t2) const
|
||||
{
|
||||
@ -978,10 +970,6 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
|
||||
|
||||
//- Inner-product of a SphericalTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
@ -996,10 +984,6 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
|
||||
//- Inner-product of a Tensor and a SphericalTensor
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
{
|
||||
@ -1014,10 +998,6 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
|
||||
|
||||
//- Inner-product of a SymmTensor and a Tensor
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
{
|
||||
@ -1040,10 +1020,6 @@ operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
|
||||
|
||||
//- Inner-product of a Tensor and a SymmTensor
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Tensor<Cmpt>
|
||||
operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
{
|
||||
@ -1066,11 +1042,7 @@ operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
|
||||
|
||||
//- Inner-product of a Tensor and a Vector
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Vector<Cmpt>
|
||||
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
|
||||
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
@ -1084,11 +1056,7 @@ operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
|
||||
|
||||
//- Inner-product of a Vector and a Tensor
|
||||
template<class Cmpt>
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
// Workaround for gcc (11+) that fails to handle tensor dot vector
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
inline Vector<Cmpt>
|
||||
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
|
||||
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
|
||||
{
|
||||
return Vector<Cmpt>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -224,25 +224,25 @@ public:
|
||||
// Random access iterator (non-const)
|
||||
|
||||
//- Return an iterator to begin of VectorSpace
|
||||
inline iterator begin();
|
||||
inline iterator begin() noexcept;
|
||||
|
||||
//- Return an iterator to end of VectorSpace
|
||||
inline iterator end();
|
||||
inline iterator end() noexcept;
|
||||
|
||||
|
||||
// Random access iterator (const)
|
||||
|
||||
//- Return const_iterator to begin of VectorSpace
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end of VectorSpace
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- Return const_iterator to begin of VectorSpace
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- Return const_iterator to end of VectorSpace
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -196,42 +196,46 @@ inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cdata() const noexcept
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin() noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
|
||||
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() noexcept
|
||||
{
|
||||
return (v_ + Ncmpts);
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin() const
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin()
|
||||
const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend() const
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend()
|
||||
const noexcept
|
||||
{
|
||||
return (v_ + Ncmpts);
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin() const
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
|
||||
const noexcept
|
||||
{
|
||||
return v_;
|
||||
}
|
||||
|
||||
|
||||
template<class Form, class Cmpt, Foam::direction Ncmpts>
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() const
|
||||
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
|
||||
const noexcept
|
||||
{
|
||||
return (v_ + Ncmpts);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user