|
[Sponsors] |
October 29, 2018, 14:42 |
Rotating a vector in OpenFOAM
|
#1 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
In mathematics, to rotate a vector about the Z-axis by an angle of , we do the the matrix multiplication:
: is the new vector obtained by rotation. is the rotation matrix. is given by: My question is: Is there any builtin function in OpenFOAM to rotate a vector without doing that manually? something like: Code:
vector V(5.0, 1.0, 3.0); vector axis(0.0, 0.0, 1.0); vector W = vector::rotate(V, axis); |
|
October 29, 2018, 16:22 |
|
#2 |
Member
Martin
Join Date: Dec 2011
Posts: 40
Rep Power: 14 |
Hi again... I don't know if it can help you, but it may help others searching for the same thing.
First of all, rotations in 3D are very different from rotations in 2D. 3D rotations belong to SO3 group, which is not a vector space, but a manifold. 3D rotations can be parametrized in different ways; a set of 3 or 4 parameters is needed to build the rotational operator. Then, in contrast to the 2D case, 3D rotations are not commutative, and the parameters are often not additive. I know that OpenFOAM can use quaternions to rotate a vector field (I dont know if another set of parameters can be used, the quaternions play the role of your angles). Quaternions are a set a of 4 parameters that parametrize a 3D rotation globally. Since OF is thought to be 3D, you would probably have to use a 3D function and feed it with a 2D rotation parameters. As far as I know, that may not be enough, there is a function called transform such that, passing the quaternion as a parameter you obtain the rotated vector field. This is: Code:
Foam::tmp<Foam::vectorField> Foam::transform ( const quaternion& q, const vectorField& tf ) Last edited by msaravia; October 29, 2018 at 18:09. |
|
October 29, 2018, 17:56 |
|
#3 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
Thank you very much dear Martin for your answer
|
|
November 15, 2018, 10:42 |
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
If you have the rotation matrix, you can just do that directly. Eg Code:
tensor rot ( cos(theta), -sin(theta), 0, sin(theta), cos(theta), 0, 0, 0, 1 );. vector vec(someX, someY, somZ); vector vec1 = transform(rot, vec); vector vec2 = invTransform(rot, vec); // probably doesn't yet work, but does in1812 ... or manually: vector vec1 = rot & vec; vector vec2 = vec & rot; Code:
tensor rot = axesRotation(axis1, axis2).R(); vector vec1 = rot & vec; /mark |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM v3.0+ ?? | SBusch | OpenFOAM | 22 | December 26, 2016 15:24 |
OpenFOAM Training, London, Chicago, Munich, Houston 2016-2017 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | September 14, 2016 04:19 |
Superlinear speedup in OpenFOAM 13 | msrinath80 | OpenFOAM Running, Solving & CFD | 18 | March 3, 2015 06:36 |
[Other] OpenFOAM 2.1.0/x: rotating devices. | ebah6 | OpenFOAM Meshing & Mesh Conversion | 3 | January 31, 2012 11:54 |
Adventure of fisrst openfoam installation on Ubuntu 710 | jussi | OpenFOAM Installation | 0 | April 24, 2008 15:25 |