From 62dd0f06504a50c4c37f6aa782d4a306cccd8f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kan=20Nilsson?= Date: Fri, 23 May 2014 19:47:24 +0200 Subject: [PATCH] Added option cylToCart, to convert points in cylindrical coordinates to Cartesian coordinates --- .../transformPoints/transformPoints.C | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C index 561ae76c6..b5e4da1dc 100644 --- a/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C +++ b/applications/utilities/mesh/manipulation/transformPoints/transformPoints.C @@ -44,6 +44,14 @@ Usage -scale vector Scales the points by the given vector. + -cylToCart (vector vector) + Assumes that constant/points is defined in cylindrical coordinates: + (radialPosition tangentialPosition axialPosition) for a coordinate + system with origin: first vec, axis: second vec, direction: third vec + Radial and axial positions should be in [m]. + Tangential positions should be in [radians]. + Transforms the points to Cartesian positions. + The any or all of the three options may be specified and are processed in the above order. @@ -69,6 +77,7 @@ Usage #include "transformGeometricField.H" #include "IStringStream.H" #include "RodriguesRotation.H" +#include "cylindricalCS.H" using namespace Foam; using namespace Foam::mathematicalConstant; @@ -151,6 +160,7 @@ int main(int argc, char *argv[]) argList::validOptions.insert("yawPitchRoll", "(yaw pitch roll)"); argList::validOptions.insert("rotateFields", ""); argList::validOptions.insert("scale", "vector"); + argList::validOptions.insert("cylToCart", "(originVec axisVec directionVec)"); # include "setRootCase.H" # include "createTime.H" @@ -186,7 +196,7 @@ int main(int argc, char *argv[]) { FatalErrorIn(args.executable()) << "No options supplied, please use one or more of " - "-translate, -rotate or -scale options." + "-translate, -rotate, -scale, or -cylToCart options." << exit(FatalError); } @@ -301,6 +311,25 @@ int main(int argc, char *argv[]) points.replace(vector::Z, scaleVector.z()*points.component(vector::Z)); } + if (args.optionFound("cylToCart")) + //HN, 140523 + { + vectorField n1n2(args.optionLookup("cylToCart")()); + n1n2[1] /= mag(n1n2[1]); + n1n2[2] /= mag(n1n2[2]); + + cylindricalCS ccs + ( + "ccs", + n1n2[0], + n1n2[1], + n1n2[2], + false // Use radians + ); + + points = ccs.globalPosition(points); + } + // Set the precision of the points data to 10 IOstream::defaultPrecision(10);