|
[Sponsors] |
January 27, 2023, 09:42 |
Rotate a field
|
#1 |
New Member
Join Date: Jan 2023
Posts: 2
Rep Power: 0 |
Hi all,
Ive been reading this forum a lot and have drawn many useful information for developing my new solver. Close to finishing, I am now stuck and looking for some help. What I want to do: I want to rotate the components of a vector respectively a tensor field. By rotation I mean just rotate the vectors or tensor by changing theirs components. I dont want to rotate the mesh here nor do I want to change the cell center locations or anything. What I do have:
Code:
// Print a vector before rotation (debugging) Info<<mesh_.lookupObjectRef<volVectorField> ( "U" ).ref()[1] << nl << endl; // Rotation to be performed vector rotaxis(0, 0, 1); // about z axis scalar rotangle(3.14159/2.0) ; // around 90° quaternion rotationquaternion(rotangle,rotaxis); // Perform rotation Foam::transform ( rotationquaternion, mesh_.lookupObjectRef<volVectorField> ( "U" ).ref() ); // Print a vector after rotation (debugging) Info<<mesh_.lookupObjectRef<volVectorField> ( "U" ).ref()[1] << nl << endl; Code:
(-3.89156e-05 1.63329e-05 -2.96595e-05) (-3.89156e-05 1.63329e-05 -2.96595e-05) Code:
(-3.89156e-05 1.63329e-05 -2.96595e-05) (-1.63329e-05 -3.89156e-05 -2.96595e-05) Any help is highly appreciated! Thank you! vtAM Last edited by vtAM; January 27, 2023 at 09:43. Reason: Code formatting |
|
January 27, 2023, 11:31 |
|
#2 |
New Member
Join Date: Jan 2023
Posts: 2
Rep Power: 0 |
Just managed to solve. This is working as inteded:
Code:
// Print a vector before rotation (debugging) Info<<mesh_.lookupObjectRef<volVectorField> ( "U" ).internalField()[678] << nl << endl; // Rotation to be performed vector rotaxis(0, 0, 1); // about z axis scalar rotangle(M_PI_2) ; // 90° quaternion rotationquaternion(rotaxis, rotangle); Info<< "quaternion " << rotationquaternion << nl << endl; // Perform rotation Foam::transform ( mesh_.lookupObjectRef<volVectorField> ( "U" ).ref(), rotationquaternion, mesh_.lookupObjectRef<volVectorField> ( "U" ).internalField() ); // Print a vector after rotation (debugging) Info<<mesh_.lookupObjectRef<volVectorField> ( "U" ).internalField()[678] << nl << endl; There are three changes made.
Cheers, vtAM |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Initial pressure field from velocity field (incompressible) | dhein | STAR-CCM+ | 3 | January 18, 2022 08:12 |
turbulence field omega stops solver | woodie | OpenFOAM Pre-Processing | 1 | January 9, 2022 10:42 |
Implement field function with data from previous time steps as boundary condition | Faraam | STAR-CCM+ | 0 | August 20, 2021 15:33 |
potential flows, helmholtz decomposition and other stuffs | pigna | Main CFD Forum | 1 | October 26, 2017 08:34 |
[General] How to create an additional vector with {Field 4, Field 5, Field 6} | Bombacar | ParaView | 1 | August 15, 2015 18:05 |