Compare commits
23 Commits
rpmbuild-2
...
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 |
@ -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;
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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.
|
||||
@ -128,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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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) 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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,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.
|
||||
@ -45,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),
|
||||
@ -510,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_;
|
||||
}
|
||||
@ -518,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_);
|
||||
}
|
||||
@ -526,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_;
|
||||
}
|
||||
@ -534,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_);
|
||||
}
|
||||
@ -542,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_;
|
||||
}
|
||||
@ -550,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);
|
||||
};
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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.
|
||||
@ -295,11 +295,11 @@ public:
|
||||
inline bool operator!=(const const_iterator& iter) const noexcept;
|
||||
};
|
||||
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
const_iterator begin() const { return cbegin(); }
|
||||
const_iterator end() const { return cend(); }
|
||||
const_iterator begin() const noexcept { return cbegin(); }
|
||||
const_iterator end() const noexcept { return cend(); }
|
||||
|
||||
|
||||
// Housekeeping
|
||||
|
||||
@ -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.
|
||||
@ -230,7 +230,7 @@ inline bool Foam::Enum<EnumType>::const_iterator::operator!=
|
||||
|
||||
template<class EnumType>
|
||||
inline typename Foam::Enum<EnumType>::const_iterator
|
||||
Foam::Enum<EnumType>::cbegin() const
|
||||
Foam::Enum<EnumType>::cbegin() const noexcept
|
||||
{
|
||||
return typename Enum<EnumType>::const_iterator(this);
|
||||
}
|
||||
@ -238,7 +238,7 @@ Foam::Enum<EnumType>::cbegin() const
|
||||
|
||||
template<class EnumType>
|
||||
inline typename Foam::Enum<EnumType>::const_iterator
|
||||
Foam::Enum<EnumType>::cend() const
|
||||
Foam::Enum<EnumType>::cend() const noexcept
|
||||
{
|
||||
return typename Enum<EnumType>::const_iterator(this, this->size());
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -167,7 +167,7 @@ public:
|
||||
inline void resize(const IntType n) noexcept;
|
||||
|
||||
//- Enforce non-negative size
|
||||
inline void clampSize();
|
||||
inline void clampSize() noexcept;
|
||||
|
||||
|
||||
// Search
|
||||
@ -212,31 +212,31 @@ public:
|
||||
inline const_iterator at(const IntType i) const;
|
||||
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- A const_iterator set to 1 beyond the end of the range.
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- A const_iterator set to 1 beyond the end of the range.
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// Bidirectional reverse input iterators (const)
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the end of range
|
||||
inline const_reverse_iterator rbegin() const;
|
||||
inline const_reverse_iterator rbegin() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the end of range
|
||||
inline const_reverse_iterator crbegin() const;
|
||||
inline const_reverse_iterator crbegin() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the begin of range
|
||||
inline const_reverse_iterator rend() const;
|
||||
inline const_reverse_iterator rend() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the begin of range
|
||||
inline const_reverse_iterator crend() const;
|
||||
inline const_reverse_iterator crend() const noexcept;
|
||||
|
||||
|
||||
// Iterators
|
||||
@ -280,13 +280,13 @@ public:
|
||||
inline const_iterator& operator++() noexcept;
|
||||
|
||||
//- Postfix increment
|
||||
inline const_iterator operator++(int);
|
||||
inline const_iterator operator++(int) noexcept;
|
||||
|
||||
//- Prefix decrement
|
||||
inline const_iterator& operator--() noexcept;
|
||||
|
||||
//- Postfix decrement
|
||||
inline const_iterator operator--(int);
|
||||
inline const_iterator operator--(int) noexcept;
|
||||
|
||||
//- Arbitrary increment
|
||||
inline const_iterator& operator+=(const IntType n) noexcept;
|
||||
@ -391,13 +391,13 @@ public:
|
||||
inline const_reverse_iterator& operator++() noexcept;
|
||||
|
||||
//- Postfix increment
|
||||
inline const_reverse_iterator operator++(int);
|
||||
inline const_reverse_iterator operator++(int) noexcept;
|
||||
|
||||
//- Prefix decrement
|
||||
inline const_reverse_iterator& operator--() noexcept;
|
||||
|
||||
//- Postfix decrement
|
||||
inline const_reverse_iterator operator--(int);
|
||||
inline const_reverse_iterator operator--(int) noexcept;
|
||||
|
||||
//- Arbitrary increment
|
||||
inline const_reverse_iterator& operator+=(const IntType n) noexcept;
|
||||
|
||||
@ -99,7 +99,7 @@ operator++() noexcept
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::const_iterator::
|
||||
operator++(int)
|
||||
operator++(int) noexcept
|
||||
{
|
||||
const_iterator old(*this);
|
||||
++value_;
|
||||
@ -120,7 +120,7 @@ operator--() noexcept
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::const_iterator::
|
||||
operator--(int)
|
||||
operator--(int) noexcept
|
||||
{
|
||||
const_iterator old(*this);
|
||||
--value_;
|
||||
@ -234,7 +234,7 @@ operator++() noexcept
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::const_reverse_iterator::
|
||||
operator++(int)
|
||||
operator++(int) noexcept
|
||||
{
|
||||
const_reverse_iterator old(*this);
|
||||
--value_;
|
||||
@ -255,7 +255,7 @@ operator--() noexcept
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::const_reverse_iterator::
|
||||
operator--(int)
|
||||
operator--(int) noexcept
|
||||
{
|
||||
const_reverse_iterator old(*this);
|
||||
++value_;
|
||||
@ -340,7 +340,7 @@ Foam::IntRange<IntType>::at(const IntType i) const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::begin() const
|
||||
Foam::IntRange<IntType>::begin() const noexcept
|
||||
{
|
||||
return const_iterator(start_);
|
||||
}
|
||||
@ -348,7 +348,7 @@ Foam::IntRange<IntType>::begin() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::cbegin() const
|
||||
Foam::IntRange<IntType>::cbegin() const noexcept
|
||||
{
|
||||
return const_iterator(start_);
|
||||
}
|
||||
@ -356,7 +356,7 @@ Foam::IntRange<IntType>::cbegin() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::end() const
|
||||
Foam::IntRange<IntType>::end() const noexcept
|
||||
{
|
||||
return const_iterator(start_ + size_);
|
||||
}
|
||||
@ -364,7 +364,7 @@ Foam::IntRange<IntType>::end() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_iterator
|
||||
Foam::IntRange<IntType>::cend() const
|
||||
Foam::IntRange<IntType>::cend() const noexcept
|
||||
{
|
||||
return const_iterator(start_ + size_);
|
||||
}
|
||||
@ -372,7 +372,7 @@ Foam::IntRange<IntType>::cend() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::rbegin() const
|
||||
Foam::IntRange<IntType>::rbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ + (size_-1));
|
||||
}
|
||||
@ -380,7 +380,7 @@ Foam::IntRange<IntType>::rbegin() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::crbegin() const
|
||||
Foam::IntRange<IntType>::crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ + (size_-1));
|
||||
}
|
||||
@ -388,7 +388,7 @@ Foam::IntRange<IntType>::crbegin() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::rend() const
|
||||
Foam::IntRange<IntType>::rend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ - 1);
|
||||
}
|
||||
@ -396,7 +396,7 @@ Foam::IntRange<IntType>::rend() const
|
||||
|
||||
template<class IntType>
|
||||
inline typename Foam::IntRange<IntType>::const_reverse_iterator
|
||||
Foam::IntRange<IntType>::crend() const
|
||||
Foam::IntRange<IntType>::crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ - 1);
|
||||
}
|
||||
@ -508,7 +508,7 @@ inline void Foam::IntRange<IntType>::resize(const IntType n) noexcept
|
||||
|
||||
|
||||
template<class IntType>
|
||||
inline void Foam::IntRange<IntType>::clampSize()
|
||||
inline void Foam::IntRange<IntType>::clampSize() noexcept
|
||||
{
|
||||
if (size_ < 0) size_ = 0;
|
||||
}
|
||||
|
||||
@ -155,16 +155,16 @@ public:
|
||||
|
||||
|
||||
//- A const_iterator set to the beginning of the list
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- A const_iterator set to beyond the end of the list
|
||||
inline const const_iterator cend() const;
|
||||
inline const const_iterator cend() const noexcept;
|
||||
|
||||
//- A const_iterator set to the beginning of the list
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- A const_iterator set to beyond the end of the list
|
||||
inline const const_iterator end() const;
|
||||
inline const const_iterator end() const noexcept;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
@ -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.
|
||||
@ -110,28 +110,28 @@ operator!=
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::labelRanges::const_iterator
|
||||
Foam::labelRanges::cbegin() const
|
||||
Foam::labelRanges::cbegin() const noexcept
|
||||
{
|
||||
return const_iterator(this);
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRanges::const_iterator
|
||||
Foam::labelRanges::cend() const
|
||||
Foam::labelRanges::cend() const noexcept
|
||||
{
|
||||
return const_iterator(this, this->size());
|
||||
}
|
||||
|
||||
|
||||
inline Foam::labelRanges::const_iterator
|
||||
Foam::labelRanges::begin() const
|
||||
Foam::labelRanges::begin() const noexcept
|
||||
{
|
||||
return const_iterator(this);
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRanges::const_iterator
|
||||
Foam::labelRanges::end() const
|
||||
Foam::labelRanges::end() const noexcept
|
||||
{
|
||||
return const_iterator(this, this->size());
|
||||
}
|
||||
|
||||
@ -5,7 +5,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.
|
||||
@ -179,28 +179,28 @@ public:
|
||||
inline const_iterator at(const label i) const;
|
||||
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator begin() const;
|
||||
inline const_iterator begin() const noexcept;
|
||||
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator cbegin() const;
|
||||
inline const_iterator cbegin() const noexcept;
|
||||
|
||||
//- A const_iterator set to 1 beyond the end of the range.
|
||||
inline const_iterator cend() const;
|
||||
inline const_iterator cend() const noexcept;
|
||||
|
||||
//- A const_iterator set to 1 beyond the end of the range.
|
||||
inline const_iterator end() const;
|
||||
inline const_iterator end() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the end of range
|
||||
inline const_reverse_iterator rbegin() const;
|
||||
inline const_reverse_iterator rbegin() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the end of range
|
||||
inline const_reverse_iterator crbegin() const;
|
||||
inline const_reverse_iterator crbegin() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the begin of range
|
||||
inline const_reverse_iterator rend() const;
|
||||
inline const_reverse_iterator rend() const noexcept;
|
||||
|
||||
//- A const_reverse_iterator set to 1 before the begin of range
|
||||
inline const_reverse_iterator crend() const;
|
||||
inline const_reverse_iterator crend() const noexcept;
|
||||
|
||||
|
||||
// Iterators
|
||||
|
||||
@ -5,7 +5,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.
|
||||
@ -314,56 +314,56 @@ Foam::sliceRange::at(const label i) const
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_iterator
|
||||
Foam::sliceRange::begin() const
|
||||
Foam::sliceRange::begin() const noexcept
|
||||
{
|
||||
return const_iterator(start_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_iterator
|
||||
Foam::sliceRange::cbegin() const
|
||||
Foam::sliceRange::cbegin() const noexcept
|
||||
{
|
||||
return const_iterator(start_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_iterator
|
||||
Foam::sliceRange::end() const
|
||||
Foam::sliceRange::end() const noexcept
|
||||
{
|
||||
return const_iterator(start_ + size_*stride_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_iterator
|
||||
Foam::sliceRange::cend() const
|
||||
Foam::sliceRange::cend() const noexcept
|
||||
{
|
||||
return const_iterator(start_ + size_*stride_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_reverse_iterator
|
||||
Foam::sliceRange::rbegin() const
|
||||
Foam::sliceRange::rbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ + (size_-1)*stride_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_reverse_iterator
|
||||
Foam::sliceRange::crbegin() const
|
||||
Foam::sliceRange::crbegin() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ + (size_-1)*stride_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_reverse_iterator
|
||||
Foam::sliceRange::rend() const
|
||||
Foam::sliceRange::rend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ - stride_, stride_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::sliceRange::const_reverse_iterator
|
||||
Foam::sliceRange::crend() const
|
||||
Foam::sliceRange::crend() const noexcept
|
||||
{
|
||||
return const_reverse_iterator(start_ - stride_, stride_);
|
||||
}
|
||||
|
||||
@ -52,13 +52,11 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class triad;
|
||||
class quaternion;
|
||||
class Istream;
|
||||
class Ostream;
|
||||
Istream& operator>>(Istream&, triad&);
|
||||
Ostream& operator<<(Ostream&, const triad&);
|
||||
inline Istream& operator>>(Istream&, triad&);
|
||||
inline Ostream& operator<<(Ostream&, const triad&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class triad Declaration
|
||||
@ -68,7 +66,6 @@ class triad
|
||||
:
|
||||
public Vector<vector>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -160,8 +157,8 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
inline friend Istream& operator>>(Istream&, triad&);
|
||||
inline friend Ostream& operator<<(Ostream&, const triad&);
|
||||
friend Istream& operator>>(Istream&, triad&);
|
||||
friend Ostream& operator<<(Ostream&, const triad&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -243,6 +243,12 @@ void Foam::dynamicRefineFvMesh::mapFields(const mapPolyMesh& mpm)
|
||||
(
|
||||
lookupClass<surfaceScalarField>()
|
||||
);
|
||||
|
||||
// Remove surfaceInterpolation to allow re-calculation on demand
|
||||
// This could be done in fvMesh::updateMesh but some dynamicFvMesh
|
||||
// might need the old interpolation fields (weights, etc).
|
||||
surfaceInterpolation::clearOut();
|
||||
|
||||
forAllIters(fluxes, iter)
|
||||
{
|
||||
if (!correctFluxes_.found(iter.key()))
|
||||
|
||||
@ -47,9 +47,9 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
// Forward Declarations
|
||||
class STLtriangle;
|
||||
Ostream& operator<<(Ostream& os, const STLtriangle& tri);
|
||||
inline Ostream& operator<<(Ostream& os, const STLtriangle& tri);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class STLtriangle Declaration
|
||||
@ -141,10 +141,10 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Ostream operator
|
||||
// Ostream Operator
|
||||
|
||||
//- Print triangle contents
|
||||
inline friend Ostream& operator<<(Ostream& os, const STLtriangle& tri);
|
||||
friend Ostream& operator<<(Ostream& os, const STLtriangle& tri);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -63,14 +64,7 @@ Foam::SRF::SRFModel::SRFModel
|
||||
mesh_(Urel_.mesh()),
|
||||
origin_("origin", dimLength, get<vector>("origin")),
|
||||
axis_(normalised(get<vector>("axis"))),
|
||||
SRFModelCoeffs_(optionalSubDict(type + "Coeffs")),
|
||||
omega_(dimensionedVector("omega", dimless/dimTime, Zero))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::SRF::SRFModel::~SRFModel()
|
||||
SRFModelCoeffs_(optionalSubDict(type + "Coeffs"))
|
||||
{}
|
||||
|
||||
|
||||
@ -109,29 +103,20 @@ const Foam::vector& Foam::SRF::SRFModel::axis() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::dimensionedVector& Foam::SRF::SRFModel::omega() const
|
||||
{
|
||||
return omega_;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
|
||||
Foam::SRF::SRFModel::Fcoriolis() const
|
||||
{
|
||||
return tmp<volVectorField::Internal>
|
||||
return tmp<DimensionedField<vector, Foam::volMesh>>::New
|
||||
(
|
||||
new volVectorField::Internal
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Fcoriolis",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
2.0*omega_ ^ Urel_
|
||||
)
|
||||
"Fcoriolis",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
2.0*omega() ^ Urel_
|
||||
);
|
||||
}
|
||||
|
||||
@ -139,20 +124,19 @@ Foam::SRF::SRFModel::Fcoriolis() const
|
||||
Foam::tmp<Foam::DimensionedField<Foam::vector, Foam::volMesh>>
|
||||
Foam::SRF::SRFModel::Fcentrifugal() const
|
||||
{
|
||||
return tmp<volVectorField::Internal>
|
||||
const dimensionedVector omega = this->omega();
|
||||
|
||||
return tmp<DimensionedField<vector, Foam::volMesh>>::New
|
||||
(
|
||||
new volVectorField::Internal
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Fcentrifugal",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
omega_ ^ (omega_ ^ (mesh_.C() - origin_))
|
||||
)
|
||||
"Fcentrifugal",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
omega ^ (omega ^ (mesh_.C() - origin_))
|
||||
);
|
||||
}
|
||||
|
||||
@ -170,7 +154,7 @@ Foam::vectorField Foam::SRF::SRFModel::velocity
|
||||
) const
|
||||
{
|
||||
tmp<vectorField> tfld =
|
||||
omega_.value()
|
||||
omega().value()
|
||||
^ (
|
||||
(positions - origin_.value())
|
||||
- axis_*(axis_ & (positions - origin_.value()))
|
||||
@ -182,21 +166,18 @@ Foam::vectorField Foam::SRF::SRFModel::velocity
|
||||
|
||||
Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::U() const
|
||||
{
|
||||
return tmp<volVectorField>
|
||||
return tmp<volVectorField>::New
|
||||
(
|
||||
new volVectorField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Usrf",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
omega_
|
||||
^ ((mesh_.C() - origin_) - axis_*(axis_ & (mesh_.C() - origin_)))
|
||||
)
|
||||
"Usrf",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
omega()
|
||||
^ ((mesh_.C() - origin_) - axis_*(axis_ & (mesh_.C() - origin_)))
|
||||
);
|
||||
}
|
||||
|
||||
@ -205,21 +186,18 @@ Foam::tmp<Foam::volVectorField> Foam::SRF::SRFModel::Uabs() const
|
||||
{
|
||||
tmp<volVectorField> Usrf = U();
|
||||
|
||||
tmp<volVectorField> tUabs
|
||||
auto tUabs = tmp<volVectorField>::New
|
||||
(
|
||||
new volVectorField
|
||||
IOobject
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"Uabs",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
Usrf
|
||||
)
|
||||
"Uabs",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
Usrf
|
||||
);
|
||||
|
||||
volVectorField& Uabs = tUabs.ref();
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,6 +51,7 @@ SourceFiles
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "vectorField.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -86,9 +88,6 @@ protected:
|
||||
//- SRF model coefficients dictionary
|
||||
dictionary SRFModelCoeffs_;
|
||||
|
||||
//- Angular velocity of the frame (rad/s)
|
||||
dimensionedVector omega_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -141,7 +140,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~SRFModel();
|
||||
virtual ~SRFModel() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -154,15 +153,15 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the angular velocity field [rad/s]
|
||||
virtual dimensionedVector omega() const = 0;
|
||||
|
||||
//- Return the origin of rotation
|
||||
const dimensionedVector& origin() const;
|
||||
|
||||
//- Return the axis of rotation
|
||||
const vector& axis() const;
|
||||
|
||||
//- Return the angular velocity field [rad/s]
|
||||
const dimensionedVector& omega() const;
|
||||
|
||||
//- Return the coriolis force
|
||||
tmp<volVectorField::Internal> Fcoriolis() const;
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,16 +47,14 @@ namespace Foam
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::SRF::rpm::rpm(const volVectorField& U)
|
||||
:
|
||||
SRFModel(typeName, U),
|
||||
rpm_(SRFModelCoeffs_.get<scalar>("rpm"))
|
||||
{
|
||||
// The angular velocity
|
||||
omega_.value() = axis_*rpmToRads(rpm_);
|
||||
}
|
||||
rpmPtr_(Function1<scalar>::New("rpm", SRFModelCoeffs_))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -65,9 +63,7 @@ bool Foam::SRF::rpm::read()
|
||||
{
|
||||
if (SRFModel::read())
|
||||
{
|
||||
SRFModelCoeffs_.readEntry("rpm", rpm_);
|
||||
|
||||
omega_.value() = axis_*rpmToRads(rpm_);
|
||||
rpmPtr_.reset(Function1<scalar>::New("rpm", SRFModelCoeffs_));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -76,4 +72,14 @@ bool Foam::SRF::rpm::read()
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedVector Foam::SRF::rpm::omega() const
|
||||
{
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
const scalar rpm = rpmPtr_->value(t);
|
||||
|
||||
return dimensionedVector("omega", dimless/dimTime, axis_*rpmToRads(rpm));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,6 +40,7 @@ SourceFiles
|
||||
#define SRF_rpm_H
|
||||
|
||||
#include "SRFModel.H"
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -60,7 +61,7 @@ class rpm
|
||||
// Private data
|
||||
|
||||
//- Revolutions per minute
|
||||
scalar rpm_;
|
||||
autoPtr<Function1<scalar>> rpmPtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -85,13 +86,16 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~rpm() = default;
|
||||
virtual ~rpm() = default;
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Read coefficients
|
||||
bool read();
|
||||
|
||||
//- Return the angular velocity field [rad/s]
|
||||
virtual dimensionedVector omega() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -41,7 +41,8 @@ Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchVectorField(p, iF),
|
||||
relative_(false),
|
||||
inletValue_(p.size(), Zero)
|
||||
inletValue_(p.size(), Zero),
|
||||
refValuePtr_(fvPatchVectorField::New("refValue", p, iF))
|
||||
{}
|
||||
|
||||
|
||||
@ -55,8 +56,15 @@ Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchVectorField(ptf, p, iF, mapper),
|
||||
relative_(ptf.relative_),
|
||||
inletValue_(ptf.inletValue_, mapper)
|
||||
{}
|
||||
inletValue_(ptf.inletValue_, mapper),
|
||||
refValuePtr_()
|
||||
{
|
||||
if (ptf.refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_ =
|
||||
fvPatchVectorField::New(ptf.refValuePtr_(), p, iF, mapper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
@ -68,8 +76,22 @@ Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchVectorField(p, iF, dict),
|
||||
relative_(dict.get<Switch>("relative")),
|
||||
inletValue_("inletValue", dict, p.size())
|
||||
{}
|
||||
inletValue_(p.size(), Zero),
|
||||
refValuePtr_()
|
||||
{
|
||||
if (dict.found("inletValue"))
|
||||
{
|
||||
inletValue_ = vectorField("inletValue", dict, p.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dict.found("refValue"))
|
||||
{
|
||||
refValuePtr_ =
|
||||
fvPatchVectorField::New(p, iF, dict.subDict("refValue"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
@ -79,8 +101,14 @@ Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchVectorField(srfvpvf),
|
||||
relative_(srfvpvf.relative_),
|
||||
inletValue_(srfvpvf.inletValue_)
|
||||
{}
|
||||
inletValue_(srfvpvf.inletValue_),
|
||||
refValuePtr_()
|
||||
{
|
||||
if (srfvpvf.refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_ = srfvpvf.refValuePtr_().clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
@ -91,8 +119,14 @@ Foam::SRFVelocityFvPatchVectorField::SRFVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchVectorField(srfvpvf, iF),
|
||||
relative_(srfvpvf.relative_),
|
||||
inletValue_(srfvpvf.inletValue_)
|
||||
{}
|
||||
inletValue_(srfvpvf.inletValue_),
|
||||
refValuePtr_()
|
||||
{
|
||||
if (srfvpvf.refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_ = srfvpvf.refValuePtr_().clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -104,6 +138,11 @@ void Foam::SRFVelocityFvPatchVectorField::autoMap
|
||||
{
|
||||
vectorField::autoMap(m);
|
||||
inletValue_.autoMap(m);
|
||||
|
||||
if (refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_->autoMap(m);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -115,10 +154,14 @@ void Foam::SRFVelocityFvPatchVectorField::rmap
|
||||
{
|
||||
fixedValueFvPatchVectorField::rmap(ptf, addr);
|
||||
|
||||
const SRFVelocityFvPatchVectorField& tiptf =
|
||||
refCast<const SRFVelocityFvPatchVectorField>(ptf);
|
||||
const auto& srfptf = refCast<const SRFVelocityFvPatchVectorField>(ptf);
|
||||
|
||||
inletValue_.rmap(tiptf.inletValue_, addr);
|
||||
inletValue_.rmap(srfptf.inletValue_, addr);
|
||||
|
||||
if (srfptf.refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_->rmap(srfptf.refValuePtr_(), addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -133,19 +176,34 @@ void Foam::SRFVelocityFvPatchVectorField::updateCoeffs()
|
||||
if (!relative_)
|
||||
{
|
||||
// Get reference to the SRF model
|
||||
const SRF::SRFModel& srf =
|
||||
db().lookupObject<SRF::SRFModel>("SRFProperties");
|
||||
const auto& srf = db().lookupObject<SRF::SRFModel>("SRFProperties");
|
||||
|
||||
// Determine patch velocity due to SRF
|
||||
const vectorField SRFVelocity(srf.velocity(patch().Cf()));
|
||||
|
||||
operator==(-SRFVelocity + inletValue_);
|
||||
if (refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_->evaluate();
|
||||
operator==(-SRFVelocity + refValuePtr_());
|
||||
}
|
||||
else
|
||||
{
|
||||
operator==(-SRFVelocity + inletValue_);
|
||||
}
|
||||
}
|
||||
// If already relative to the SRF simply supply the inlet value as a fixed
|
||||
// value
|
||||
else
|
||||
{
|
||||
operator==(inletValue_);
|
||||
if (refValuePtr_.valid())
|
||||
{
|
||||
refValuePtr_->evaluate();
|
||||
operator==(refValuePtr_());
|
||||
}
|
||||
else
|
||||
{
|
||||
operator==(inletValue_);
|
||||
}
|
||||
}
|
||||
|
||||
fixedValueFvPatchVectorField::updateCoeffs();
|
||||
@ -156,7 +214,18 @@ void Foam::SRFVelocityFvPatchVectorField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchVectorField::write(os);
|
||||
os.writeEntry("relative", relative_);
|
||||
inletValue_.writeEntry("inletValue", os);
|
||||
|
||||
if (refValuePtr_.valid())
|
||||
{
|
||||
os.beginBlock("refValue");
|
||||
refValuePtr_->write(os);
|
||||
os.endBlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
inletValue_.writeEntry("inletValue", os);
|
||||
}
|
||||
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -114,6 +114,9 @@ class SRFVelocityFvPatchVectorField
|
||||
//- Inlet value [m/s]
|
||||
vectorField inletValue_;
|
||||
|
||||
//- Optional patch to retrieve values from
|
||||
tmp<fvPatchVectorField> refValuePtr_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -397,7 +397,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
|
||||
|
||||
surfaceWriterPtr_->nFields() = 1; // Needed for VTK legacy
|
||||
|
||||
surfaceWriterPtr_->write(fieldName, allValues);
|
||||
fileName outputName =
|
||||
surfaceWriterPtr_->write(fieldName, allValues);
|
||||
|
||||
// Case-local file name with "<case>" to make relocatable
|
||||
dictionary propsDict;
|
||||
propsDict.add("file", time_.relativePath(outputName, true));
|
||||
this->setProperty(fieldName, propsDict);
|
||||
|
||||
surfaceWriterPtr_->clear();
|
||||
}
|
||||
|
||||
@ -96,8 +96,7 @@ Usage
|
||||
|
||||
Options for the \c patchMapMethod entry:
|
||||
\verbatim
|
||||
directAMI
|
||||
mapNearestAMI
|
||||
nearestFaceAMI
|
||||
faceAreaWeightAMI
|
||||
partialFaceAreaWeightAMI
|
||||
\endverbatim
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -129,11 +129,8 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< "- first layer thickness ('firstLayerThickness')" << nl
|
||||
<< "- overall thickness ('thickness')" << endl;
|
||||
}
|
||||
firstLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("firstLayerThickness")
|
||||
);
|
||||
thickness = readScalar(dict.lookup("thickness"));
|
||||
firstLayerThickness = dict.get<scalar>("firstLayerThickness");
|
||||
thickness = dict.get<scalar>("thickness");
|
||||
break;
|
||||
|
||||
case FIRST_AND_EXPANSION:
|
||||
@ -143,11 +140,8 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< "- first layer thickness ('firstLayerThickness')" << nl
|
||||
<< "- expansion ratio ('expansionRatio')" << endl;
|
||||
}
|
||||
firstLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("firstLayerThickness")
|
||||
);
|
||||
expansionRatio = readScalar(dict.lookup("expansionRatio"));
|
||||
firstLayerThickness = dict.get<scalar>("firstLayerThickness");
|
||||
expansionRatio = dict.get<scalar>("expansionRatio");
|
||||
break;
|
||||
|
||||
case FINAL_AND_TOTAL:
|
||||
@ -157,11 +151,8 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< "- final layer thickness ('finalLayerThickness')" << nl
|
||||
<< "- overall thickness ('thickness')" << endl;
|
||||
}
|
||||
finalLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("finalLayerThickness")
|
||||
);
|
||||
thickness = readScalar(dict.lookup("thickness"));
|
||||
finalLayerThickness = dict.get<scalar>("finalLayerThickness");
|
||||
thickness = dict.get<scalar>("thickness");
|
||||
break;
|
||||
|
||||
case FINAL_AND_EXPANSION:
|
||||
@ -171,11 +162,8 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< "- final layer thickness ('finalLayerThickness')" << nl
|
||||
<< "- expansion ratio ('expansionRatio')" << endl;
|
||||
}
|
||||
finalLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("finalLayerThickness")
|
||||
);
|
||||
expansionRatio = readScalar(dict.lookup("expansionRatio"));
|
||||
finalLayerThickness = dict.get<scalar>("finalLayerThickness");
|
||||
expansionRatio = dict.get<scalar>("expansionRatio");
|
||||
break;
|
||||
|
||||
case TOTAL_AND_EXPANSION:
|
||||
@ -185,8 +173,8 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< "- overall thickness ('thickness')" << nl
|
||||
<< "- expansion ratio ('expansionRatio')" << endl;
|
||||
}
|
||||
thickness = readScalar(dict.lookup("thickness"));
|
||||
expansionRatio = readScalar(dict.lookup("expansionRatio"));
|
||||
thickness = dict.get<scalar>("thickness");
|
||||
expansionRatio = dict.get<scalar>("expansionRatio");
|
||||
break;
|
||||
|
||||
case FIRST_AND_RELATIVE_FINAL:
|
||||
@ -200,22 +188,13 @@ void Foam::layerParameters::readLayerParameters
|
||||
<< " ('finalLayerThickness')" << nl
|
||||
<< endl;
|
||||
}
|
||||
firstLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("firstLayerThickness")
|
||||
);
|
||||
finalLayerThickness = readScalar
|
||||
(
|
||||
dict.lookup("finalLayerThickness")
|
||||
);
|
||||
firstLayerThickness = dict.get<scalar>("firstLayerThickness");
|
||||
finalLayerThickness = dict.get<scalar>("finalLayerThickness");
|
||||
break;
|
||||
|
||||
default:
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"layerParameters::layerParameters(..)",
|
||||
dict
|
||||
) << "problem." << exit(FatalIOError);
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "problem." << exit(FatalIOError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -586,10 +565,8 @@ Foam::layerParameters::layerParameters
|
||||
thickness_[patchi],
|
||||
expansionRatio_[patchi]
|
||||
);
|
||||
minThickness_[patchi] = readScalar
|
||||
(
|
||||
layerDict.lookup("minThickness")
|
||||
);
|
||||
minThickness_[patchi] =
|
||||
layerDict.get<scalar>("minThickness");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -613,7 +590,7 @@ Foam::layerParameters::layerParameters
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
"firstLayerThickness",
|
||||
firstLayerThickness_[patchi]
|
||||
firstLayerThickness_[patchi]
|
||||
);
|
||||
layerDict.readIfPresent
|
||||
(
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -2873,6 +2873,7 @@ void Foam::snappySnapDriver::determineBaffleFeatures
|
||||
(
|
||||
pp.meshEdges(mesh.edges(), mesh.pointEdges())
|
||||
);
|
||||
// Collect all coupled edges. Does not filter duplicates/order
|
||||
syncTools::syncEdgeList
|
||||
(
|
||||
mesh,
|
||||
@ -2880,7 +2881,8 @@ void Foam::snappySnapDriver::determineBaffleFeatures
|
||||
edgeFaceNormals,
|
||||
listPlusEqOp<point>(),
|
||||
List<point>(),
|
||||
mapDistribute::transform()
|
||||
mapDistribute::transform(),
|
||||
noOp()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user