ENH: symmetryPolyPatch: handle zero faces case

This commit is contained in:
mattijs
2013-12-17 10:53:19 +00:00
parent c2f8fca557
commit 39a8a088c0

View File

@ -114,17 +114,26 @@ const Foam::vector& Foam::symmetryPlanePolyPatch::n() const
// as the average face-normal // as the average face-normal
if (magSqr(n_) < 0.5) if (magSqr(n_) < 0.5)
{ {
const vectorField& nf(faceNormals()); if (returnReduce(size(), sumOp<label>()) == 0)
n_ = gAverage(nf);
// Check the symmetry plane is planar
forAll(nf, facei)
{ {
if (magSqr(n_ - nf[facei]) > SMALL) // No faces in patch. Avoid gAverage complaining and set
// normal to nonsense value to catch any use
n_ = vector::rootMax;
}
else
{
const vectorField& nf(faceNormals());
n_ = gAverage(nf);
// Check the symmetry plane is planar
forAll(nf, facei)
{ {
FatalErrorIn("symmetryPlanePolyPatch::n()") if (magSqr(n_ - nf[facei]) > SMALL)
<< "Symmetry plane '" << name() << "' is not planar" {
<< exit(FatalError); FatalErrorIn("symmetryPlanePolyPatch::n()")
<< "Symmetry plane '" << name() << "' is not planar"
<< exit(FatalError);
}
} }
} }
} }