mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Have on coupledPolyPatch per face information on which are collocated
This commit is contained in:
@ -35,139 +35,48 @@ defineTypeNameAndDebug(Foam::globalPoints, 0);
|
|||||||
|
|
||||||
const Foam::label Foam::globalPoints::fromCollocated = labelMax/2;
|
const Foam::label Foam::globalPoints::fromCollocated = labelMax/2;
|
||||||
|
|
||||||
const Foam::scalar Foam::globalPoints::mergeDist = ROOTVSMALL;
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
// Routines to handle global indices
|
// 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
|
|
||||||
(
|
|
||||||
const coupledPolyPatch& pp,
|
|
||||||
const scalar mergeDist
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// Initialise to false
|
|
||||||
PackedBoolList collocated(pp.size());
|
|
||||||
|
|
||||||
const vectorField& separation = pp.separation();
|
|
||||||
const tensorField& forwardT = pp.forwardT();
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
// Fully transformed.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Per face transformation.
|
|
||||||
forAll(pp, faceI)
|
|
||||||
{
|
|
||||||
if (noTransform(forwardT[faceI], mergeDist))
|
|
||||||
{
|
|
||||||
collocated[faceI] = 1u;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return collocated;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::PackedBoolList Foam::globalPoints::collocatedPoints
|
Foam::PackedBoolList Foam::globalPoints::collocatedPoints
|
||||||
(
|
(
|
||||||
const coupledPolyPatch& pp,
|
const coupledPolyPatch& pp
|
||||||
const scalar mergeDist
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Initialise to false
|
// Initialise to false
|
||||||
PackedBoolList collocated(pp.nPoints());
|
PackedBoolList isCollocated(pp.nPoints());
|
||||||
|
|
||||||
const vectorField& separation = pp.separation();
|
const boolList& collocated = pp.collocated();
|
||||||
const tensorField& forwardT = pp.forwardT();
|
|
||||||
|
|
||||||
if (forwardT.size() == 0)
|
if (collocated.size() == 0)
|
||||||
{
|
{
|
||||||
// Parallel.
|
isCollocated = 1;
|
||||||
if (separation.size() == 0)
|
|
||||||
{
|
|
||||||
collocated = 1u;
|
|
||||||
}
|
|
||||||
else if (separation.size() == 1)
|
|
||||||
{
|
|
||||||
// Fully separate.
|
|
||||||
}
|
|
||||||
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)
|
else if (collocated.size() == 1)
|
||||||
{
|
{
|
||||||
// Fully transformed.
|
// Uniform.
|
||||||
|
if (collocated[0])
|
||||||
|
{
|
||||||
|
isCollocated = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Per face transformation.
|
// Per face collocated or not.
|
||||||
for (label pointI = 0; pointI < pp.nPoints(); pointI++)
|
const labelListList& pointFaces = pp.pointFaces();
|
||||||
{
|
|
||||||
label faceI = pp.pointFaces()[pointI][0];
|
|
||||||
|
|
||||||
if (noTransform(forwardT[faceI], mergeDist))
|
forAll(pointFaces, pfi)
|
||||||
|
{
|
||||||
|
if (collocated[pointFaces[pfi][0]])
|
||||||
{
|
{
|
||||||
collocated[pointI] = 1u;
|
isCollocated[pfi] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return collocated;
|
return isCollocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -467,8 +376,7 @@ void Foam::globalPoints::initOwnPoints
|
|||||||
(
|
(
|
||||||
collocatedPoints
|
collocatedPoints
|
||||||
(
|
(
|
||||||
refCast<const coupledPolyPatch>(pp),
|
refCast<const coupledPolyPatch>(pp)
|
||||||
mergeDist
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -563,8 +471,7 @@ void Foam::globalPoints::sendPatchPoints
|
|||||||
(
|
(
|
||||||
collocatedPoints
|
collocatedPoints
|
||||||
(
|
(
|
||||||
procPatch,
|
procPatch
|
||||||
mergeDist
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -663,8 +570,7 @@ void Foam::globalPoints::receivePatchPoints
|
|||||||
(
|
(
|
||||||
collocatedPoints
|
collocatedPoints
|
||||||
(
|
(
|
||||||
procPatch,
|
procPatch
|
||||||
mergeDist
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -726,8 +632,7 @@ void Foam::globalPoints::receivePatchPoints
|
|||||||
(
|
(
|
||||||
collocatedPoints
|
collocatedPoints
|
||||||
(
|
(
|
||||||
cycPatch,
|
cycPatch
|
||||||
mergeDist
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1233,8 +1138,7 @@ void Foam::globalPoints::receiveSharedPoints
|
|||||||
(
|
(
|
||||||
collocatedPoints
|
collocatedPoints
|
||||||
(
|
(
|
||||||
cycPatch,
|
cycPatch
|
||||||
mergeDist
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -127,9 +127,6 @@ class globalPoints
|
|||||||
// collocated coupled points.
|
// collocated coupled points.
|
||||||
static const label fromCollocated;
|
static const label fromCollocated;
|
||||||
|
|
||||||
//- Distance to check whether points/faces are collocated.
|
|
||||||
static const scalar mergeDist;
|
|
||||||
|
|
||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -162,22 +159,9 @@ class globalPoints
|
|||||||
|
|
||||||
// Private Member Functions
|
// 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
|
//- Return per point collocated status
|
||||||
static PackedBoolList collocatedPoints
|
static PackedBoolList collocatedPoints(const coupledPolyPatch&);
|
||||||
(
|
|
||||||
const coupledPolyPatch&,
|
|
||||||
const scalar mergeDist
|
|
||||||
);
|
|
||||||
|
|
||||||
// Wrappers around global point numbering to add collocated bit
|
// Wrappers around global point numbering to add collocated bit
|
||||||
|
|
||||||
|
|||||||
@ -285,6 +285,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
separation_.setSize(0);
|
separation_.setSize(0);
|
||||||
forwardT_ = I;
|
forwardT_ = I;
|
||||||
reverseT_ = I;
|
reverseT_ = I;
|
||||||
|
collocated_.setSize(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -299,10 +300,14 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
{
|
{
|
||||||
// Rotation, no separation
|
// Rotation, no separation
|
||||||
|
|
||||||
|
// Assume per-face differening transformation, correct later
|
||||||
|
|
||||||
separation_.setSize(0);
|
separation_.setSize(0);
|
||||||
|
|
||||||
forwardT_.setSize(Cf.size());
|
forwardT_.setSize(Cf.size());
|
||||||
reverseT_.setSize(Cf.size());
|
reverseT_.setSize(Cf.size());
|
||||||
|
collocated_.setSize(Cf.size());
|
||||||
|
collocated_ = false;
|
||||||
|
|
||||||
forAll (forwardT_, facei)
|
forAll (forwardT_, facei)
|
||||||
{
|
{
|
||||||
@ -321,6 +326,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
{
|
{
|
||||||
forwardT_.setSize(1);
|
forwardT_.setSize(1);
|
||||||
reverseT_.setSize(1);
|
reverseT_.setSize(1);
|
||||||
|
collocated_.setSize(1);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -332,11 +338,15 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// No rotation, possible separation
|
||||||
|
|
||||||
forwardT_.setSize(0);
|
forwardT_.setSize(0);
|
||||||
reverseT_.setSize(0);
|
reverseT_.setSize(0);
|
||||||
|
|
||||||
separation_ = (nf&(Cr - Cf))*nf;
|
separation_ = (nf&(Cr - Cf))*nf;
|
||||||
|
|
||||||
|
collocated_.setSize(separation_.size());
|
||||||
|
|
||||||
// Three situations:
|
// Three situations:
|
||||||
// - separation is zero. No separation.
|
// - separation is zero. No separation.
|
||||||
// - separation is same. Single separation vector.
|
// - separation is same. Single separation vector.
|
||||||
@ -344,15 +354,23 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
|
|
||||||
// Check for different separation per face
|
// Check for different separation per face
|
||||||
bool sameSeparation = true;
|
bool sameSeparation = true;
|
||||||
|
bool doneWarning = false;
|
||||||
|
|
||||||
forAll(separation_, facei)
|
forAll(separation_, facei)
|
||||||
{
|
{
|
||||||
scalar smallSqr = sqr(smallDist[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 (magSqr(separation_[facei] - separation_[0]) > smallSqr)
|
||||||
{
|
{
|
||||||
if (debug)
|
sameSeparation = false;
|
||||||
|
|
||||||
|
if (!doneWarning && debug)
|
||||||
{
|
{
|
||||||
|
doneWarning = true;
|
||||||
|
|
||||||
Pout<< " separation " << separation_[facei]
|
Pout<< " separation " << separation_[facei]
|
||||||
<< " at " << facei
|
<< " at " << facei
|
||||||
<< " differs from separation[0] " << separation_[0]
|
<< " differs from separation[0] " << separation_[0]
|
||||||
@ -360,15 +378,13 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
<< smallDist[facei]
|
<< smallDist[facei]
|
||||||
<< ". Assuming non-uniform separation." << endl;
|
<< ". Assuming non-uniform separation." << endl;
|
||||||
}
|
}
|
||||||
sameSeparation = false;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sameSeparation)
|
if (sameSeparation)
|
||||||
{
|
{
|
||||||
// Check for zero separation (at 0 so everywhere)
|
// Check for zero separation (at 0 so everywhere)
|
||||||
if (magSqr(separation_[0]) < sqr(smallDist[0]))
|
if (collocated_[0])
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -378,6 +394,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
}
|
}
|
||||||
|
|
||||||
separation_.setSize(0);
|
separation_.setSize(0);
|
||||||
|
collocated_ = boolList(1, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -389,6 +406,7 @@ void Foam::coupledPolyPatch::calcTransformTensors
|
|||||||
}
|
}
|
||||||
|
|
||||||
separation_.setSize(1);
|
separation_.setSize(1);
|
||||||
|
collocated_ = boolList(1, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,6 +64,9 @@ class coupledPolyPatch
|
|||||||
//- Neighbour-cell transformation tensor
|
//- Neighbour-cell transformation tensor
|
||||||
mutable tensorField reverseT_;
|
mutable tensorField reverseT_;
|
||||||
|
|
||||||
|
//- Are faces collocated. Either size 0,1 or length of patch.
|
||||||
|
mutable boolList collocated_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Static data members
|
// Static data members
|
||||||
@ -261,7 +264,6 @@ public:
|
|||||||
return separation_;
|
return separation_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Are the cyclic planes parallel
|
//- Are the cyclic planes parallel
|
||||||
bool parallel() const
|
bool parallel() const
|
||||||
{
|
{
|
||||||
@ -280,6 +282,12 @@ public:
|
|||||||
return reverseT_;
|
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
|
//- Initialize ordering for primitivePatch. Does not
|
||||||
// refer to *this (except for name() and type() etc.)
|
// refer to *this (except for name() and type() etc.)
|
||||||
|
|||||||
Reference in New Issue
Block a user