diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C index 1cdd66490d..ac17397ad2 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C @@ -301,8 +301,8 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating Foam::point pt1 = edgePt + s + ppDist*normal; Foam::point pt2 = edgePt - s + ppDist*normal; - Foam::point pt3 = reflectPointInPlane(pt1, facePlane); - Foam::point pt4 = reflectPointInPlane(pt2, facePlane); + Foam::point pt3 = facePlane.mirror(pt1); + Foam::point pt4 = facePlane.mirror(pt2); pts.append(Vb(pt1, Vb::vtInternalFeatureEdge)); pts.append(Vb(pt2, Vb::vtInternalFeatureEdge)); @@ -449,7 +449,7 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating if (masterPointReflectionsPrev.found(iter.key())) { const Foam::point reflectedPt = - reflectPointInPlane(pt, masterPointReflectionsPrev[iter.key()]); + masterPointReflectionsPrev[iter.key()].mirror(pt); // Info<< " Adding Prev " << reflectedPt << " " // << indexedVertexEnum::vertexTypeNames_[reflectedPtType] @@ -461,7 +461,7 @@ void Foam::conformalVoronoiMesh::createEdgePointGroupByCirculating if (masterPointReflectionsNext.found(iter.key())) { const Foam::point reflectedPt = - reflectPointInPlane(pt, masterPointReflectionsNext[iter.key()]); + masterPointReflectionsNext[iter.key()].mirror(pt); // Info<< " Adding Next " << reflectedPt << " " // << indexedVertexEnum::vertexTypeNames_[reflectedPtType] @@ -815,8 +815,8 @@ void Foam::conformalVoronoiMesh::createOpenEdgePointGroup Foam::point pt1 = edgePt + s + ppDist*n; Foam::point pt2 = edgePt - s + ppDist*n; - Foam::point pt3 = reflectPointInPlane(pt1, facePlane); - Foam::point pt4 = reflectPointInPlane(pt2, facePlane); + Foam::point pt3 = facePlane.mirror(pt1); + Foam::point pt4 = facePlane.mirror(pt2); pts.append(Vb(pt1, Vb::vtInternalSurface)); pts.append(Vb(pt2, Vb::vtInternalSurface)); @@ -1235,8 +1235,7 @@ void Foam::conformalVoronoiMesh::addMasterAndSlavePoints const plane& reflPlane = masterPointPlanes[planeI](); - const Foam::point slavePt = - reflectPointInPlane(masterPt, reflPlane); + const Foam::point slavePt = reflPlane.mirror(masterPt); // Info<< " Slave " << planeI << " = " << slavePt << endl; @@ -1717,27 +1716,9 @@ Foam::List Foam::conformalVoronoiMesh::reflectPointInPlanes forAll(planes, planeI) { - reflectedPoints[planeI] = reflectPointInPlane(p, planes[planeI]()); + reflectedPoints[planeI] = planes[planeI]().mirror(p); } return reflectedPoints; } - -Foam::point Foam::conformalVoronoiMesh::reflectPointInPlane -( - const Foam::point p, - const plane& planeN -) const -{ - const vector reflectedPtDir = p - planeN.nearestPoint(p); - - if ((planeN.normal() & reflectedPtDir) > 0) - { - return p - 2.0*planeN.distance(p)*planeN.normal(); - } - else - { - return p + 2.0*planeN.distance(p)*planeN.normal(); - } -} diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C index 410b20b387..fe4f649f15 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C +++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.C @@ -447,6 +447,21 @@ Foam::plane::side Foam::plane::sideOfPlane(const point& p) const } +Foam::point Foam::plane::mirror(const point& p) const +{ + const vector mirroredPtDir = p - nearestPoint(p); + + if ((normal() & mirroredPtDir) > 0) + { + return p - 2.0*distance(p)*normal(); + } + else + { + return p + 2.0*distance(p)*normal(); + } +} + + void Foam::plane::writeDict(Ostream& os) const { os.writeKeyword("planeType") << "pointAndNormal" diff --git a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H index 3a47e6bf2e..44564fa92a 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H +++ b/src/OpenFOAM/meshes/primitiveShapes/plane/plane.H @@ -194,6 +194,9 @@ public: // If the point is on the plane, then returns NORMAL. side sideOfPlane(const point& p) const; + //- Mirror the supplied point in the plane. Return the mirrored point. + point mirror(const point& p) const; + //- Write to dictionary void writeDict(Ostream&) const; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.C index 2de3fab7e0..c8d6c3fb96 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,7 +73,7 @@ Foam::solidBodyMotionFunctions::axisRotationMotion::transformation() const { scalar t = time_.value(); - // Rotation around centre of gravity (in radians) + // Rotation origin (in radians) vector omega ( t*degToRad(radialVelocity_.x()), @@ -83,7 +83,7 @@ Foam::solidBodyMotionFunctions::axisRotationMotion::transformation() const scalar magOmega = mag(omega); quaternion R(omega/magOmega, magOmega); - septernion TR(septernion(CofG_)*R*septernion(-CofG_)); + septernion TR(septernion(origin_)*R*septernion(-origin_)); Info<< "solidBodyMotionFunctions::axisRotationMotion::transformation(): " << "Time = " << t << " transformation: " << TR << endl; @@ -99,7 +99,7 @@ bool Foam::solidBodyMotionFunctions::axisRotationMotion::read { solidBodyMotionFunction::read(SBMFCoeffs); - SBMFCoeffs_.lookup("CofG") >> CofG_; + SBMFCoeffs_.lookup("origin") >> origin_; SBMFCoeffs_.lookup("radialVelocity") >> radialVelocity_; return true; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H index d372d82480..bc6b679365 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/axisRotationMotion/axisRotationMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,8 +57,8 @@ class axisRotationMotion { // Private data - //- Centre of gravity - point CofG_; + //- Origin + point origin_; //- Rotational velocity (deg/s) vector radialVelocity_; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.C index d729963b39..11715cd93f 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -82,7 +82,7 @@ transformation() const eulerAngles *= pi/180.0; quaternion R(eulerAngles.x(), eulerAngles.y(), eulerAngles.z()); - septernion TR(septernion(CofG_)*R*septernion(-CofG_)); + septernion TR(septernion(origin_)*R*septernion(-origin_)); Info<< "solidBodyMotionFunctions::oscillatingRotatingMotion::" << "transformation(): " @@ -99,7 +99,7 @@ bool Foam::solidBodyMotionFunctions::oscillatingRotatingMotion::read { solidBodyMotionFunction::read(SBMFCoeffs); - SBMFCoeffs_.lookup("CofG") >> CofG_; + SBMFCoeffs_.lookup("origin") >> origin_; SBMFCoeffs_.lookup("amplitude") >> amplitude_; SBMFCoeffs_.lookup("omega") >> omega_; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H index e0737a8b4d..cbe10a95ec 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/oscillatingRotatingMotion/oscillatingRotatingMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,7 +57,7 @@ class oscillatingRotatingMotion // Private data //- Centre of gravity - point CofG_; + point origin_; //- Amplitude vector amplitude_; diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.C index 58e1faddc3..7d716e687a 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,10 +54,11 @@ Foam::solidBodyMotionFunctions::rotatingMotion::rotatingMotion const Time& runTime ) : - solidBodyMotionFunction(SBMFCoeffs, runTime) -{ - read(SBMFCoeffs); -} + solidBodyMotionFunction(SBMFCoeffs, runTime), + origin_(SBMFCoeffs_.lookup("origin")), + axis_(SBMFCoeffs_.lookup("axis")), + omega_(DataEntry::New("omega", SBMFCoeffs_)) +{} // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // @@ -73,16 +74,11 @@ Foam::solidBodyMotionFunctions::rotatingMotion::transformation() const { scalar t = time_.value(); - // Motion around a centre of gravity - - // Rotation around centre of gravity (in degrees) - vector eulerAngles = radialVelocity_*t; - - // Convert the rotational motion from deg to rad - eulerAngles *= pi/180.0; + // Rotation around axis + vector eulerAngles = omega_->integrate(0, t)*axis_; quaternion R(eulerAngles.x(), eulerAngles.y(), eulerAngles.z()); - septernion TR(septernion(CofG_)*R*septernion(-CofG_)); + septernion TR(septernion(origin_)*R*septernion(-origin_)); Info<< "solidBodyMotionFunctions::rotatingMotion::transformation(): " << "Time = " << t << " transformation: " << TR << endl; @@ -98,8 +94,10 @@ bool Foam::solidBodyMotionFunctions::rotatingMotion::read { solidBodyMotionFunction::read(SBMFCoeffs); - SBMFCoeffs_.lookup("CofG") >> CofG_; - SBMFCoeffs_.lookup("radialVelocity") >> radialVelocity_; + omega_.reset + ( + DataEntry::New("omega", SBMFCoeffs_).ptr() + ); return true; } diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H index 487f7ec726..87ec08746f 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,8 +25,10 @@ Class Foam::solidBodyMotionFunctions::rotatingMotion Description - SolidBodyMotionFvMesh 6DoF motion function. Constant - velocity rotation around CoG. + SolidBodyMotionFvMesh 6DoF motion function. + + The rotation is defined by an origin and axis of rotation and an angular + speed. SourceFiles rotatingMotion.C @@ -39,6 +41,8 @@ SourceFiles #include "solidBodyMotionFunction.H" #include "primitiveFields.H" #include "point.H" +#include "DataEntry.H" +#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,11 +61,14 @@ class rotatingMotion { // Private data - //- Centre of gravity - point CofG_; + //- Origin of the axis + const vector origin_; - //- Rotational velocity (deg/s) - vector radialVelocity_; + //- Axis vector + const vector axis_; + + //- Angular velocty (rad/sec) + autoPtr > omega_; // Private Member Functions diff --git a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C index 05c86b7883..54ad050fc6 100644 --- a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C @@ -1386,17 +1386,11 @@ Foam::Istream& Foam::operator>> Foam::extendedFeatureEdgeMesh::sideVolumeType& vt ) { - // Read beginning of sideVolumeType - is.readBegin("sideVolumeType"); - - int type; + label type; is >> type; vt = static_cast(type); - // Read end of volumeType - is.readEnd("sideVolumeType"); - // Check state of Istream is.check("operator>>(Istream&, sideVolumeType&)"); @@ -1410,7 +1404,7 @@ Foam::Ostream& Foam::operator<< const Foam::extendedFeatureEdgeMesh::sideVolumeType& vt ) { - os << static_cast(vt); + os << static_cast