|
[Sponsors] |
August 4, 2014, 11:22 |
How to write a vector in CEL language
|
#1 |
New Member
Join Date: Jan 2012
Posts: 3
Rep Power: 14 |
CEL language has a "Conditional If Statement", which use the following syntax: if( cond_expr, true_expr, false_expr ) .
I want to define the " true_expr " as a vector if the conditional test is true. But I do not know how to write the "true_expr" as a vector (in cartesian coordinate system and cylindrical coordinate system)? Give an example, ********************** if(z>1&&z<2&&30[degree]<theta&&theta<(60[degree])*180/pi),100[N/m^3] ,0[N/m^3])) ************************* I want to change the "100[N/m^3]" to "F=k1*Fx+K2*Fy", and then transform it to cylindrical coordinate system. ps. Fx and Fy are vectors. Thank you for your time reading this and looking forward to your reply. |
|
August 4, 2014, 14:52 |
|
#2 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
Your question is a bit vague on what you are trying to achieve. The functionality is very clear that is takes a logical expression, and evaluate two scalar expressions.
Are you trying to satisfy 3 conditions at once ?, i.e. every component of the cylindrical vector . For complex expressions, I usually break them down to simple expressions, so the conditional is easier to read if (a && b && c, MyTrueResult, MyFalseResult) MyTrueResult = .... MyFalseResult = ... That helps to also separate the Cartesian to cylindrical conversions such as MyRadialComp = MyCart X * ... + MyCart Y * .. + MyCart Z * ... MyThetaComp = MyCart X * ... + MyCart Y * .. + MyCart Z * ... MyAxialComp = MyCart X * ... + MyCart Y * .. + MyCart Z * ... Keep in mind that you can actually access the components of a vector my suffixing _x, _y, or _z to the variable name. For example, MyVar_x is the X component of variable MyVar. Similar to force_x, force_y, etc.. Hope the above helps, |
|
August 4, 2014, 21:44 |
|
#3 |
New Member
Join Date: Jan 2012
Posts: 3
Rep Power: 14 |
Thank you for your reply.
Your explanation is very clearly. But, there is a question really bothers me. Now, I want to add a body force into the flow field, and the area of body force have been given at " cond_expr " under cylindrical coordinate system. ********************************************* The "Conditional If Statement" is as follows, if(z>1&&z<2[m] && 30[degree]<theta&&theta<(30[degree]+(3[mm]/(r+0.000001[mm]))*180/pi) &&(-z*tan(pi/18))<r&&r<(-z*tan(pi/18)+1.5[mm]), BODYFORCE [N/m^3] ,0[N/m^3])) ************************************************** *** The total body force is as follows, BODYFORCE = BODYFORCE _x+ BODYFORCE _y BODYFORCE _x= k1*exp (-((x-x0-(y-y0))/y)^2-k2*(y-y0)^2) BODYFORCE _y=k3*exp(-((x-x0)/y)^2-k4*(y-y0)^2) ********************************************** I do not know how can I put the cartesian vector BODYFORCE into the " Conditional If Statement ", in which the " cond_expr " are written under cylindrical coordinate system. Maybe I should change the BODYFORCE into cylindrical conversions firstly. And is there suffixing _r, _theta, or _z in cylindrical coordinate system like _x, _y and _z in cylindrical coordinate system. Looking forward to your reply. |
|
August 5, 2014, 21:33 |
|
#4 |
New Member
Join Date: Jan 2012
Posts: 3
Rep Power: 14 |
Thank you for your reply.
Your explanation is very clearly. But, there is a question really bothers me. Now, I want to add a body force into the flow field, and the area of body force have been given at " cond_expr " under cylindrical coordinate system. ********************************************* The "Conditional If Statement" is as follows, if(z>1&&z<2[m] && 30[degree]<theta&&theta<(30[degree]+(3[mm]/(r+0.000001[mm]))*180/pi) &&(-z*tan(pi/18))<r&&r<(-z*tan(pi/18)+1.5[mm]), BODYFORCE [N/m^3] ,0[N/m^3])) ************************************************** *** The total body force is as follows, BODYFORCE = BODYFORCE _x+ BODYFORCE _y BODYFORCE _x= k1*exp (-((x-x0-(y-y0))/y)^2-k2*(y-y0)^2) BODYFORCE _y=k3*exp(-((x-x0)/y)^2-k4*(y-y0)^2) ********************************************** I do not know how can I put the cartesian vector BODYFORCE into the " Conditional If Statement ", in which the " cond_expr " are written under cylindrical coordinate system. Maybe I should change the BODYFORCE into cylindrical conversions firstly. And is there suffixing _r, _theta, or _z in cylindrical coordinate system like _x, _y and _z in cylindrical coordinate system. Looking forward to your reply. |
|
August 6, 2014, 10:17 |
|
#5 |
Senior Member
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33 |
Unfortunately, the variable indexing does not include cylindrical component ones. You will be on your own having to do the conversions.
Also, you can only use expressions that resolve to a scalar anywhere in CEL; therefore, vectors must be handled component wise (unroll, or split in simpler expressions) Hope the above helps, |
|
Tags |
conditional if statement |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
[Helyx OS] Helyx-OS (GUI for SnappyHexMesh | elvis | OpenFOAM Community Contributions | 210 | January 30, 2017 19:57 |
How to specify a polyline or plane in CFX Expression Language (CEL) in CFX-Pre? | francis1 | CFX | 5 | February 6, 2013 11:16 |
Comparison between C/C++ and Fortran? | rick | Main CFD Forum | 45 | September 6, 2011 01:52 |
CEL language | painterwolf | CFX | 1 | May 24, 2009 20:44 |