cyclic ordering fix

This commit is contained in:
mattijs
2008-07-17 14:15:43 +01:00
parent 46b102bd8f
commit ce66358a57
2 changed files with 44 additions and 30 deletions

View File

@ -60,27 +60,35 @@ const NamedEnum<cyclicPolyPatch::transformType, 3>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::label Foam::cyclicPolyPatch::findMaxArea
(
const pointField& points,
const faceList& faces
)
{
label maxI = -1;
scalar maxAreaSqr = -GREAT;
forAll(faces, faceI)
{
scalar areaSqr = magSqr(faces[faceI].normal(points));
if (areaSqr > maxAreaSqr)
{
maxAreaSqr = areaSqr;
maxI = faceI;
}
}
return maxI;
}
void Foam::cyclicPolyPatch::calcTransforms() void Foam::cyclicPolyPatch::calcTransforms()
{ {
if (size() > 0) if (size() > 0)
{ {
const pointField& points = this->points(); const pointField& points = this->points();
maxI_ = -1;
scalar maxAreaSqr = -GREAT;
for (label faceI = 0; faceI < size()/2; faceI++)
{
const face& f = operator[](faceI);
scalar areaSqr = magSqr(f.normal(points));
if (areaSqr > maxAreaSqr)
{
maxAreaSqr = areaSqr;
maxI_ = faceI;
}
}
primitivePatch half0 primitivePatch half0
( (
SubList<face> SubList<face>
@ -369,6 +377,9 @@ bool Foam::cyclicPolyPatch::getGeometricHalves
} }
// Given a split of faces into left and right half calculate the centres
// and anchor points. Transform the left points so they align with the
// right ones.
void Foam::cyclicPolyPatch::getCentresAndAnchors void Foam::cyclicPolyPatch::getCentresAndAnchors
( (
const primitivePatch& pp, const primitivePatch& pp,
@ -403,11 +414,17 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
} }
default: default:
{ {
// Assumes that cyclic is correctly ordered, so that face[maxI_] // Assumes that cyclic is planar. This is also the initial
// on each side is equivalent. // condition for patches without faces.
n0 = half0Faces[maxI_].normal(pp.points());
// Determine the face with max area on both halves. These
// two faces are used to determine the transformation tensors
label max0I = findMaxArea(pp.points(), half0Faces);
n0 = half0Faces[max0I].normal(pp.points());
n0 /= mag(n0) + VSMALL; n0 /= mag(n0) + VSMALL;
n1 = half1Faces[maxI_].normal(pp.points());
label max1I = findMaxArea(pp.points(), half1Faces);
n1 = half1Faces[max1I].normal(pp.points());
n1 /= mag(n1) + VSMALL; n1 /= mag(n1) + VSMALL;
} }
} }
@ -596,7 +613,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL), coupledEdgesPtr_(NULL),
featureCos_(0.9), featureCos_(0.9),
maxI_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero) rotationCentre_(point::zero)
@ -617,7 +633,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL), coupledEdgesPtr_(NULL),
featureCos_(0.9), featureCos_(0.9),
maxI_(-1),
transform_(UNKNOWN), transform_(UNKNOWN),
rotationAxis_(vector::zero), rotationAxis_(vector::zero),
rotationCentre_(point::zero) rotationCentre_(point::zero)
@ -658,7 +673,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL), coupledEdgesPtr_(NULL),
featureCos_(pp.featureCos_), featureCos_(pp.featureCos_),
maxI_(pp.maxI_),
transform_(pp.transform_), transform_(pp.transform_),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_) rotationCentre_(pp.rotationCentre_)
@ -680,7 +694,6 @@ Foam::cyclicPolyPatch::cyclicPolyPatch
coupledPointsPtr_(NULL), coupledPointsPtr_(NULL),
coupledEdgesPtr_(NULL), coupledEdgesPtr_(NULL),
featureCos_(pp.featureCos_), featureCos_(pp.featureCos_),
maxI_(pp.maxI_),
transform_(pp.transform_), transform_(pp.transform_),
rotationAxis_(pp.rotationAxis_), rotationAxis_(pp.rotationAxis_),
rotationCentre_(pp.rotationCentre_) rotationCentre_(pp.rotationCentre_)

View File

@ -98,9 +98,6 @@ private:
// Used to split cyclic into halves. // Used to split cyclic into halves.
scalar featureCos_; scalar featureCos_;
//- Index of largest cell face
label maxI_;
//- Type of transformation - rotational or translational //- Type of transformation - rotational or translational
transformType transform_; transformType transform_;
@ -113,8 +110,12 @@ private:
// Private member functions // Private member functions
//- Find amongst selected faces the one with the largest area
static label findMaxArea(const pointField&, const faceList&);
void calcTransforms(); void calcTransforms();
// Face ordering // Face ordering
//- Find the two parts of the faces of pp using feature edges. //- Find the two parts of the faces of pp using feature edges.
@ -169,16 +170,16 @@ protected:
// Protected Member functions // Protected Member functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
void initGeometry(); virtual void initGeometry();
//- Calculate the patch geometry //- Calculate the patch geometry
void calcGeometry(); virtual void calcGeometry();
//- Initialise the patches for moving points //- Initialise the patches for moving points
void initMovePoints(const pointField&); virtual void initMovePoints(const pointField&);
//- Correct patches after moving points //- Correct patches after moving points
void movePoints(const pointField&); virtual void movePoints(const pointField&);
//- Initialise the update of the patch topology //- Initialise the update of the patch topology
virtual void initUpdateMesh(); virtual void initUpdateMesh();