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

Global node coordinates values FSI-UDF

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By etedalgara

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2021, 05:58
Unhappy Global node coordinates values FSI-UDF
  #1
New Member
 
Marcelo Ruiz
Join Date: Feb 2021
Location: Italy
Posts: 17
Rep Power: 5
CFDavatar is on a distinguished road
Hello everybody,

I am traying to reproduce the motion of a fish in 2D. I am using the Macro DEFINE_GRID_MOTION(). I want to extract the initial coordinates of the fish, so that I can use it over all simulation. I other words, motion is defined by the initial position f(x_0,y_0,t). I have tried to code it in the same macro. Nevertheless, I have not succeed.

Could you please provide me any advice?
Which macro I can use to extract the Initial values and store it in a global variable matrix/array?


In the next code I try to extract the minimum and maximum coordinates before the deformation. However it did not work properly:

Code:
DEFINE_GRID_MOTION(motion, domain, dt, time, dtime)
{

	Thread* tf = DT_THREAD(dt);
	face_t f;
	Node* v;
	
	double xprev, yprev, hprev, d, h;
	int n;

	double x_max, x_min;
	x_max = -0.99e38;
	x_min = 0.99e38;
	
	begin_f_loop(f, tf) // I used this loop to find the maximum and minimum and maximum but it did not work
	{
		f_node_loop(f, tf,n)
		{
			v = F_NODE(f,tf, n);
			x_max = MAX(x_max, NODE_X(v));
			x_min = MIN(x_min, NODE_X(v));
		}
	}end_f_loop(f, tf)

#if RP_NODE
		x_max = PRF_GRHIGH1(x_max);
		x_min = PRF_GRHIGH1(x_min);
#endif
	SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

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

			if (NODE_POS_NEED_UPDATE(v))
			{
				NODE_POS_UPDATED(v);
				
				if (CURRENT_TIME > 0.0)
				{ 
					xprev = NODE_X(v);
					yprev = NODE_Y(v);
					hprev = kinematics(xprev, PREVIOUS_TIME,x_max,x_min); //Function for the kinematics of fish
					d = yprev;
					h = kinematics(xprev, CURRENT_TIME, x_max, x_min); //Function for the kinematics of fish
					NODE_Y(v) = d+hprev-h;
				}
			}
		}
	}
	end_f_loop(f,tf)
}


Thank you for the advice,
CFDavatar is offline   Reply With Quote

Old   February 27, 2021, 09:36
Default
  #2
Member
 
Join Date: Jan 2020
Posts: 31
Rep Power: 6
etedalgara is on a distinguished road
Quote:
Originally Posted by CFDavatar View Post
Hello everybody,

I am traying to reproduce the motion of a fish in 2D. I am using the Macro DEFINE_GRID_MOTION(). I want to extract the initial coordinates of the fish, so that I can use it over all simulation. I other words, motion is defined by the initial position f(x_0,y_0,t). I have tried to code it in the same macro. Nevertheless, I have not succeed.

Could you please provide me any advice?
Which macro I can use to extract the Initial values and store it in a global variable matrix/array?


In the next code I try to extract the minimum and maximum coordinates before the deformation. However it did not work properly:

Code:
DEFINE_GRID_MOTION(motion, domain, dt, time, dtime)
{

	Thread* tf = DT_THREAD(dt);
	face_t f;
	Node* v;
	
	double xprev, yprev, hprev, d, h;
	int n;

	double x_max, x_min;
	x_max = -0.99e38;
	x_min = 0.99e38;
	
	begin_f_loop(f, tf) // I used this loop to find the maximum and minimum and maximum but it did not work
	{
		f_node_loop(f, tf,n)
		{
			v = F_NODE(f,tf, n);
			x_max = MAX(x_max, NODE_X(v));
			x_min = MIN(x_min, NODE_X(v));
		}
	}end_f_loop(f, tf)

#if RP_NODE
		x_max = PRF_GRHIGH1(x_max);
		x_min = PRF_GRHIGH1(x_min);
#endif
	SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));

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

			if (NODE_POS_NEED_UPDATE(v))
			{
				NODE_POS_UPDATED(v);
				
				if (CURRENT_TIME > 0.0)
				{ 
					xprev = NODE_X(v);
					yprev = NODE_Y(v);
					hprev = kinematics(xprev, PREVIOUS_TIME,x_max,x_min); //Function for the kinematics of fish
					d = yprev;
					h = kinematics(xprev, CURRENT_TIME, x_max, x_min); //Function for the kinematics of fish
					NODE_Y(v) = d+hprev-h;
				}
			}
		}
	}
	end_f_loop(f,tf)
}


Thank you for the advice,
Hi. I think this can help you:
after this code use N_UDMI(v,0) & N_UDMI(v,1) as the initial condition nodes for x and y. please search about DEFINE_ON_DEMAND macro. Don't forget that you must "Execute on Demand" it in fluent after Initialization.

DEFINE_ON_DEMAND(NODE_FIRST)
{
Domain *d= Get_Domain(1);
Thread *t=Lookup_Thread(d,ID);
face_t f;
Node *v;
int n;
FILE *fout;
real time=CURRENT_TIME;
thread_loop_f (t,d)
{
begin_f_loop(f,t)
{
f_node_loop(f,t,n)
{
v = F_NODE(f,t,n);
N_UDMI(v,0) = NODE_X(v);
N_UDMI(v,1) = NODE_Y(v);
}
}
}
end_f_loop (f,t)
}
CFDavatar likes this.
etedalgara is offline   Reply With Quote

Old   October 26, 2021, 23:49
Default
  #3
New Member
 
Thomas Sprengeler
Join Date: Oct 2020
Posts: 3
Rep Power: 6
sprengeler is on a distinguished road
Were you able to store the initial coordinates and make this work?
sprengeler is offline   Reply With Quote

Old   October 27, 2021, 10:25
Default
  #4
New Member
 
Marcelo Ruiz
Join Date: Feb 2021
Location: Italy
Posts: 17
Rep Power: 5
CFDavatar is on a distinguished road
Quote:
Originally Posted by sprengeler View Post
Were you able to store the initial coordinates and make this work?
Hello, at the end I just kept the fish swiiming from a fixed reference coordinate system. You can try with etedalgara suggestion above
CFDavatar is offline   Reply With Quote

Old   October 27, 2021, 12:27
Default
  #5
New Member
 
Thomas Sprengeler
Join Date: Oct 2020
Posts: 3
Rep Power: 6
sprengeler is on a distinguished road
Quote:
Originally Posted by CFDavatar View Post
Hello, at the end I just kept the fish swiiming from a fixed reference coordinate system. You can try with etedalgara suggestion above
Is there a way to specify a fixed reference coordinate system in your UDF?
sprengeler is offline   Reply With Quote

Reply

Tags
define_grid_motion(), fluid-solid, fsi, global variables


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
courant number increases to rather large values 6863523 OpenFOAM Running, Solving & CFD 22 July 6, 2023 00:48
pimpleDyMFoam computation randomly stops babapeti OpenFOAM Running, Solving & CFD 5 January 24, 2018 06:28
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 11:08
How to obtain node values in UDF? Maciej FLUENT 0 October 23, 2006 09:10
Help: how to get node values with UDF? Dazhi Guo FLUENT 0 February 4, 2001 01:59


All times are GMT -4. The time now is 14:50.