|
[Sponsors] |
July 2, 2019, 09:38 |
Cube root in OpenFOAM
|
#1 |
New Member
Join Date: Jun 2019
Posts: 17
Rep Power: 7 |
Hello everyone,
Does anyone knows how to put cube root in OpenFOAM? |
|
July 5, 2019, 09:59 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Yes, this is quite straightforward. Knowing that we can calculate the square root of something e.g. x with :
Code:
sqrtX = sqrt(x) Code:
cbrtX = cbrt(x) Code:
cbrtX = pow(x,1.0/3.0) |
|
July 5, 2019, 10:42 |
|
#3 |
New Member
Join Date: Jun 2019
Posts: 17
Rep Power: 7 |
Thanks a lot!
|
|
July 5, 2019, 10:43 |
|
#4 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
For a more safe result (including negative numbers) you can use the following:
Code:
// calculate the cube root of abs(x) cbrtAbsX = pow(abs(x), 1.0/3.0) // the cube root is returned according to the sign of x cbrtX = (x < 0)? -cbrtAbsX:cbrtAbsX |
|
July 5, 2019, 11:24 |
|
#5 |
New Member
Join Date: Jun 2019
Posts: 17
Rep Power: 7 |
Thanks for the suggestion!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OpenFOAM course for beginners | Jibran | OpenFOAM Announcements from Other Sources | 2 | November 4, 2019 09:51 |
How to contribute to the community of OpenFOAM users and to the OpenFOAM technology | wyldckat | OpenFOAM | 17 | November 10, 2017 16:54 |
[snappyHexMesh] snappyHexMesh on sharp corners (cube) | Regis_ | OpenFOAM Meshing & Mesh Conversion | 0 | June 5, 2015 00:47 |
[OpenFOAM.org] How to get OpenFoam compiled on a cluster with CentOS 6.5 and no root permissions | hulli | OpenFOAM Installation | 2 | November 6, 2014 19:01 |
Environment errors with .deb install and ubuntu 13.04 64 bit | jonathanbyrn | OpenFOAM Installation | 14 | September 26, 2013 06:22 |