July 8, 2021 at 2:25 pm
Subscriber
I have made this based on the manual..
#include "udf.h"
static int last_ts = -1; /* Global variable. Time step is never <0 */
DEFINE_ADJUST(first_iter_only, domain)
{
int curr_ts;
int my_variable;
face_t f;
Thread *t;
curr_ts = N_TIME;
if (last_ts != curr_ts)
{
last_ts = curr_ts;
{
real P; /*pressure*/
P = F_P(f,t);
/* Loop and check the condition */
if( P > 1000000 ) {
my_variable = 1; /*OPEN VALVE*/
} else {
my_variable = 0; /*CLOSE VALVE*/
}
}
}
}
DEFINE_PROFILE(outletvalve,t,i)
{
real a; /*viscous resistance = 1/permeability*/
begin_f_loop(f,t)
{
if( my_variable == 1)
a = 1.0;
else
a = 1e12;
F_PROFILE(f,t,i) = a;
}
end_f_loop(f,t)
}
what do you think?
#include "udf.h"
static int last_ts = -1; /* Global variable. Time step is never <0 */
DEFINE_ADJUST(first_iter_only, domain)
{
int curr_ts;
int my_variable;
face_t f;
Thread *t;
curr_ts = N_TIME;
if (last_ts != curr_ts)
{
last_ts = curr_ts;
{
real P; /*pressure*/
P = F_P(f,t);
/* Loop and check the condition */
if( P > 1000000 ) {
my_variable = 1; /*OPEN VALVE*/
} else {
my_variable = 0; /*CLOSE VALVE*/
}
}
}
}
DEFINE_PROFILE(outletvalve,t,i)
{
real a; /*viscous resistance = 1/permeability*/
begin_f_loop(f,t)
{
if( my_variable == 1)
a = 1.0;
else
a = 1e12;
F_PROFILE(f,t,i) = a;
}
end_f_loop(f,t)
}
what do you think?