|
[Sponsors] |
OpenFOAM 4.x: pow function cause floating point error |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 11, 2016, 10:13 |
OpenFOAM 4.x: pow function cause floating point error
|
#1 |
New Member
SSSSS
Join Date: Jun 2011
Posts: 29
Rep Power: 15 |
Hi,
I want to do some calculation with point coordinate with pow function. The code is roughly as follows: Code:
const pointMesh& pMesh = pointMesh::New(mesh); vectorField coord = this->points0(); scalarField sf(this->points0().size()); forAll(sf, pointi) { sf[pointi] = pow(coord[pointi].x(), 0.6); } when the exponent is integer type e.g., 2 instead of 0.6, then it works. The problem is always when the exponent is scalar type or float type. Any advice? |
|
September 11, 2016, 10:48 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quick answer: My guess is that you have "x" values that are negative. For example:
Code:
pow(a,0.5) Code:
sqrt(a)
__________________
|
|
September 11, 2016, 11:36 |
|
#3 |
New Member
SSSSS
Join Date: Jun 2011
Posts: 29
Rep Power: 15 |
Yes, you are right. Thanks alot.
|
|
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Running UDF with Supercomputer | roi247 | FLUENT | 4 | October 15, 2015 14:41 |
ParaView for OF-1.6-ext | Chrisi1984 | OpenFOAM Installation | 0 | December 31, 2010 07:42 |
Installation OF1.5-dev | ttdtud | OpenFOAM Installation | 46 | May 5, 2009 03:32 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |
[Gmsh] Gmsh and samplesurface | touf | OpenFOAM Meshing & Mesh Conversion | 2 | December 10, 2007 03:27 |