|
[Sponsors] |
Define value of field function when it's equal to 0 |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 8, 2022, 07:49 |
Define value of field function when it's equal to 0
|
#1 |
New Member
Join Date: Aug 2021
Posts: 5
Rep Power: 5 |
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? |
|
January 8, 2022, 12:44 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,752
Rep Power: 66 |
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 |
|
January 23, 2022, 12:03 |
|
#3 |
New Member
Join Date: Aug 2021
Posts: 5
Rep Power: 5 |
Thank you, worked perfectly!
|
|
Tags |
field fucntion, if statement, time |
|
|
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 |