CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

Define value of field function when it's equal to 0

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 8, 2022, 07:49
Default Define value of field function when it's equal to 0
  #1
New Member
 
Join Date: Aug 2021
Posts: 5
Rep Power: 5
Faraam is on a distinguished road
Hello,

is there a way to set the value of a field function when it becomes 0?

The field function f(t) is defined as:

f(t) = 1/(sin(2*pi*t))^2,

with t representing time. The field function becomes 0 at e.g. t = 0.

Since a division by 0 is not possible I want to replace the value of f(t) when it's value is N.a.N. for example by implementing an if statement.

Is there a way to realise the replacement by an if condition or by another way?
Faraam is offline   Reply With Quote

Old   January 8, 2022, 12:44
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,752
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
The answer to your question regarding if is:

if ( boolean ? a : b)
returns a when the boolean is true, else returns b

But the answer to your problem lies in implementation. Use a max function like so:
f(t) = 1/max((sin(2*pi*t))^2,1e-10)

This way you divide by 1e-10 instead of 0 when sin^2 becomes very small
Faraam likes this.
LuckyTran is online now   Reply With Quote

Old   January 23, 2022, 12:03
Default
  #3
New Member
 
Join Date: Aug 2021
Posts: 5
Rep Power: 5
Faraam is on a distinguished road
Thank you, worked perfectly!
Faraam is offline   Reply With Quote

Reply

Tags
field fucntion, if statement, time


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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 12:04
[mesh manipulation] refineMesh Error mohsen.boojari OpenFOAM Meshing & Mesh Conversion 3 March 1, 2018 23:07
Installing OF 1.6 on Mac OS X gschaider OpenFOAM Installation 129 June 19, 2010 10:23
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59


All times are GMT -4. The time now is 21:32.