CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] funkySetFields - expression evaluation - error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 25, 2012, 11:02
Default funkySetFields - expression evaluation - error
  #1
Member
 
Join Date: Nov 2010
Posts: 41
Rep Power: 15
grjmell is on a distinguished road
I have following expression in my funkSetFieldsDict:

Code:
expressions
(
    setInternalField
    {
        field Ub;
        expression  "pos().z >= 0.1 ? vector(log(pos().z-0.08),0,0) : vector(0,0,0) ";
        keepPatches true;
    }
);
I always get a floating point error, unless i remove the "-0.08" bit. due to the condition to only evaluate that equation if pos().z >= 0.1 there should be no log of zero... so i don't understand why i always get that error?? in my mesh pos().z goes from 0 to 0.5.
grjmell is offline   Reply With Quote

Old   January 25, 2012, 19:09
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by grjmell View Post
I have following expression in my funkSetFieldsDict:

Code:
expressions
(
    setInternalField
    {
        field Ub;
        expression  "pos().z >= 0.1 ? vector(log(pos().z-0.08),0,0) : vector(0,0,0) ";
        keepPatches true;
    }
);
I always get a floating point error, unless i remove the "-0.08" bit. due to the condition to only evaluate that equation if pos().z >= 0.1 there should be no log of zero... so i don't understand why i always get that error?? in my mesh pos().z goes from 0 to 0.5.
The problem is that for "a ? b : c" FSF first evaluates b and c and then picks from them according to a. Avoiding this would mean reprogramming almost all field operations.

The best solution I can think of is "vector(log(pos().z >= 0.1 ? pos().z-0.08 : 1),0,0)" (untested - hope there is no syntax error)
gschaider is offline   Reply With Quote

Old   January 26, 2012, 04:46
Default
  #3
Member
 
Join Date: Nov 2010
Posts: 41
Rep Power: 15
grjmell is on a distinguished road
Thanks for the explanation. It is a clever work around!
grjmell is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building OpenFOAM1.7.0 from source ata OpenFOAM Installation 46 March 6, 2022 13:21
[OpenFOAM.org] compile error in dynamicMesh and thermophysicalModels libraries NickG OpenFOAM Installation 3 December 30, 2019 00:21
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 11:39
POSDAT problem piotka STAR-CD 4 June 12, 2009 08:43
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 17:51


All times are GMT -4. The time now is 00:14.