|
[Sponsors] |
June 3, 2020, 11:15 |
CEL Step function use
|
#1 |
Member
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14 |
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. |
|
June 3, 2020, 13:02 |
|
#2 |
Senior Member
M
Join Date: Dec 2017
Posts: 642
Rep Power: 12 |
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. |
|
June 3, 2020, 13:14 |
|
#3 |
Member
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14 |
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. |
|
June 3, 2020, 14:54 |
|
#4 |
Senior Member
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32 |
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. |
|
June 3, 2020, 15:28 |
|
#5 |
Member
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14 |
For each cell I need to sum all cells above the y coordinate value of the cell. So the summation range changes per cell
|
|
June 3, 2020, 15:41 |
|
#6 |
Senior Member
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32 |
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. |
|
June 3, 2020, 16:04 |
|
#7 |
Member
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14 |
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
|
|
June 3, 2020, 17:20 |
|
#8 |
Senior Member
Join Date: Jun 2009
Posts: 1,811
Rep Power: 32 |
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. |
|
June 4, 2020, 11:24 |
|
#9 |
Member
Anonymous
Join Date: Jan 2012
Location: Canada
Posts: 65
Rep Power: 14 |
Thanks Opaque - I appreciate you taking the time to think about this.
|
|
|
|
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 |