Skip to content
Snippets Groups Projects
Commit 7b5da77f authored by Henry's avatar Henry
Browse files

symmetryPlanePolyPatch: calculate the plane normal during construction to...

symmetryPlanePolyPatch: calculate the plane normal during construction to guarantee parallel consistency
parent 29b8ad5e
No related merge requests found
......@@ -50,7 +50,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(name, size, start, index, bm, patchType),
n_(vector::zero)
n_(calcNormal())
{}
......@@ -64,7 +64,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(name, dict, index, bm, patchType),
n_(vector::zero)
n_(calcNormal())
{}
......@@ -75,7 +75,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm),
n_(vector::zero)
n_(calcNormal())
{}
......@@ -89,7 +89,7 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm, index, newSize, newStart),
n_(vector::zero)
n_(calcNormal())
{}
......@@ -103,47 +103,42 @@ Foam::symmetryPlanePolyPatch::symmetryPlanePolyPatch
)
:
polyPatch(pp, bm, index, mapAddressing, newStart),
n_(vector::zero)
n_(calcNormal())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * //
const Foam::vector& Foam::symmetryPlanePolyPatch::n() const
Foam::vector Foam::symmetryPlanePolyPatch::calcNormal() const
{
// If the symmetry normal is not set calculate it
// as the average face-normal
if (magSqr(n_) < 0.5)
if (returnReduce(size(), sumOp<label>()) == 0)
{
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);
// 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)
// Check the symmetry plane is planar
forAll(nf, facei)
{
if (magSqr(n - nf[facei]) > SMALL)
{
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);
}
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_;
return n;
}
}
......
......@@ -52,8 +52,13 @@ class symmetryPlanePolyPatch
{
// Private data
//- Symmetry plane normal (calculated on demand)
mutable vector n_;
//- Symmetry plane normal
vector n_;
// Private member functions
//- Calculate and return the symmetry plane normal
vector calcNormal() const;
public:
......@@ -162,7 +167,10 @@ public:
// Member Functions
//- Return symmetry plane normal
const vector& n() const;
const vector& n() const
{
return n_;
}
};
......
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