|
[Sponsors] |
January 5, 2019, 08:04 |
Rewriting UDF For Parallel Processing
|
#1 |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
I have the attached UDF, which outputs X-velocity from "line 7" in the model, to a text file. It works great for serial processing, but I need it for parallel processing. I only know the basics about writing UDFs for parallel processing and have successfully rewritten a few others in the past, from serial to parallel. However, I'm unsuccessful with this one. I cannot seem to figure out how to rewrite the attached UDF so it works for parallel processing.
Can anybody offer feedback to help me rewrite this for parallel processing? (note, I'm using v182 Fluent) Thanks in advance! M Ridzon |
|
January 6, 2019, 22:22 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Code:
#include "udf.h" #include "surf.h" #include "cxsurf.h" #include "cxiface.h" #include "dx.h" DEFINE_EXECUTE_AT_END(write_line_data) { Surface *s; Surf_Point *p; Domain *d = Get_Domain(1); int i, j, k, l,index, nw,nfp; real value, x, y, z; char *what; char *datafn; int line_id; FILE *fp; //datafn = RP_Get_String("line_name"); //line_id = RP_Get_Integer("line_id"); datafn = "line-7.txt"; line_id = 7; fp = fopen(datafn,"a"); /* s is the surface having data of surface id SID */ /* s->np no of points s->nf no of faces s->points points to array of np points s->ip pointer to interpolation vector of np points s->cells pointer to cells of each point s->nfl facet list */ s = SurfaceList+line_id; what = "x-velocity"; /* header */ fprintf(fp," x-coordinate, y-coordinate, z-coordinate,"); fprintf(fp,"%16s",what); fprintf(fp,"\n"); Node_Function_Values(d,what); p = s->points; for(i=0;i<s->np;i++) { x = Get_Surface_Point_Coord(p,X_DIM); y = Get_Surface_Point_Coord(p,Y_DIM); z = Get_Surface_Point_Coord(p,Z_DIM); value = Surface_Value(p); fprintf(fp,"% 16.9E,% 16.9E,% 16.9E",x,y,z); fprintf(fp,",% 16.9E",value); fprintf(fp,"\n"); p += 1; } fclose(fp); } The idea of parallel computation in fluent: calculations are made on nodes, input/output and communication between nodes are made on host It means, if you want to get some data, you sould first send it to host, then write to file. For more information read Ansys Fluent Customization manual best regards |
|
January 7, 2019, 09:39 |
|
#3 | |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
I received this UDF secondhand. I was told that various commands therein are hardcoded and/or "undocumented." And I believe "SurfaceList" is one of those hardcoded variables. I believe it is defined within the header file, "cxiface.h." As I said, the script works fine in serial, which leads me to believe this is inconsequential.
Quote:
Any further input would be greatly appreciated! |
||
January 7, 2019, 12:58 |
|
#4 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
I'm too lazy to assist with your udf endeavor. But there is already a built-in tool called solution data export that will write your x-velocity, y-velocity, and z-velocity on a line to a text file. Is there a reason you must do this using a udf?
|
|
January 7, 2019, 13:42 |
|
#5 |
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
Well, that's unfortunate. If I could respectfully say, perhaps you should have not even come here to comment. I'm looking for help, not tire kickers.
Yes, there is a good reason. And I was trying to be brief and succinct to get to my point without going into many unnecessary details about the bigger agenda. No, your suggestion will not work because of what needs to take place in the bigger picture. |
|
January 7, 2019, 15:23 |
|
#6 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
I'm sorry I even bothered to come here and comment.
Well then good luck. Have a nice day. |
|
January 7, 2019, 15:52 |
|
#7 | ||
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
Quote:
Quote:
|
|||
January 7, 2019, 16:31 |
|
#8 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
I just asked why a built in tool cannot be used for this problem. There is no point debugging a stack of udf's when a simpler solution exists, if it would work.
Oh and yes, this is not the udf subforum. Not that I was going to chastise you for it. Finally, AlexanderZ already told you what the issue is and you ignored it. But I guess it is inconsequential... Reading and writing files in parallel need to be done very differently. |
|
January 10, 2019, 14:31 |
|
#9 | ||
Member
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12 |
@LuckyTran,
@AlexanderZ gave me a high level overview of how parallel processing has to be done, versus serial. I'm thankful he took the time to share something that wasn't laced with chastisement (like you tend to do), but it was unfruitful. Fact is, I already knew those basics, and that was mentioned in my initial post when I said... Quote:
Quote:
|
|||
January 10, 2019, 14:42 |
|
#10 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66 |
Of course it is expected that you will figure it out on your own eventually. That is the goal of these forums! People only point you in the general direction. If you want other people to do the work for you, there is a section for freelancing.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
need TUI or UDF post processing command help. | Ash Kot | FLUENT | 4 | September 7, 2022 02:41 |
udf for valve closing a pipe using dynamic mesh | chem engineer | Fluent UDF and Scheme Programming | 2 | May 13, 2017 10:39 |
Help with unsteady calculation with source/sink UDF | RobV | FLUENT | 1 | November 13, 2016 06:44 |
Fluent Radiation/porous media | Schmitt pierre-Louis | FLUENT | 26 | September 1, 2016 11:29 |
Help with unsteady calculation with source/sink UDF | RobV | Fluent UDF and Scheme Programming | 3 | March 10, 2016 04:45 |