CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

How to write a vector in CEL language

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 4, 2014, 11:22
Default How to write a vector in CEL language
  #1
New Member
 
Join Date: Jan 2012
Posts: 3
Rep Power: 14
narcker is on a distinguished road
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.
narcker is offline   Reply With Quote

Old   August 4, 2014, 14:52
Default
  #2
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
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,
Opaque is offline   Reply With Quote

Old   August 4, 2014, 21:44
Smile
  #3
New Member
 
Join Date: Jan 2012
Posts: 3
Rep Power: 14
narcker is on a distinguished road
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.
narcker is offline   Reply With Quote

Old   August 5, 2014, 21:33
Default
  #4
New Member
 
Join Date: Jan 2012
Posts: 3
Rep Power: 14
narcker is on a distinguished road
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.
narcker is offline   Reply With Quote

Old   August 6, 2014, 10:17
Default
  #5
Senior Member
 
Join Date: Jun 2009
Posts: 1,880
Rep Power: 33
Opaque will become famous soon enough
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,
Opaque is offline   Reply With Quote

Reply

Tags
conditional if statement


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
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


All times are GMT -4. The time now is 22:04.