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

using DEFINE_GEOM to change 2D geometry- shear constant area

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 4, 2020, 15:11
Default using DEFINE_GEOM to change 2D geometry- shear constant area
  #1
New Member
 
ystein
Join Date: Apr 2020
Posts: 2
Rep Power: 0
ystein is on a distinguished road
Hi All,

I have been trying to deform a square into a rhombic shape such as the attached pure strain image and have been testing out a few UDFs to deform the boundaries.
purestrain.PNG


I start out with a simple mesh geometry like this:
mesh_square.PNG
and use DEFINE_GEOM to deform all four walls (labeling is wall12 top right wall and then going clockwise).
This is my dynamic mesh setup page:
dynamicmesh.PNG


Current issues with my UDF:
(1) Something that I am worried about is CURRENT_TIME, so I tried to output it as a message, but it always shows like 21 times? Should i put it outside the function? such as in my TUI:

"Updating mesh to time 3.00000e-02 (step = 00003)... time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
time = 0.020000
"


(2) my mesh is only moving in the y direction, but I know I need to be stretching all four "corners" so it should update x and y.
meshmotion.PNG

Any help is appreciated. I have also tried to use DEFINE_GRID_MOTION to move the walls at an angle, but to no avail.

I have attached my full UDF, but a snippet of it is as follows:

#include "udf.h"
#include "unsteady.h"

#define W 64 /* side wall of trough, mm */
#define gamma 0.2 /* desired strain */
#define vel_exp 5e-2 /* expansion velocity mm/s */
#define vel_comp 4.52267e-2 /* compression velocity mm/s */

DEFINE_GEOM(wall_12geom, domain, dt, position)
{ Message("time = %f\n ", CURRENT_TIME , '\n');
real D,R,L,l;
real hD,hL,hl;
real dlength_L, dlength_l;
real update_length_L, update_length_l;

/*constants */
D = sqrt(2)*W; /*diagnol of square, intial*/
R = sqrt((2+gamma)/(2-gamma));
L = R*D; /*expansion axis diagnol, final*/
l = pow(D,2)/L; /* compression axis diagnol, final*/
hD=D/2; /* use these variables to calculte angle*/

real t = CURRENT_TIME;
real slope12, intercept12; /* geometry line */

dlength_L = vel_exp*t; /*delta change in expansion axis from ORIGIN, lengthening x axis*/
dlength_l = -1*vel_comp*t; /*delta change in compression axis from ORIGIN, shortening y axis*/

update_length_L = hD + dlength_L; /* every time step length, L from ORIGIN to sharp corner*/
update_length_l = hD + dlength_l; /* every time step length,l from ORIGIN to sharp corner*/

/* set variables */
slope12 = dlength_l/dlength_L; /*neg */
intercept12 = update_length_l; /*pos*/

/* set y = mx + b dependent on time*/
position[0] = position[0] + dlength_L; /* START HERE */

position[1] = slope12*position[0] + intercept12;


}
Attached Files
File Type: c define_geom_allwall.c (4.8 KB, 0 views)
ystein is offline   Reply With Quote

Old   May 5, 2020, 07:20
Default Shape Deformation
  #2
Senior Member
 
vinerm's Avatar
 
Vinerm
Join Date: Jun 2009
Location: Nederland
Posts: 2,946
Blog Entries: 1
Rep Power: 35
vinerm will become famous soon enough
Instead of using DEFINE_GEOM, use DEFINE_GRID_MOTION. This way you can control motion of each individual node instead of a boundary. If you want to use DEFINE_GEOM, then you have to define four different functions, one for each edge.
__________________
Regards,
Vinerm

PM to be used if and only if you do not want something to be shared publicly. PM is considered to be of the least priority.
vinerm is offline   Reply With Quote

Old   May 5, 2020, 08:27
Default
  #3
New Member
 
ystein
Join Date: Apr 2020
Posts: 2
Rep Power: 0
ystein is on a distinguished road
Quote:
Originally Posted by vinerm View Post
Instead of using DEFINE_GEOM, use DEFINE_GRID_MOTION. This way you can control motion of each individual node instead of a boundary. If you want to use DEFINE_GEOM, then you have to define four different functions, one for each edge.
Hi Vinerm,

Thank you for your reply. I had originally used DEFINE_GRID_MOTION to control the edge boundaries ( one function for each edge), but did not get it to work properly. With DEFINE_GRID_MOTION, I moved each node of the boundaries based on the angle of the two corners that were moving. My code for one of the wall boundaries is below.

However, I think you are saying I should use DEFINE_GRID_MOTION on the interior surface body too? I'm a little confused how you would avoid cell skew using that? Could you expound on that? Thanks!

I wonder if this has to do with constraining a mesh that resists the movement of the boundary walls to turn " inward."


Code:
/*expansion*/
DEFINE_CG_MOTION(corner2cg, dt, cg_vel, cg_omega, time, dtime) 
{
  cg_vel[0] = vel_exp;
  cg_vel[1] = 0.0;
  cg_vel[2] = 0.0;


}

/*compression*/
DEFINE_CG_MOTION(corner3cg, dt, cg_vel, cg_omega, time, dtime) 
{
  cg_vel[0] = 0.0;
  cg_vel[1] = vel_comp;
  cg_vel[2] = 0.0;


}

/*expansion*/
DEFINE_CG_MOTION(corner4cg, dt, cg_vel, cg_omega, time, dtime) 
{
  cg_vel[0] = -1*vel_exp;
  cg_vel[1] = 0.0;
  cg_vel[2] = 0.0;


}

/* PROGRESS */
DEFINE_GRID_MOTION(wall_12grid, domain, dt, time, dtime)
{
  Thread *tf = DT_THREAD (dt);
  face_t f;
  Node *v;
  real D,R,L,l;
  real hD,hL,hl;
  real dlength_L, dlength_l;
  real update_length_L, update_length_l;
  real alpha_new,d_alpha;
  real NV_VEC(centroid), NV_VEC(rvec), NV_VEC(dvel), NV_VEC(dx);
  real NV_VEC(d_omega);
  int n;
  
  /* !!!! update here !!!!*/
  /* initialize the vectors */
  NV_D(centroid, =, 0, 0.0, 0.000); /* meters CONSTANTLY MOVING! */
  NV_S(d_omega,=,0.0); /* cycles per second */
  
  /*constants */
	D = sqrt(2)*W; /*diagnol of square, intial*/
	R = sqrt((2+gamma)/(2-gamma)); 
	L = R*D; /*expansion axis diagnol, final*/
	l = pow(D,2)/L; /* compression axis diagnol, final*/
	
	hD=D/2; /* use these variables to calculte angle*/
	hL=L/2;
	hl=l/2;

	
	dlength_L = vel_exp*time; /*delta change in expansion axis from ORIGIN, lengthening*/
	dlength_l = -1*vel_comp*time; /*delta change in compression axis from ORIGIN, shortening*/
	
	update_length_L = hD + dlength_L; /* every time step length, L from ORIGIN*/
	update_length_l = hD + dlength_l; /* every time step length,l from ORIGIN*/
	
	alpha_new = atan2(update_length_l,update_length_L); /* change in angle of wall,rad */
	d_alpha = alpha_prev - alpha_new; /* change in angle from prior timestep to now, rad */
	alpha_prev = alpha_new; /* store change in angle (rad) per time step */
	
	d_omega[2] = d_alpha/dtime/(2*M_PI); /* cycles per second [Hz] every time step update*/
	
	/* change the reference vector */ 
	centroid[0] = update_length_L;

	Message("centroid_x = %f,dlength_L = %f, dlength_l = %f, alpha_new = %f, alpha_prev = %f", centroid[0],dlength_L, dlength_l, alpha_new,alpha_prev );
  
/* Set/activate the deforming flag on adjacent cell zone, which      */
/* means that the cells adjacent to the deforming wall will also be  */
/* deformed, in order to avoid skewness.                             */
  SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));

/* Loop over the deforming boundary zone's faces;                    */
/* inner loop loops over all nodes of a given face;                  */
/* Thus, since one node can belong to several faces, one must guard  */
/* against operating on a given node more than once:                 */

  begin_f_loop (f, tf)
    {
      f_node_loop (f, tf, n)
        {
          v = F_NODE(f, tf, n);

          /* Update the current node only if it has not been         */
		  /* previously visited:                                     */
          if (NODE_POS_NEED_UPDATE (v))
            {
              /* Set flag to indicate that the current node's        */
			  /* position has been updated, so that it will not be   */
              /* updated during a future pass through the loop:      */
              NODE_POS_UPDATED (v);
			  
			  NV_VV(rvec, =, NODE_COORD(v),-,centroid); /* setting vector distance*/
			  NV_CROSS(dx, d_omega, rvec); /* velocity vector, m/s = (1/s * m )*/
			  NV_S(dx,*=,dtime); /* distance vector*/
			  NV_V(NODE_COORD(v),+=,dx); /* updating current nodes to new position) */
		
            }
        }
    }
  end_f_loop (f, tf);
  
  b++;
}
ystein 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
Non overlap area fractions saisanthoshm88 CFX 11 September 17, 2015 18:42
fluid flow but temperature raises from nowhere? mxcfd STAR-CCM+ 5 September 16, 2014 05:46
vitual _ real deneb FLUENT 3 January 22, 2007 04:31
Restarted run and change in geometry...question Vanessa CFX 3 August 28, 2006 07:55
can I change the geometry file? a.melandinos CFX 2 March 8, 2002 12:57


All times are GMT -4. The time now is 02:30.