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

Parallelizing UDF for Mesh Motion

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By avd28

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 17, 2016, 17:30
Default Parallelizing UDF for Mesh Motion
  #1
New Member
 
Join Date: May 2015
Posts: 29
Rep Power: 10
avd28 is on a distinguished road
Hi,

I have a UDF which defines the sinusoidal motion of a mesh. I have tried to parallelize it, but have run into segmentation faults.

This UDF is charecterized by the fact that the mesh information is read from an external file into an array (3 arrays for 3 dimensions) and then is looped over.

I have used the HOST to read the info from the external file and NODEs to perform the looping and mesh motion.

I'd be grateful for an opinion.

Code:
#include "udf.h"
#include "unsteady.h"
#include "mem.h"
FILE *fout;
/* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
DEFINE_GRID_MOTION(Parenchyma,domain,dt,time,dtime)
{
Thread *tf= DT_THREAD(dt);
face_t f;
Node *v;
real NV_VEC(A);
real NV_VEC(dx);
real previous_time;
real amplitude;
real waveform;
int n;
float f1;
float f2;
float f3;
float npx[4029];
float npy[4029];
float npz[4029];
char buffer[100];
int v1;
int i;
int beta;
host_to_node_real_5(NV_VEC(A),NV_VEC(dx),previous_time,amplitude,waveform);
host_to_node_int_4(n,v1,i,beta);
host_to_node_float_3(f1,f2,f3);


/*read node cordinates fron the file on host*/
#if RP_HOST

	fout = fopen("w1_neo5.out", "r");
	fgets(buffer,100,fout); /* skip the first line*/
	while(feof(fout)==0)
		{
			fscanf(fout, "%d %e %e %e\n", &v1, &f1, &f2, &f3);
			npx[v1-1]=f1;
			npy[v1-1]=f2;
			npz[v1-1]=f3;
		}
	fclose(fout);
#endif

host_to_node_float(npx,4029);
host_to_node_float(npy,4029);
host_to_node_float(npz,4029);
/*read file in host and then send read data to nodes*/

/* calculate displacement vector at the node normal to the surface on compute nodes */

#if !RP_HOST
	i=0;
	begin_f_loop(f,tf)
		{
			previous_time=PREVIOUS_TIME;
			F_AREA(A,f,tf);
			beta = 0.053;
			amplitude=beta/2;
			waveform= sin ((2.094395102 * time) - (3.141/2));
/*waveform=-1*(0.2138*cos(x*w)+0.8512*sin(x*w)+0.01898*cos(2*x*w) +
0.1687*sin(2*x*w));*/
			dx[0]=amplitude*(A[0]/NV_MAG(A)*waveform);
			dx[1]=amplitude*(A[1]/NV_MAG(A)*waveform);
			dx[2]=amplitude*(A[2]/NV_MAG(A)*waveform);
			f_node_loop(f,tf,n)
				{
					v = F_NODE(f,tf,n);
 /* update node if the current node has not been previously */
 /* visited when looping through previous faces */
					if ( NODE_POS_NEED_UPDATE (v))
						{
 /* indicate that node position has been update */
 /*so that it's not updated more than once */
							NODE_POS_UPDATED(v);

							NODE_COORD(v)[0]= (npx[i]*dx[0])+npx[i] + (npx[i]*amplitude);
							NODE_COORD(v)[1]= (npy[i]*dx[1])+npy[i] + (npy[i]*amplitude);
							NODE_COORD(v)[2]= (npz[i]*dx[2])+npz[i] + (npz[i]*amplitude);
							i=i+1;
						}
				}
		}
	end_f_loop(f,tf);
#endif
}
/* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */
jinsong likes this.
avd28 is offline   Reply With Quote

Old   November 4, 2016, 02:10
Default
  #2
New Member
 
Join Date: Apr 2016
Location: Australia
Posts: 3
Rep Power: 10
heart_modeller is on a distinguished road
Hi,

I'm trying to do exactly the same thing, has this problem been solved?

thanks
heart_modeller is offline   Reply With Quote

Old   September 23, 2017, 05:20
Default the same code
  #3
New Member
 
leo
Join Date: Sep 2017
Posts: 15
Rep Power: 8
jinsong is on a distinguished road
i wanted a type of moving mesh using a udf same as you ,but i got some trouble,did you have done,a question is that can the code identify the cotent of external file one by one? and then give it to node coordinate?any sugesstion will be appreciate,thank advanced.




Quote:
Originally Posted by heart_modeller View Post
Hi,

I'm trying to do exactly the same thing, has this problem been solved?

thanks
jinsong is offline   Reply With Quote

Reply

Tags
parallel, parallel error, udf, udf and programming


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
UDF: Restrict boat to only heave motion Baxter Fluent UDF and Scheme Programming 0 September 17, 2015 04:56
UDF for ball motion inside a valve. A.Jalal Fluent UDF and Scheme Programming 0 July 29, 2015 14:17
Fluent UDF Discontinuous Motion lequi7 Fluent UDF and Scheme Programming 2 November 3, 2011 23:18
automatic parallelizing udf chaos FLUENT 2 August 1, 2011 01:51
UDF error CG Motion Alex FLUENT 0 March 22, 2006 17:40


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