CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Mesh Utilities (
-   -   transformPoints and rotateMesh (

bephi March 31, 2011 04:51

transformPoints and rotateMesh
hi at all!
i have a mesh which i would like to translate and rotate so that the coordinate system is in the middle of the inlet (nearly a circle) and the z-axis should be normal to the inlet surface.

when i read in just the inlet i get the following coordinates:
X Range: 0.00153 to 0.00418 (delta: 0.0026)
Y Range: 0.159 to 0.16 (delta: 0.00179)
Z Range: -0.218 to 0.216 (delta: 0.00212)

does anyone know how i can accomplish my aim with the utilities transformPoints -translate and rotateMesh?

with regards!

MartinB March 31, 2011 07:12

Hi bephi,

simple way to get the center:
x_c = 0.5 * (0.00153 + 0.00418)
y_c = 0.5 * (0.159 + 0.16)
z_c = 0.5 * (-0.218 to 0.216)

Test in paraview:
- Just import "inlet"-patch
- Sources->Sphere
- insert x_c, y_c and z_c in "Center"
- "Radius" = 0.00005

More exact way:
- import "inlet" patch into paraview
- File->Save Data, "Files of type: .csv"
- FieldAssociation "Points"
- Import the .csv-file into OpenOffice Calc
- use "AVERAGE" function for each column

Result is: (0.002850023 0.159609 -0.2167553)
Check in paraview as described above.

Move mesh with:

transformPoints -translate "(-0.002850023 -0.159609 +0.2167553)"
The surface normal is "0.004016555 0.7621565 0.647346". Desired direction is "0 0 -1".

rotateMesh "(0.004016555 0.7621565 0.647346)" "(0 0 -1)"
That's it...

Have fun


bephi March 31, 2011 07:50

Thank you very much! Everything worked fine! I always used a wrong normal vector! Now the mesh is like its supposed to be!

ehsan December 10, 2011 23:07


I like to move my all cells of my mesh only by dx/2 and dy/2 and create a new mesh. Could you please help me how to apply transform mesh command to create a new mesh whose cells are moved by dx/2 and dy/2 relative to the first mesh?

Thanks a lot


asoltoon February 14, 2013 01:14

Hi all,

I want to rotate my primary mesh block(around x axis) that is produced by blockMesh to align it with my STL file, but when I run:

rotateMesh "(0 1 0)" "(0 0 1)"
the following error appears:

| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:                      |
|    \\/    M anipulation  |                                                |
Build  : 2.1.1-221db2718bbb
Exec  : rotateMesh (0 1 0) (0 0 1)
Date  : Feb 14 2013
Time  : 08:36:43
Host  : "Ali-Laptop"
PID    : 3307
Case  : /home/ali/OpenFOAM/ali-2.1.1/run/tutorials/mesh/snappyHexMesh/wigleyTutor
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Writing points into directory "/home/ali/OpenFOAM/ali-2.1.1/run/tutorials/mesh/snappyHexMesh/wigleyTutor/constant/polyMesh"

No times selected

    From function rotateMesh
    in file db/Time/timeSelector.C at line 257.

FOAM exiting

when I don't rotate my mesh block and run SHM, then I can rotate the generated mesh but the rotation before final mesh generation is not possible. Can anybody help me?


nimasam February 14, 2013 02:44

Dear Ali

you can use following command

transformPoints -rotate  '( (0 1 0) (0 0 1) )'

asoltoon February 14, 2013 03:18

Thanks for the reply Nima.

sh.d July 31, 2013 10:21

Hi namasam
I want to rotat airfoil without rotated mesh. and using simplefoam in Different angles of attack
please can you help me?

nimasam July 31, 2013 10:24

its impossible to rotate airfoil but! fixed the mesh :P
you may want to change the direction of inlet velocity

linch August 13, 2013 05:13


short & simple question: how to use the transformPoints utility from a custom directory?

transformPoints  -roots sourceDir/sourceCase -case targetDir/targetCase -scale "(2.0 2.0 2.0)"
returns error:

bool IPstream::init(int& argc, char**& argv) : attempt to run parallel on 1 processor

From function UPstream::init(int& argc, char**& argv)
in file UPstream.C at line 81.

FOAM aborting
I suppose, that the -roots option is the wrong one, isn't? But in the options list I don't see any suitable option, to specify the root dir:

Usage: transformPoints [OPTIONS]
-case <dir> specify alternate case directory, default is the cwd
-noFunctionObjects do not execute functionObjects
-parallel run in parallel
-region <name> specify alternative mesh region
-rollPitchYaw <vector> transform in terms of '(roll pitch yaw)' in degrees
-roots <(dir1 .. dirN)> slave root directories for distributed running
-rotate <(vectorA vectorB)> transform in terms of a rotation between <vectorA> and <vectorB> - eg, '( (1 0 0) (0 0 1) )'
-rotateFields read and transform vector and tensor fields too
-scale <vector> scale by the specified amount - eg, '(0.001 0.001 0.001)' for a uniform [mm] to [m] scaling
-translate <vector> translate by the specified <vector> - eg, '(1 0 0)'
-yawPitchRoll <vector> transform in terms of '(yaw pitch roll)' in degrees
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage

Using: OpenFOAM-2.1.x (see
Build: 2.1.x-c1330db6b6e8
Something like -root instead of -roots would be the right option. I also tried

transformPoints  sourceDir/sourceCase targetDir/targetCase -scale "(2.0 2.0 2.0)"
, but it seems I have to provide options, since the error is:

Wrong number of arguments, expected 0 found 2
Best regards,

nimasam August 13, 2013 05:41

maybe you want to choose -case

transformPoints -case <write your path> -scale '(2.0 2.0 2.0)'

linch August 13, 2013 07:28

Ah ok,

it works, thanks. For that, I have to copy the mesh from the source to the target first. I was just irritated by the Hrvoje's post:

Originally Posted by hjasak (Post 181009)
Try something like:

transformPoints <root> <case> -scale "(1e-3 1e-3 1e-3)"



Porisel October 2, 2013 09:07

i typed following and got an error

transformPoints -scale (1000 1000 1000)
before, i done blockmesh and snappyhexmesh.

the problem, the stl points will be interpreted as meters, but should be millimeters.

the error:

Wrong number of arguments, expectet 0 found 2
typed it in the case folder.

colinB October 2, 2013 09:39

Dear Porisel

you are trying to use the wrong command!

the transformPoints command is used to transform an existing
mesh which has been created with sHM or blockMesh.

In order to transform your stl file however you need the command:


to see how it works type: surfaceTransformPoints -help

To get more insight on the commands available and what to use
them for have a look at the documentation of OpenFoam
chapter 3.6 where you find a detailed list of all utilities.


Porisel October 2, 2013 09:45

Hi colinB,
thank you for your answer.
i already have generated the mesh with blockmesh and snappyhexmesh. now i want to scale the whole mesh, because i dont want to have exorbitant velocity and pressure values ;)

but i will try surfaceTransformpoints.

kind regards,

colinB October 2, 2013 10:25

Oh sorry I misunderstood your post:

"before, i done blockmesh and snappyhexmesh."

the error then is that you forgot the inverted commas around your vector
so the correct command reads:

transformPoints -scale '(1000 1000 1000)'

maybe you also have to add a source file and a target file
(I'm not sure, but for surfaceTransformPoints you have to do so)


Porisel October 7, 2013 02:56

with inverted commas it dont work, too. but with quotationmarks it works well.

Madi July 12, 2016 10:46

4 Attachment(s)
Hi to all,

i tried to change my coordinate system. At the moment it is in the inlet, I tried to move it in the outlet at a waterlevel of 0.85. So i used

transformPoints -translate (15 0 0.85) But the only thing thats changed is that my mesh moved 15 m in x direction and 0.85 m in the z direction. The coordinate system remains the same. (Pictures)

Can someone fix my problem?


Madi July 12, 2016 11:49

ok i found my mistake, i move it into the negative way (- 15 0 -0.85) Then it's Zero in the outlet.

But now i want to do setFields again. But i didn't work anymore? But why? I doesnt write in the alpha.water file and dont make a box in my case. Isnt it allowd to do setFields after transform points?

bullmut October 19, 2016 13:01

Small q: can i rotate a zone?
The utility says i can rotate a region but i would like to rotate a cell zone...

Any advice

All times are GMT -4. The time now is 02:31.