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

How to use UDF to get a grid cell centroid coordinates?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2016, 07:57
Default How to use UDF to get a grid cell centroid coordinates?
  #1
New Member
 
Lvan Lee
Join Date: Apr 2016
Posts: 3
Rep Power: 10
lvanlee is on a distinguished road
It was a simulation about mold electromagnetic stirring in continuous casting.
I worked out the lorentz force from Ansys Maxwell, now I want to add the lorentz force as source terms using the DEFINE_SOURCE macro.
So first, I need the cell centroid coordinates of the model mesh.
Then put the lorentz force on every coordinate as a momentum source.
So, how could I get the coordinates?
Thanks very much !

#include"udf.h"
FILE*fout;float xx[ND_ND];

DEFINE_ON_DEMAND(get_coords)
{
Domain *domain;
face_t f; cell_t c;Thread *t;
domain=Get_Domain(1);
t=Lookup_Thread(domain,2);
fout=fopen("faces.out","w");

if (fout==NULL)
Message("Can't open the file");

else

{ begin_c_loop(c,t)

{ F_CENTROID(xx,c,t);
fprintf(fout,"%d %g %g %g\n",c,xx[0],xx[1],xx[2]);
}
end_c_loop(c,t)

fprintf(fout,"\n");
fclose(fout);
}
}

this udf can't work out
lvanlee is offline   Reply With Quote

Old   April 27, 2016, 08:50
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
F_CENTROID gives the face centers. C_CENTROID gives the cell centers.
LuckyTran is offline   Reply With Quote

Old   April 27, 2016, 10:54
Default
  #3
New Member
 
Lvan Lee
Join Date: Apr 2016
Posts: 3
Rep Power: 10
lvanlee is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
F_CENTROID gives the face centers. C_CENTROID gives the cell centers.
Thank you. It was a mistake and I use the C_CENTROID actually. But when I interpreted the UDF, it shows the "line 28: function "CX_Message" not found (pc=55).“ But I just have 27 lines, no line 28 at all.
lvanlee is offline   Reply With Quote

Old   January 3, 2021, 12:10
Default
  #4
New Member
 
Krishna
Join Date: Oct 2016
Posts: 12
Rep Power: 10
kavatar is on a distinguished road
Hello,

Could you please tell which solver did you use in Ansys Maxwell to calculate the Lorentz Force? Was it Eddy Current Solver or Magnetic Transient Solver?

And did this UDF worked to apply the Lorentz Force in Ansys Fluent.

I am also working on similar kind of Problem. Your comment would be of great help to me.

Thanks in advance !!
kavatar is offline   Reply With Quote

Old   December 20, 2021, 07:55
Default
  #5
New Member
 
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6
ssetay is on a distinguished road
Hi,
I'm doing similar work, has your problem been solved?
Can i ask some questions?
Thinks!
ssetay is offline   Reply With Quote

Reply

Tags
define_on_demand macro, fluent, udf


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
Setting cell variable values in a fluid zone using UDF eromon84 Fluent UDF and Scheme Programming 6 March 28, 2021 12:59
[OpenFOAM] View grid coordinates in Paraview ozzythewise ParaView 3 June 6, 2017 05:12
[OpenFOAM] Get cell center coordinates in a python script francois ParaView 2 June 3, 2017 09:20
I know the cell ID, how do I find the cell coordinates? simpomann OpenFOAM Programming & Development 6 June 30, 2014 11:29
Identifying cell in parallel UDF upeksa Fluent UDF and Scheme Programming 0 July 24, 2013 12:27


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