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

Interface and contact detection problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2021, 04:38
Default Interface and contact detection problem
  #1
New Member
 
Join Date: Feb 2020
Posts: 22
Rep Power: 6
Silence is on a distinguished road
Hello everyone,
Background
I am using ‘contact detection’ to set a motion limit, but I failed, details have been shown in Figure 1, whole fluid zone consists of zone1(fluid top) and zone2(fluid film), bottom face of zone1 and top face of zone 2 are set as interface, a force is exerted on the bottom face of zone2 to realize the motion along y axis, the limit distance that motion will be stopped is set as 0.9mm(the initial distance between top face of zone2 and bot face of zone2 is 1mm), details about contact detection is shown in Figure 2, however, when the distance reaches 0.9mm, the moving wall is still in active.
Besides, I found that once the bot face of zone1 and top face of zone2 are set as interface, two new faces with suffix “non-overlapping” appear, and warnings will be popped out if I choose to display them, which is shown in Figure 3.
UDF for dynamic mesh and contact detection are presented.
Questions
(1) why contact detection fails to stop the motion?
(2) face with suffix “non-overlapping” is the face that original face cuts off the interface between two faces, right?
(3) why the face with suffix “non-overlapping” cannot be displayed?(I saw its type is “wall”)
Any advice will be highly appreciated, thx!
Regards,


Figure 1


Figure 2


Figure 3

UDF Code
Code:
#include <iostream>
#include "udf.h"
using namespace std;

DEFINE_SDOF_PROPERTIES(external_force, prop, dt, time, dtime)
{
	real force;
        force = 0.4;

	/* Basic property */
	prop[SDOF_MASS] = 1;
	prop[SDOF_LOAD_F_Y] = force;

	/* Translation constraint */
	prop[SDOF_ZERO_TRANS_X] = TRUE;
	prop[SDOF_ZERO_TRANS_Z] = TRUE;
	/* Rotation constraint */
	prop[SDOF_ZERO_ROT_X] = TRUE;
	prop[SDOF_ZERO_ROT_Y] = TRUE;
	prop[SDOF_ZERO_ROT_Z] = TRUE;

#if RP_HOST
	cout << "Host force value: " << force << "N" << endl;
#endif
}

DEFINE_CONTACT(contact_props, dt, contacts)
{
	Objp* o;
	face_t face;
	Thread* thread;
	Domain* domain = NULL;
	Dynamic_Thread* ndt = NULL;
	int tid, nid, n_faces;
	real v0dotn1, v1dotn0;
	real nc_mag, norm0_mag, norm1_mag;
	real N3V_VEC(vel_rel);
	real N3V_VEC(nc), N3V_VEC(nctmp);
	real N3V_VEC(xc), N3V_VEC(xctmp);
	real N3V_VEC(vel0), N3V_VEC(omega0), N3V_VEC(theta0), N3V_VEC(norm0);
	real N3V_VEC(vel1), N3V_VEC(omega1), N3V_VEC(theta1), N3V_VEC(norm1);

	if (!Data_Valid_P())
	{
		return;
	}

	/* Define a common contact point / plane */
	N3V_S(nc, =, 0.0);
	N3V_S(xc, =, 0.0);

	/* Fetch current thread ID */
	tid = THREAD_ID(DT_THREAD(dt));
	nid = -1;
	n_faces = 0;
	loop(o, contacts)
	{
		face = O_F(o);
		thread = O_F_THREAD(o);
		/* Skip faces on current thread */
		if (THREAD_ID(thread) == tid)
		{
			continue;
		}

		/* Note ID of the other thread for posterity */
		if (nid == -1)
		{
			nid = THREAD_ID(thread);
		}

		N3V_S(nctmp, =, 0.0);
		N3V_S(xctmp, =, 0.0);
		F_AREA(nctmp, face, thread);
		F_CENTROID(xctmp, face, thread);

		/**
		* Negative sum because wall normals
		* point out of the fluid domain
		*/
		N3V_V(nc, -=, nctmp);
		N3V_V(xc, +=, xctmp);
		n_faces++;
	}

# if RP_NODE 
	{
		/* Reduce in parallel */
		nid = PRF_GIHIGH1(nid);
		n_faces = PRF_GISUM1(n_faces);
		PRF_GRSUM3(nc[0], nc[1], nc[2]);
		PRF_GRSUM3(xc[0], xc[1], xc[2]);
	}
# endif

	node_to_host_int_2(nid, n_faces);
	node_to_host_real_3(nc[0], nc[1], nc[2]);
	node_to_host_real_3(xc[0], xc[1], xc[2]);
	if (n_faces > 0)
	{
		nc_mag = N3V_MAG(nc) + REAL_MIN;
		N3V_S(nc, /=, nc_mag);
		N3V_S(xc, /=, n_faces);
	}
	else
	{
		return;
	}

#if RP_HOST
	Message
	(
		"\nContact:: tid: %d nid: %d n_faces: %d "
		"Point: (%f %f %f) Normal: (%f %f %f)",
		tid, nid, n_faces,
		xc[0], xc[1], xc[2],
		nc[0], nc[1], nc[2]
	);
#endif

	/* Fetch thread for opposite body */
	domain = THREAD_DOMAIN(DT_THREAD(dt));
	thread = Lookup_Thread(domain, nid);
	if (NULLP(thread))
	{
		Message("\nWarning: No thread for nid: %d ", nid);
		return;
	}
	else
	{
		ndt = THREAD_DT(thread);
	}

	SDOF_Get_Motion(dt, vel0, omega0, theta0);
	N3V_VV(norm0, =, xc, -, DT_CG(dt));
	norm0_mag = N3V_MAG(norm0) + REAL_MIN;
	N3V_S(norm0, /=, norm0_mag);
	if (NULLP(ndt))
	{
		N3V_V(norm1, =, nc);
		N3V_S(vel1, =, 0.0);
		N3V_V(vel_rel, =, vel0);
	}
	else
	{
		SDOF_Get_Motion(ndt, vel1, omega1, theta1);
		N3V_VV(vel_rel, =, vel0, -, vel1);
		N3V_VV(norm1, =, xc, -, DT_CG(ndt));
		norm1_mag = N3V_MAG(norm1) + REAL_MIN;
		N3V_S(norm1, /=, norm1_mag);

		if (N3V_DOT(vel_rel, nc) < 0.0)
		{
			v1dotn0 = 2 * N3V_DOT(vel1, norm0);
			N3V_S(norm0, *=, v1dotn0);
			N3V_V(vel1, -=, norm0);
			SDOF_Overwrite_Motion(ndt, vel1, omega1, theta1);
		}
	}

	if (N3V_DOT(vel_rel, nc) < 0.0)
	{
		v0dotn1 = 1 * N3V_DOT(vel0, norm1);
		N3V_S(norm1, *=, v0dotn1);
		N3V_V(vel0, -=, norm1);
		SDOF_Overwrite_Motion(dt, vel0, omega0, theta0);
	}

#if RP_HOST
	Message
	(
		"\ncontact_props: Updated :: vel0 = (%f %f %f) vel1 = (%f %f %f)",
		vel0[0], vel0[1], vel0[2], vel1[0], vel1[1], vel1[2]
	);
#endif
}
Silence 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
Pinning the interface contact line - VOF model pat.jachimczyk Fluent UDF and Scheme Programming 8 June 21, 2022 11:12
How to use the CFX periodic interface zhihuawan CFX 61 January 15, 2018 16:20
Wrong interface curvature capturing and contact line calculation at low capillary nu Mahmoud_aboukhedr OpenFOAM Running, Solving & CFD 0 April 14, 2015 14:04
Defining contact regions in FSI problem.!!! sreemvlk ANSYS 0 June 12, 2014 00:33
Problem with inserting a thermal contact resistance in domain interface. jerryx70c CFX 1 March 4, 2013 14:16


All times are GMT -4. The time now is 17:01.