|
[Sponsors] |
How to use UDF to get a grid cell centroid coordinates? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 27, 2016, 07:57 |
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 |
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 |
|
April 27, 2016, 08:50 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66 |
F_CENTROID gives the face centers. C_CENTROID gives the cell centers.
|
|
April 27, 2016, 10:54 |
|
#3 |
New Member
Lvan Lee
Join Date: Apr 2016
Posts: 3
Rep Power: 10 |
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.
|
|
January 3, 2021, 12:10 |
|
#4 |
New Member
Krishna
Join Date: Oct 2016
Posts: 12
Rep Power: 10 |
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 !! |
|
December 20, 2021, 07:55 |
|
#5 |
New Member
ssetay
Join Date: Aug 2020
Posts: 6
Rep Power: 6 |
Hi,
I'm doing similar work, has your problem been solved? Can i ask some questions? Thinks! |
|
Tags |
define_on_demand macro, fluent, udf |
|
|
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 |