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

Time varying porosity/viscous resistance

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By pakk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 21, 2019, 11:00
Exclamation Time varying porosity/viscous resistance
  #1
New Member
 
Anonymous
Join Date: May 2019
Posts: 1
Rep Power: 0
CFDuser1995 is on a distinguished road
Dear all,


I am working on a project in which I would like to vary the porosity or viscous resistance in a domain over time. This is the UDF I tried to interpreted in Fluent:


#include "udf.h" //file that contains definitions for define functions and fluent operations

DEFINE_PROFILE(vis_res,th,i)
{
real x[ND_ND];
real a;
real t = CURRENT_TIME;
cell_t c;

begin_c_loop(c,th)
{
C_CENTROID(x,c,th);
if(t >= 0 && t <= 0.4)
a = 1e9;
else(t > 0.4 && t <= 0.8)
a = 1.0;
F_PROFILE(c,th,i) = a;
}
end_c_loop(c,th)
}


I received errors, I hope someone can help me to modify the UDF.



Thanks in advance!!
CFDuser1995 is offline   Reply With Quote

Old   May 22, 2019, 06:43
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
what kind of error did you get? describe in details, put here console output

best regards
AlexanderZ is offline   Reply With Quote

Old   May 27, 2019, 06:36
Default
  #3
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
Your "else" should be "else if".
pakk is offline   Reply With Quote

Old   November 4, 2019, 13:20
Default Time dependant viscous resistance
  #4
New Member
 
shivam salokhe
Join Date: Feb 2017
Posts: 10
Rep Power: 9
sshivam is on a distinguished road
Hello, I am working on the same problem but in my case, I need to modify the visc resistance using an equation which is the function of wetting time of cell and total flow time. To do so, I am using the VOF approach to model the two-phase flow in porous media. So the following things I expect from UDF

1. Consider for a cell, it should record the time when the volume fraction becomes unity (tw) which varies for different cells.
2. The viscous resistance for secondary phase should be modified using the following equation a = (1/(3.7E-15*(current_time-tw)^2-1.75E-12*(current_time-tw)+6E-10))

any suggestions on this?
sshivam is offline   Reply With Quote

Old   November 4, 2019, 14:32
Default
  #5
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
I guess the challenge is in the first part. In pseudo-code:

Code:
Add one UDM, which will represent the wetting time per cell. 
Initialize this UDM at a large value.
Add a scalar update:
 For each cell:
  Check if the vof is 1
  If so, check if the current time is below the UDM value. 
  If so, update the UDM value to the current time.
pakk is offline   Reply With Quote

Old   November 5, 2019, 07:21
Default
  #6
New Member
 
shivam salokhe
Join Date: Feb 2017
Posts: 10
Rep Power: 9
sshivam is on a distinguished road
#include "udf.h"

DEFINE_PROFILE(vis_res,c,i)
{
int phase_domain_index;
cell_t cell;
Thread *cell_thread;
Domain *subdomain;
real xc[ND_ND];

real current_time;
current_time = CURRENT_TIME;


sub_domain_loop(subdomain, mixture_domain, phase_domain_index) /* loop over all subdomains (phases) in the superdomain (mixture) */
{
if (DOMAIN_ID(subdomain) == 2) /* loop if secondary phase */

thread_loop_c (cell_thread,subdomain) /* loop over all cell threads in the secondary phase domain */
{

begin_c_loop_all (cell,cell_thread) /* loop over all cells in secondary phase cell threads */
{

C_CENTROID(xc,cell,cell_thread);

if

C_VOF(cell,cell_thread) = 1.; /* if volume fraction to 1*/

tw = C_time(c,t); /*wetting time*/

C_UDMI(c,t,0)=tw; /*saving wetting time*/

a = (1/(3.7E-15*(current_time-tw)^2-1.75E-12*(current_time-tw)+6E-10));

else

a =(1/9E-10);

F_PROFILE(c,t,i) = a;
}
}
}
end_c_loop_all (cell,cell_thread)

From ansys udf manual I have created this UDF. Since I am new to this. I would like to have your comments and suggestions on the same.
sshivam is offline   Reply With Quote

Old   November 5, 2019, 08:47
Default
  #7
Senior Member
 
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27
pakk will become famous soon enough
After some grammar fixes:

Code:
#include "udf.h"

DEFINE_PROFILE(vis_res,t,i)
{
int phase_domain_index;
cell_t cell;
Thread *cell_thread;
Domain *subdomain;
real a;
real current_time = CURRENT_TIME;

sub_domain_loop(subdomain, mixture_domain, phase_domain_index) /* loop over all subdomains (phases) in the superdomain (mixture) */
{
 if (DOMAIN_ID(subdomain) == 2) /* loop if secondary phase */
 thread_loop_c (cell_thread,subdomain) /* loop over all cell threads in the secondary phase domain */
 {
  begin_c_loop_all (cell,cell_thread) /* loop over all cells in secondary phase cell threads */
  {
  if (C_VOF(cell,cell_thread) > 0.99999) /* if volume fraction is close enough to one*/
   {
   if (C_UDMI(cell,t,0)==0) C_UDMI(cell,t,0)=current_time; /*saving wetting time only if it is the first time that it wets*/
   a = (1/(3.7E-15*pow(current_time-C_UDMI(cell,t,0),2)-1.75E-12*(current_time-C_UDMI(cell,t,0))+6E-10));
   } else {
   a = (1/9E-10);
   }
  F_PROFILE(cell,t,i) = a;
  }
 }
}
end_c_loop_all (cell,cell_thread)
}
Surely this will still fail, but at least it is closer.
And I think it can be simplified a lot further, but I am not so experienced with writing for secondary phases, and I don't have Fluent right now:

Code:
#include "udf.h"

DEFINE_PROFILE(vis_res,t,i)
{
cell_t cell;
real current_time = CURRENT_TIME;

begin_c_loop_all (cell,t) /* loop over all cells in secondary phase cell threads */
{
if (C_VOF(cell,t) > 0.99999) /* if volume fraction is close enough to one*/
 {
 if (C_UDMI(cell,t,0)==0) C_UDMI(cell,t,0)=current_time; /*saving wetting time only if it is the first time that it wets*/
 F_PROFILE(cell,t,i) = (1/(3.7E-15*pow(current_time-C_UDMI(cell,t,0),2)-1.75E-12*(current_time-C_UDMI(cell,t,0))+6E-10));
 } else {
 F_PROFILE(cell,t,i) = (1/9E-10);
 }
}
end_c_loop_all (cell,t)
}
Look at my changes critically, I did not test them.
sshivam likes this.
pakk is offline   Reply With Quote

Old   November 5, 2019, 08:54
Default
  #8
New Member
 
shivam salokhe
Join Date: Feb 2017
Posts: 10
Rep Power: 9
sshivam is on a distinguished road
Thanks a lot for simplifications. I look forward to testing it
sshivam is offline   Reply With Quote

Reply

Tags
porosity, viscous resistance


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
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 42 May 8, 2024 00:17
Elastic or Plastic Deformations in OpenFOAM NickolasPl OpenFOAM Pre-Processing 36 September 23, 2023 09:22
[Other] Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Community Contributions 58 December 23, 2021 03:36
High Courant Number @ icoFoam Artex85 OpenFOAM Running, Solving & CFD 11 February 16, 2017 14:40
plot over time fferroni OpenFOAM Post-Processing 7 June 8, 2012 08:56


All times are GMT -4. The time now is 13:20.