sandbox/fintzin/Rising-Suspenion/CA.h
- @file CA.h
- @author fintzi nicolas (fintzi.nicolas@ifpen.fr)
- @brief
- @version 0.1
- @date 2022-09-25
- @copyright Copyright (c) 2022
Declaration of the structures gathering all the closure terms
typedef struct {
double Vd; //volume of the dispersed phase
double S; //Surface of the interfaces
double Vf; //volume of the continuous or fluid phase
double dissd; //Energy Dissipation inside the dispersed phase
double dissf; //Energy Dissipation inside the fluid phase
; //Velocity of the bulk
coord U; //Acceleration of the bulk
coord A; //Momentum of the bulk
coord RhoU; //Velocity of the fluid phase
coord Uf; //Velocity of the dispersed phase
coord Ud; //Pseudo tensor of fluctuation for the fluid phase
tens UpUpf; //Pseudo tensor of fluctuation for the dispersed phase
tens UpUpd; //Pseudo tensor of fluctuation 3rd order for the fluid phase
coord UpUpUpf; //Pseudo tensor of fluctuation 3rd order for the dispersed phase
coord UpUpUpd}CA;
functoin that compute the bulk velocity and momentum
void avg_U_and_V(CA * st){
={0},RhoU={0},A={0};
coord Uforeach(reduction(+:U) reduction(+:RhoU) reduction(+:A)){
double rho = f[]*(rho1-rho2)+rho2;
double dm=dv()*rho;
foreach_dimension(){
.x += u.x[]*dv();
U.x+=dm*u.x[];//average momentum
RhoU}
}
foreach_face(reduction(+:A))
.x += a.x[]*dv();
A
->RhoU = RhoU;
st->U = div_coord(U,(Ls*Ls));
st->A = div_coord(A,(Ls*Ls));
st}
computation of the averaged velocities and volume of both phases
void avg_Ui_and_Vol(CA * st){
double Vd=0,Vf=0,S=0;
={0},Uf={0};
coord Ud// calcul des vol moy , vel moy and momentum Vf
foreach(reduction(+:Ud) reduction(+:Uf) reduction(+:Vd)
reduction(+:Vf) reduction(+:S)){
+= dv()*f[];
Vd += dv()*(1.-f[]);
Vf foreach_dimension(){
.x += dv()*f[]*u.x[];//average velocity in the drops
Ud.x += dv()*(1-f[])*u.x[];//average velocity in the fluid
Uf}
if(f[] > EPS && f[] < 1.-EPS){
= mycs(point, f), p;
coord n double alpha = plane_alpha(f[], n);
+= pow(Delta, dimension - 1) * plane_area_center(n, alpha, &p);
S }
};
->Ud = div_coord(Ud,Vd);
st->Uf = div_coord(Uf,Vf);
st->Vf = Vf;
st->Vd = Vd;
st->S = S;
st}
computation of the diagonal componant of the pseudo turbulant tensor i.e. \int u_i u_j dV
void UpUpfd_UpUpUpfd(CA * st){
={{0}},UpUpd={{0}};
tens UpUpf={0},UpUpUpd={0};
coord UpUpUpfforeach(reduction(+:UpUpf) reduction(+:UpUpd)
reduction(+:UpUpUpf) reduction(+:UpUpUpd))
einstein_sum(i,j){
.i.j += (u.i[] - st->Uf.i) * (u.j[] - st->Uf.j) * dv() * (1 - f[]);
UpUpf.i.j += (u.i[] - st->Ud.i) * (u.j[] - st->Ud.j) * dv() * f[];
UpUpd.i += pow(u.i[] - st->Uf.i,3) * dv() * (1 - f[]);
UpUpUpf.i += pow(u.i[] - st->Ud.i,3) * dv() * f[];
UpUpUpd}
->UpUpf = div_tens(UpUpf,st->Vf);
st->UpUpd = div_tens(UpUpd,st->Vd);
st->UpUpUpf = div_coord(UpUpUpf,st->Vf);
st->UpUpUpd = div_coord(UpUpUpd,st->Vd);
st}
computation of the dissipation rate inside both phases
void dissipation_rate (CA * st)
{
double rateWater = 0.0;
double rateAir = 0.0;
foreach (reduction (+:rateWater) reduction (+:rateAir)) {
;
tens Gudouble tau;
(u,Gu);
vec_gradeinstein_sum(i,j){
= (Gu.i.j + Gu.j.i)*(Gu.i.j + Gu.j.i);
tau }
+= mu1/rho[]*f[] * tau; //water
rateWater += mu2/rho[]*(1. - f[])*tau; //air
rateAir }
->dissd = rateWater/st->Vd;
st->dissf = rateAir/st->Vf;
st}
computation of the closures terms for the i eme phase
void calcul_CA(CA * st){
avg_U_and_V(st);
avg_Ui_and_Vol(st);
UpUpfd_UpUpUpfd(st);
dissipation_rate(st);
}
print all the components of CA in the fCA.csv file
void print_CA(CA st,int step){
int nvof = list_len(interfaces);
= fopen("fCA.csv","a");
fCA fprintf(fCA,"%d,%g,%d,%g",step,t,nvof,st.Vd/pow(Ls,dimension));
fprintf(fCA,",%g,%g,%g,%g,%g",st.S,st.Vd,st.Vf,st.dissd,st.dissf);
einstein_sum(i,j){
fprintf(fCA,",%g",st.U.i);
fprintf(fCA,",%g",st.Ud.i);
fprintf(fCA,",%g",st.Uf.i);
fprintf(fCA,",%g",st.RhoU.i);
fprintf(fCA,",%g",st.A.i);
fprintf(fCA,",%g",st.UpUpf.i.j);
fprintf(fCA,",%g",st.UpUpd.i.j);
fprintf(fCA,",%g",st.UpUpUpf.i);
fprintf(fCA,",%g",st.UpUpUpd.i);
}
fprintf(fCA,"\n");
fclose(fCA);
}