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

CEL Step function use

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 3, 2020, 11:15
Default CEL Step function use
  #1
Member
 
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14
Industrial_CFD is on a distinguished road
I would like to know if it is possible to use a step function to help me sum values above a cell's "y" coordinate in a subdomain.


Essentially I would like to do the following pseudo code using step(), and sum():


ycor = y coordinate of cell of interest


for i = 1:number of cells in subdomain

if y < ycor, variable = 0
sum(variable)@subdomain


I was hoping to nest a step function inside sum, e.g. sum(step()*variable)@subdomain.


Except I am unsure if this possible using CEL, mainly because I can't envision how to use the cell's current location as a marker in the step function.
Industrial_CFD is offline   Reply With Quote

Old   June 3, 2020, 13:02
Default
  #2
Senior Member
 
M
Join Date: Dec 2017
Posts: 642
Rep Power: 12
AtoHM is on a distinguished road
Use step it as a factor inside your sum like this to set to zero the values below your offset:

sum(step(y * 1 [m^-1] - yourOffset) * yourVariableToSum)@Domain

I just tried it, and it worked in CFD Post for me. Pre does not allow evaluation of such an expression.
Keep in mind step returns 0.5 when in evaluates to 0.
AtoHM is offline   Reply With Quote

Old   June 3, 2020, 13:14
Default
  #3
Member
 
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14
Industrial_CFD is on a distinguished road
I am pretty convinced it can't be done; I need it in Pre, just thought I would throw it out there.

Essentially for each cell, I need to sum a variable on the cells above it in the subdomain during the solver run.

If I had a constant location, e.g. 2 m, then it is relatively straightforward.

But it gets complicated when that location is based on the cell value. I think I may need a fortran routine that gets the cell centroid, then uses a DO LOOP to perform the sum on the cells above that coordinate value.
Industrial_CFD is offline   Reply With Quote

Old   June 3, 2020, 14:54
Default
  #4
Senior Member
 
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32
Opaque will become famous soon enough
Do you need the sum to be based on a coordinate, or a region of cells?

If the region of cells is known in the mesh topology, or physics topoloy, you can use the "inside()@region" function, say

MySum = inside()@MySumRegion * variable to sum

Basically adds 0 * variable if outside the region, and 1 * variable within the region
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   June 3, 2020, 15:28
Default
  #5
Member
 
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14
Industrial_CFD is on a distinguished road
For each cell I need to sum all cells above the y coordinate value of the cell. So the summation range changes per cell
Industrial_CFD is offline   Reply With Quote

Old   June 3, 2020, 15:41
Default
  #6
Senior Member
 
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32
Opaque will become famous soon enough
The brute force of doing so is to create a variable that is zero below a given y, and 1 above it.

y0 = 0.1 [m]
AboveY0 = if (y-y0 > 0, 1.0, 0.0)

after sum over all the cells in one go => sum (AboveY0 * Variable)@Region

where Region contains all the cells in the loop.

will that work for you?
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   June 3, 2020, 16:04
Default
  #7
Member
 
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14
Industrial_CFD is on a distinguished road
I am not sure - the main issue is that my y0 is equal to the cell y coordinate. So I need a way to create y0 for each cell, then perform the if statement you suggested
Industrial_CFD is offline   Reply With Quote

Old   June 3, 2020, 17:20
Default
  #8
Senior Member
 
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32
Opaque will become famous soon enough
Perhaps if you explain what calculation you are trying to achieve/realize, i.e. the mathematical formula, others in the forum may be able to describe another approach.
__________________
Note: I do not answer CFD questions by PM. CFD questions should be posted on the forum.
Opaque is offline   Reply With Quote

Old   June 4, 2020, 11:24
Default
  #9
Member
 
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14
Industrial_CFD is on a distinguished road
Thanks Opaque - I appreciate you taking the time to think about this.
Industrial_CFD is offline   Reply With Quote

Reply


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
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 5, 2023 23:48
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 17:22
Floating point exception error lpz_michele OpenFOAM Running, Solving & CFD 53 October 19, 2015 02:50
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 06:42
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07


All times are GMT -4. The time now is 17:06.