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

Udf for adaptive time step, error in loop

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   July 6, 2019, 02:04
Default Udf for adaptive time step, error in loop
  #1
New Member
 
Francesco Labianca
Join Date: Jun 2019
Posts: 6
Rep Power: 6
francescolab is on a distinguished road
Could someone, please, help me with this udf code? It's write in the right way but it doesn't work and don't do function in the "else" https://pastebin.com/raw/SMazER3X
Code:
  



#include "udf.h"
#include"udf.h"
#include"metric.h"
#include"stdio.h"
#include"math.h"
#include"stdlib.h"
#include"mem.h"

DEFINE_DELTAT(deltat,d)
{
real time_step;
real tx=CURRENT_TIME;
Thread *t,*t0, *t1 =NULL;
cell_t c0, c1 =-1;
face_t f;
Domain *domain;
real x0[ND_ND];
real x1[ND_ND];
int n =0;
real dx =0.0, dy =0.0;
domain = Get_Domain(1);
n =0;
real cent[2];
double centr_x, centr_y;
double vel_x, vel_y;

if ( tx<=1 ) {
 time_step=0.01;
} else {
 DEFINE_ON_DEMAND(calc_distance)
{

thread_loop_f(t,domain)
{
begin_f_loop (f,t)
{
c0 = F_C0(f,t);
t0 = F_C0_THREAD(f,t);
if (BOUNDARY_FACE_THREAD_P(t))
{}
else
{
n+=1;
t1 = F_C1_THREAD(f,t);
c1 = F_C1(f,t);
C_CENTROID(x0,c0,t0);
C_CENTROID(x1,c1,t1);
dx = x1[0]-x0[0];
dy = x1[1]-x0[1];
}
}
end_f_loop (f,t)
}
DEFINE_ADJUST(velocity_profile_face,d)
{
thread_loop_f(t,d)
{
begin_f_loop(f,t)
{
F_CENTROID(cent,f,t);

centr_x = cent[0];
centr_y = cent[1];
vel_x = F_U(f,t);
vel_y = F_U(f,t);

}
end_f_loop(f,t)
}
time_step=MAX (time_step, (dx / vel_x) *0.8);
time_step=MAX (time_step, (dy / vel_y) *0.8);
}
}
}
return time_step;
}
francescolab is offline   Reply With Quote

 


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 7, 2024 23:17
Transient simulation not converging skabilan OpenFOAM Running, Solving & CFD 14 December 16, 2019 23:12
Setting up Lid driven Cavity Benchmark with 1M cells for multiple cores puneet336 OpenFOAM Running, Solving & CFD 11 April 7, 2019 00:58
AMI interDyMFoam for mixer nu problem danny123 OpenFOAM Programming & Development 8 September 6, 2013 02:34
pisoFoam with k-epsilon turb blows up - Some questions Heroic OpenFOAM Running, Solving & CFD 26 December 17, 2012 03:34


All times are GMT -4. The time now is 00:54.