Compare commits

..

44 Commits

Author SHA1 Message Date
d3a079b4da COMP: g++11: suppress optimisation. See #3024 2024-01-19 20:52:34 +01:00
177176c5ff BUG: particle: use correct celli. Fixes #1992
Was checking the old celli instead of the result of
re-finding the position. See also Foundation commit 50a965f8866683a81d79cbc7811af7333baf9d10.
2023-10-10 15:40:47 +01:00
53feaf2560 BUG: mapFields: incorrect patches. Fixes #2944. 2023-08-30 16:39:16 +02:00
d189f95c7d BUG: UPstream::shutdown misbehaves with external initialisation (fixes #2808)
- freeCommmunicatorComponents needs an additional bounds check.
  When MPI is initialized outside of OpenFOAM, there are no
  UPstream communicator equivalents
2023-06-20 09:33:13 +02:00
bc7053dbf9 Revert "BUG: Fixing ray dAve and omega for 1D and 2D cases"
This reverts commit 5848b0afd5.
2023-05-22 09:37:50 +01:00
b087bc52de BUG: VTK write pointSet fails in parallel (fixes #2773)
- de-referenced autoPtr with () instead of ref() will fail on
  non-master ranks.
2023-05-05 16:01:37 +02:00
69f2c34e5f COMP: code adjustments for gcc-13 (#2714) 2023-02-28 16:24:06 +01:00
4dda01f161 CONFIG: improve handling of empty/non-empty ThirdParty directory 2023-02-28 16:10:00 +01:00
a7e464a70a CONFIG: foamConfigurePaths support for sys-openmpi major version 2023-02-28 16:09:59 +01:00
f40d60aa78 CONFIG: accept module-prefix 'none' as equivalent to 'false' (ie, disabled) 2023-02-28 16:09:59 +01:00
12e7bba017 BUG: solidIsothermalReactionRate: redefine the latent energy (fixes #2646) 2022-11-30 10:17:12 +00:00
ee66a09a72 ENH: solidIsothermalReactionRate: new solid reaction rate model
STYLE: solidArrheniusReactionRate: modernise code
2022-11-29 14:39:26 +00:00
f1ac837448 ENH: makeSolidReaction: modify macros to allow new models 2022-11-28 11:43:12 +00:00
7dcab65ffd BUG: related to #1676 - avoid recalculating map multiple times on topo changes 2022-11-02 20:32:14 +00:00
ff8cdfa7de ENH: use local ref to map() to avoid excessive rebuilding during topo changes 2022-10-25 14:41:56 +01:00
da5048fd70 BUG: totalFlowRateAdvectiveDiffusive: missing autoMap. Fixes #2475 2022-09-28 16:41:32 +01:00
555d76bb7b BUG: Fixing pyrolysis region motion. 2022-09-10 10:01:33 +01:00
546e2c0243 BUG: incorrect order for output scaling (transformPoints, ...)
- the output write scaling should be applied *after* undoing the
  effects of the specified rotation centre. Fixes #2566

ENH: update option names for transformPoints and surfaceTransformPoints

- prefer  '-auto-centre' and '-centre', but also accept the previous
  options '-auto-origin' and '-origin' as aliases.

  Changing to '-centre' avoids possible confusion with
  coordinate system origin().
2022-08-18 13:35:09 +02:00
b4324b1297 COMP: missing std::array include (searchable sphere) 2022-06-27 10:05:31 +02:00
b12839ffc3 CONFIG: bump patch level 2022-06-23 09:51:24 +02:00
3f5c240cdb COMP: Gcc 11+ potential fix - see #2434 2022-06-23 09:51:24 +02:00
50420f755c COMP: references to temporaries
COMP: include <limits>
2022-06-23 09:51:24 +02:00
2d8870a878 COMP: gcc-12 buffer check bypasses xsputn (#2481, #2496)
- add overflow() method to the SHA1 streambuf. Previously could rely
  on xsputn for adding to sha1 content, but streams now check pptr()
  first to test for the buffering range and thus overflow() is needed.
2022-06-23 09:51:24 +02:00
8221721d44 BUG: sample/store surface field triggers dimension check (fixes #2361)
- when used for example with wallShearStress, the stress field is
  initially created as incompressible but later updated with the
  correct compressible/incompressible dimensions.

  If this field is sampled as a surface and stored on the registry
  the dimensions should be reset() and not '=' assigned, since that
  causes a dimension check which will obviously fail.
2022-02-11 14:35:06 +01:00
f4ccdec894 BUG: error with empty distributed roots specification (fixes #2196) 2021-09-08 10:21:02 +02:00
0f7277fd5e BUG: ParticleCollector - corrected and simplified parallel reductions. See #2184 2021-09-06 16:29:50 +02:00
2f5da5af4b BUG: Curle - added missing division by r. See #2169 2021-09-06 16:29:49 +02:00
e95f8b1a8d BUG: boundaryData output incorrect when no fields are sampled (fixes #2163)
- add "point data" or "face data" note to the boundaryData output
  for easier diagnositics in the future.
2021-07-20 17:04:02 +02:00
5d8e43e86e BUG: noise did not set num of output fields (VTK legacy) [fixes #2133] 2021-06-25 10:35:36 +02:00
f53c9dd6da BUG: liquidProperties - corrected read scalar (was label). See #2142 2021-06-25 10:33:37 +02:00
3b29395a66 BUG: surfaceFieldValue with vectorWeights blocks in parallel (fixes #2129) 2021-06-18 15:47:18 +02:00
308af39136 COMP: sign check to avoid warnings about new[] range 2021-04-27 10:20:25 +02:00
6740925621 CONFIG: bump patch level 2021-04-14 20:09:25 +02:00
19b90a1130 BUG: generic point patch fails (fixes #2062)
- the generic constructor could be called twice in pointPatchField::New,
  which results in an attempt to transfer tokens twice.
2021-04-14 19:35:41 +02:00
21dda3254c BUG: noiseModel - respect lower frequency bound in octave calculation. Fixes #2041 2021-03-23 17:12:43 +00:00
dbed3a0602 BUG: Curle FO - corrected division by 4pi. Fixes #2035 2021-03-18 16:41:40 +00:00
8d3efa1cb9 BUG: AABBTree - corrected addressing. Fixes #2028 2021-03-16 12:27:38 +00:00
a8c9b5936e BUG: cannot set expression from command-line (fixes #2012) 2021-02-25 08:29:15 +01:00
a334aaae78 ENH: noiseModel gainX - protect against very small input frequencies 2021-02-15 12:51:35 +00:00
ae8ccd7b94 BUG: foamToEnsight cellZones missing mesh coverage (closes #2002) 2021-02-15 13:10:01 +01:00
0ee7a23504 CONFIG: ensure PV_PLUGIN_PATH is also in the library path 2021-02-15 13:09:58 +01:00
9913dfb31a CONFIG: bump patch level 2021-02-10 13:48:10 +01:00
77c31a7bef BUG: inconsistent surfaceFieldValue writing (fixes #1999)
- setup writer outside the data loop to ensure that the number of
  output fields is correct (VTK format).

- ignore 'interpolate' on sampled surfaces to ensure proper
  face sampling, never allow point sampling

BUG: incorrect debug-switch for sampledIsoSurface
2021-02-10 13:47:53 +01:00
4245909efb BUG: typo in etc/colourTables 2021-02-03 15:05:36 +01:00
165 changed files with 2848 additions and 3454 deletions

View File

@ -73,10 +73,10 @@ echo
applications/Allwmake $targetType $*
# Additional components/modules
if [ "$FOAM_MODULE_PREFIX" = false ]
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
then
echo "========================================"
echo "OpenFOAM modules disabled (prefix=false)"
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
echo
elif [ -d "$WM_PROJECT_DIR/modules" ]
then

View File

@ -1,2 +1,2 @@
api=2012
patch=0
patch=220610

View File

@ -1,26 +0,0 @@
{
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();
}

View File

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

View File

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

View File

@ -1,99 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
-------------------------------------------------------------------------------
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;
}
// ************************************************************************* //

View File

@ -1,22 +0,0 @@
// 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);
}

View File

@ -1 +0,0 @@
const volScalarField& psi = thermo.psi();

View File

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

View File

@ -1,109 +0,0 @@
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();
}

View File

@ -44,7 +44,11 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class magnet;
Istream& operator>>(Istream&, magnet&);
Ostream& operator<<(Ostream&, const magnet&);

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -38,8 +37,6 @@ Description
#include "Time.H"
#include "Random.H"
#include "PackedList.H"
#include "flipOp.H"
#include "pointList.H"
using namespace Foam;
@ -226,6 +223,8 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
fullData[meshPointi] = pt;
}
//Pout<< "sparseData:" << sparseData << endl;
syncTools::syncPointMap
(
mesh,
@ -310,6 +309,8 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
fullData[meshEdgeI] = pt;
}
//Pout<< "sparseData:" << sparseData << endl;
syncTools::syncEdgeMap
(
mesh,
@ -407,7 +408,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen)
{
labelList nMasters(mesh.nPoints(), Zero);
const bitSet isMasterPoint(syncTools::getMasterPoints(mesh));
bitSet isMasterPoint(syncTools::getMasterPoints(mesh));
forAll(isMasterPoint, pointi)
{
@ -483,7 +484,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
{
labelList nMasters(edges.size(), Zero);
const bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
bitSet isMasterEdge(syncTools::getMasterEdges(mesh));
forAll(isMasterEdge, edgeI)
{
@ -518,310 +519,6 @@ 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;
@ -851,58 +548,12 @@ 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);
const bitSet isMasterFace(syncTools::getMasterFaces(mesh));
bitSet isMasterFace(syncTools::getMasterFaces(mesh));
forAll(isMasterFace, facei)
{
@ -953,12 +604,6 @@ 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);

View File

@ -1,17 +0,0 @@
#!/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
#------------------------------------------------------------------------------

View File

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

View File

@ -1,21 +0,0 @@
/*--------------------------------*- 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;
// ************************************************************************* //

View File

@ -1,103 +0,0 @@
/*--------------------------------*- 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
(
);
// ************************************************************************* //

View File

@ -1,48 +0,0 @@
/*--------------------------------*- 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;
// ************************************************************************* //

View File

@ -1,26 +0,0 @@
/*--------------------------------*- 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);
// ************************************************************************* //

View File

@ -1,51 +0,0 @@
/*--------------------------------*- 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;
}
// ************************************************************************* //

View File

@ -1,52 +0,0 @@
/*--------------------------------*- 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;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,7 +39,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "Fstream.H"
#include "polyMesh.H"
#include "pointField.H"
#include "unitConversion.H"
using namespace Foam;
@ -76,7 +76,8 @@ int main(int argc, char *argv[])
word block;
string zoneName;
token punctuation;
label iPoints, jPoints;
label iPoints;
label jPoints;
Istring >> block;
Istring >> block;
@ -116,11 +117,11 @@ int main(int argc, char *argv[])
}
// correct error in biconic meshes
for (point& p : points)
forAll(points, i)
{
if (p.y() < 1e-07)
if (points[i][1] < 1e-07)
{
p.y() = 0;
points[i][1] = 0.0;
}
}
@ -145,30 +146,18 @@ int main(int argc, char *argv[])
);
}
// Write (overwrite) points
{
IOobject iopoints
(
"points",
runTime.constant(), // instance
polyMesh::meshSubDir, // local
runTime
);
const fileName polyMeshPath(runTime.constantPath()/"polyMesh");
const fileName pointsFile(polyMeshPath/"points");
OFstream pFile(pointsFile);
if (!exists(polyMeshPath)) mkDir(polyMeshPath);
if (!exists(iopoints.path()))
{
mkDir(iopoints.path());
}
Info<< "Writing points to: " << nl
<< " " << pointsFile << endl;
OFstream os(iopoints.objectPath(), runTime.writeStreamOption());
runTime.writeHeader(pFile, "vectorField");
pFile << pointsWedge;
runTime.writeEndDivider(pFile);
Info<< "Writing points to: " << nl
<< " " << os.name() << endl;
iopoints.writeHeader(os, vectorIOField::typeName);
os << pointsWedge;
IOobject::writeEndDivider(os);
}
Info<< "End\n" << endl;

View File

@ -53,8 +53,8 @@ Usage
-rotate-angle (vector angle)
Rotate angle degrees about vector axis.
or -yawPitchRoll (yawdegrees pitchdegrees rolldegrees)
or -rollPitchYaw (rolldegrees pitchdegrees yawdegrees)
or -yawPitchRoll : (yaw pitch roll) degrees
or -rollPitchYaw : (roll pitch yaw) degrees
-scale scalar|vector
Scale the points by the given scalar or vector on output.
@ -251,15 +251,18 @@ int main(int argc, char *argv[])
);
argList::addBoolOption
(
"auto-origin",
"Use bounding box centre as origin for rotations"
"auto-centre",
"Use bounding box centre as centre for rotations"
);
argList::addOption
(
"origin",
"centre",
"point",
"Use specified <point> as origin for rotations"
"Use specified <point> as centre for rotations"
);
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
argList::addOptionCompat("centre", {"origin", 2206});
argList::addOption
(
"rotate",
@ -390,18 +393,18 @@ int main(int argc, char *argv[])
points += v;
}
vector origin;
bool useOrigin = args.readIfPresent("origin", origin);
if (args.found("auto-origin") && !useOrigin)
vector rotationCentre;
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-centre") && !useRotationCentre)
{
useOrigin = true;
origin = boundBox(points).centre();
useRotationCentre = true;
rotationCentre = boundBox(points).centre();
}
if (useOrigin)
if (useRotationCentre)
{
Info<< "Set origin for rotations to " << origin << endl;
points -= origin;
Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= rotationCentre;
}
if (args.found("rotate"))
@ -482,15 +485,15 @@ int main(int argc, char *argv[])
}
}
if (useRotationCentre)
{
Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += rotationCentre;
}
// Output scaling
applyScaling(points, getScalingOpt("scale", args));
if (useOrigin)
{
Info<< "Unset origin for rotations from " << origin << endl;
points += origin;
}
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));

View File

@ -675,7 +675,7 @@ int main(int argc, char *argv[])
{
for
(
const word& opt
const char * const opt
: { "cellSet", "cellZone", "faceSet", "pointSet" }
)
{

View File

@ -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.
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
expressions::exprString
expression
(
args[expression],
args["expression"],
dictionary::null
);

View File

@ -92,7 +92,7 @@ bool setCellFieldType
fieldType field(fieldHeader, mesh, false);
const Type& value = pTraits<Type>(fieldValueStream);
const Type value = pTraits<Type>(fieldValueStream);
if (selectedCells.size() == field.size())
{
@ -244,7 +244,7 @@ bool setFaceFieldType
fieldType field(fieldHeader, mesh);
const Type& value = pTraits<Type>(fieldValueStream);
const Type value = pTraits<Type>(fieldValueStream);
// Create flat list of selected faces and their value.
Field<Type> allBoundaryValues(mesh.nBoundaryFaces());

View File

@ -188,15 +188,18 @@ int main(int argc, char *argv[])
);
argList::addBoolOption
(
"auto-origin",
"Use bounding box centre as origin for rotations"
"auto-centre",
"Use bounding box centre as centre for rotations"
);
argList::addOption
(
"origin",
"centre",
"point",
"Use specified <point> as origin for rotations"
"Use specified <point> as centre for rotations"
);
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
argList::addOptionCompat("centre", {"origin", 2206});
argList::addOption
(
"rotate",
@ -334,18 +337,18 @@ int main(int argc, char *argv[])
points += v;
}
vector origin;
bool useOrigin = args.readIfPresent("origin", origin);
if (args.found("auto-origin") && !useOrigin)
vector rotationCentre;
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-centre") && !useRotationCentre)
{
useOrigin = true;
origin = boundBox(points).centre();
useRotationCentre = true;
rotationCentre = boundBox(points).centre();
}
if (useOrigin)
if (useRotationCentre)
{
Info<< "Set origin for rotations to " << origin << endl;
points -= origin;
Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= rotationCentre;
}
if (args.found("rotate"))
@ -406,15 +409,15 @@ int main(int argc, char *argv[])
points = transform(rot, points);
}
if (useRotationCentre)
{
Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += rotationCentre;
}
// Output scaling
applyScaling(points, getScalingOpt("write-scale", args));
if (useOrigin)
{
Info<< "Unset origin for rotations from " << origin << endl;
points += origin;
}
surf1.movePoints(points);
surf1.write(exportName, writeFileType);

View File

@ -7,7 +7,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, distributed under GPL-3.0-or-later.
@ -140,8 +140,8 @@ do
esac
else
echo "Ignore bad/invalid plugin-path: $pluginPath" 1>&2
unset pluginPath
fi
unset pluginPath
;;
-block*) # Silently accepts -blockMesh
@ -238,8 +238,11 @@ then
;;
esac
if [ -n "$pluginError" ]
if [ -z "$pluginError" ]
then
# Ensure plugin is also in the lib-path
LD_LIBRARY_PATH="${PV_PLUGIN_PATH}:$LD_LIBRARY_PATH"
else
cat<< NO_PLUGIN 1>&2
$pluginError
See '${0##*/} -help-build' for more information

View File

@ -7,7 +7,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, distributed under GPL-3.0-or-later.
@ -55,6 +55,8 @@ Equivalent options:
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
-openmpi-system -sys-openmpi
-openmpi-third -openmpi
HELP_COMPAT
exit 0 # A clean exit
@ -89,10 +91,9 @@ Compiler
mpc-VERSION For ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
-mpi=NAME Specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi[=VER] Use ThirdParty openmpi, with version for 'FOAM_MPI'
-sys-openmpi[=MAJ] Use system openmpi, with specified major version
Components versions (ThirdParty)
-adios VER specify 'adios2_version'
@ -212,12 +213,13 @@ _inlineSed()
# Local filename (for reporting)
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
if grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file"
then
[ -n "$msg" ] && echo " $msg ($localFile)"
else
echo "Failed: ${msg:-replacement} in $localFile"
return 1
}
[ -n "$msg" ] && echo " $msg ($localFile)"
fi
return 0
}
@ -278,8 +280,8 @@ replaceEtc()
local file="$1"
shift
file=$(_foamEtc "$file")
replace $file "$@"
file="$(_foamEtc "$file")"
replace "$file" "$@"
}
@ -289,24 +291,36 @@ replaceEtcCsh()
local file="$1"
shift
file=$(_foamEtc "$file")
replaceCsh $file "$@"
file="$(_foamEtc "$file")"
replaceCsh "$file" "$@"
}
# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
# Returns values via optValue, nOptArgs variables!!
optValue=""
nOptArgs=0 # The number of args to shift
getOptionValue()
{
local value="$2"
[ -n "$value" ] || die "'$1' option requires an argument"
optValue="${1#*=}"
if [ "$optValue" = "$1" ]
then
# Eg, -option value
optValue="$2"
[ -n "$optValue" ] || die "'$1' option requires an argument"
nOptArgs=1
else
# Eg, -option=value
nOptArgs=0
fi
# Remove any surrounding double quotes
value="${value%\"}"
value="${value#\"}"
echo "$value"
optValue="${optValue%\"}"
optValue="${optValue#\"}"
}
@ -366,7 +380,7 @@ removeCshMagic()
#------------------------------------------------------------------------------
unset adjusted optMpi
unset adjusted
# Parse options
while [ "$#" -gt 0 ]
do
@ -421,26 +435,37 @@ CONFIG_CSH
[ -n "$FOAM_CONFIG_ETC" ] || unset FOAM_CONFIG_ETC
;;
-project-path)
-project-path=* | -project-path)
# Replace WM_PROJECT_DIR=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\""
getOptionValue "$@"
shift "${nOptArgs:-0}"
removeBashMagic $(_foamEtc bashrc)
removeCshMagic $(_foamEtc cshrc)
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_PROJECT_DIR "\"$optValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optValue\""
adjusted=true
shift
removeBashMagic "$(_foamEtc bashrc)"
removeCshMagic "$(_foamEtc cshrc)"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-version | -foamVersion | --projectVersion)
-version=* | -version | -foamVersion | --projectVersion)
# Replace WM_PROJECT_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_PROJECT_VERSION "$optionValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_PROJECT_VERSION "$optValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-sp | -SP | -float32)
@ -466,131 +491,168 @@ CONFIG_CSH
-int32 | -int64)
# Replace WM_LABEL_SIZE=...
optionValue="${1#-int}"
replaceEtc bashrc WM_LABEL_SIZE "$optionValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue"
optValue="${1#-int}"
replaceEtc bashrc WM_LABEL_SIZE "$optValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optValue"
adjusted=true
;;
## Compiler ##
-clang)
-clang=* | -clang)
# Replace default_clang_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/compiler default_clang_version "$optionValue"
replaceEtc config.csh/compiler default_clang_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/compiler default_clang_version "$optValue"
replaceEtc config.csh/compiler default_clang_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-gcc)
-gcc=* | -gcc)
# Replace default_gcc_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/compiler default_gcc_version "$optionValue"
replaceEtc config.csh/compiler default_gcc_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/compiler default_gcc_version "$optValue"
replaceEtc config.csh/compiler default_gcc_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-system-compiler | -system)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-third-compiler | -third | -ThirdParty)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
gmp-[4-9]* | gmp-system)
# gcc-related package
replaceEtc config.sh/compiler default_gmp_version "$1"
replaceEtc config.csh/compiler default_gmp_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_gmp_version "$optValue"
replaceEtc config.csh/compiler default_gmp_version "$optValue"
adjusted=true
;;
mpfr-[2-9]* | mpfr-system)
# gcc-related package
replaceEtc config.sh/compiler default_mpfr_version "$1"
replaceEtc config.csh/compiler default_mpfr_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_mpfr_version "$optValue"
replaceEtc config.csh/compiler default_mpfr_version "$optValue"
adjusted=true
;;
mpc-[0-9]* | mpc-system)
# gcc-related package
replaceEtc config.sh/compiler default_mpc_version "$1"
replaceEtc config.csh/compiler default_mpc_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_mpc_version "$optValue"
replaceEtc config.csh/compiler default_mpc_version "$optValue"
adjusted=true
;;
## MPI ##
-mpi)
-mpi=* | -mpi)
# Explicitly set WM_MPLIB=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_MPLIB "$optionValue"
replaceEtcCsh cshrc WM_MPLIB "$optionValue"
optMpi=system
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_MPLIB "$optValue"
replaceEtcCsh cshrc WM_MPLIB "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-openmpi)
# Replace FOAM_MPI=openmpi-<digits>.. and set to use third-party
# The edit is slightly fragile, but works
expected="openmpi-[1-9][.0-9]*"
optMpi=$(getOptionValue "$@")
_matches "$optMpi" "$expected" || \
die "'$1' has bad value: '$optMpi'"
_inlineSed $(_foamEtc config.sh/mpi) \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optMpi" \
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
_inlineSed $(_foamEtc config.csh/mpi) \
"FOAM_MPI $expected" \
"FOAM_MPI $optMpi" \
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
adjusted=true
shift
;;
-openmpi-system)
-sys-openmpi=* | -sys-openmpi | -openmpi-system)
optValue="$(echo "$1" | sed -ne 's/^.*mpi=\([1-9][0-9]*\).*/\1/p')"
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI
optMpi=system
adjusted=true
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI"$optValue"
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI"$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
-openmpi=* | -openmpi | -openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI
# - use default setting for openmpi, or
# replace FOAM_MPI=openmpi-<digits>..
# The edit is slightly fragile, but works
expected="openmpi-[1-9][.0-9]*"
optValue="$(echo "$1" | sed -ne 's/^.*mpi=//p')"
if [ -n "$optValue" ]
then
if [ "${optValue#openmpi-}" = "$optValue" ]
then
optValue="openmpi-$optValue"
fi
_matches "$optValue" "$expected" || \
die "'${1%=*}' has bad value: '$optValue'"
_inlineSed "$(_foamEtc config.sh/mpi)" \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optValue" \
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optValue'"
_inlineSed "$(_foamEtc config.csh/mpi)" \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optValue" \
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optValue'"
fi
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
optMpi=third
adjusted=true
;;
@ -599,146 +661,242 @@ CONFIG_CSH
-adios | -adios2)
# Replace adios2_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 adios2_version "$optionValue"
replaceEtc config.csh/adios2 adios2_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/adios2 adios2_version "$optValue"
replaceEtc config.csh/adios2 adios2_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-adios-path | -adios2-path)
# Replace ADIOS2_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-boost)
# Replace boost_version=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" boost_version "$optionValue"
replaceEtc config.csh/"$cfgName" boost_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" boost_version "$optValue"
replaceEtc config.csh/"$cfgName" boost_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-boost-path)
# Replace BOOST_ARCH_PATH=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cgal)
# Replace cgal_version=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" cgal_version "$optionValue"
replaceEtc config.csh/"$cfgName" cgal_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" cgal_version "$optValue"
replaceEtc config.csh/"$cfgName" cgal_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cgal-path)
# Replace CGAL_ARCH_PATH=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optValue"
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-fftw)
# Replace fftw_version=...
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
replaceEtc config.sh/"$cfgName" fftw_version "$optionValue"
replaceEtc config.csh/"$cfgName" fftw_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" fftw_version "$optValue"
replaceEtc config.csh/"$cfgName" fftw_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-fftw-path)
# Replace FFTW_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cmake)
# Replace cmake_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake cmake_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/cmake cmake_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cmake-path)
# Replace CMAKE_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-kahip)
# Replace KAHIP_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/kahip KAHIP_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-kahip-path)
# Replace KAHIP_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-metis)
# Replace METIS_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/metis METIS_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/metis METIS_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-metis-path)
# Replace METIS_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-scotch | -scotchVersion | --scotchVersion)
# Replace SCOTCH_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/scotch SCOTCH_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-scotch-path | -scotchArchPath | --scotchArchPath)
# Replace SCOTCH_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
@ -747,107 +905,156 @@ CONFIG_CSH
-paraview | -paraviewVersion | --paraviewVersion)
# Replace ParaView_VERSION=...
expected="[5-9][.0-9]*" # but also accept system
optionValue=$(getOptionValue "$@")
_matches "$optionValue" "$expected" || \
[ "$optionValue" != "${optionValue%system}" ] || \
die "'$1' has bad value: '$optionValue'"
replaceEtc config.sh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
_matches "$optValue" "$expected" || \
[ "$optValue" != "${optValue%system}" ] || \
die "'${1%=*}' has bad value: '$optValue'"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_VERSION "$optValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-paraview-qt)
# Replace ParaView_QT=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview ParaView_QT "$optionValue"
replaceEtc config.csh/paraview ParaView_QT "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_QT "$optValue"
replaceEtc config.csh/paraview ParaView_QT "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-paraview-path | -paraviewInstall | --paraviewInstall)
# Replace ParaView_DIR=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_DIR \""$optValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-llvm)
# Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk mesa_llvm "$optValue"
replaceEtc config.csh/vtk mesa_llvm "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-mesa)
# Replace mesa_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk mesa_version "$optionValue"
replaceEtc config.csh/vtk mesa_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk mesa_version "$optValue"
replaceEtc config.csh/vtk mesa_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-vtk)
# Replace vtk_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk vtk_version "$optionValue"
replaceEtc config.csh/vtk vtk_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk vtk_version "$optValue"
replaceEtc config.csh/vtk vtk_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-llvm-path)
# Replace LLVM_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-mesa-path)
# Replace MESA_ARCH_PATH...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-vtk-path)
# Replace VTK_DIR...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk VTK_DIR \""$optValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
## Misc ##
# Obsolete flags
-sigfpe | -no-sigfpe)
echo "Enable/disable FOAM_SIGFPE now via controlDict" 1>&2
;;
-archOption | --archOption)
# Replace WM_ARCH_OPTION=...
optionValue=$(getOptionValue "$@")
echo "Ignoring $1 option: no longer supported" 1>&2
shift
;;
# Obsolete options
-archOption | --archOption | \
-foamInstall | --foamInstall | -projectName | --projectName)
# Removed for 1812
optionValue=$(getOptionValue "$@")
echo "Ignoring $1 option: obsolete" 1>&2
shift
echo "Ignoring obsolete option: $1" 1>&2
getOptionValue "$@"
shift "${nOptArgs:-0}"
;;
*)

View File

@ -6,7 +6,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2021 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -32,9 +32,8 @@
#
# Debian-style without OpenFOAM sub-directory
#
# foamPackRelease -debian origin/develop
# foamPackRelease -debian=openfoam2002_200129 origin/develop
# foamPackRelease -name=openfoam2002_200129.orig -no-prefix origin/develop
# foamPackRelease -debian=openfoam2002_200129 origin/develop
#
#------------------------------------------------------------------------------
Script="${0##*/}"
@ -56,8 +55,7 @@ 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, -zstd Alias for -compress=tgz, -compress=xz, -compress=zstd
-debian Auto (debian) naming with -no-prefix, -xz
-tgz, -xz Alias for -compress=tgz, -compress=xz
-debian=NAME Short-cut for -name=NAME.orig, -no-prefix, -xz
-help Print help
@ -118,11 +116,6 @@ do
-h | -help*)
printHelp
;;
-debian)
tarName="debian" # Special placeholder
prefixDir=false # No prefix directory
: "${compress:=xz}" # Default 'xz' compression
;;
-debian=*)
tarName="${1#*=}"
cleanTarName
@ -173,7 +166,7 @@ do
-with-api=*)
packageApi="${1#*=}"
;;
-tgz | -xz | -zst | -zstd)
-tgz | -xz)
compress="${1#*-}"
;;
--)
@ -266,11 +259,10 @@ 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/=/-/')"
@ -298,25 +290,8 @@ then
unset prefixDir
fi
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
;;
('')
if [ -z "$tarName" ]
then
tarName="OpenFOAM-v${packageApi}"
if [ "$withSource" = false ]
then
@ -326,12 +301,11 @@ case "$tarName" in
if [ "$withPatchNum" = false ]
then
echo "Ignoring patch number for output name" 1>&2
elif [ "${patch:-0}" != 0 ]
elif [ "${patch:-0}" -gt 0 ]
then
tarName="${tarName}${versionSeparator}${patch}"
fi
;;
esac
fi
echo 1>&2
echo "Tar-file name: $tarName.tar" 1>&2
@ -470,7 +444,7 @@ case "$compress" in
(gz | gzip)
echo "Using gzip compression" 1>&2
echo 'gzip -f -9 "$outputDir/$tarName.tar"'
echo 'gzip -f9 "$outputDir/$tarName.tar"'
echo
echo '# End of compression'
;;
@ -485,21 +459,14 @@ case "$compress" in
(bz | bzip | bzip2)
echo "Using bzip2 compression" 1>&2
echo 'bzip2 -f -9 "$outputDir/$tarName.tar"'
echo 'bzip2 -f9 "$outputDir/$tarName.tar"'
echo
echo '# End of compression'
;;
(xz)
echo "Using xz compression" 1>&2
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 'xz -f9 "$outputDir/$tarName.tar"'
echo
echo '# End of compression'
;;

View File

@ -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=com
export WM_PROJECT_VERSION=v2012
#------------------------------------------------------------------------------
# Configuration environment variables.

View File

@ -44,7 +44,7 @@ coldAndHot
fire
{
// ParaView: Black-Body Radiation
interpolate rbg;
interpolate rgb;
table
(
@ -70,7 +70,7 @@ rainbow
greyscale
{
// ParaView: grayscale
interpolate rbg;
interpolate rgb;
table
(
@ -82,7 +82,7 @@ greyscale
xray
{
// ParaView: "X ray"
interpolate rbg;
interpolate rgb;
table
(

View File

@ -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, distributed under GPL-3.0-or-later.
@ -174,12 +174,13 @@ _foamAddPath "${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN}"
# Dummy versions of external libraries. To be found last in library path
_foamAddLib "$FOAM_LIBBIN/dummy"
# External (ThirdParty) libraries. Also allowed to be unset
if ( -d "$WM_THIRD_PARTY_DIR" ) then
# External (ThirdParty) libraries:
# - check if already compiled, or will be compiled.
# can also be unset
unsetenv FOAM_EXT_LIBBIN
if ( -d "$WM_THIRD_PARTY_DIR/platforms" || -f "$WM_THIRD_PARTY_DIR/Allwmake" ) then
setenv FOAM_EXT_LIBBIN "$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib"
_foamAddLib "$FOAM_EXT_LIBBIN"
else
unsetenv FOAM_EXT_LIBBIN
endif
# OpenFOAM libraries (user, group, standard)

View File

@ -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, distributed under GPL-3.0-or-later.
@ -174,13 +174,14 @@ _foamAddPath "$FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN"
# Dummy versions of external libraries. To be found last in library path
_foamAddLib "$FOAM_LIBBIN/dummy"
# External (ThirdParty) libraries. Also allowed to be unset
if [ -d "$WM_THIRD_PARTY_DIR" ]
# External (ThirdParty) libraries:
# - check if already compiled, or will be compiled.
# can also be unset
unset FOAM_EXT_LIBBIN
if [ -d "$WM_THIRD_PARTY_DIR/platforms" ] || [ -f "$WM_THIRD_PARTY_DIR/Allwmake" ]
then
export FOAM_EXT_LIBBIN="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib"
_foamAddLib "$FOAM_EXT_LIBBIN"
else
unset FOAM_EXT_LIBBIN
fi
# OpenFOAM libraries (user, group, standard)

View File

@ -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 com
setenv WM_PROJECT_VERSION v2012
#------------------------------------------------------------------------------
# Configuration environment variables.

View File

@ -12,7 +12,13 @@ targetType=libso
export FOAM_MODULE_PREFIX
echo "========================================"
echo "Compile OpenFOAM modules"
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
then
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
echo
exit 0
fi
echo "prefix = $FOAM_MODULE_PREFIX"
echo
echo " ignoring possible compilation errors"

View File

@ -161,7 +161,7 @@ public:
// + (numElem % elem_per_block) ? 1 : 0
// \endcode
// But avoiding the modulus operation
static constexpr label num_blocks(label numElem) noexcept
static constexpr label num_blocks(label numElem)
{
return ((numElem - 1 + elem_per_block) / elem_per_block);
}
@ -385,6 +385,10 @@ 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;
@ -395,16 +399,6 @@ 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
@ -525,7 +519,10 @@ public:
void assign(const PackedList<Width>& rhs) { (*this) = rhs; }
//- Alias for resize()
void setSize(const label n, unsigned int val = 0u) { resize(n, val); }
void setSize(const label len, unsigned int val = 0u)
{
resize(len, val);
}
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -548,21 +548,7 @@ inline Foam::label Foam::PackedList<Width>::nBlocks() const
template<unsigned Width>
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
inline std::streamsize Foam::PackedList<Width>::byteSize() const
{
return num_blocks(size()) * sizeof(block_type);
}
@ -577,7 +563,7 @@ inline void Foam::PackedList<Width>::swap(PackedList<Width>& rhs)
}
blocks_.swap(rhs.blocks_);
std::swap(size_, rhs.size_);
Foam::Swap(size_, rhs.size_);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2019 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.data()),
reinterpret_cast<char*>(list.storage().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.cdata()),
reinterpret_cast<const char*>(list.storage().cdata()),
list.byteSize()
);
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2019 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.cdata()),
reinterpret_cast<const char*>(list.storage().cdata()),
list.byteSize()
);
}

View File

@ -34,7 +34,7 @@ Foam::PtrListDictionary<T>::PtrListDictionary(const label size)
:
DictionaryBase<PtrList<T>, T>(2*size)
{
PtrList<T>::resize(size);
PtrList<T>::setSize(size);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 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>& other
CompactListList<T, Container>& lst
)
{
if (this == &other)
if (this == &lst)
{
return; // Self-swap is a no-op
}
std::swap(size_, other.size_);
offsets_.swap(other.offsets_);
m_.swap(other.m_);
Foam::Swap(size_, lst.size_);
offsets_.swap(lst.offsets_);
m_.swap(lst.m_);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -103,7 +103,7 @@ public:
// Constructors
//- Default construct
//- Null constructor.
inline CompactListList();
//- Construct by converting given List<List<T>>
@ -197,7 +197,7 @@ public:
labelList sizes() const;
//- Swap contents
void swap(CompactListList<T, Container>& other);
void swap(CompactListList<T, Container>& lst);
//- Transfer contents into this and annul the argument
void transfer(CompactListList<T, Container>& list);
@ -261,15 +261,13 @@ public:
};
// Note: uses default Foam::Swap (move construct/assignment)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "CompactListListI.H"
#include "CompactListListI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,6 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -38,7 +39,7 @@ Foam::label Foam::DynamicList<T, SizeMin>::removeElements
{
if (!slice.size())
{
// No-op
// Noop
return 0;
}
else if (slice.after() >= this->size())
@ -88,4 +89,40 @@ 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;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,10 +56,18 @@ namespace Foam
template<class T, int SizeMin> class DynamicList;
template<class T, int SizeMin>
inline Istream& operator>>(Istream&, DynamicList<T, SizeMin>&);
Ostream& operator<<
(
Ostream& os,
const DynamicList<T, SizeMin>& lst
);
template<class T, int SizeMin>
inline Ostream& operator<<(Ostream&, const DynamicList<T, SizeMin>&);
Istream& operator>>
(
Istream& is,
DynamicList<T, SizeMin>& lst
);
/*---------------------------------------------------------------------------*\
@ -87,25 +95,36 @@ 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& list);
inline void assignDynList(const ListType& lst);
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 len);
inline explicit DynamicList(const label nElem);
//- Construct with given size and value for all elements.
inline DynamicList(const label len, const T& val);
inline DynamicList(const label nElem, const T& val);
//- Construct with given size initializing all elements to zero
inline DynamicList(const label len, const Foam::zero);
inline DynamicList(const label nElem, const Foam::zero);
//- Copy construct.
inline DynamicList(const DynamicList<T, SizeMin>& lst);
@ -162,62 +181,64 @@ public:
inline label capacity() const noexcept;
// Sizing
// Edit
//- 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 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);
//- 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.
// 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 addressable size.
// New space will be allocated if required.
inline void resize(const label newLen);
//- Alter addressable list size and fill new space with constant.
inline void setSize(const label nElem, const T& val);
//- Alter addressable size and fill new space with constant value
inline void resize(const label newLen, const T& val);
//- 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);
//- Alias for resize()
void setSize(const label n) { this->resize(n); }
//- 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, const T& val) { this->resize(n, val); }
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size, use setCapacity() for that.
inline void reserve(const label nElem);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear() noexcept;
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear();
//- 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() noexcept;
//- Expand the addressable size to fit the allocated capacity.
// Returns the previous addressable size.
inline label expandStorage();
//- 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();
// Edit
//- Swap content, independent of sizing parameter
//- Swap content with any sized DynamicList
template<int AnySizeMin>
inline void swap(DynamicList<T, AnySizeMin>& other);
inline void swap(DynamicList<T, AnySizeMin>& lst);
//- Transfer contents of the argument List into this.
inline void transfer(List<T>& list);
inline void transfer(List<T>& lst);
//- Transfer contents of any sized DynamicList into this.
template<int AnySizeMin>
inline void transfer(DynamicList<T, AnySizeMin>& list);
inline void transfer(DynamicList<T, AnySizeMin>& lst);
//- Transfer contents of the argument SortableList into this.
inline void transfer(SortableList<T>& list);
inline void transfer(SortableList<T>& lst);
//- Append an element to the end of this list.
inline DynamicList<T, SizeMin>& append(const T& val);
@ -290,7 +311,8 @@ public:
// Member Operators
//- Return non-const access to an element, resizing list if needed
//- Return non-const access to an element,
//- resizing list if necessary
inline T& operator()(const label i);
//- Assignment of all addressed entries to the given value
@ -334,32 +356,29 @@ public:
inline void operator=(SortableList<T>&& lst);
// IOstream Operators
// IOstream operators
//- Read from Istream, discarding existing contents
friend Istream& operator>> <T, SizeMin>
(
Istream& is,
DynamicList<T, SizeMin>& rhs
);
// Write DynamicList to Ostream.
friend Ostream& operator<< <T, SizeMin>
(
Ostream& os,
const DynamicList<T, SizeMin>& lst
);
//- Write to Ostream
friend Ostream& operator<< <T, SizeMin>
(
Ostream& os,
const DynamicList<T, SizeMin>& rhs
);
//- Read from Istream, discarding contents of existing DynamicList.
friend Istream& operator>> <T, SizeMin>
(
Istream& is,
DynamicList<T, SizeMin>& lst
);
};
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
// Global Functions
// Exchange contents of lists - see DynamicList::swap().
template<class T, int SizeMinA, int SizeMinB>
inline void Swap(DynamicList<T, SizeMinA>& a, DynamicList<T, SizeMinB>& b)
{
a.swap(b);
}
template<class T, int SizeMin1, int SizeMin2>
inline void Swap(DynamicList<T, SizeMin1>& a, DynamicList<T, SizeMin2>& b);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,29 +28,29 @@ License
#include "FixedList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T, int SizeMin>
template<class ListType>
inline void Foam::DynamicList<T, SizeMin>::assignDynList
(
const ListType& list
const ListType& lst
)
{
const label newLen = list.size();
const label newSize = lst.size();
if (newLen <= capacity_)
if (capacity_ >= newSize)
{
// Can copy w/o reallocating - adjust addressable size accordingly.
List<T>::setAddressableSize(newLen);
List<T>::operator=(list);
List<T>::size(newSize);
List<T>::operator=(lst);
}
else
{
// Ensure list size consistency prior to copying.
List<T>::setAddressableSize(capacity_);
List<T>::size(capacity_);
List<T>::operator=(list);
List<T>::operator=(lst);
capacity_ = List<T>::size();
}
}
@ -61,29 +61,27 @@ 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 len)
inline Foam::DynamicList<T, SizeMin>::DynamicList(const label nElem)
:
List<T>(),
capacity_(0)
{
reserve(len);
reserve(nElem);
}
template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const label len,
const label nElem,
const T& val
)
:
List<T>(len, val),
List<T>(nElem, val),
capacity_(List<T>::size())
{}
@ -91,11 +89,11 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const label len,
const label nElem,
const Foam::zero
)
:
List<T>(len, Zero),
List<T>(nElem, Zero),
capacity_(List<T>::size())
{}
@ -103,10 +101,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const DynamicList<T, SizeMin>& list
const DynamicList<T, SizeMin>& lst
)
:
List<T>(list),
List<T>(lst),
capacity_(List<T>::size())
{}
@ -115,10 +113,10 @@ template<class T, int SizeMin>
template<int AnySizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const DynamicList<T, AnySizeMin>& list
const DynamicList<T, AnySizeMin>& lst
)
:
List<T>(list),
List<T>(lst),
capacity_(List<T>::size())
{}
@ -126,10 +124,10 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const UList<T>& list
const UList<T>& lst
)
:
List<T>(list),
List<T>(lst),
capacity_(List<T>::size())
{}
@ -138,12 +136,12 @@ template<class T, int SizeMin>
template<unsigned N>
inline Foam::DynamicList<T, SizeMin>::DynamicList
(
const FixedList<T, N>& list
const FixedList<T, N>& lst
)
:
capacity_(0)
{
this->operator=(list);
this->operator=(lst);
}
@ -220,14 +218,6 @@ 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>
@ -240,83 +230,124 @@ inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const noexcept
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::setCapacity
(
const label newCapacity
const label nElem
)
{
label currLen = List<T>::size();
capacity_ = newCapacity;
label nextFree = List<T>::size();
capacity_ = nElem;
if (currLen > capacity_)
if (nextFree > capacity_)
{
// Truncate addressed sizes too
currLen = capacity_;
nextFree = capacity_;
}
List<T>::resize(capacity_);
List<T>::setAddressableSize(currLen);
// We could also enforce sizing granularity
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::reserve
(
const label len
const label nElem
)
{
if (capacity_ < len)
// Allocate more capacity if necessary
if (nElem > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
capacity_ = max
(
SizeMin,
max
(
nElem,
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
label(2 * capacity_)
)
);
// Adjust allocated size, leave addressed size untouched
const label currLen = List<T>::size();
List<T>::resize(capacity_);
List<T>::setAddressableSize(currLen);
const label nextFree = List<T>::size();
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::resize
inline void Foam::DynamicList<T, SizeMin>::setSize
(
const label newLen
const label nElem
)
{
if (capacity_ < newLen)
// Allocate more capacity if necessary
if (nElem > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
capacity_ = max
(
SizeMin,
max
(
nElem,
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
label(2 * capacity_)
)
);
List<T>::resize(capacity_);
List<T>::setSize(capacity_);
}
// Adjust addressed size
List<T>::setAddressableSize(newLen);
List<T>::size(nElem);
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::setSize
(
const label nElem,
const T& val
)
{
label nextFree = List<T>::size();
setSize(nElem);
// Set new elements to constant value
while (nextFree < nElem)
{
this->operator[](nextFree++) = val;
}
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::resize
(
const label newLen,
const T& val
const label nElem
)
{
label currLen = List<T>::size();
resize(newLen);
// Fill newly exposed with constant value
while (currLen < newLen)
{
this->operator[](currLen++) = val;
}
this->setSize(nElem);
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::clear() noexcept
inline void Foam::DynamicList<T, SizeMin>::resize
(
const label nElem,
const T& val
)
{
List<T>::setAddressableSize(0);
this->setSize(nElem, val);
}
template<class T, int SizeMin>
inline void Foam::DynamicList<T, SizeMin>::clear()
{
List<T>::size(0);
}
@ -329,14 +360,14 @@ inline void Foam::DynamicList<T, SizeMin>::clearStorage()
template<class T, int SizeMin>
inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage() noexcept
inline Foam::label Foam::DynamicList<T, SizeMin>::expandStorage()
{
const label currLen = List<T>::size();
const label nextFree = List<T>::size();
// Allow addressing into the entire list
List<T>::setAddressableSize(capacity_);
List<T>::size(capacity_);
return currLen;
return nextFree;
}
@ -344,16 +375,16 @@ template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>&
Foam::DynamicList<T, SizeMin>::shrink()
{
const label currLen = List<T>::size();
if (currLen < capacity_)
const label nextFree = List<T>::size();
if (capacity_ > nextFree)
{
// Use the full list when resizing
List<T>::setAddressableSize(capacity_);
List<T>::size(capacity_);
// Capacity and size are identical
capacity_ = currLen;
List<T>::resize(currLen);
// Redundant: List<T>::setAddressableSize(currLen);
// The new size
capacity_ = nextFree;
List<T>::setSize(capacity_);
List<T>::size(nextFree);
}
return *this;
}
@ -363,30 +394,41 @@ template<class T, int SizeMin>
template<int AnySizeMin>
inline void Foam::DynamicList<T, SizeMin>::swap
(
DynamicList<T, AnySizeMin>& other
DynamicList<T, AnySizeMin>& lst
)
{
// Cannot compare 'this' for different types, so use cdata()
if (this->cdata() == other.cdata())
if (this->cdata() == lst.cdata())
{
return; // Self-swap is a no-op
}
// Swap storage and addressable size
UList<T>::swap(other);
DynamicList<T, SizeMin>& cur = *this;
// Swap capacity
std::swap(this->capacity_, other.capacity_);
// 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);
}
template<class T, int SizeMin>
inline void
Foam::DynamicList<T, SizeMin>::transfer(List<T>& list)
Foam::DynamicList<T, SizeMin>::transfer(List<T>& lst)
{
// Take over storage, clear addressing for list
capacity_ = list.size();
List<T>::transfer(list);
// Take over storage, clear addressing for lst.
capacity_ = lst.size();
List<T>::transfer(lst);
}
@ -395,21 +437,21 @@ template<int AnySizeMin>
inline void
Foam::DynamicList<T, SizeMin>::transfer
(
DynamicList<T, AnySizeMin>& list
DynamicList<T, AnySizeMin>& lst
)
{
// Cannot compare 'this' for different types, so use cdata()
if (this->cdata() == list.cdata())
if (this->cdata() == lst.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_ = list.capacity();
capacity_ = lst.capacity();
List<T>::transfer(static_cast<List<T>&>(list));
list.clearStorage(); // Ensure capacity=0
List<T>::transfer(static_cast<List<T>&>(lst));
lst.clearStorage(); // Ensure capacity=0
}
@ -417,12 +459,12 @@ template<class T, int SizeMin>
inline void
Foam::DynamicList<T, SizeMin>::transfer
(
SortableList<T>& list
SortableList<T>& lst
)
{
list.shrink(); // Shrink away sort indices
capacity_ = list.size(); // Capacity after transfer == list size
List<T>::transfer(list);
lst.shrink(); // Shrink away sort indices
capacity_ = lst.size(); // Capacity after transfer == list size
List<T>::transfer(lst);
}
@ -434,7 +476,7 @@ Foam::DynamicList<T, SizeMin>::append
)
{
const label idx = List<T>::size();
resize(idx + 1);
setSize(idx + 1);
this->operator[](idx) = val; // copy element
return *this;
@ -449,7 +491,7 @@ Foam::DynamicList<T, SizeMin>::append
)
{
const label idx = List<T>::size();
resize(idx + 1);
setSize(idx + 1);
this->operator[](idx) = std::move(val); // move assign element
return *this;
@ -466,12 +508,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();
resize(idx + lst.size());
setSize(idx + lst.size());
for (const T& val : lst)
{
@ -490,7 +532,7 @@ Foam::DynamicList<T, SizeMin>::append
)
{
label idx = List<T>::size();
resize(idx + lst.size());
setSize(idx + lst.size());
for (const T& val : lst)
{
@ -508,7 +550,8 @@ Foam::DynamicList<T, SizeMin>::append
)
{
label idx = List<T>::size();
resize(idx + lst.size());
setSize(idx + lst.size());
for (const T& val : lst)
{
@ -529,7 +572,7 @@ Foam::DynamicList<T, SizeMin>::append
label idx = List<T>::size();
const label n = lst.size();
resize(idx + n);
setSize(idx + n);
for (label i=0; i<n; ++i)
{
@ -543,25 +586,25 @@ template<class T, int SizeMin>
inline Foam::DynamicList<T, SizeMin>&
Foam::DynamicList<T, SizeMin>::append
(
List<T>&& list
List<T>&& lst
)
{
if (this == &list)
if (this == &lst)
{
FatalErrorInFunction
<< "Attempted appending to self"
<< abort(FatalError);
<< "Attempted appending to self" << abort(FatalError);
}
label idx = List<T>::size();
resize(idx + list.size());
for (T& val : list)
setSize(idx + lst.size());
for (T& val : lst)
{
Foam::Swap(this->operator[](idx++), val); // moved content
}
list.clear();
lst.clear();
return *this;
}
@ -620,7 +663,7 @@ inline T Foam::DynamicList<T, SizeMin>::remove()
const T& val = List<T>::operator[](idx);
List<T>::setAddressableSize(idx);
List<T>::size(idx);
return val;
}
@ -699,7 +742,7 @@ inline T& Foam::DynamicList<T, SizeMin>::operator()
{
if (i >= List<T>::size())
{
resize(i + 1);
setSize(i + 1);
}
return this->operator[](i);
@ -745,7 +788,7 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
{
const label n = lst.size();
resize(n);
setSize(n);
for (label i=0; i<n; ++i)
{
@ -863,34 +906,16 @@ inline void Foam::DynamicList<T, SizeMin>::operator=
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class T, int SizeMin>
inline Foam::Istream& Foam::operator>>
template<class T, int SizeMin1, int SizeMin2>
inline void Foam::Swap
(
Istream& is,
DynamicList<T, SizeMin>& rhs
DynamicList<T, SizeMin1>& a,
DynamicList<T, SizeMin2>& 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;
a.swap(b);
}

View File

@ -31,20 +31,6 @@ 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
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -216,8 +216,6 @@ 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
@ -281,7 +279,7 @@ public:
inline void resize(const label n);
//- Dummy function, to make FixedList consistent with List
void setSize(const label n) { this->resize(n); }
inline void setSize(const label n);
//- Assign all entries to the given value
inline void fill(const T& val);
@ -342,25 +340,25 @@ public:
// Random access iterator (non-const)
//- Return an iterator to begin traversing the FixedList
inline iterator begin() noexcept;
inline iterator begin();
//- Return an iterator to end traversing the FixedList
inline iterator end() noexcept;
inline iterator end();
// Random access iterator (const)
//- Return const_iterator to begin traversing the constant FixedList
inline const_iterator cbegin() const noexcept;
inline const_iterator cbegin() const;
//- Return const_iterator to end traversing the constant FixedList
inline const_iterator cend() const noexcept;
inline const_iterator cend() const;
//- Return const_iterator to begin traversing the constant FixedList
inline const_iterator begin() const noexcept;
inline const_iterator begin() const;
//- Return const_iterator to end traversing the constant FixedList
inline const_iterator end() const noexcept;
inline const_iterator end() const;
// Reverse iterator (non-const)
@ -399,7 +397,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>& other);
inline void swap(FixedList<T, N>& list);
// STL Member Operators
@ -491,12 +489,9 @@ struct is_contiguous_scalar<FixedList<T, N>> : is_contiguous_scalar<T> {};
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
//- Swap FixedList contents - see FixedList::swap().
// Internally actually swaps the individual list elements
// Internally this actually swaps the individual list elements
template<class T, unsigned N>
inline void Swap(FixedList<T, N>& a, FixedList<T, N>& b)
{
a.swap(b);
}
inline void Swap(FixedList<T, N>& lhs, FixedList<T, N>& rhs);
//- Hashing for FixedList data, which uses Hasher for contiguous data and

View File

@ -327,6 +327,15 @@ 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)
{
@ -348,16 +357,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>& other)
inline void Foam::FixedList<T, N>::swap(FixedList<T, N>& list)
{
if (this == &other)
if (this == &list)
{
return; // Self-swap is a no-op
}
for (unsigned i=0; i<N; ++i)
{
Foam::Swap(v_[i], other.v_[i]);
Foam::Swap(v_[i], list.v_[i]);
}
}
@ -481,6 +490,8 @@ 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]);
@ -492,7 +503,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() noexcept
Foam::FixedList<T, N>::begin()
{
return v_;
}
@ -500,7 +511,7 @@ Foam::FixedList<T, N>::begin() noexcept
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::begin() const noexcept
Foam::FixedList<T, N>::begin() const
{
return v_;
}
@ -508,7 +519,7 @@ Foam::FixedList<T, N>::begin() const noexcept
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::cbegin() const noexcept
Foam::FixedList<T, N>::cbegin() const
{
return v_;
}
@ -516,7 +527,7 @@ Foam::FixedList<T, N>::cbegin() const noexcept
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::iterator
Foam::FixedList<T, N>::end() noexcept
Foam::FixedList<T, N>::end()
{
return (v_ + N);
}
@ -524,7 +535,7 @@ Foam::FixedList<T, N>::end() noexcept
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::end() const noexcept
Foam::FixedList<T, N>::end() const
{
return (v_ + N);
}
@ -532,7 +543,7 @@ Foam::FixedList<T, N>::end() const noexcept
template<class T, unsigned N>
inline typename Foam::FixedList<T, N>::const_iterator
Foam::FixedList<T, N>::cend() const noexcept
Foam::FixedList<T, N>::cend() const
{
return (v_ + N);
}
@ -586,4 +597,13 @@ 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);
}
// ************************************************************************* //

View File

@ -50,6 +50,7 @@ void Foam::List<T>::doResize(const label newSize)
{
if (newSize > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
T* nv = new T[newSize];
const label overlap = min(this->size_, newSize);

View File

@ -93,7 +93,7 @@ class List
template<class List2>
inline void copyList(const List2& list);
//- Change allocation size - backend for resize.
//- Change allocation size of List. Backend for resize/setSize.
void doResize(const label newSize);
//- Construct given begin/end iterators and number of elements
@ -123,7 +123,7 @@ public:
// Constructors
//- Default construct
//- Null constructor
inline constexpr List() noexcept;
//- Construct with given size
@ -208,27 +208,24 @@ 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);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,8 +31,9 @@ License
template<class T>
inline void Foam::List<T>::doAlloc()
{
if (this->size_)
if (this->size_ > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
this->v_ = new T[this->size_];
}
}
@ -128,17 +129,31 @@ namespace Foam
{
// Template specialization for bool. Fills with false
template<>
inline void List<bool>::resize(const label newLen)
inline void List<bool>::resize(const label newSize)
{
this->resize(newLen, false);
this->resize(newSize, false);
}
}
template<class T>
inline void Foam::List<T>::resize(const label newLen)
inline void Foam::List<T>::resize(const label len)
{
this->doResize(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);
}

View File

@ -213,8 +213,8 @@ Foam::PackedList<Width> Foam::reorder
}
// Verify addresses (for movable refs)
// Info<< "reordered in " << name(input.cdata()) << nl
// << "reordered out " << name(output.cdata()) << nl;
// Info<< "reordered in " << name(input.storage().cdata()) << nl
// << "reordered out " << name(output.storage().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.cdata()) << nl;
// Info<< "now have " << name(input.storage().cdata()) << nl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 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>& other)
void Foam::SortableList<T>::swap(SortableList<T>& lst)
{
if (this == &other)
if (this == &lst)
{
return; // Self-swap is a no-op
}
List<T>::swap(other);
indices_.swap(other.indices_);
List<T>::swap(lst);
indices_.swap(lst.indices_);
}
@ -267,4 +267,13 @@ 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);
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -72,7 +72,7 @@ public:
// Constructors
//- Default construct
//- Null constructor, sort later (eg, after assignment or transfer)
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>& other);
inline void swap(SortableList<T>& lst);
// Member Operators
@ -160,22 +160,20 @@ public:
//- Move assignment, removing indices. Takes linear time
inline void operator=(List<T>&& lst);
//- Move operator (constant time)
//- Move operator. Takes linear 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)
{
a.swap(b);
}
inline void Swap(SortableList<T>& a, SortableList<T>& b);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -193,7 +193,7 @@ std::streamsize Foam::UList<T>::byteSize() const
if (!is_contiguous<T>::value)
{
FatalErrorInFunction
<< "Invalid for non-contiguous data types"
<< "Cannot return binary size of a list with non-primitive elements"
<< abort(FatalError);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,13 +101,9 @@ protected:
// Protected Member Functions
//- Set addressed size to be inconsistent with allocated storage.
//- Override size to be inconsistent with allocated storage.
// Use with care
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); }
inline void size(const label n) noexcept;
//- Write the UList with its compound type
void writeEntry(Ostream& os) const;
@ -252,15 +248,22 @@ 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 noexcept;
inline const T* cdata() const;
//- 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() noexcept;
inline T* data();
//- Return the first element of the list
inline T& first();
@ -274,10 +277,6 @@ 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
@ -372,25 +371,25 @@ public:
// Random access iterator (non-const)
//- Return an iterator to begin traversing the UList
inline iterator begin() noexcept;
inline iterator begin();
//- Return an iterator to end traversing the UList
inline iterator end() noexcept;
inline iterator end();
// Random access iterator (const)
//- Return const_iterator to begin traversing the constant UList
inline const_iterator cbegin() const noexcept;
inline const_iterator cbegin() const;
//- Return const_iterator to end traversing the constant UList
inline const_iterator cend() const noexcept;
inline const_iterator cend() const;
//- Return const_iterator to begin traversing the constant UList
inline const_iterator begin() const noexcept;
inline const_iterator begin() const;
//- Return const_iterator to end traversing the constant UList
inline const_iterator end() const noexcept;
inline const_iterator end() const;
// Reverse iterators (non-const)
@ -583,12 +582,9 @@ 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)
{
a.swap(b);
}
inline void Swap(UList<T>& a, UList<T>& b);
//- Hashing for UList data, which uses Hasher for contiguous data and

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -28,6 +28,7 @@ License
#include "error.H"
#include "pTraits.H"
#include "Swap.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -194,14 +195,14 @@ inline const T& Foam::UList<T>::last() const
template<class T>
inline const T* Foam::UList<T>::cdata() const noexcept
inline const T* Foam::UList<T>::cdata() const
{
return v_;
}
template<class T>
inline T* Foam::UList<T>::data() noexcept
inline T* Foam::UList<T>::data()
{
return v_;
}
@ -272,42 +273,42 @@ inline Foam::UList<T>::operator const Foam::List<T>&() const
template<class T>
inline typename Foam::UList<T>::iterator
Foam::UList<T>::begin() noexcept
Foam::UList<T>::begin()
{
return v_;
}
template<class T>
inline typename Foam::UList<T>::const_iterator
Foam::UList<T>::begin() const noexcept
Foam::UList<T>::begin() const
{
return v_;
}
template<class T>
inline typename Foam::UList<T>::const_iterator
Foam::UList<T>::cbegin() const noexcept
Foam::UList<T>::cbegin() const
{
return v_;
}
template<class T>
inline typename Foam::UList<T>::iterator
Foam::UList<T>::end() noexcept
Foam::UList<T>::end()
{
return (v_ + size_);
}
template<class T>
inline typename Foam::UList<T>::const_iterator
Foam::UList<T>::end() const noexcept
Foam::UList<T>::end() const
{
return (v_ + size_);
}
template<class T>
inline typename Foam::UList<T>::const_iterator
Foam::UList<T>::cend() const noexcept
Foam::UList<T>::cend() const
{
return (v_ + size_);
}
@ -356,7 +357,7 @@ Foam::UList<T>::crend() const
template<class T>
inline void Foam::UList<T>::setAddressableSize(const label n) noexcept
inline void Foam::UList<T>::size(const label n) noexcept
{
size_ = n;
}
@ -384,8 +385,8 @@ inline void Foam::UList<T>::swap(UList<T>& list)
return; // Self-swap is a no-op
}
std::swap(size_, list.size_);
std::swap(v_, list.v_);
Foam::Swap(size_, list.size_);
Foam::Swap(v_, list.v_);
}
@ -408,4 +409,11 @@ inline void Foam::reverse(UList<T>& list)
}
template<class T>
inline void Foam::Swap(UList<T>& a, UList<T>& b)
{
a.swap(b);
}
// ************************************************************************* //

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -71,11 +71,17 @@ class PtrDynList
label capacity_;
// Private Member Functions
//- Adjust addressable size
void setAddressableSize(const label len);
public:
// Constructors
//- Default construct
//- Construct null
inline constexpr PtrDynList() noexcept;
//- Construct with given capacity.
@ -112,20 +118,23 @@ public:
const T* set(const label i) const { return this->get(i); }
// Sizing
// Edit
//- Delete the allocated entries, but retain the list size.
using PtrList<T>::free;
//- Alter the size of the underlying storage.
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);
inline void setCapacity(const label nElem);
//- Alter the addressed list size.
inline void resize(const label newLen);
//- Same as resize()
void setSize(const label n) { this->resize(n); }
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);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
@ -136,26 +145,16 @@ public:
//- Expand the addressable size to fit the allocated capacity.
// Returns the previous addressable size.
inline label expandStorage() noexcept;
inline label expandStorage();
//- 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);
@ -235,6 +234,7 @@ public:
//- Move assignment with different sizing parameters
template<int AnySizeMin>
inline void operator=(PtrDynList<T, AnySizeMin>&& list);
};

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,6 +29,15 @@ 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>
@ -45,7 +54,7 @@ inline Foam::PtrDynList<T, SizeMin>::PtrDynList(const label len)
PtrList<T>(len),
capacity_(len)
{
PtrList<T>::setAddressableSize(0);
setAddressableSize(0);
}
@ -98,34 +107,35 @@ 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 newCapacity)
inline void Foam::PtrDynList<T, SizeMin>::setCapacity(const label nElem)
{
label currLen = PtrList<T>::size();
capacity_ = newCapacity;
label nextFree = PtrList<T>::size();
capacity_ = nElem;
if (currLen > capacity_)
if (nextFree > capacity_)
{
// Truncate addressed sizes too
currLen = capacity_;
nextFree = capacity_;
}
PtrList<T>::resize(capacity_);
PtrList<T>::setAddressableSize(currLen);
setAddressableSize(nextFree);
}
template<class T, int SizeMin>
inline void Foam::PtrDynList<T, SizeMin>::reserve(const label len)
inline void Foam::PtrDynList<T, SizeMin>::reserve(const label nElem)
{
if (capacity_ < len)
if (nElem > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
// Allocate more capacity if necessary
capacity_ = max(SizeMin, max(nElem, label(2*capacity_)));
// Adjust allocated size, leave addressed size untouched
const label currLen = PtrList<T>::size();
const label nextFree = PtrList<T>::size();
PtrList<T>::resize(capacity_);
PtrList<T>::setAddressableSize(currLen);
setAddressableSize(nextFree);
}
}
@ -137,25 +147,31 @@ inline void Foam::PtrDynList<T, SizeMin>::resize(const label newLen)
const label oldLen = ptrs.size();
if (capacity_ < newLen)
if (newLen > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
// Allocate more capacity if necessary
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;
}
}
// Adjust addressed size
PtrList<T>::setAddressableSize(newLen);
setAddressableSize(newLen);
}
template<class T, int SizeMin>
inline void Foam::PtrDynList<T, SizeMin>::setSize(const label newLen)
{
this->resize(newLen);
}
@ -163,7 +179,7 @@ template<class T, int SizeMin>
inline void Foam::PtrDynList<T, SizeMin>::clear()
{
(this->ptrs_).free(); // free old pointers
PtrList<T>::setAddressableSize(0);
setAddressableSize(0);
}
@ -176,30 +192,30 @@ inline void Foam::PtrDynList<T, SizeMin>::clearStorage()
template<class T, int SizeMin>
inline Foam::label Foam::PtrDynList<T, SizeMin>::expandStorage() noexcept
inline Foam::label Foam::PtrDynList<T, SizeMin>::expandStorage()
{
const label currLen = PtrList<T>::size();
const label nextFree = PtrList<T>::size();
// Allow addressing into the entire list
PtrList<T>::setAddressableSize(capacity_);
setAddressableSize(capacity_);
return currLen;
return nextFree;
}
template<class T, int SizeMin>
inline void Foam::PtrDynList<T, SizeMin>::shrink()
{
const label currLen = PtrList<T>::size();
if (currLen < capacity_)
label nextFree = PtrList<T>::size();
if (capacity_ > nextFree)
{
// Use the full list when resizing
PtrList<T>::setAddressableSize(capacity_);
setAddressableSize(capacity_);
// Capacity and size are identical
capacity_ = currLen;
PtrList<T>::resize(currLen);
// Redundant: PtrList<T>::setAddressableSize(currLen);
// The new size
capacity_ = nextFree;
PtrList<T>::resize(capacity_);
setAddressableSize(nextFree);
}
}
@ -213,27 +229,6 @@ 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)
@ -337,7 +332,7 @@ inline Foam::autoPtr<T> Foam::PtrDynList<T, SizeMin>::remove()
autoPtr<T> old(this->ptrs_[idx]);
this->ptrs_[idx] = nullptr;
PtrList<T>::setAddressableSize(idx);
setAddressableSize(idx);
return old;
}

View File

@ -149,7 +149,7 @@ public:
void resize(const label newLen);
//- Same as resize()
void setSize(const label newLen) { this->resize(newLen); }
inline void setSize(const label newLen);
//- Construct and append an element to the end of the list
template<class... Args>

View File

@ -101,6 +101,13 @@ 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)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 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);
//- Set addressed size to be inconsistent with allocated storage.
//- Override size to be inconsistent with allocated storage.
// Use with care
inline void setAddressableSize(const label n) noexcept;
inline void setAddressableSize(const label n);
//- Write output, optionally silently trimming nullptrs
Ostream& write(Ostream& os, const bool trimNull=false) const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -85,12 +85,9 @@ inline Foam::Detail::PtrListDetail<T>::PtrListDetail
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline void Foam::Detail::PtrListDetail<T>::setAddressableSize
(
const label n
) noexcept
inline void Foam::Detail::PtrListDetail<T>::setAddressableSize(const label n)
{
List<T*>::setAddressableSize(n);
List<T*>::size(n);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -78,16 +78,10 @@ protected:
Detail::PtrListDetail<T> ptrs_;
// Protected Member Functions
//- Adjust addressable size
inline void setAddressableSize(const label n) noexcept;
// Constructors
//- Low-level move construct
inline explicit UPtrList(Detail::PtrListDetail<T>&& ptrs);
inline UPtrList(Detail::PtrListDetail<T>&& ptrs);
public:
@ -164,15 +158,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); }
@ -182,12 +176,12 @@ public:
//- Set list size to zero.
inline void clear();
//- Change the size of the list.
//- Reset size of list.
// New entries are initialized to nullptr.
inline void resize(const label newLen);
//- Alias for resize()
void setSize(const label n) { this->resize(n); }
//- Same as resize()
inline void setSize(const label newLen);
//- Squeeze out intermediate nullptr entries in the list of pointers
// \return the number of non-null entries
@ -241,7 +235,6 @@ public:
//- Random-access iterator with non-const access
class iterator
{
// Pointer to parent
T** ptr_;
public:
@ -254,52 +247,51 @@ public:
friend class const_iterator;
//- Construct for a given entry
inline iterator(T** ptr) noexcept;
inline iterator(T** ptr);
// Member Functions
// Member functions
//- Return pointer, can be nullptr.
inline pointer get() const;
// Member Operators
// Member operators
inline bool operator==(const iterator& iter) const;
inline bool operator!=(const iterator& iter) const;
inline pointer operator->() const;
inline reference operator*() const;
reference operator()() const { return this->operator*(); }
inline reference operator[](difference_type n) const;
inline reference operator()() const;
// Forward iteration
inline iterator& operator++() noexcept;
inline iterator operator++(int) noexcept;
inline iterator& operator++();
inline iterator operator++(int);
inline iterator& operator--() noexcept;
inline iterator operator--(int) noexcept;
inline iterator& operator--();
inline iterator operator--(int);
// 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 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 noexcept;
inline difference_type operator-(const iterator& iter) const;
inline bool operator==(const iterator& iter) const noexcept;
inline bool operator!=(const iterator& iter) const noexcept;
inline reference operator[](difference_type n) const;
inline bool operator<(const iterator& iter) const noexcept;
inline bool operator>(const iterator& iter) const noexcept;
inline bool operator<(const iterator& iter) const;
inline bool operator>(const iterator& iter) const;
inline bool operator<=(const iterator& iter) const noexcept;
inline bool operator>=(const iterator& iter) const noexcept;
inline bool operator<=(const iterator& iter) const;
inline bool operator>=(const iterator& iter) const;
};
//- Random-access iterator with const access
class const_iterator
{
// Pointer to parent
const T* const* ptr_;
public:
@ -311,68 +303,68 @@ public:
using reference = const T&;
//- Construct for a given entry
inline const_iterator(const T* const* ptr) noexcept;
inline const_iterator(const T* const* ptr);
//- Copy construct from non-const iterator
inline const_iterator(const iterator& iter) noexcept;
inline const_iterator(const iterator& iter);
// Member Functions
// Member functions
//- Return pointer, can be nullptr.
inline pointer get() const;
// Member Operators
// Member operators
inline bool operator==(const const_iterator& iter) const;
inline bool operator!=(const const_iterator& iter) const;
inline pointer operator->() const;
inline reference operator*() const;
reference operator()() const { return this->operator*(); }
inline reference operator[](difference_type n) const;
inline reference operator()() const;
// Forward iteration
inline const_iterator& operator++() noexcept;
inline const_iterator operator++(int) noexcept;
inline const_iterator& operator++();
inline const_iterator operator++(int);
inline const_iterator& operator--() noexcept;
inline const_iterator operator--(int) noexcept;
inline const_iterator& operator--();
inline const_iterator operator--(int);
// 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 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 noexcept;
inline difference_type operator-(const const_iterator& iter) const;
inline bool operator==(const const_iterator& iter) const noexcept;
inline bool operator!=(const const_iterator& iter) const noexcept;
inline reference operator[](difference_type n) const;
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;
inline bool operator>(const const_iterator& iter) const;
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;
inline bool operator>=(const const_iterator& iter) const;
};
//- Return an iterator to begin traversing the UPtrList
inline iterator begin() noexcept;
inline iterator begin();
//- Return an iterator to end traversing the UPtrList
inline iterator end() noexcept;
inline iterator end();
//- Return an const_iterator to begin traversing the UPtrList
inline const_iterator cbegin() const noexcept;
inline const_iterator cbegin() const;
//- Return an const_iterator to end traversing the UPtrList
inline const_iterator cend() const noexcept;
inline const_iterator cend() const;
//- Return an const_iterator to begin traversing the UPtrList
inline const_iterator begin() const noexcept;
inline const_iterator begin() const;
//- Return an const_iterator to end traversing the UPtrList
inline const_iterator end() const noexcept;
inline const_iterator end() const;
// IOstream operator
@ -383,6 +375,7 @@ public:
Ostream& os,
const UPtrList<T>& list
);
};

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,15 +26,6 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T>
inline void Foam::UPtrList<T>::setAddressableSize(const label n) noexcept
{
ptrs_.setAddressableSize(n);
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T>
@ -186,6 +177,13 @@ 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)
{
@ -254,8 +252,7 @@ inline const T* Foam::UPtrList<T>::operator()(const label i) const
// * * * * * * * * * * * * * * * * iterator * * * * * * * * * * * * * * * * //
template<class T>
inline Foam::UPtrList<T>::iterator::
iterator(T** ptr) noexcept
inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
:
ptr_(ptr)
{}
@ -268,6 +265,20 @@ 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
{
@ -283,14 +294,15 @@ inline T& Foam::UPtrList<T>::iterator::operator*() const
template<class T>
inline T& Foam::UPtrList<T>::iterator::operator[](label n) const
inline T& Foam::UPtrList<T>::iterator::operator()() const
{
return **(ptr_ + n);
return **ptr_;
}
template<class T>
inline typename Foam::UPtrList<T>::iterator&
Foam::UPtrList<T>::iterator::operator++() noexcept
Foam::UPtrList<T>::iterator::operator++()
{
++ptr_;
return *this;
@ -299,7 +311,7 @@ Foam::UPtrList<T>::iterator::operator++() noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::iterator::operator++(int) noexcept
Foam::UPtrList<T>::iterator::operator++(int)
{
iterator iter(*this);
++ptr_;
@ -309,7 +321,7 @@ Foam::UPtrList<T>::iterator::operator++(int) noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator&
Foam::UPtrList<T>::iterator::operator--() noexcept
Foam::UPtrList<T>::iterator::operator--()
{
--ptr_;
return *this;
@ -318,7 +330,7 @@ Foam::UPtrList<T>::iterator::operator--() noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::iterator::operator--(int) noexcept
Foam::UPtrList<T>::iterator::operator--(int)
{
iterator iter(*this);
--ptr_;
@ -328,7 +340,7 @@ Foam::UPtrList<T>::iterator::operator--(int) noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator&
Foam::UPtrList<T>::iterator::operator+=(label n) noexcept
Foam::UPtrList<T>::iterator::operator+=(label n)
{
ptr_ += n;
return *this;
@ -337,7 +349,7 @@ Foam::UPtrList<T>::iterator::operator+=(label n) noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator&
Foam::UPtrList<T>::iterator::operator-=(label n) noexcept
Foam::UPtrList<T>::iterator::operator-=(label n)
{
ptr_ -= n;
return *this;
@ -346,7 +358,7 @@ Foam::UPtrList<T>::iterator::operator-=(label n) noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::iterator::operator+(label n) const noexcept
Foam::UPtrList<T>::iterator::operator+(label n) const
{
return iterator(ptr_ + n);
}
@ -354,7 +366,7 @@ Foam::UPtrList<T>::iterator::operator+(label n) const noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::iterator::operator-(label n) const noexcept
Foam::UPtrList<T>::iterator::operator-(label n) const
{
return iterator(ptr_ - n);
}
@ -362,56 +374,42 @@ Foam::UPtrList<T>::iterator::operator-(label n) const noexcept
template<class T>
inline Foam::label
Foam::UPtrList<T>::iterator::
operator-(const iterator& iter) const noexcept
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 noexcept
inline T& Foam::UPtrList<T>::iterator::operator[](label n) const
{
return ptr_ == iter.ptr_;
return *(*this + n);
}
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 noexcept
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 noexcept
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 noexcept
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 noexcept
inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
{
return ptr_ >= iter.ptr_;
}
@ -420,16 +418,14 @@ operator>=(const iterator& iter) const noexcept
// * * * * * * * * * * * * * * * const_iterator * * * * * * * * * * * * * * //
template<class T>
inline Foam::UPtrList<T>::const_iterator::
const_iterator(const T* const* ptr) noexcept
inline Foam::UPtrList<T>::const_iterator::const_iterator(const T* const* ptr)
:
ptr_(ptr)
{}
template<class T>
inline Foam::UPtrList<T>::const_iterator::
const_iterator(const iterator& iter) noexcept
inline Foam::UPtrList<T>::const_iterator::const_iterator(const iterator& iter)
:
ptr_(iter.ptr_)
{}
@ -442,6 +438,26 @@ 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
{
@ -457,16 +473,15 @@ inline const T& Foam::UPtrList<T>::const_iterator::operator*() const
template<class T>
inline const T&
Foam::UPtrList<T>::const_iterator::operator[](label n) const
inline const T& Foam::UPtrList<T>::const_iterator::operator()() const
{
return **(ptr_ + n);
return **ptr_;
}
template<class T>
inline typename Foam::UPtrList<T>::const_iterator&
Foam::UPtrList<T>::const_iterator::operator++() noexcept
Foam::UPtrList<T>::const_iterator::operator++()
{
++ptr_;
return *this;
@ -475,7 +490,7 @@ Foam::UPtrList<T>::const_iterator::operator++() noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::const_iterator::operator++(int) noexcept
Foam::UPtrList<T>::const_iterator::operator++(int)
{
const_iterator iter(*this);
++ptr_;
@ -485,7 +500,7 @@ Foam::UPtrList<T>::const_iterator::operator++(int) noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator&
Foam::UPtrList<T>::const_iterator::operator--() noexcept
Foam::UPtrList<T>::const_iterator::operator--()
{
--ptr_;
return *this;
@ -494,7 +509,7 @@ Foam::UPtrList<T>::const_iterator::operator--() noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::const_iterator::operator--(int) noexcept
Foam::UPtrList<T>::const_iterator::operator--(int)
{
const_iterator iter(*this);
--ptr_;
@ -504,7 +519,7 @@ Foam::UPtrList<T>::const_iterator::operator--(int) noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator&
Foam::UPtrList<T>::const_iterator::operator+=(label n) noexcept
Foam::UPtrList<T>::const_iterator::operator+=(label n)
{
ptr_ += n;
return *this;
@ -513,7 +528,7 @@ Foam::UPtrList<T>::const_iterator::operator+=(label n) noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator&
Foam::UPtrList<T>::const_iterator::operator-=(label n) noexcept
Foam::UPtrList<T>::const_iterator::operator-=(label n)
{
ptr_ -= n;
return *this;
@ -522,7 +537,7 @@ Foam::UPtrList<T>::const_iterator::operator-=(label n) noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::const_iterator::operator+(label n) const noexcept
Foam::UPtrList<T>::const_iterator::operator+(label n) const
{
return const_iterator(ptr_ + n);
}
@ -530,7 +545,7 @@ Foam::UPtrList<T>::const_iterator::operator+(label n) const noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::const_iterator::operator-(label n) const noexcept
Foam::UPtrList<T>::const_iterator::operator-(label n) const
{
return const_iterator(ptr_ - n);
}
@ -538,56 +553,55 @@ Foam::UPtrList<T>::const_iterator::operator-(label n) const noexcept
template<class T>
inline Foam::label
Foam::UPtrList<T>::const_iterator::
operator-(const const_iterator& iter) const noexcept
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 noexcept
inline const T&
Foam::UPtrList<T>::const_iterator::operator[](label n) const
{
return ptr_ == iter.ptr_;
return *(*this + n);
}
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 noexcept
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 noexcept
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 noexcept
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 noexcept
inline bool Foam::UPtrList<T>::const_iterator::operator>=
(
const const_iterator& iter
) const
{
return ptr_ >= iter.ptr_;
}
@ -597,7 +611,7 @@ operator>=(const const_iterator& iter) const noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::begin() noexcept
Foam::UPtrList<T>::begin()
{
return ptrs_.begin();
}
@ -605,7 +619,7 @@ Foam::UPtrList<T>::begin() noexcept
template<class T>
inline typename Foam::UPtrList<T>::iterator
Foam::UPtrList<T>::end() noexcept
Foam::UPtrList<T>::end()
{
return ptrs_.end();
}
@ -613,7 +627,7 @@ Foam::UPtrList<T>::end() noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::cbegin() const noexcept
Foam::UPtrList<T>::cbegin() const
{
return ptrs_.cbegin();
}
@ -621,7 +635,7 @@ Foam::UPtrList<T>::cbegin() const noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::cend() const noexcept
Foam::UPtrList<T>::cend() const
{
return ptrs_.cend();
}
@ -629,7 +643,7 @@ Foam::UPtrList<T>::cend() const noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::begin() const noexcept
Foam::UPtrList<T>::begin() const
{
return ptrs_.begin();
}
@ -637,7 +651,7 @@ Foam::UPtrList<T>::begin() const noexcept
template<class T>
inline typename Foam::UPtrList<T>::const_iterator
Foam::UPtrList<T>::end() const noexcept
Foam::UPtrList<T>::end() const
{
return ptrs_.end();
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -511,8 +511,8 @@ public:
// Writing
//- Write the standard OpenFOAM file/dictionary banner
// Optionally without editor syntax hint (eg, for logs)
static Ostream& writeBanner(Ostream& os, const bool noSyntaxHint=false);
// Optionally without -*- C++ -*- editor hint (eg, for logs)
static Ostream& writeBanner(Ostream& os, bool noHint=false);
//- Write the standard file section divider
static Ostream& writeDivider(Ostream& os);
@ -520,17 +520,11 @@ public:
//- Write the standard end file divider
static Ostream& writeEndDivider(Ostream& os);
//- Write header with current type() and arch information
//- Write header
bool writeHeader(Ostream& os) 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;
//- Write header. Allow override of type
bool writeHeader(Ostream& os, const word& objectType) const;
// Error Handling

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,8 +42,7 @@ License
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Foam::Ostream&
Foam::IOobject::writeBanner(Ostream& os, const bool noSyntaxHint)
Foam::Ostream& Foam::IOobject::writeBanner(Ostream& os, bool noHint)
{
// The version padded with spaces to fit after "Version: "
// - initialized with zero-length string to detect if it has been populated
@ -67,7 +66,7 @@ Foam::IOobject::writeBanner(Ostream& os, const bool noSyntaxHint)
os <<
"/*--------------------------------";
if (noSyntaxHint)
if (noHint)
{
// Without syntax hint
os << "---------";
@ -117,12 +116,7 @@ Foam::Ostream& Foam::IOobject::writeEndDivider(Ostream& os)
}
bool Foam::IOobject::writeHeader
(
Ostream& os,
const word& objectType,
const bool noArchAscii
) const
bool Foam::IOobject::writeHeader(Ostream& os, const word& type) const
{
if (!os.good())
{
@ -133,37 +127,25 @@ bool Foam::IOobject::writeHeader
return false;
}
IOobject::writeBanner(os)
<< "FoamFile" << nl
<< '{' << nl
<< " version " << os.version() << ';' << nl
<< " format " << os.format() << ';' << nl;
writeBanner(os)
<< "FoamFile\n{\n"
<< " version " << os.version() << ";\n"
<< " format " << os.format() << ";\n"
<< " class " << type << ";\n";
if (os.format() == IOstream::BINARY || !noArchAscii)
if (os.format() == IOstream::BINARY)
{
// Arch information (BINARY: always, ASCII: can disable)
os << " arch " << foamVersion::buildArch << ';' << nl;
os << " arch " << foamVersion::buildArch << ";\n";
}
if (!note().empty())
{
os << " note " << note() << ';' << nl;
os << " note " << note() << ";\n";
}
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;
os << " location " << instance()/db().dbDir()/local() << ";\n"
<< " object " << name() << ";\n"
<< "}" << nl;
writeDivider(os) << nl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -188,47 +188,41 @@ void Foam::decomposedBlockData::writeHeader
Ostream& os,
const IOstream::versionNumber version,
const IOstream::streamFormat format,
const word& objectType,
const word& type,
const string& note,
const fileName& location,
const word& objectName
const word& name
)
{
IOobject::writeBanner(os)
<< "FoamFile" << nl
<< '{' << nl
<< " version " << version << ';' << nl
<< " format " << format << ';' << nl
<< " arch " << foamVersion::buildArch << ';' << nl;
<< "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";
}
if (Pstream::parRun())
{
os << " blocks " << Pstream::nProcs() << ';' << nl;
}
if (!note.empty())
{
os << " note " << note << ';' << nl;
os << " blocks " << Pstream::nProcs() << ";\n";
}
os << " class ";
if (objectType.empty())
if (note.size())
{
// Empty type not allowed - use 'dictionary' fallback
os << "dictionary";
}
else
{
os << objectType;
}
os << ';' << nl;
if (!location.empty())
{
os << " location " << location << ';' << nl;
os << " note " << note << ";\n";
}
os << " object " << objectName << ';' << nl
<< '}' << nl;
if (location.size())
{
os << " location " << location << ";\n";
}
os << " object " << name << ";\n"
<< "}" << nl;
IOobject::writeDivider(os) << nl;
}
@ -982,8 +976,9 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
// Scatter header information
string versionString(os.version().str());
label formatValue(os.format());
Pstream::scatter(versionString, Pstream::msgType(), comm_);
label formatValue(os.format());
Pstream::scatter(formatValue, Pstream::msgType(), comm_);
//word masterName(name());
@ -1002,8 +997,8 @@ bool Foam::decomposedBlockData::writeData(Ostream& os) const
writeHeader
(
os,
IOstreamOption::versionNumber(versionString),
IOstreamOption::streamFormat(formatValue),
IOstream::versionNumber(versionString),
IOstream::streamFormat(formatValue),
io.headerClassName(),
io.note(),
masterLocation,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd.
Copyright (C) 2020 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& objectType,
const word& type,
const string& note,
const fileName& location,
const word& objectName
const word& name
);
//- Read selected block (non-seeking) + header information

View File

@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef OSHA1stream_H
#define OSHA1stream_H
#ifndef Foam_OSHA1stream_H
#define Foam_OSHA1stream_H
#include "OSstream.H"
#include "SHA1.H"
@ -63,10 +63,17 @@ class osha1stream
protected:
//- Handle overflow
virtual int overflow(int c = EOF)
{
if (c != EOF) sha1_.append(c);
return c;
}
//- Put sequence of characters
virtual std::streamsize xsputn(const char* s, std::streamsize n)
{
sha1_.append(s, n);
if (n) sha1_.append(s, n);
return n;
}

View File

@ -54,8 +54,8 @@ template<class Container, class Delimiters> class OutputAdaptor;
template<class Container, class Delimiters>
inline Ostream& operator<<
(
Ostream& os,
const FlatOutput::OutputAdaptor<Container, Delimiters>& adaptor
Ostream&,
const FlatOutput::OutputAdaptor<Container, Delimiters>&
);
@ -187,7 +187,8 @@ public:
// Operators
//- Ostream Operator
friend Ostream& operator<<
inline friend Ostream&
operator<<
(
Ostream& os,
const OutputAdaptor<Container, Delimiters>& adaptor

View File

@ -158,7 +158,7 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
OTstream toks;
result.writeValue(toks);
return std::move(toks);
return tokenList(std::move(toks.tokens()));
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2018 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 noexcept;
inline const orientedType& oriented() const;
//- Return non-const access to the oriented type
inline orientedType& oriented() noexcept;
inline orientedType& oriented();
//- Set the oriented flag
inline void setOriented(const bool oriented = true) noexcept;
inline void setOriented(const bool oriented = true);
//- Return field
inline const Field<Type>& field() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,15 +61,14 @@ inline Foam::dimensionSet& Foam::DimensionedField<Type, GeoMesh>::dimensions()
template<class Type, class GeoMesh>
inline const Foam::orientedType&
Foam::DimensionedField<Type, GeoMesh>::oriented() const noexcept
Foam::DimensionedField<Type, GeoMesh>::oriented() const
{
return oriented_;
}
template<class Type, class GeoMesh>
inline Foam::orientedType&
Foam::DimensionedField<Type, GeoMesh>::oriented() noexcept
inline Foam::orientedType& Foam::DimensionedField<Type, GeoMesh>::oriented()
{
return oriented_;
}
@ -79,7 +78,7 @@ template<class Type, class GeoMesh>
inline void Foam::DimensionedField<Type, GeoMesh>::setOriented
(
const bool oriented
) noexcept
)
{
oriented_.setOriented(oriented);
}

View File

@ -6,7 +6,6 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -121,12 +120,9 @@ bool Foam::DimensionedField<Type, GeoMesh>::writeData
) const
{
os.writeEntry("dimensions", dimensions());
os << nl;
oriented_.writeEntry(os);
if (oriented_.writeEntry(os))
{
os << nl;
}
os<< nl << nl;
Field<Type>::writeEntry(fieldDictEntry, os);

View File

@ -1 +1,77 @@
#warning File removed - left for old dependency check only
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 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;
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,6 +32,7 @@ Description
SourceFiles
DynamicFieldI.H
DynamicField.C
\*---------------------------------------------------------------------------*/
@ -46,14 +47,24 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declarations
template<class T, int SizeMin> class DynamicField;
template<class T, int SizeMin>
inline Istream& operator>>(Istream&, DynamicField<T, SizeMin>&);
Ostream& operator<<
(
Ostream& os,
const DynamicField<T, SizeMin>& fld
);
template<class T, int SizeMin>
inline Ostream& operator<<(Ostream&, const DynamicField<T, SizeMin>&);
Istream& operator>>
(
Istream& is,
DynamicField<T, SizeMin>& fld
);
/*---------------------------------------------------------------------------*\
Class DynamicField Declaration
@ -66,7 +77,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_;
@ -76,7 +87,7 @@ class DynamicField
//- Copy assignment from another list
template<class ListType>
inline void assignDynList(const ListType& list);
inline void assignDynField(const ListType& list);
public:
@ -91,7 +102,7 @@ public:
// Constructors
//- Default construct, an empty field without allocation.
//- Construct null
inline constexpr DynamicField() noexcept;
//- Construct empty field with given reserve size.
@ -151,69 +162,69 @@ public:
);
//- Construct from Istream. Size set to size of list read.
inline explicit DynamicField(Istream& is);
explicit DynamicField(Istream& is);
//- Clone
inline tmp<DynamicField<T, SizeMin>> clone() const;
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;
// Sizing
// Edit
//- 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);
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);
//- 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 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); }
inline void reserve(const label nElem);
//- Clear the addressed list, i.e. set the size to zero.
// Allocated size does not change
inline void clear() noexcept;
inline void clear();
//- 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() noexcept;
inline label expandStorage();
//- Shrink the allocated space to the number of elements used.
// Returns a reference to the DynamicField.
inline DynamicField<T, SizeMin>& shrink();
// Edit
//- Swap content, independent of sizing parameter
//- Swap content with any sized DynamicField
template<int AnySizeMin>
inline void swap(DynamicField<T, AnySizeMin>& other);
inline void swap(DynamicField<T, AnySizeMin>& list);
//- Transfer the parameter contents into this
inline void transfer(List<T>& list);
@ -226,11 +237,10 @@ 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);
//- Move append an element
inline DynamicField<T, SizeMin>& append(T&& val);
//- Append an element at the end of the list
inline DynamicField<T, SizeMin>&
append(const T& val);
//- Append a List at the end of this list
inline DynamicField<T, SizeMin>&
@ -242,15 +252,12 @@ public:
// Member Operators
//- Return non-const access to an element, resizing list if needed
//- Return non-const access to an element, resizing list if necessary
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);
@ -267,22 +274,6 @@ 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
);
};
@ -296,6 +287,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "DynamicField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2019 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>::assignDynList
inline void Foam::DynamicField<T, SizeMin>::assignDynField
(
const ListType& list
)
{
const label newLen = list.size();
const label newSize = list.size();
if (newLen <= capacity_)
if (capacity_ >= newSize)
{
// Can copy w/o reallocating - adjust addressable size accordingly.
List<T>::setAddressableSize(newLen);
List<T>::operator=(list);
Field<T>::size(list.size());
Field<T>::operator=(list);
}
else
{
// Ensure list size consistency prior to copying.
List<T>::setAddressableSize(capacity_);
Field<T>::size(capacity_);
List<T>::operator=(list);
capacity_ = List<T>::size();
Field<T>::operator=(list);
capacity_ = Field<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>(),
capacity_(0)
Field<T>(len),
capacity_(Field<T>::size())
{
reserve(len);
Field<T>::size(0);
}
@ -207,6 +207,7 @@ inline Foam::DynamicField<T, SizeMin>::DynamicField
{}
//- Construct by mapping from the given field
template<class T, int SizeMin>
inline Foam::DynamicField<T, SizeMin>::DynamicField
(
@ -219,22 +220,6 @@ 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>
@ -247,103 +232,144 @@ inline Foam::label Foam::DynamicField<T, SizeMin>::capacity() const noexcept
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::setCapacity
(
const label newCapacity
const label nElem
)
{
label currLen = List<T>::size();
capacity_ = newCapacity;
label nextFree = Field<T>::size();
capacity_ = nElem;
if (currLen > capacity_)
if (nextFree > capacity_)
{
// Truncate addressed sizes too
currLen = capacity_;
// truncate addressed sizes too
nextFree = capacity_;
}
List<T>::resize(capacity_);
List<T>::setAddressableSize(currLen);
// We could also enforce sizing granularity
Field<T>::setSize(capacity_);
Field<T>::size(nextFree);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::reserve
(
const label len
const label nElem
)
{
if (capacity_ < len)
// Allocate more capacity if necessary
if (nElem > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(len, label(2 * capacity_)));
capacity_ = max
(
SizeMin,
max
(
nElem,
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
label(2*capacity_)
)
);
// Adjust allocated size, leave addressed size untouched
const label currLen = List<T>::size();
List<T>::resize(capacity_);
List<T>::setAddressableSize(currLen);
const label nextFree = Field<T>::size();
Field<T>::setSize(capacity_);
Field<T>::size(nextFree);
}
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::resize
inline void Foam::DynamicField<T, SizeMin>::setSize
(
const label newLen
const label nElem
)
{
if (capacity_ < newLen)
// Allocate more capacity if necessary
if (nElem > capacity_)
{
// Increase capacity (doubling)
capacity_ = max(SizeMin, max(newLen, label(2 * capacity_)));
capacity_ = max
(
SizeMin,
max
(
nElem,
// label(SizeInc + capacity_ * SizeMult / SizeDiv)
label(2*capacity_)
)
);
List<T>::resize(capacity_);
Field<T>::setSize(capacity_);
}
// Adjust addressed size
List<T>::setAddressableSize(newLen);
Field<T>::size(nElem);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::setSize
(
const label nElem,
const T& val
)
{
label nextFree = Field<T>::size();
setSize(nElem);
// Set new elements to constant value
while (nextFree < nElem)
{
this->operator[](nextFree++) = val;
}
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::resize
(
const label newLen,
const T& val
const label nElem
)
{
label currLen = List<T>::size();
resize(newLen);
// Fill newly exposed with constant value
while (currLen < newLen)
{
this->operator[](currLen++) = val;
}
this->setSize(nElem);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::clear() noexcept
inline void Foam::DynamicField<T, SizeMin>::resize
(
const label nElem,
const T& val
)
{
List<T>::setAddressableSize(0);
this->setSize(nElem, val);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::clear()
{
Field<T>::size(0);
}
template<class T, int SizeMin>
inline void Foam::DynamicField<T, SizeMin>::clearStorage()
{
List<T>::clear();
Field<T>::clear();
capacity_ = 0;
}
template<class T, int SizeMin>
inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage() noexcept
inline Foam::label Foam::DynamicField<T, SizeMin>::expandStorage()
{
const label currLen = List<T>::size();
const label nextFree = Field<T>::size();
// Allow addressing into the entire list
List<T>::setAddressableSize(capacity_);
Field<T>::size(capacity_);
return currLen;
return nextFree;
}
@ -351,16 +377,16 @@ template<class T, int SizeMin>
inline Foam::DynamicField<T, SizeMin>&
Foam::DynamicField<T, SizeMin>::shrink()
{
const label currLen = Field<T>::size();
if (currLen < capacity_)
label nextFree = Field<T>::size();
if (capacity_ > nextFree)
{
// Use the full list when resizing
List<T>::setAddressableSize(capacity_);
Field<T>::size(capacity_);
// Capacity and size are identical
capacity_ = currLen;
List<T>::resize(currLen);
// Redundant: List<T>::setAddressableSize(currLen);
// The new size
capacity_ = nextFree;
Field<T>::setSize(capacity_);
Field<T>::size(nextFree);
}
return *this;
}
@ -370,27 +396,38 @@ template<class T, int SizeMin>
template<int AnySizeMin>
inline void Foam::DynamicField<T, SizeMin>::swap
(
DynamicField<T, AnySizeMin>& other
DynamicField<T, AnySizeMin>& lst
)
{
// Cannot compare 'this' for different types, so use cdata()
if (this->cdata() == other.cdata())
if (this->cdata() == lst.cdata())
{
return; // Self-swap is a no-op
}
// Swap storage and addressable size
UList<T>::swap(other);
DynamicField<T, SizeMin>& cur = *this;
// Swap capacity
std::swap(this->capacity_, other.capacity_);
// 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);
}
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);
}
@ -406,7 +443,7 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
// Cannot compare 'this' for different types, so use cdata()
if (this->cdata() == list.cdata())
{
return; // Self-assignment is a no-op
return; // Self-swap is a no-op
}
// Take over storage as-is (without shrink, without using SizeMin)
@ -428,7 +465,7 @@ inline void Foam::DynamicField<T, SizeMin>::transfer
// Cannot compare 'this' for different types, so use cdata()
if (this->cdata() == list.cdata())
{
return; // Self-assignment is a no-op
return; // Self-swap is a no-op
}
// Take over storage as-is (without shrink, without using SizeMin)
@ -448,28 +485,13 @@ Foam::DynamicField<T, SizeMin>::append
)
{
const label idx = List<T>::size();
resize(idx + 1);
setSize(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
@ -480,12 +502,11 @@ 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();
resize(idx + list.size());
setSize(idx + list.size());
for (const T& val : list)
{
@ -509,7 +530,7 @@ inline T Foam::DynamicField<T, SizeMin>::remove()
const T& val = List<T>::operator[](idx);
List<T>::setAddressableSize(idx);
List<T>::size(idx);
return val;
}
@ -525,7 +546,7 @@ inline T& Foam::DynamicField<T, SizeMin>::operator()
{
if (i >= Field<T>::size())
{
resize(i + 1);
setSize(i + 1);
}
return this->operator[](i);
@ -542,23 +563,13 @@ 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
)
{
assignDynList(list);
assignDynField(list);
}
@ -573,7 +584,7 @@ inline void Foam::DynamicField<T, SizeMin>::operator=
return; // Self-assignment is a no-op
}
assignDynList(list);
assignDynField(list);
}
@ -608,35 +619,4 @@ 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;
}
// ************************************************************************* //

View File

@ -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.
@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
@ -55,20 +55,22 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if
(
actualPatchType == word::null
actualPatchType.empty()
|| actualPatchType != p.type()
)
{
if (pfPtr().constraintType() != p.constraintType())
{
// Use default constraint type
// Incompatible (constraint-wise) with the patch type
// - use default constraint type
auto patchTypeCstrIter =
pointPatchConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found())
{
FatalErrorInFunction
<< "inconsistent patch and patchField types for \n"
<< "Inconsistent patch and patchField types for\n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalError);
@ -138,20 +140,17 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if
(
!dict.found("patchType")
!dict.found("patchType")
|| dict.get<word>("patchType") != p.type()
)
{
if (pfPtr().constraintType() == p.constraintType())
if (pfPtr().constraintType() != p.constraintType())
{
// Compatible (constraint-wise) with the patch type
return pfPtr;
}
else
{
// Use default constraint type
auto patchTypeCstrIter
= dictionaryConstructorTablePtr_->cfind(p.type());
// Incompatible (constraint-wise) with the patch type
// - use default constraint type
auto patchTypeCstrIter =
dictionaryConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found())
{
@ -166,7 +165,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
}
}
return cstrIter()(p, iF, dict);
return pfPtr;
}

View File

@ -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.
@ -1205,7 +1205,7 @@ void Foam::argList::parse
{
parRunControl_.distributed(true);
source = "-roots";
if (roots.size() != 1)
if (roots.size() > 1)
{
dictNProcs = roots.size()+1;
}
@ -1214,6 +1214,7 @@ void Foam::argList::parse
{
roots.resize(Pstream::nProcs()-1, fileName::null);
parRunControl_.distributed(true);
source = "-hostRoots";
ITstream is(source, options_["hostRoots"]);
@ -1252,7 +1253,7 @@ void Foam::argList::parse
}
}
if (roots.size() != 1)
if (roots.size() > 1)
{
dictNProcs = roots.size()+1;
}
@ -1296,6 +1297,12 @@ void Foam::argList::parse
{
parRunControl_.distributed(true);
decompDict.readEntry("roots", roots);
if (roots.empty())
{
DetailInfo
<< "WARNING: running distributed"
<< " but did not specify roots!" << nl;
}
}
}
@ -1363,8 +1370,8 @@ void Foam::argList::parse
{
options_.set("case", roots[slave-1]/globalCase_);
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
toSlave << args_ << options_ << roots.size();
OPstream toProc(Pstream::commsTypes::scheduled, slave);
toProc << args_ << options_ << parRunControl_.distributed();
}
options_.erase("case");
@ -1410,24 +1417,24 @@ void Foam::argList::parse
// Distribute the master's argument list (unaltered)
for (const int slave : Pstream::subProcs())
{
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
toSlave << args_ << options_ << roots.size();
OPstream toProc(Pstream::commsTypes::scheduled, slave);
toProc << args_ << options_ << parRunControl_.distributed();
}
}
}
else
{
// Collect the master's argument list
label nroots;
bool isDistributed;
IPstream fromMaster
(
Pstream::commsTypes::scheduled,
Pstream::masterNo()
);
fromMaster >> args_ >> options_ >> nroots;
fromMaster >> args_ >> options_ >> isDistributed;
parRunControl_.distributed(nroots);
parRunControl_.distributed(isDistributed);
// Establish rootPath_/globalCase_/case_ for slave
setCasePaths();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2018 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -94,15 +94,16 @@ bool Foam::OFstreamCollator::writeFile
// We don't have IOobject so cannot use IOobject::writeHeader
if (!append)
{
OSstream& os = osPtr();
decomposedBlockData::writeHeader
(
*osPtr,
os,
ver,
fmt,
typeName,
"", // note
fName, // location
fName.name() // object name
"",
fName,
fName.name()
);
}
}

View File

@ -202,7 +202,8 @@ inline Foam::Matrix<Form, Type>::Matrix
)
:
mRows_(Mb.m()),
nCols_(Mb.n())
nCols_(Mb.n()),
v_(nullptr)
{
doAlloc();
@ -224,7 +225,8 @@ inline Foam::Matrix<Form, Type>::Matrix
)
:
mRows_(Mb.m()),
nCols_(Mb.n())
nCols_(Mb.n()),
v_(nullptr)
{
doAlloc();
@ -460,20 +462,6 @@ 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>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,8 +123,8 @@ public:
// Constructors
//- Default construct (empty matrix)
inline Matrix() noexcept;
//- Construct null
inline Matrix();
//- Construct given number of rows/columns
Matrix(const label m, const label n);
@ -204,9 +204,6 @@ 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;
@ -447,25 +444,25 @@ public:
// Random Access Iterator (non-const)
//- Return an iterator to begin traversing a Matrix
inline iterator begin() noexcept;
inline iterator begin();
//- Return an iterator to end traversing a Matrix
inline iterator end() noexcept;
inline iterator end();
// Random Access Iterator (const)
//- Return const_iterator to begin traversing a constant Matrix
inline const_iterator cbegin() const noexcept;
inline const_iterator cbegin() const;
//- Return const_iterator to end traversing a constant Matrix
inline const_iterator cend() const noexcept;
inline const_iterator cend() const;
//- Return const_iterator to begin traversing a constant Matrix
inline const_iterator begin() const noexcept;
inline const_iterator begin() const;
//- Return const_iterator to end traversing a constant Matrix
inline const_iterator end() const noexcept;
inline const_iterator end() const;
// IO

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,8 +35,9 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
{
const label len = size();
if (len)
if (len > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
v_ = new Type[len];
}
}
@ -45,7 +46,7 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Type>
inline Foam::Matrix<Form, Type>::Matrix() noexcept
inline Foam::Matrix<Form, Type>::Matrix()
:
mRows_(0),
nCols_(0),
@ -510,7 +511,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() noexcept
Foam::Matrix<Form, Type>::begin()
{
return v_;
}
@ -518,7 +519,7 @@ Foam::Matrix<Form, Type>::begin() noexcept
template<class Form, class Type>
inline typename Foam::Matrix<Form, Type>::iterator
Foam::Matrix<Form, Type>::end() noexcept
Foam::Matrix<Form, Type>::end()
{
return v_ + (mRows_ * nCols_);
}
@ -526,7 +527,7 @@ Foam::Matrix<Form, Type>::end() noexcept
template<class Form, class Type>
inline typename Foam::Matrix<Form, Type>::const_iterator
Foam::Matrix<Form, Type>::cbegin() const noexcept
Foam::Matrix<Form, Type>::cbegin() const
{
return v_;
}
@ -534,7 +535,7 @@ Foam::Matrix<Form, Type>::cbegin() const noexcept
template<class Form, class Type>
inline typename Foam::Matrix<Form, Type>::const_iterator
Foam::Matrix<Form, Type>::cend() const noexcept
Foam::Matrix<Form, Type>::cend() const
{
return v_ + (mRows_ * nCols_);
}
@ -542,7 +543,7 @@ Foam::Matrix<Form, Type>::cend() const noexcept
template<class Form, class Type>
inline typename Foam::Matrix<Form, Type>::const_iterator
Foam::Matrix<Form, Type>::begin() const noexcept
Foam::Matrix<Form, Type>::begin() const
{
return v_;
}
@ -550,7 +551,7 @@ Foam::Matrix<Form, Type>::begin() const noexcept
template<class Form, class Type>
inline typename Foam::Matrix<Form, Type>::const_iterator
Foam::Matrix<Form, Type>::end() const noexcept
Foam::Matrix<Form, Type>::end() const
{
return v_ + (mRows_ * nCols_);
}

View File

@ -0,0 +1 @@
#warning File removed - left for old dependency check only

View File

@ -48,8 +48,8 @@ namespace Foam
// Forward Declarations
class labelledTri;
inline Istream& operator>>(Istream&, labelledTri&);
inline Ostream& operator<<(Ostream&, const labelledTri&);
Istream& operator>>(Istream&, labelledTri&);
Ostream& operator<<(Ostream&, const labelledTri&);
/*---------------------------------------------------------------------------*\
Class labelledTri Declaration
@ -119,8 +119,8 @@ public:
// IOstream Operators
friend Istream& operator>>(Istream&, labelledTri&);
friend Ostream& operator<<(Ostream&, const labelledTri&);
inline friend Istream& operator>>(Istream&, labelledTri&);
inline friend Ostream& operator<<(Ostream&, const labelledTri&);
};

View File

@ -45,7 +45,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declarations
class objectMap;
inline bool operator==(const objectMap& a, const objectMap& b);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -138,19 +138,18 @@ public:
);
//- Synchronize values on all mesh edges.
template<class T, class CombineOp, class TransformOp, class FlipOp>
template<class T, class CombineOp, class TransformOp>
static void syncEdgeList
(
const polyMesh& mesh,
List<T>& edgeValues,
const CombineOp& cop,
const T& nullValue,
const TransformOp& top,
const FlipOp& fop
const TransformOp& top
);
//- Synchronize values on selected mesh edges.
template<class T, class CombineOp, class TransformOp, class FlipOp>
template<class T, class CombineOp, class TransformOp>
static void syncEdgeList
(
const polyMesh& mesh,
@ -158,8 +157,7 @@ public:
List<T>& edgeValues,
const CombineOp& cop,
const T& nullValue,
const TransformOp& top,
const FlipOp& fop
const TransformOp& top
);
//- Synchronize values on boundary faces only.
@ -279,8 +277,7 @@ public:
edgeValues,
cop,
nullValue,
mapDistribute::transform(),
noOp()
mapDistribute::transform()
);
}
@ -300,8 +297,7 @@ public:
positions,
cop,
nullValue,
mapDistribute::transformPosition(),
noOp()
mapDistribute::transformPosition()
);
}
@ -323,8 +319,7 @@ public:
edgeValues,
cop,
nullValue,
mapDistribute::transform(),
noOp()
mapDistribute::transform()
);
}
@ -346,8 +341,7 @@ public:
positions,
cop,
nullValue,
mapDistribute::transformPosition(),
noOp()
mapDistribute::transformPosition()
);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2021 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -798,15 +798,14 @@ void Foam::syncTools::syncPointList
}
template<class T, class CombineOp, class TransformOp, class FlipOp>
template<class T, class CombineOp, class TransformOp>
void Foam::syncTools::syncEdgeList
(
const polyMesh& mesh,
List<T>& edgeValues,
const CombineOp& cop,
const T& nullValue,
const TransformOp& top,
const FlipOp& fop
const TransformOp& top
)
{
if (edgeValues.size() != mesh.nEdges())
@ -817,47 +816,12 @@ 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
(
@ -873,29 +837,12 @@ void Foam::syncTools::syncEdgeList
// Extract back onto mesh
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));
const bool sameOrientation = ((dir == 1) == orientation[i]);
if (sameOrientation)
{
edgeValues[meshEdges[i]] = cppFld[i];
}
else
{
edgeValues[meshEdges[i]] = fop(cppFld[i]);
}
edgeValues[meshEdges[i]] = cppFld[i];
}
}
template<class T, class CombineOp, class TransformOp, class FlipOp>
template<class T, class CombineOp, class TransformOp>
void Foam::syncTools::syncEdgeList
(
const polyMesh& mesh,
@ -903,8 +850,7 @@ void Foam::syncTools::syncEdgeList
List<T>& edgeValues,
const CombineOp& cop,
const T& nullValue,
const TransformOp& top,
const FlipOp& fop
const TransformOp& top
)
{
if (edgeValues.size() != meshEdges.size())
@ -914,48 +860,19 @@ 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 label meshEdgei = meshEdges[i];
const auto iter = mpm.cfind(meshEdgei);
const auto iter = mpm.cfind(meshEdges[i]);
if (iter.found())
{
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]);
}
cppFld[*iter] = edgeValues[i];
}
}
@ -972,25 +889,11 @@ void Foam::syncTools::syncEdgeList
forAll(meshEdges, i)
{
label meshEdgei = meshEdges[i];
Map<label>::const_iterator iter = mpm.find(meshEdgei);
if (iter != mpm.end())
const auto iter = mpm.cfind(meshEdges[i]);
if (iter.found())
{
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]);
}
edgeValues[i] = cppFld[*iter];
}
}
}
@ -1022,147 +925,50 @@ void Foam::syncTools::syncBoundaryFaceList
if (parRun)
{
if
(
is_contiguous<T>::value
&& Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
)
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send
for (const polyPatch& pp : patches)
{
const label startRequest = UPstream::nRequests();
// Receive buffer
List<T> receivedValues(mesh.nBoundaryFaces());
// Set up reads
for (const polyPatch& pp : patches)
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
{
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
SubList<T> fld
(
receivedValues,
procPatch.size(),
procPatch.offset()
);
const label patchStart = procPatch.start()-boundaryOffset;
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]);
}
}
// Send slice of values on the patch
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
toNbr<< SubList<T>(faceValues, procPatch.size(), patchStart);
}
}
else
pBufs.finishedSends();
// Receive and combine.
for (const polyPatch& pp : patches)
{
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send
for (const polyPatch& pp : patches)
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
{
if (isA<processorPolyPatch>(pp) && pp.size() > 0)
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)
{
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);
}
cop(faceValues[bFacei++], nbrVal);
}
}
}
@ -1186,10 +992,10 @@ void Foam::syncTools::syncBoundaryFaceList
const label nbrStart = nbrPatch.start()-boundaryOffset;
// Transform (copy of) data on both sides
List<T> ownVals(SubList<T>(faceValues, patchSize, ownStart));
Field<T> ownVals(SubList<T>(faceValues, patchSize, ownStart));
top(nbrPatch, ownVals);
List<T> nbrVals(SubList<T>(faceValues, patchSize, nbrStart));
Field<T> nbrVals(SubList<T>(faceValues, patchSize, nbrStart));
top(cycPatch, nbrVals);
label bFacei = ownStart;
@ -1242,39 +1048,10 @@ void Foam::syncTools::syncFaceList
if (parRun)
{
const label startRequest = UPstream::nRequests();
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Receive buffers
PtrList<PackedList<Width>> recvInfos(patches.size());
// Send
// 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())
@ -1287,29 +1064,18 @@ void Foam::syncTools::syncFaceList
procPatch.start()-boundaryOffset,
procPatch.size()
);
const label patchi = procPatch.index();
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()
);
// Send slice of values on the patch
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
toNbr<< PackedList<Width>(faceValues, range);
}
}
// Wait for all comms to finish
Pstream::waitRequests(startRequest);
pBufs.finishedSends();
// Receive and combine.
// Combine with existing data
for (const polyPatch& pp : patches)
{
if (isA<processorPolyPatch>(pp) && pp.size())
@ -1318,8 +1084,13 @@ void Foam::syncTools::syncFaceList
refCast<const processorPolyPatch>(pp);
const label patchSize = procPatch.size();
const label patchi = procPatch.index();
const PackedList<Width>& recvInfo = recvInfos[patchi];
// 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;
@ -1335,66 +1106,6 @@ 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;
// }
// }
//}
}

View File

@ -49,7 +49,13 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
template<class Point, class PointRef> class line;

View File

@ -280,13 +280,13 @@ public:
{
if (is.format() == IOstream::ASCII)
{
is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
return is >> pHit.hit_ >> pHit.point_ >> pHit.index_;
}
else
{
// TODO (2019-08-06):
// cannot properly handle mixed-precision reading
// owing to bool and Point type.
// owning to bool and Point type.
is.read
(

View File

@ -57,9 +57,11 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class plane;
// Forward declarations
class Istream;
class Ostream;
class tetPoints;
class plane;
template<class Point, class PointRef> class tetrahedron;
@ -308,7 +310,7 @@ public:
boundBox bounds() const;
// IOstream Operators
// IOstream operators
friend Istream& operator>> <Point, PointRef>
(

View File

@ -54,6 +54,8 @@ namespace Foam
{
// Forward Declarations
class Istream;
class Ostream;
class plane;
class triPoints;
@ -353,7 +355,7 @@ public:
) const;
// IOstream Operators
// IOstream operators
friend Istream& operator>> <Point, PointRef>
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,9 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "orientedType.H"
#include "dictionary.H"
#include "Istream.H"
#include "Ostream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,14 +35,12 @@ 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,
@ -91,19 +86,19 @@ Foam::orientedType::orientedType(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::orientedType::orientedOption& Foam::orientedType::oriented() noexcept
Foam::orientedType::orientedOption& Foam::orientedType::oriented()
{
return oriented_;
}
Foam::orientedType::orientedOption Foam::orientedType::oriented() const noexcept
Foam::orientedType::orientedOption Foam::orientedType::oriented() const
{
return oriented_;
}
void Foam::orientedType::setOriented(const bool oriented) noexcept
void Foam::orientedType::setOriented(const bool oriented)
{
oriented_ = oriented ? ORIENTED : UNORIENTED;
}
@ -121,16 +116,12 @@ void Foam::orientedType::read(const dictionary& dict)
}
bool Foam::orientedType::writeEntry(Ostream& os) const
void Foam::orientedType::writeEntry(Ostream& os) const
{
const bool output = (oriented_ == ORIENTED);
if (output)
if (oriented_ == ORIENTED)
{
os.writeEntry("oriented", orientedOptionNames[oriented_]);
}
return output;
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -37,6 +37,9 @@ SourceFiles
#ifndef orientedType_H
#define orientedType_H
#include "Istream.H"
#include "Ostream.H"
#include "dictionary.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -44,10 +47,12 @@ SourceFiles
namespace Foam
{
// Forward Declarations
// Forward declaration of friend functions and operators
class orientedType;
Istream& operator>>(Istream& is, orientedType& ot);
Ostream& operator<<(Ostream& os, const orientedType& ot);
/*---------------------------------------------------------------------------*\
@ -58,25 +63,24 @@ class orientedType
{
public:
// Public Data Types
// Public data types
//- Enumeration defining oriented flags
//- Enumeration defining the valid oriented flags
enum orientedOption
{
UNKNOWN = 0,
ORIENTED = 1,
UNORIENTED = 2
ORIENTED,
UNORIENTED,
UNKNOWN
};
//- Named enumerations for oriented flags
static const Enum<orientedOption> orientedOptionNames;
private:
// Private Data
// Private data
//- Oriented type
//- Oriented flag
orientedOption oriented_;
@ -84,20 +88,20 @@ public:
// Constructors
//- Default construct as "UNKNOWN"
//- Null constructor - flag initialised to false
orientedType();
//- Copy construct
//- Copy constructor
orientedType(const orientedType& ot);
//- Construct from bool
explicit orientedType(const bool oriented);
orientedType(const bool oriented);
//- Construct from Istream
explicit orientedType(Istream& is);
orientedType(Istream& is);
// Member Functions
// Member functions
//- Return true if can operate on this pair of oriented types
static bool checkType
@ -107,23 +111,22 @@ public:
);
//- Return non-const reference to the oriented flag
orientedOption& oriented() noexcept;
orientedOption& oriented();
//- Return the oriented flag
orientedOption oriented() const noexcept;
//- Return const reference to the oriented flag
orientedOption oriented() const;
//- Set the oriented flag
void setOriented(const bool oriented = true) noexcept;
void setOriented(const bool oriented = true);
//- Read the "oriented" state from dictionary
//- Read the oriented state from dictionary
void read(const dictionary& dict);
//- Write the "oriented" flag entry (if ORIENTED)
// \return True if entry was written
bool writeEntry(Ostream& os) const;
//- Write the oriented flag entry
void writeEntry(Ostream& os) const;
// Member Operators
// Member operators
void operator=(const orientedType& ot);
@ -136,9 +139,10 @@ public:
bool operator()() const;
// IOstream Operators
// IOstream operators
friend Istream& operator>>(Istream& is, orientedType& ot);
friend Ostream& operator<<(Ostream& os, const orientedType& ot);
};

View File

@ -45,6 +45,9 @@ Description
\*---------------------------------------------------------------------------*/
#include "mathematicalConstants.H"
#include "error.H"
#include <cmath>
#include <limits>
using namespace Foam::constant::mathematical;

View File

@ -43,6 +43,10 @@ Description
\*---------------------------------------------------------------------------*/
#include "mathematicalConstants.H"
#include "error.H"
#include <cmath>
#include <limits>
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -513,6 +513,10 @@ inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::T() const
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
{
@ -536,6 +540,10 @@ Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::schur(const Tensor<Cmpt>& t2) const
{
@ -970,6 +978,10 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
//- Inner-product of a SphericalTensor and a Tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -984,6 +996,10 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product of a Tensor and a SphericalTensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
{
@ -998,6 +1014,10 @@ operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
//- Inner-product of a SymmTensor and a Tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -1020,6 +1040,10 @@ operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product of a Tensor and a SymmTensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
{
@ -1042,7 +1066,11 @@ operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
//- Inner-product of a Tensor and a Vector
template<class Cmpt>
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Vector<Cmpt>
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
{
return Vector<Cmpt>
@ -1056,7 +1084,11 @@ operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
//- Inner-product of a Vector and a Tensor
template<class Cmpt>
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Vector<Cmpt>
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
{
return Vector<Cmpt>

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2020 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() noexcept;
inline iterator begin();
//- Return an iterator to end of VectorSpace
inline iterator end() noexcept;
inline iterator end();
// Random access iterator (const)
//- Return const_iterator to begin of VectorSpace
inline const_iterator cbegin() const noexcept;
inline const_iterator cbegin() const;
//- Return const_iterator to end of VectorSpace
inline const_iterator cend() const noexcept;
inline const_iterator cend() const;
//- Return const_iterator to begin of VectorSpace
inline const_iterator begin() const noexcept;
inline const_iterator begin() const;
//- Return const_iterator to end of VectorSpace
inline const_iterator end() const noexcept;
inline const_iterator end() const;
// IOstream Operators

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -196,46 +196,42 @@ 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() noexcept
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() noexcept
inline Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
{
return (v_ + Ncmpts);
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin()
const noexcept
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cbegin() const
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend()
const noexcept
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::cend() const
{
return (v_ + Ncmpts);
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin()
const noexcept
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::begin() const
{
return v_;
}
template<class Form, class Cmpt, Foam::direction Ncmpts>
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end()
const noexcept
inline const Cmpt* Foam::VectorSpace<Form, Cmpt, Ncmpts>::end() const
{
return (v_ + Ncmpts);
}

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