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

Rewriting UDF For Parallel Processing

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By LuckyTran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 5, 2019, 08:04
Default Rewriting UDF For Parallel Processing
  #1
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
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
Attached Files
File Type: c test1_Copy_That_Works_in_Serial.c (1.3 KB, 19 views)
m_ridzon is offline   Reply With Quote

Old   January 6, 2019, 22:22
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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);
}
SurfaceList variable is not defined in your udf

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
AlexanderZ is offline   Reply With Quote

Old   January 7, 2019, 09:39
Default
  #3
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
Quote:
Originally Posted by AlexanderZ View Post
SurfaceList variable is not defined in your udf
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:
Originally Posted by AlexanderZ View Post
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.
Yes, I basically understand these concepts. And as I mentioned, I've applied these concepts and rewritten a few "serial" UDFs in the past to make them work in parallel processing. However, I've not been successful applying those same concepts to this UDF, which is why I came here to seek help.

Any further input would be greatly appreciated!
m_ridzon is offline   Reply With Quote

Old   January 7, 2019, 12:58
Default
  #4
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
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?
LuckyTran is offline   Reply With Quote

Old   January 7, 2019, 13:42
Default
  #5
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
I'm too lazy to assist with your udf endeavor
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.

Quote:
Originally Posted by LuckyTran View Post
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?
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.
m_ridzon is offline   Reply With Quote

Old   January 7, 2019, 15:23
Default
  #6
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
I'm sorry I even bothered to come here and comment.


Well then good luck. Have a nice day.
LuckyTran is offline   Reply With Quote

Old   January 7, 2019, 15:52
Default
  #7
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
I'm sorry I even bothered to come here and comment.


Well then good luck. Have a nice day.
Why do you do this to users in here? You kick tires, but don't give much meaningful feedback. In the thread below from a few months ago, you chastised me for picking the wrong sub-forum and then made the statement about the "community that I wish could have done me better." I believe this community could do better and I believe there are a lot of smart people in here who have the answers. But the community (you included) is reluctant to reach out and help (to use your words, some are "lazy"). But you're not doing anything to help out. You probably know the answer to my situation, but are just stalking around, being "lazy" (your words), and stirring up commotion.

Quote:
Originally Posted by LuckyTran View Post
I'm simply telling you that this particular sub-forum predates Ansys and Ansys workbench. Asking a workbench question in the Ansys section would have probably gotten you a better response. And asking the question in Ansys customer support definitely would have gotten you a better response since there you are entitled to an answer. A lot of users here only use Fluent and have never used workbench and probably never will ever use workbench.

It's also really hard to answer an odd inquiry. All the time there are questions of how to read a data file that was previously saved. Just do it is not a helpful response... Answering with just do it normally gets the person trying to help flamed. Not answering, gets complaints that they're not answering (which you just aptly proved). So to summarize, don't be salty that your question went unanswered and diss the same community that you wish could have done you better.
m_ridzon is offline   Reply With Quote

Old   January 7, 2019, 16:31
Default
  #8
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
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.
LuckyTran is offline   Reply With Quote

Old   January 10, 2019, 14:31
Default
  #9
Member
 
Matt Ridzon
Join Date: Jun 2014
Posts: 91
Rep Power: 12
m_ridzon is on a distinguished road
@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:
Originally Posted by m_ridzon View Post
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.
Instead, I needed help to dig into the nitty-gritty and look at the syntax, and I conveyed that in my reply to him, but heard no more from him...
Quote:
Originally Posted by m_ridzon View Post
Yes, I basically understand these concepts. And as I mentioned, I've applied these concepts and rewritten a few "serial" UDFs in the past to make them work in parallel processing. However, I've not been successful applying those same concepts to this UDF, which is why I came here to seek help.

Any further input would be greatly appreciated!
But all that to say...NEVERMIND! I figured it out myself earlier today and have a functional UDF for parallel processing.
m_ridzon is offline   Reply With Quote

Old   January 10, 2019, 14:42
Default
  #10
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,754
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
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.
recep911234 likes this.
LuckyTran is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 17:59.