|
[Sponsors] |
February 17, 2016, 17:30 |
Parallelizing UDF for Mesh Motion
|
#1 |
New Member
Join Date: May 2015
Posts: 29
Rep Power: 11 |
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 } /* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& */ |
|
Tags |
parallel, parallel error, udf, udf and programming |
|
|
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 |