diff --git a/applications/test/quaternion/Test-quaternion.C b/applications/test/quaternion/Test-quaternion.C index 1317ad4bf3..852a31fed1 100644 --- a/applications/test/quaternion/Test-quaternion.C +++ b/applications/test/quaternion/Test-quaternion.C @@ -68,6 +68,21 @@ void printRotation(const quaternion& quat) } +bool equalTensors(const tensor& rot1, const tensor& rot2) +{ + for (direction cmpt=0; cmpt < tensor::nComponents; ++cmpt) + { + // Cannot be really picky, but SMALL is reasonable + if (mag(rot1[cmpt] - rot2[cmpt]) > SMALL) + { + return false; + } + } + + return true; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -108,8 +123,17 @@ int main(int argc, char *argv[]) "(vector angle)", "Rotate about the by degrees - eg, '((1 0 0) 45)'" ); + argList::addBoolOption + ( + "verbose", + "Additional verbosity" + ); + argList args(argc, argv); + const bool verbose = args.found("verbose"); + + vector rotVector; if (args.readIfPresent("rollPitchYaw", rotVector)) @@ -122,10 +146,18 @@ int main(int argc, char *argv[]) rotVector *= degToRad(); - const quaternion quat(quaternion::rotationSequence::XYZ, rotVector); + const quaternion quat(quaternion::eulerOrder::XYZ, rotVector); printRotation(quat); + + // Euler + const tensor rot + ( + euler::rotation(euler::eulerOrder::XYZ, rotVector, false) + ); + printRotation(rot); } + if (args.readIfPresent("yawPitchRoll", rotVector)) { Info<< nl @@ -136,9 +168,16 @@ int main(int argc, char *argv[]) rotVector *= degToRad(); - const quaternion quat(quaternion::rotationSequence::ZYX, rotVector); + const quaternion quat(quaternion::eulerOrder::ZYX, rotVector); printRotation(quat); + + // Euler + const tensor rot + ( + euler::rotation(euler::eulerOrder::ZYX, rotVector, false) + ); + printRotation(rot); } if (args.readIfPresent("euler", rotVector)) { @@ -152,7 +191,7 @@ int main(int argc, char *argv[]) rotVector *= degToRad(); - const quaternion quat(quaternion::rotationSequence::ZXZ, rotVector); + const quaternion quat(quaternion::eulerOrder::ZXZ, rotVector); printRotation(quat); } @@ -266,23 +305,44 @@ int main(int argc, char *argv[]) Info<< "Test conversion from and to Euler-angles" << nl; vector angles(0.1, 0.2, 0.3); - for (int rs=quaternion::ZYX; rs SMALL ) { FatalErrorInFunction - << "Inconsistent conversion for rotation sequence " - << rs << exit(FatalError) - << nl; + << "Inconsistent conversion for euler rotation order " + << orderName << nl << exit(FatalError); + } + + + tensor rotQ(quaternion(order, angles).R()); + tensor rotE(euler::rotation(order, angles, false)); + + if (verbose) + { + Info<< "euler " << orderName << angles << nl; + printRotation(rotE); + } + + if (!equalTensors(rotQ, rotE)) + { + WarningInFunction + << "Inconsistent quaternion/euler rotation matrices for " + << orderName << nl; + + printRotation(rotQ); + printRotation(rotE); + + FatalError + << nl << exit(FatalError); } } diff --git a/applications/test/sizeof/Make/options b/applications/test/sizeof/Make/options index 4e772fdf9d..410c857f85 100644 --- a/applications/test/sizeof/Make/options +++ b/applications/test/sizeof/Make/options @@ -1,2 +1,5 @@ -/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + /* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/utilities/mesh/manipulation/transformPoints/Make/options b/applications/utilities/mesh/manipulation/transformPoints/Make/options index 16eb624bec..969020c4af 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/Make/options +++ b/applications/utilities/mesh/manipulation/transformPoints/Make/options @@ -1,6 +1,8 @@ EXE_INC = \ - -I$(LIB_SRC)/finiteVolume/lnInclude + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteVolume \ + -lmeshTools \ -lgenericPatchFields diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 698ec7f601..f19e726fc8 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -57,7 +57,7 @@ Usage With -rotateFields (in combination with -rotate/yawPitchRoll/rollPitchYaw) it will also read & transform vector & tensor fields. - Note: +Note roll (rotation about x) pitch (rotation about y) yaw (rotation about z) @@ -73,9 +73,11 @@ Usage #include "pointFields.H" #include "transformField.H" #include "transformGeometricField.H" -#include "unitConversion.H" +#include "axisAngleRotation.H" +#include "EulerCoordinateRotation.H" using namespace Foam; +using namespace Foam::coordinateRotations; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -284,40 +286,38 @@ int main(int argc, char *argv[]) n1n2[0].normalise(); n1n2[1].normalise(); - const tensor rotT = rotationTensor(n1n2[0], n1n2[1]); + const tensor rot(rotationTensor(n1n2[0], n1n2[1])); - Info<< "Rotating points by " << rotT << endl; - - points = transform(rotT, points); + Info<< "Rotating points by " << rot << endl; + points = transform(rot, points); if (doRotateFields) { - rotateFields(args, runTime, rotT); + rotateFields(args, runTime, rot); } } else if (args.found("rotate-angle")) { - const Tuple2 axisAngle + const Tuple2 rotAxisAngle ( args.lookup("rotate-angle")() ); + const vector& axis = rotAxisAngle.first(); + const scalar& angle = rotAxisAngle.second(); + Info<< "Rotating points " << nl - << " about " << axisAngle.first() << nl - << " angle " << axisAngle.second() << nl; + << " about " << axis << nl + << " angle " << angle << nl; - const quaternion quat - ( - axisAngle.first(), - degToRad(axisAngle.second()) - ); + const tensor rot(axisAngle::rotation(axis, angle, true)); - Info<< "Rotating points by quaternion " << quat << endl; - points = transform(quat, points); + Info<< "Rotating points by " << rot << endl; + points = transform(rot, points); if (doRotateFields) { - rotateFields(args, runTime, quat.R()); + rotateFields(args, runTime, rot); } } else if (args.readIfPresent("rollPitchYaw", v)) @@ -327,16 +327,14 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " yaw " << v.z() << nl; - v *= degToRad(); + const tensor rot(euler::rotation(euler::eulerOrder::XYZ, v, true)); - const quaternion quat(quaternion::rotationSequence::XYZ, v); - - Info<< "Rotating points by quaternion " << quat << endl; - points = transform(quat, points); + Info<< "Rotating points by " << rot << endl; + points = transform(rot, points); if (doRotateFields) { - rotateFields(args, runTime, quat.R()); + rotateFields(args, runTime, rot); } } else if (args.readIfPresent("yawPitchRoll", v)) @@ -346,16 +344,14 @@ int main(int argc, char *argv[]) << " pitch " << v.y() << nl << " roll " << v.z() << nl; - v *= degToRad(); + const tensor rot(euler::rotation(euler::eulerOrder::ZYX, v, true)); - const quaternion quat(quaternion::rotationSequence::ZYX, v); - - Info<< "Rotating points by quaternion " << quat << endl; - points = transform(quat, points); + Info<< "Rotating points by " << rot << endl; + points = transform(rot, points); if (doRotateFields) { - rotateFields(args, runTime, quat.R()); + rotateFields(args, runTime, rot); } } diff --git a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C index 7232b683f4..6e3c8f5aec 100644 --- a/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C +++ b/applications/utilities/surface/surfaceMeshExtract/surfaceMeshExtract.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -24,7 +24,7 @@ License along with OpenFOAM. If not, see . Application - surfaceMeshTriangulate + surfaceMeshExtract Group grpSurfaceUtilities @@ -47,6 +47,7 @@ Description #include "argList.H" #include "Time.H" #include "polyMesh.H" +#include "emptyPolyPatch.H" #include "processorPolyPatch.H" #include "ListListOps.H" #include "uindirectPrimitivePatch.H" @@ -58,6 +59,57 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +labelList getSelectedPatches +( + const polyBoundaryMesh& patches, + const wordRes& whitelist, + const wordRes& blacklist +) +{ + DynamicList