
[Sponsors] 
September 29, 2014, 04:22 
Cartesian to polar using FunkySetFields >>> Division by zero

#1 
New Member
Philipp Gruschka
Join Date: Jun 2014
Posts: 5
Rep Power: 4 
Hello everybody!
First of all, I'm pretty new to OpenFOAM! Currently I'm trying to transform cartesian coordinates to cylindrical coordinates by using funkySetFields. My problem is that the calculation of the circumferential coordinate (phi) requires the calculation of arctan(y/x). For the areas where phi is calculated by arctan(y/x), the case x=0 is clearly excluded, which I also wanted to implement by 1.) using an exclusion in the expression line, e.g. expression "pos().x > 0 ? arctan(y/x) : (elseifcond.)" 2.) using the condition option, e.g. expression "arctan(y/x)" condition "pos().x > 0" Both results in division by zero exceptions, like the expression is applied to the field before the condition is evaluated. Also I'm not quite sure whether funkySetFields understands arcusfunctions. Hope somebody can help me! Thanks in advance, Philipp 

September 29, 2014, 17:43 

#2  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,997
Rep Power: 42 
Quote:
The workaround would be to make sure that the division by 0 never happens. Like this for instance: "pos().x>0 ? arctan(y/(pos().x>0 ? x : 1e10)): (other expression)" or "pos().x>0 ? arctan(y/max(x,1e10)) : othrexpr"
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

October 1, 2014, 05:21 

#3 
New Member
Philipp Gruschka
Join Date: Jun 2014
Posts: 5
Rep Power: 4 
That works fine, thank you!
Two other quesions: 1.) Is there a way to create a pseudounsteady calculation of the field with funkySetFields? Starting from a simple 0/ folder, I'd like to use time and/or deltaT in my dictionary, so that I can compute three or four further timesteps without really calculating it with OpenFOAM. Therefore funkySetFields should be able to automatically create new time folders. 2.) How can I declarate and use variables and constants in FSF? I read something about #include and allowFunctionObjects, but since I'm not really familiar with the OpenFOAM structures I don't really know how to do it... Again, thank you very much in advance!!! 

October 1, 2014, 18:30 

#4  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,997
Rep Power: 42 
Quote:
FSF only works if timefolders are there. So at least you'd have to create the folders for FSF (OF) to recognize them. Then you can insert a field as usual What you CAN do to emulate that behaviour is use replayTransientBC: add expressionFieldfunctionObjects that create the fields you want in system/controlDict and apply the utility Variables are only possible in FSF if used in dictionary mode (if the expression is specified in a dictionary and not in the command line).
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

Tags 
funkysetfields, swak4foam 
Thread Tools  
Display Modes  

