symmetryPlanePolyPatch: calculate n_ in initGeometry

This commit is contained in:
Henry
2014-02-01 20:35:12 +00:00
parent d25d7b28f5
commit ddc1b8fe0a
2 changed files with 45 additions and 43 deletions

View File

@ -37,6 +37,40 @@ namespace Foam
addToRunTimeSelectionTable(polyPatch, symmetryPlanePolyPatch, dictionary);
}
// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * //
void Foam::symmetryPlanePolyPatch::calcGeometry(PstreamBuffers&)
{
if (returnReduce(size(), sumOp<label>()) == 0)
{
// 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)
{
if (magSqr(n_ - nf[facei]) > SMALL)
{
FatalErrorIn("symmetryPlanePolyPatch::n()")
<< "Symmetry plane '" << name() << "' is not planar."
<< endl
<< " Either split the patch into planar parts"
<< " or use the " << symmetryPolyPatch::typeName
<< " patch type"
<< exit(FatalError);
}
}
}
}
// * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
@ -50,7 +84,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(name, size, start, index, bm, patchType),
n_(calcNormal())
n_(vector::rootMax)
{}
@ -64,7 +98,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(name, dict, index, bm, patchType),
n_(calcNormal())
n_(vector::rootMax)
{}
@ -75,7 +109,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm),
n_(calcNormal())
n_(vector::rootMax)
{}
@ -89,7 +123,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm, index, newSize, newStart),
n_(calcNormal())
n_(vector::rootMax)
{}
@ -103,43 +137,8 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm, index, mapAddressing, newStart),
n_(calcNormal())
n_(vector::rootMax)
{}
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::symmetryPlanePolyPatch::calcNormal() const
{
if (returnReduce(size(), sumOp<label>()) == 0)
{
// No faces in patch. Avoid gAverage complaining and set
// normal to nonsense value to catch any use
return vector::rootMax;
}
else
{
const vectorField& nf(faceNormals());
vector n = gAverage(nf);
// Check the symmetry plane is planar
forAll(nf, facei)
{
if (magSqr(n - nf[facei]) > SMALL)
{
FatalErrorIn("symmetryPlanePolyPatch::n()")
<< "Symmetry plane '" << name() << "' is not planar."
<< endl
<< " Either split the patch into planar parts"
<< " or use the " << symmetryPolyPatch::typeName
<< " patch type"
<< exit(FatalError);
}
}
return n;
}
}
// ************************************************************************* //

View File

@ -55,10 +55,13 @@ class symmetryPlanePolyPatch
//- Symmetry plane normal
vector n_;
// Private member functions
//- Calculate and return the symmetry plane normal
vector calcNormal() const;
protected:
// Protected Member Functions
//- Calculate the patch geometry
virtual void calcGeometry(PstreamBuffers&);
public: