CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Pre-Processing

funkySetFields - expression evaluation - error

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 25, 2012, 12:02
Default funkySetFields - expression evaluation - error
  #1
Member
 
Greg Melling
Join Date: Nov 2010
Posts: 41
Rep Power: 6
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, 20:09
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40
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, 05:46
Default
  #3
Member
 
Greg Melling
Join Date: Nov 2010
Posts: 41
Rep Power: 6
grjmell is on a distinguished road
Thanks for the explanation. It is a clever work around!
grjmell is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Native ParaView Reader Bugs tj22 OpenFOAM Paraview & paraFoam 267 July 20, 2015 22:29
Problem About Running Fluent In Linux mitra FLUENT 12 October 15, 2014 09:27
Building OpenFOAM1.7.0 from source ata OpenFOAM Installation 42 May 14, 2012 20:48
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 20:41.