CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Number of variables stored in user defined memory locations(C_UDMI)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 20, 2021, 02:55
Post Number of variables stored in user defined memory locations(C_UDMI)
  #1
Member
 
Join Date: Jul 2020
Location: India
Posts: 66
Rep Power: 6
Cooper24 is on a distinguished road
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.
Cooper24 is offline   Reply With Quote

Old   December 20, 2021, 13:18
Default
  #2
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
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.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 20, 2021, 22:31
Default
  #3
Member
 
Join Date: Jul 2020
Location: India
Posts: 66
Rep Power: 6
Cooper24 is on a distinguished road
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 is offline   Reply With Quote

Old   December 21, 2021, 09:26
Post
  #4
Member
 
Join Date: Jul 2020
Location: India
Posts: 66
Rep Power: 6
Cooper24 is on a distinguished road
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.
Attached Images
File Type: png side.png (37.3 KB, 14 views)
Cooper24 is offline   Reply With Quote

Old   December 21, 2021, 11:39
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
I don't understand your problem. The UDF from your first post seems to do what you describe, so what more do you want?
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 21, 2021, 12:19
Default
  #6
Member
 
Join Date: Jul 2020
Location: India
Posts: 66
Rep Power: 6
Cooper24 is on a distinguished road
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.
Cooper24 is offline   Reply With Quote

Old   December 21, 2021, 13:36
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 26
pakk will become famous soon enough
Now I understand. I don't know a simple way to do that.
__________________
"The UDF library you are trying to load (libudf) is not compiled for parallel use on the current platform" is NOT the error after compiling. It is the error after loading. To see compiler errors, look at your screen after you click "build".
pakk is offline   Reply With Quote

Old   December 21, 2021, 13:50
Default
  #8
Member
 
Join Date: Jul 2020
Location: India
Posts: 66
Rep Power: 6
Cooper24 is on a distinguished road
No issues. Thanks for your answers.
Cooper24 is offline   Reply With Quote

Reply

Tags
cell centre data, udmi, user defined memory


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
SimpleFoam & Theater jipai OpenFOAM Running, Solving & CFD 3 June 18, 2019 10:11
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops avinashjagdale OpenFOAM Meshing & Mesh Conversion 53 March 8, 2019 09:42
SigFpe when running ANY application in parallel Pj. OpenFOAM Running, Solving & CFD 3 April 23, 2015 14:53
AMI interDyMFoam for mixer danny123 OpenFOAM Running, Solving & CFD 4 June 19, 2013 04:49
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 04:15


All times are GMT -4. The time now is 21:56.