|
[Sponsors] |
November 2, 2015, 14:05 |
Define_grid_motion udf
|
#1 |
Member
|
Hi
I have a UDF written for sinusoidal grid motion of a channel wall. It is compiled successfully but there is no motion on channel wall. I need someone who can identify the mistakes in my UDF. I am really in need of some useful suggestions. thank you Code:
#include "udf.h" #include "dynamesh_tools.h" #include <stdlib.h> #include <math.h> #define AH 0.1 // Average Height of Channel #define XL 2.0 // Length #define WA 15 // Wave Amplitude #define PI 3.1415925 #define C 0.1 //Wave Speed #define Lambda 0.5 // wavelength #define XStep 0.01 #define XSize XL/XStep #define HStep 0.0038 #define HSize AH/HStep DEFINE_GRID_MOTION(peristaltic, domain, dt, time, dtime) { Thread *tf = DT_THREAD(dt) ; int counter, i; face_t f ; float curr_time = CURRENT_TIME ; float tmpv = 0; float sint = 0; float xVec[1001] ; float hVec[1001] ; xVec[0] = 0 ; for (counter = 1 ; counter < XSize ; counter++) { xVec[counter] = xVec[counter - 1] + XStep; } i = 1; begin_f_loop(f,tf) { curr_time = CURRENT_TIME; sint = sin(2 * PI/Lambda * (xVec[i])); hVec[i] = AH + (WA * sint); i = i + 1; } end_f_loop(f,tf) } |
|
November 2, 2015, 16:22 |
|
#2 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
You need to set the neighboring boundaries and interior zone as deforming (as well as apply your user-defined grid motion to the channel wall). A quick way to set the interior zone as deforming is within the UDF:
Code:
Thread *tf = DT_THREAD((Dynamic_Thread *)dt); SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf)); Perhaps to check your UDF and MDM settings, move the channel wall outwards with a linear motion (if this case works fine then the problem is with your sinusoidal code). |
|
November 3, 2015, 02:41 |
|
#3 |
Member
|
Thank you 'e' for your useful guidance as usual. As I mentioned earlier I don't have much knowledge about writing UDF's. Can you kindly write all the changes required in the UDF. you are right I need inlet, outlet and interior as deforming.
Best Regards |
|
November 3, 2015, 03:50 |
|
#4 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
An example of adding the code as I mentioned above (for the interior zone):
Code:
#include "udf.h" #include "dynamesh_tools.h" #include <stdlib.h> #include <math.h> #define AH 0.1 // Average Height of Channel #define XL 2.0 // Length #define WA 15 // Wave Amplitude #define PI 3.1415925 #define C 0.1 //Wave Speed #define Lambda 0.5 // wavelength #define XStep 0.01 #define XSize XL/XStep #define HStep 0.0038 #define HSize AH/HStep DEFINE_GRID_MOTION(peristaltic, domain, dt, time, dtime) { Thread *tf = DT_THREAD(dt) ; int counter, i; face_t f ; float curr_time = CURRENT_TIME ; float tmpv = 0; float sint = 0; float xVec[1001] ; float hVec[1001] ; xVec[0] = 0 ; SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf)); for (counter = 1 ; counter < XSize ; counter++) { xVec[counter] = xVec[counter - 1] + XStep; } i = 1; begin_f_loop(f,tf) { curr_time = CURRENT_TIME; sint = sin(2 * PI/Lambda * (xVec[i])); hVec[i] = AH + (WA * sint); i = i + 1; } end_f_loop(f,tf) } |
|
November 4, 2015, 00:20 |
|
#5 |
Member
|
thank you 'e'. I will try this code along with your suggestions and will get back to you.
Best Regards |
|
November 7, 2015, 03:54 |
|
#6 | |
Member
|
Quote:
but instead of producing a sinusoidal deformation on the wall it only displaces by a certain amount. I have given the full details in the links https://www.dropbox.com/s/8blln9jxqz...image.png?dl=0 https://www.dropbox.com/s/o51wl5o2sb...nal_UDF.c?dl=0 https://www.dropbox.com/s/ke5pbl930d...annel.msh?dl=0 https://www.dropbox.com/s/jjn5rk7urx...annel.out?dl=0 whats wrong in my UDF? kindly help me out!!! |
||
November 7, 2015, 07:01 |
|
#7 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
The links you have provided are broken.
The x-position of each node can be retrieved using the NODE_X macro; instead of manually using an array ("xVec"). You've not moved any node positions in your UDF, and you should loop through the nodes of each face with "f_node_loop(f,tf,n)". Have a look at the examples in the UDF manual. |
|
November 7, 2015, 11:42 |
Define_grid_motion UDF
|
#8 |
Member
|
Thank you 'e' for your quick response. Sorry for the broken links. I have given the links again below.
kindly take a look at them. also the image on order to view the current deformation produced in the channel. https://www.dropbox.com/s/ke5pbl930d...annel.msh?dl=0 https://www.dropbox.com/s/jjn5rk7urx...annel.out?dl=0 https://www.dropbox.com/s/o51wl5o2sb...nal_UDF.c?dl=0 https://www.dropbox.com/s/8blln9jxqz...image.png?dl=0 I will also refer to the UDF manual. can you kindly give which specific version of UDF manual does contain an example like mine. can you share a link Best regards |
|
November 7, 2015, 17:53 |
|
#9 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
For reference, the UDF you're currently using is copied below. This new version includes the f_node_loop and should be deforming the mesh boundary. Any version of the UDF manual should be fine to read an example from, but preferably use the same version number as your Fluent installation. Have a read of the DEFINE_GRID_MOTION section: it won't have your exact case (sinusoidal deformation) but has the required tools.
It's unclear why you're scanning an output file ("channel.out") to read in the node positions (use the NODE_X, NODE_Y and NODE_Z macros instead). You've set the variable "x=3;" on line 47 and then used this value for your sine function, giving a constant value for all nodes (regardless of their actual x-position). Code:
#include "udf.h" #include "dynamesh_tools.h" FILE *fout; DEFINE_GRID_MOTION(peristaltic, 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 AH; real WA; real PI; real c; real x; real Lambda; real sint; real hVec; int n; float f1; float f2; float npx[301] ; float npy[301] ; int v1; int i; char buffer[100]; fout = fopen("channel.out", "r"); fgets(buffer,100,fout); while(feof(fout)==0) { fscanf(fout, "%d %f %f\n", &v1, &f1, &f2); npx[v1]=f1; npy[v1]=f2; } fclose(fout); i = 1; begin_f_loop(f,tf) { previous_time =PREVIOUS_TIME; F_AREA(A,f,tf); PI = 3.1415925; Lambda = 0.5; c= 0.5; x=3; AH = 0.5; WA = 0.2; sint = sin(2 * PI/Lambda)*(x - c*time); hVec = AH - (WA * sint); dx[0] = (A[0]/NV_MAG(A)*hVec); dx[1] = (A[1]/NV_MAG(A)*hVec); 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]=dx[0]+npx[i]; NODE_COORD(v)[1]=dx[1]+npy[i]; i=i+1; } } } end_f_loop(f,tf); } |
|
November 8, 2015, 06:43 |
|
#10 |
Member
|
Dear 'e' I have used the .out file concept from an example similar to mine. I have studied the example given in UDF manual. but I can not understand neither find the meaning of the syntax used. can you kindly explain a bit.
Code:
* node motion based on simple beam deflection equation * compiled UDF * **********************************************************/ #include "udf.h" DEFINE_GRID_MOTION(beam, domain, dt, time, dtime) { Thread *tf = DT_THREAD (dt); face_t f; Node *v; real NV_VEC (omega), NV_VEC (axis), NV_VEC (dx); real NV_VEC (origin), NV_VEC (rvec); real sign; int n; /* set deforming flag on adjacent cell zone */ SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf)); sign = -5.0 * sin (26.178 * time); Message ("time = %f, omega = %f\n", time, sign); NV_S (omega, =, 0.0); NV_D (axis, =, 0.0, 1.0, 0.0); NV_D (origin, =, 0.0, 0.0, 0.152); begin_f_loop (f, tf) { f_node_loop (f, tf, n) { v = F_NODE (f, tf, n); /* update node if x position is greater than 0.02 and that the current node has not been previously visited when looping through previous faces */ if (NODE_X (v) > 0.020 && 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); omega[1] = sign * pow (NODE_X (v)/0.230, 0.5); NV_VV (rvec, =, NODE_COORD (v), -, origin); NV_CROSS (dx, omega, rvec); NV_S (dx, *=, dtime); NV_V (NODE_COORD (v), +=, dx); } } } end_f_loop (f, tf); } thank you for your time |
|
November 8, 2015, 17:39 |
|
#11 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
First, instead of using vectors it might be clearer (and simpler) to specify values on a component basis. For example, use dx, dy and dz for displacements instead of a single vector (dx).
The vector operations below match the equations in the manual. Code:
real NV_VEC (omega), NV_VEC (axis), NV_VEC (dx); real NV_VEC (origin), NV_VEC (rvec); Code:
Message ("time = %f, omega = %f\n", time, sign); Code:
NV_S (omega, =, 0.0); NV_D (axis, =, 0.0, 1.0, 0.0); NV_D (origin, =, 0.0, 0.0, 0.152); Code:
omega[1] = sign * pow (NODE_X (v)/0.230, 0.5); Code:
NV_VV (rvec, =, NODE_COORD (v), -, origin); Code:
NV_CROSS (dx, omega, rvec); Code:
NV_S (dx, *=, dtime); Code:
NV_V (NODE_COORD (v), +=, dx); |
|
November 9, 2015, 12:33 |
|
#12 |
Member
|
thanks alot 'e'. I am trying to modify the UDF according to your suggestions. I hope it will fulfill my requirements.
I will be in touch with you. Best Regards |
|
January 18, 2016, 10:34 |
|
#13 |
New Member
giulia
Join Date: Jan 2016
Posts: 2
Rep Power: 0 |
hello, i'm wondering how the file "channel.out" is organised! Thank you !
|
|
January 18, 2016, 17:13 |
|
#14 |
Senior Member
Join Date: Mar 2015
Posts: 892
Rep Power: 18 |
The file "channel.out" includes a column for the node number, x-coordinate and y-coordinate. This file is posted above and I've copied the first few lines below:
Code:
nodenumber x-coordinate y-coordinate 1 3.000000000E+00 5.000000000E-01 2 2.990000010E+00 5.000000000E-01 3 2.980000019E+00 5.000000000E-01 4 2.970000029E+00 5.000000000E-01 5 2.960000038E+00 5.000000000E-01 |
|
January 19, 2016, 01:55 |
|
#15 |
Member
|
If you are interested in obtaining channel.out file. click on export solution data in file menu. there you can export a number of parameters including the nodal positions.
|
|
January 19, 2016, 06:25 |
|
#16 |
New Member
giulia
Join Date: Jan 2016
Posts: 2
Rep Power: 0 |
Thank you! i'm traying to export the displacements of structures nodes from LS-Dyna in a file.txt, which will be the opening file in the UDF- Grid motion. I have some hesitations about the difference of numeration of nodes from LSDyna and Fluent and the corrispondence of these nodes.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WILLING TO PAY/ FREELANCER REQUIRED / small UDF coding force loads over body / 6DOF | acasas | CFD Freelancers | 1 | January 23, 2015 08:26 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |