Commit 0720fb74 authored by mattijs's avatar mattijs
Browse files

ENH: Have on coupledPolyPatch per face information on which are collocated

parent a7c6b2a5
......@@ -35,141 +35,50 @@ defineTypeNameAndDebug(Foam::globalPoints, 0);
const Foam::label Foam::globalPoints::fromCollocated = labelMax/2;
const Foam::scalar Foam::globalPoints::mergeDist = ROOTVSMALL;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Routines to handle global indices
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool Foam::globalPoints::noTransform(const tensor& tt, const scalar mergeDist)
{
return
(mag(tt.xx()-1) < mergeDist)
&& (mag(tt.yy()-1) < mergeDist)
&& (mag(tt.zz()-1) < mergeDist)
&& (mag(tt.xy()) < mergeDist)
&& (mag(tt.xz()) < mergeDist)
&& (mag(tt.yx()) < mergeDist)
&& (mag(tt.yz()) < mergeDist)
&& (mag(tt.zx()) < mergeDist)
&& (mag(tt.zy()) < mergeDist);
}
// Calculates per face whether couple is collocated.
Foam::PackedBoolList Foam::globalPoints::collocatedFaces
Foam::PackedBoolList Foam::globalPoints::collocatedPoints
(
const coupledPolyPatch& pp,
const scalar mergeDist
const coupledPolyPatch& pp
)
{
// Initialise to false
PackedBoolList collocated(pp.size());
PackedBoolList isCollocated(pp.nPoints());
const vectorField& separation = pp.separation();
const tensorField& forwardT = pp.forwardT();
const boolList& collocated = pp.collocated();
if (forwardT.size() == 0)
{
// Parallel.
if (separation.size() == 0)
{
collocated = 1u;
}
else if (separation.size() == 1)
{
// Fully separate. Do not synchronise.
}
else
{
// Per face separation.
forAll(pp, faceI)
{
if (mag(separation[faceI]) < mergeDist)
{
collocated[faceI] = 1u;
}
}
}
}
else if (forwardT.size() == 1)
if (collocated.size() == 0)
{
// Fully transformed.
}
else
{
// Per face transformation.
forAll(pp, faceI)
{
if (noTransform(forwardT[faceI], mergeDist))
{
collocated[faceI] = 1u;
}
}
isCollocated = 1;
}
return collocated;
}
Foam::PackedBoolList Foam::globalPoints::collocatedPoints
(
const coupledPolyPatch& pp,
const scalar mergeDist
)
{
// Initialise to false
PackedBoolList collocated(pp.nPoints());
const vectorField& separation = pp.separation();
const tensorField& forwardT = pp.forwardT();
if (forwardT.size() == 0)
else if (collocated.size() == 1)
{
// Parallel.
if (separation.size() == 0)
{
collocated = 1u;
}
else if (separation.size() == 1)
// Uniform.
if (collocated[0])
{
// Fully separate.
isCollocated = 1;
}
else
{
// Per face separation.
for (label pointI = 0; pointI < pp.nPoints(); pointI++)
{
label faceI = pp.pointFaces()[pointI][0];
if (mag(separation[faceI]) < mergeDist)
{
collocated[pointI] = 1u;
}
}
}
}
else if (forwardT.size() == 1)
{
// Fully transformed.
}
else
{
// Per face transformation.
for (label pointI = 0; pointI < pp.nPoints(); pointI++)
{
label faceI = pp.pointFaces()[pointI][0];
// Per face collocated or not.
const labelListList& pointFaces = pp.pointFaces();
if (noTransform(forwardT[faceI], mergeDist))
forAll(pointFaces, pfi)
{
if (collocated[pointFaces[pfi][0]])
{
collocated[pointI] = 1u;
isCollocated[pfi] = 1;
}
}
}
return collocated;
return isCollocated;
}
Foam::label Foam::globalPoints::toGlobal
(
......@@ -467,8 +376,7 @@ void Foam::globalPoints::initOwnPoints
(
collocatedPoints
(
refCast<const coupledPolyPatch>(pp),
mergeDist
refCast<const coupledPolyPatch>(pp)
)
);
......@@ -563,8 +471,7 @@ void Foam::globalPoints::sendPatchPoints
(
collocatedPoints
(
procPatch,
mergeDist
procPatch
)
);
......@@ -663,8 +570,7 @@ void Foam::globalPoints::receivePatchPoints
(
collocatedPoints
(
procPatch,
mergeDist
procPatch
)
);
......@@ -726,8 +632,7 @@ void Foam::globalPoints::receivePatchPoints
(
collocatedPoints
(
cycPatch,
mergeDist
cycPatch
)
);
......@@ -1233,8 +1138,7 @@ void Foam::globalPoints::receiveSharedPoints
(
collocatedPoints
(
cycPatch,
mergeDist
cycPatch
)
);
......
......@@ -127,9 +127,6 @@ class globalPoints
// collocated coupled points.
static const label fromCollocated;
//- Distance to check whether points/faces are collocated.
static const scalar mergeDist;
// Private data
......@@ -162,22 +159,9 @@ class globalPoints
// Private Member Functions
//- Is identity transform?
static bool noTransform(const tensor&, const scalar mergeDist);
//- Return per face collocated status
static PackedBoolList collocatedFaces
(
const coupledPolyPatch&,
const scalar mergeDist
);
//- Return per point collocated status
static PackedBoolList collocatedPoints
(
const coupledPolyPatch&,
const scalar mergeDist
);
static PackedBoolList collocatedPoints(const coupledPolyPatch&);
// Wrappers around global point numbering to add collocated bit
......
......@@ -285,6 +285,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
separation_.setSize(0);
forwardT_ = I;
reverseT_ = I;
collocated_.setSize(0);
}
else
{
......@@ -299,10 +300,14 @@ void Foam::coupledPolyPatch::calcTransformTensors
{
// Rotation, no separation
// Assume per-face differening transformation, correct later
separation_.setSize(0);
forwardT_.setSize(Cf.size());
reverseT_.setSize(Cf.size());
collocated_.setSize(Cf.size());
collocated_ = false;
forAll (forwardT_, facei)
{
......@@ -321,6 +326,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
{
forwardT_.setSize(1);
reverseT_.setSize(1);
collocated_.setSize(1);
if (debug)
{
......@@ -332,11 +338,15 @@ void Foam::coupledPolyPatch::calcTransformTensors
}
else
{
// No rotation, possible separation
forwardT_.setSize(0);
reverseT_.setSize(0);
separation_ = (nf&(Cr - Cf))*nf;
collocated_.setSize(separation_.size());
// Three situations:
// - separation is zero. No separation.
// - separation is same. Single separation vector.
......@@ -344,15 +354,23 @@ void Foam::coupledPolyPatch::calcTransformTensors
// Check for different separation per face
bool sameSeparation = true;
bool doneWarning = false;
forAll(separation_, facei)
{
scalar smallSqr = sqr(smallDist[facei]);
collocated_[facei] = (magSqr(separation_[facei]) < smallSqr);
// Check if separation differing w.r.t. face 0.
if (magSqr(separation_[facei] - separation_[0]) > smallSqr)
{
if (debug)
sameSeparation = false;
if (!doneWarning && debug)
{
doneWarning = true;
Pout<< " separation " << separation_[facei]
<< " at " << facei
<< " differs from separation[0] " << separation_[0]
......@@ -360,15 +378,13 @@ void Foam::coupledPolyPatch::calcTransformTensors
<< smallDist[facei]
<< ". Assuming non-uniform separation." << endl;
}
sameSeparation = false;
break;
}
}
if (sameSeparation)
{
// Check for zero separation (at 0 so everywhere)
if (magSqr(separation_[0]) < sqr(smallDist[0]))
if (collocated_[0])
{
if (debug)
{
......@@ -378,6 +394,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
}
separation_.setSize(0);
collocated_ = boolList(1, true);
}
else
{
......@@ -389,6 +406,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
}
separation_.setSize(1);
collocated_ = boolList(1, false);
}
}
}
......
......@@ -64,6 +64,9 @@ class coupledPolyPatch
//- Neighbour-cell transformation tensor
mutable tensorField reverseT_;
//- Are faces collocated. Either size 0,1 or length of patch.
mutable boolList collocated_;
public:
// Static data members
......@@ -261,7 +264,6 @@ public:
return separation_;
}
//- Are the cyclic planes parallel
bool parallel() const
{
......@@ -280,6 +282,12 @@ public:
return reverseT_;
}
//- Are faces collocated. Either size 0,1 or length of patch
const boolList& collocated() const
{
return collocated_;
}
//- Initialize ordering for primitivePatch. Does not
// refer to *this (except for name() and type() etc.)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment