From d5829988d80578d4ba2ef48aa6a26e29f419f97c Mon Sep 17 00:00:00 2001 From: graham Date: Thu, 28 Jan 2010 13:56:13 +0000 Subject: [PATCH] plane class: adding normalisation of normal vector for vector only constructor. --- .../meshes/primitiveShapes/plane/plane.C | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C index 2e90e4d62c..6f711cc603 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C +++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C @@ -128,7 +128,20 @@ Foam::plane::plane(const vector& normalVector) : unitVector_(normalVector), basePoint_(vector::zero) -{} +{ + scalar magUnitVector(mag(unitVector_)); + + if (magUnitVector > VSMALL) + { + unitVector_ /= magUnitVector; + } + else + { + FatalErrorIn("plane::plane(const point&, const vector&)") + << "plane normal has zero length" + << abort(FatalError); + } +} // Construct from point and normal vector @@ -146,8 +159,8 @@ Foam::plane::plane(const point& basePoint, const vector& normalVector) else { FatalErrorIn("plane::plane(const point&, const vector&)") - << "plane normal has got zero length" - << abort(FatalError); + << "plane normal has zero length" + << abort(FatalError); } } @@ -217,8 +230,8 @@ Foam::plane::plane(const dictionary& dict) "plane::plane(const dictionary&)", dict ) - << "Invalid plane type: " << planeType - << abort(FatalIOError); + << "Invalid plane type: " << planeType + << abort(FatalIOError); } } @@ -238,7 +251,7 @@ Foam::plane::plane(Istream& is) else { FatalErrorIn("plane::plane(Istream& is)") - << "plane normal has got zero length" + << "plane normal has zero length" << abort(FatalError); } }