From ddc1b8fe0a6546a171cd61c01cbd2e326414b959 Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Sat, 1 Feb 2014 20:35:12 +0000 Subject: [PATCH] symmetryPlanePolyPatch: calculate n_ in initGeometry --- .../symmetryPlane/symmetryPlanePolyPatch.C | 79 +++++++++---------- .../symmetryPlane/symmetryPlanePolyPatch.H | 9 ++- 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C index 34af0b708c5..d3c78904b97 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C @@ -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; - } -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.H index 5117b1b7bc8..90ce862cf82 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.H @@ -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: -- GitLab