CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Number of variables stored in user defined memory locations(C_UDMI) (https://www.cfd-online.com/Forums/fluent-udf/240230-number-variables-stored-user-defined-memory-locations-c_udmi.html)

Cooper24 December 20, 2021 02:55

Number of variables stored in user defined memory locations(C_UDMI)
 
Let us say I loop over all the cells in the domain and store the values of cell centres(xc[0] and xc[1]) in two different C_UDMs only if a certain condition is satisfied as shown below:

begin_c_loop(c,t)
{
C_CENTROID(xc,c,t);
real r = sqrt(pow(xc[0]-x0-v*time,2.0) + pow(xc[1]-y0,2.0));

if(r<=R && xc[2] == -0.0000855)
{
C_UDMI(c,t,7) = c;
C_UDMI(c,t,8) = xc[0];
C_UDMI(c,t,9) = xc[1];
C_UDMI(c,t,10) = xc[2];
}
}
end_c_loop(c,t)

Now I want to make a 2D dynamic array consisting of the elements in C_UDMI(c,t,8) and C_UDMI(c,t,9) i.e, a 2D array with elements being x and y centres of the cells.
As I understand, I need to find the number of variables in both the UDMs after each iteration and then I can allocate a 2D dynamic array. Can someone help with the method to find the number of variables in UDMs after each iteration? Or if there is another way to store the cell centres apart from allocating a dynamic array? Please help if you know any method.

Thanks in advance.

pakk December 20, 2021 13:18

Quote:

As I understand, I need to find the number of variables in both the UDMs
I think you use the wrong terminology. Each UDM contains one variable, so that would be a very easy answer.

I guess that you mean how many values are stored in the UDMs. Including the ones with value zero, it's the number of cells in your simulation. If you only want to know how many values were set in your loop, the simplest method is to just count them. Add a counter in your code, set it at zero initially, and add one every time that you put a value in a UDM.

Cooper24 December 20, 2021 22:31

Thanks pakk. And sorry for the words. Yes, I want to know the number of values for each variable stored in a UDM after each iteration/time-step.
I will add what you have suggested.

Cooper24 December 21, 2021 09:26

1 Attachment(s)
I did what you suggested. Now since my if condition satisfies a circular region, so in 3D I will have a cylindrical region. Now I know the cell ids and centres of all the cells inside this cylindrical region. Looking from the side, the cylindrical region consists of a number of columns and each column has a number of cells.
My target is to loop over all the columns and over all the cells inside the column. From my understanding, using begin_c_loop anywhere starts to loop over all the cells in an order which I can't know. Can anyone please share some thoughts on how to do this? I have attached an image showing the cylindrical region I am talking about.

pakk December 21, 2021 11:39

I don't understand your problem. The UDF from your first post seems to do what you describe, so what more do you want?

Cooper24 December 21, 2021 12:19

From my first post, I am able able to get all the cells inside a cylindrical region as the if condition is for a circle and in 3D domain, it would include all the cells inside a cylindrical region.
Now, for each column of cells along z direction(vertical and each column will have a number of cells), I want to identify a particular cell. By looping through all the columns, I want to identify all those cells. My doubt is how to loop along each column of cells? I have shown in the previous image how a cylinder is made of a number of columns and each column is made up of a number of cells.

pakk December 21, 2021 13:36

Now I understand. I don't know a simple way to do that.

Cooper24 December 21, 2021 13:50

No issues. Thanks for your answers.


All times are GMT -4. The time now is 23:00.