Commit 7402cd7b authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: make sampleSets setSamples movable - preliminary to issue #869

- add some more documentation
parent c05dab5e
......@@ -58,6 +58,19 @@ void Foam::coordSet::checkDimensions() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::coordSet::coordSet
(
const word& name,
const coordFormat axisType
)
:
pointField(),
name_(name),
axis_(axisType),
curveDist_()
{}
Foam::coordSet::coordSet
(
const word& name,
......
......@@ -52,7 +52,6 @@ class coordSet
:
public pointField
{
public:
// Public data types
......@@ -94,8 +93,11 @@ public:
//- Construct from components
// Note: curveDist will be empty
coordSet(const word& name, const word& axis);
coordSet(const word& name, const coordFormat axisType);
//- Construct from components
// Note: curveDist will be empty
coordSet(const word& name, const word& axis);
//- Copy construct from components
coordSet
......@@ -128,19 +130,38 @@ public:
return coordFormatNames[axis_];
}
//- Cumulative distance
//- Set the points
void setPoints(const List<point>& newPoints)
{
static_cast<pointField&>(*this) = newPoints;
}
//- Set the points
void setPoints(List<point>&& newPoints)
{
static_cast<pointField&>(*this) = std::move(newPoints);
}
//- Return the cumulative distance
const scalarList& curveDist() const
{
return curveDist_;
}
//- Set cumulative distance
//- Set the cumulative distance
void setCurveDist(const scalarList& curveDist)
{
curveDist_ = curveDist;
checkDimensions();
}
//- Set the cumulative distance
void setCurveDist(scalarList&& curveDist)
{
curveDist_ = std::move(curveDist);
checkDimensions();
}
//- Is axis specification a vector
bool hasVectorAxis() const;
......
......@@ -68,15 +68,15 @@ void Foam::arraySet::calcSamples
const scalar deltaz = spanBox_.z()/(pointsDensity_.z() + 1);
label p(0);
for (label k=1; k<=pointsDensity_.z(); k++)
for (label k=1; k<=pointsDensity_.z(); ++k)
{
for (label j=1; j<=pointsDensity_.y(); j++)
for (label j=1; j<=pointsDensity_.y(); ++j)
{
for (label i=1; i<=pointsDensity_.x(); i++)
for (label i=1; i<=pointsDensity_.x(); ++i)
{
vector t(deltax*i , deltay*j, deltaz*k);
sampleCoords[p] = coordSys_.origin() + t;
p++;
++p;
}
}
}
......@@ -126,14 +126,20 @@ void Foam::arraySet::genSamples()
samplingSegments.shrink();
samplingCurveDist.shrink();
// Move into *this
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
std::move(samplingPts),
std::move(samplingCells),
std::move(samplingFaces),
std::move(samplingSegments),
std::move(samplingCurveDist)
);
if (debug)
{
write(Info);
}
}
......@@ -156,11 +162,6 @@ Foam::arraySet::arraySet
spanBox_(spanBox)
{
genSamples();
if (debug)
{
write(Info);
}
}
......@@ -178,18 +179,7 @@ Foam::arraySet::arraySet
spanBox_(dict.lookup("spanBox"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::arraySet::~arraySet()
{}
// ************************************************************************* //
......@@ -25,6 +25,18 @@ Class
Foam::arraySet
Description
Specifies an x,y,z array of uniformly distributed sampling points.
For a dictionary specification:
\table
Property | Description | Required | Default
type | array | yes |
axis | x, y, z, xyz, distance | yes |
pointsDensity | The sampling density as (x y z) integers | yes |
spanBox | The sample box dimensions (vector) | yes |
\endtable
The dictionary can also contain an embedded coordinateSystem specification.
SourceFiles
arraySet.C
......@@ -43,7 +55,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class passiveParticle;
template<class Type> class particle;
......@@ -114,7 +126,7 @@ public:
//- Destructor
virtual ~arraySet();
virtual ~arraySet() = default;
};
......
......@@ -111,7 +111,7 @@ void Foam::circleSet::calcSamples
radius*constant::mathematical::pi/180.0*theta
);
nPoint++;
++nPoint;
}
else
{
......@@ -148,14 +148,20 @@ void Foam::circleSet::genSamples()
samplingSegments.shrink();
samplingCurveDist.shrink();
// Move into *this
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
std::move(samplingPts),
std::move(samplingCells),
std::move(samplingFaces),
std::move(samplingSegments),
std::move(samplingCurveDist)
);
if (debug)
{
write(Info);
}
}
......@@ -180,11 +186,6 @@ Foam::circleSet::circleSet
dTheta_(dTheta)
{
genSamples();
if (debug)
{
write(Info);
}
}
......@@ -200,26 +201,15 @@ Foam::circleSet::circleSet
origin_(dict.lookup("origin")),
circleAxis_(dict.lookup("circleAxis")),
startPoint_(dict.lookup("startPoint")),
dTheta_(readScalar(dict.lookup("dTheta")))
dTheta_(dict.get<scalar>("dTheta"))
{
// Normalise circleAxis
circleAxis_ /= mag(circleAxis_);
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::circleSet::~circleSet()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::point Foam::circleSet::getRefPoint(const List<point>& pts) const
......
......@@ -27,6 +27,17 @@ Class
Description
Samples along a circular path
For a dictionary specification:
\table
Property | Description | Required | Default
type | circle | yes |
axis | x, y, z, xyz, distance | yes |
origin | The origin of the circle | yes |
circleAxis | The axis of the circle | yes |
startPoint | Starting point of the circle | yes |
dTheta | Sampling increment in degrees | yes |
\endtable
SourceFiles
circleSet.C
......@@ -43,7 +54,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class meshSearch;
/*---------------------------------------------------------------------------*\
......@@ -121,15 +132,14 @@ public:
);
// Destructor
virtual ~circleSet();
//- Destructor
virtual ~circleSet() = default;
// Member Functions
//- Get reference point
virtual point getRefPoint(const List<point>&) const;
virtual point getRefPoint(const List<point>& pts) const;
};
......
......@@ -161,14 +161,20 @@ void Foam::cloudSet::genSamples()
samplingSegments.shrink();
samplingCurveDist.shrink();
// Move into *this
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
std::move(samplingPts),
std::move(samplingCells),
std::move(samplingFaces),
std::move(samplingSegments),
std::move(samplingCurveDist)
);
if (debug)
{
write(Info);
}
}
......@@ -187,11 +193,6 @@ Foam::cloudSet::cloudSet
sampleCoords_(sampleCoords)
{
genSamples();
if (debug)
{
write(Info);
}
}
......@@ -207,18 +208,7 @@ Foam::cloudSet::cloudSet
sampleCoords_(dict.lookup("points"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cloudSet::~cloudSet()
{}
// ************************************************************************* //
......@@ -25,6 +25,15 @@ Class
Foam::cloudSet
Description
Samples at arbitrary locations with a volume mesh.
For a dictionary specification:
\table
Property | Description | Required | Default
type | cloud | yes |
axis | x, y, z, xyz, distance | yes |
points | The locations | yes |
\endtable
SourceFiles
cloudSet.C
......@@ -42,12 +51,12 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class passiveParticle;
template<class Type> class particle;
/*---------------------------------------------------------------------------*\
Class cloudSet Declaration
Class cloudSet Declaration
\*---------------------------------------------------------------------------*/
class cloudSet
......@@ -105,7 +114,7 @@ public:
//- Destructor
virtual ~cloudSet();
virtual ~cloudSet() = default;
};
......
......@@ -36,10 +36,10 @@ namespace Foam
{
defineTypeNameAndDebug(faceOnlySet, 0);
addToRunTimeSelectionTable(sampledSet, faceOnlySet, word);
const scalar faceOnlySet::tol = 1e-6;
}
const Foam::scalar Foam::faceOnlySet::tol = 1e-6;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......@@ -60,7 +60,7 @@ bool Foam::faceOnlySet::trackToBoundary
point trackPt = singleParticle.position();
while(true)
while (true)
{
point oldPoint = trackPt;
......@@ -265,7 +265,7 @@ void Foam::faceOnlySet::calcSamples
}
else
{
bHitI++;
++bHitI;
}
}
......@@ -280,7 +280,7 @@ void Foam::faceOnlySet::calcSamples
trackPt = pushIn(bHits[bHitI].hitPoint(), trackFacei);
trackCelli = getBoundaryCell(trackFacei);
segmentI++;
++segmentI;
startSegmentI = samplingPts.size();
}
......@@ -313,15 +313,20 @@ void Foam::faceOnlySet::genSamples()
samplingSegments.shrink();
samplingCurveDist.shrink();
// Copy into *this
// Move into *this
setSamples
(
samplingPts,
samplingCells,
samplingFaces,
samplingSegments,
samplingCurveDist
std::move(samplingPts),
std::move(samplingCells),
std::move(samplingFaces),
std::move(samplingSegments),
std::move(samplingCurveDist)
);
if (debug)
{
write(Info);
}
}
......@@ -342,11 +347,6 @@ Foam::faceOnlySet::faceOnlySet
end_(end)
{
genSamples();
if (debug)
{
write(Info);
}
}
......@@ -363,18 +363,7 @@ Foam::faceOnlySet::faceOnlySet
end_(dict.lookup("end"))
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::faceOnlySet::~faceOnlySet()
{}
// ************************************************************************* //
......@@ -25,6 +25,16 @@ Class
Foam::faceOnlySet
Description
Sample on faces along a specified path
For a dictionary specification:
\table
Property | Description | Required | Default
type | face | yes |
axis | x, y, z, xyz, distance | yes |
start | The start point | yes |
end | The end point | yes |
\endtable
SourceFiles
faceOnlySet.C
......@@ -129,7 +139,7 @@ public:
//- Destructor
virtual ~faceOnlySet();
virtual ~faceOnlySet() = default;
// Member Functions
......
......@@ -69,10 +69,10 @@ void Foam::midPointSet::genSamples()
midCells[mSamplei] = cellm;
midSegments[mSamplei] = segments_[samplei];
midCurveDist[mSamplei] = mag(midPoints[mSamplei] - start());
mSamplei++;
++mSamplei;
}
samplei++;
++samplei;
}
if (samplei == size() - 1)
......@@ -80,7 +80,7 @@ void Foam::midPointSet::genSamples()
break;
}
samplei++;
++samplei;
}
midPoints.setSize(mSamplei);
......@@ -88,14 +88,22 @@ void Foam::midPointSet::genSamples()
midSegments.setSize(mSamplei);
midCurveDist.setSize(mSamplei);
labelList midFaces(midCells.size(), -1);
// Move into *this
setSamples
(
midPoints,
midCells,
labelList(midCells.size(), -1),
midSegments,
midCurveDist
std::move(midPoints),
std::move(midCells),
std::move(midFaces),
std::move(midSegments),
std::move(midCurveDist)
);
if (debug)
{
write(Info);
}
}
......@@ -114,11 +122,6 @@ Foam::midPointSet::midPointSet
faceOnlySet(name, mesh, searchEngine, axis, start, end)
{
genSamples();
if (debug)
{
write(Info);
}
}
......@@ -133,18 +136,7 @@ Foam::midPointSet::midPointSet
faceOnlySet(name, mesh, searchEngine, dict)
{
genSamples();
if (debug)
{
write(Info);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::midPointSet::~midPointSet()
{}
// ************************************************************************* //
......@@ -41,7 +41,7 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
// Forward declarations
class meshSearch;
/*---------------------------------------------------------------------------*\
......@@ -87,7 +87,7 @@ public: