KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
Variables | |
bool | do_simplifications = False |
Settings explanation DIMENSION TO COMPUTE: This symbolic generator is valid for both 2D and 3D cases. More... | |
string | dim_to_compute = "Both" |
string | linearisation = "Picard" |
bool | divide_by_rho = True |
bool | ASGS_stabilization = True |
string | mode = "c" |
string | time_integration = "bdf2" |
string | output_filename = "two_fluid_navier_stokes.cpp" |
string | template_filename = "two_fluid_navier_stokes_template.cpp" |
string | err_msg = "Wrong time_integration. Given \'" + time_integration + "\'. Available options are \'bdf2\' , \'alpha_method\'and \'theta_scheme\'." |
list | dim_vector = [2] |
templatefile = open(template_filename) | |
Read the template file. More... | |
outstring = templatefile.read() | |
int | nnodes = 3 |
int | strain_size = 3 |
bool | impose_partion_of_unity = False |
N | |
DN | |
DNenr = DefineMatrix('DNenr',nnodes,dim) | |
Nenr = DefineVector('Nenr',nnodes) | |
v = DefineMatrix('v',nnodes,dim) | |
Unknown fields definition. More... | |
vn = DefineMatrix('vn',nnodes,dim) | |
vnn = DefineMatrix('vnn',nnodes,dim) | |
p = DefineVector('p',nnodes) | |
penr = DefineVector('penr',nnodes) | |
w = DefineMatrix('w',nnodes,dim) | |
Test functions definition. More... | |
q = DefineVector('q',nnodes) | |
qenr = DefineVector('qenr' ,nnodes) | |
f = DefineMatrix('f',nnodes,dim) | |
Other data definitions. More... | |
fn = DefineMatrix('fn',nnodes,dim) | |
vmeshn = DefineMatrix('vmeshn',nnodes,dim) | |
C = DefineSymmetricMatrix('C',strain_size,strain_size) | |
Constitutive matrix definition. More... | |
stress = DefineVector('stress',strain_size) | |
Stress vector definition. More... | |
dt = sympy.Symbol('dt', positive = True) | |
Other simbols definition. More... | |
rho = sympy.Symbol('rho', positive = True) | |
nu = sympy.Symbol('nu', positive = True) | |
mu = sympy.Symbol('mu', positive = True) | |
tau1 = sympy.Symbol('tau1', positive = True) | |
tau2 = sympy.Symbol('tau2', positive = True) | |
h = sympy.Symbol('h', positive = True) | |
dyn_tau = sympy.Symbol('dyn_tau', positive = True) | |
stab_c1 = sympy.Symbol('stab_c1', positive = True) | |
stab_c2 = sympy.Symbol('stab_c2', positive = True) | |
volume_error_ratio = sympy.Symbol('volume_error_ratio') | |
art_dyn_visc_coeff = sympy.Symbol('art_dyn_visc_coeff') | |
vconv = DefineMatrix('vconv',nnodes,dim) | |
Convective velocity definition. More... | |
vmesh = DefineMatrix('vmesh',nnodes,dim) | |
vconv_gauss = vconv.transpose()*N | |
float | vconv_gauss_norm = 0.0 |
Compute the stabilization parameters. More... | |
K_darcy = sympy.Symbol('K_darcy', positive = True) | |
Data interpolation to the Gauss points. More... | |
bdf0 = sympy.Symbol('bdf0') | |
Backward differences coefficients. More... | |
bdf1 = sympy.Symbol('bdf1') | |
bdf2 = sympy.Symbol('bdf2') | |
tuple | acceleration = (bdf0*v +bdf1*vn + bdf2*vnn) |
v_gauss = v.transpose()*N | |
f_gauss = f.transpose()*N | |
max_sprectral_radius = sympy.Symbol('max_spectral_radius', positive = True) | |
acceleration_alpha_method = DefineMatrix('acceleration_alpha_method',nnodes,dim) | |
float | alpha_m = 0.5*((3-max_sprectral_radius)/(1+max_sprectral_radius)) |
int | alpha_f = 1/(1+max_sprectral_radius) |
float | gamma = 0.5+ alpha_m -alpha_f |
int | f_alpha = fn+alpha_f*(f-fn) |
alpha method affected variables More... | |
int | v_alpha = vn+alpha_f*(v-vn) |
tuple | acceleration_n = (v-vn)/(gamma*dt)+acceleration_alpha_method*(gamma-1)/gamma |
p_gauss = p.transpose()*N | |
Data interpolation to the Gauss points. More... | |
penr_gauss = penr.transpose()*Nenr | |
w_gauss = w.transpose()*N | |
q_gauss = q.transpose()*N | |
qenr_gauss = qenr.transpose()*Nenr | |
tuple | accel_gauss = acceleration.transpose()*N |
grad_v = DN.transpose()*v | |
Gradients computation. More... | |
grad_w = DN.transpose()*w | |
grad_q = DN.transpose()*q | |
grad_qenr = DNenr.transpose()*qenr | |
grad_p = DN.transpose()*p | |
grad_penr = DNenr.transpose()*penr | |
div_v = div(DN,v) | |
div_v_stabilization = div(DN,v) | |
div_w = div(DN,w) | |
div_vconv = div(DN,vconv) | |
grad_sym_v_voigt = grad_sym_voigtform(DN,v) | |
grad_sym_w_voigt = grad_sym_voigtform(DN,w) | |
tuple | convective_term = (vconv_gauss.transpose()*grad_v) |
tuple | rv_galerkin = rho*w_gauss.transpose()*f_gauss - rho*w_gauss.transpose()*accel_gauss - rho*w_gauss.transpose()*convective_term.transpose() - grad_sym_w_voigt.transpose()*stress + div_w*p_gauss |
Galerkin Functional. More... | |
tuple | vel_residual = rho*f_gauss - rho*accel_gauss - rho*convective_term.transpose() - grad_p |
mas_residual = -div_v_stabilization[0,0]+volume_error_ratio | |
tuple | vel_subscale = tau1*vel_residual |
mas_subscale = tau2*mas_residual | |
tuple | rv_stab = grad_q.transpose()*vel_subscale |
tuple | rv = rv_galerkin + rv_stab |
Add the stabilization terms to the original residual terms. More... | |
dofs = sympy.zeros(nnodes*(dim+1), 1) | |
Define DOFs and test function vectors. More... | |
testfunc = sympy.zeros(nnodes*(dim+1), 1) | |
rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) | |
Compute LHS and RHS For the RHS computation one wants the residual of the previous iteration (residual based formulation). More... | |
rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) | |
lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) | |
lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) | |
vel_residual_enr = rho*f_gauss - rho*(accel_gauss + convective_term.transpose()) - grad_p - grad_penr | |
K V x = b + rhs_eV H Kee penr = rhs_ee. More... | |
vel_subscale_enr = vel_residual_enr * tau1 | |
rv_galerkin_enriched = div_w*penr_gauss | |
rv_stab_enriched = grad_qenr.transpose()*vel_subscale_enr | |
rv_enriched = rv_galerkin_enriched | |
dofs_enr = sympy.zeros(nnodes,1) | |
Add the stabilization terms to the original residual terms. More... | |
testfunc_enr = sympy.zeros(nnodes,1) | |
rhs_eV | |
K V x = b + rhs_eV H Kee penr = rhs_ee. More... | |
V | |
rhs_ee | |
H | |
Kee | |
V_out = OutputMatrix_CollectingFactors(V,"V",mode) | |
H_out = OutputMatrix_CollectingFactors(H,"H",mode) | |
Kee_out = OutputMatrix_CollectingFactors(Kee,"Kee",mode) | |
rhs_ee_out = OutputVector_CollectingFactors(rhs_ee,"rhs_ee",mode) | |
tuple | vel_residual_norm = vel_residual.norm() |
grad_v_norm = grad_v.norm() | |
float | artificial_mu = 0.5*h*art_dyn_visc_coeff*(vel_residual_norm/grad_v_norm) |
grad_v_norm_out = OutputScalar(grad_v_norm, "grad_v_norm", mode) | |
artificial_mu_out = OutputScalar(artificial_mu, "artificial_mu", mode) | |
out = open(output_filename,'w') | |
tuple generate_two_fluid_navier_stokes.accel_gauss = acceleration.transpose()*N |
generate_two_fluid_navier_stokes.acceleration_alpha_method = DefineMatrix('acceleration_alpha_method',nnodes,dim) |
tuple generate_two_fluid_navier_stokes.acceleration_n = (v-vn)/(gamma*dt)+acceleration_alpha_method*(gamma-1)/gamma |
int generate_two_fluid_navier_stokes.alpha_f = 1/(1+max_sprectral_radius) |
float generate_two_fluid_navier_stokes.alpha_m = 0.5*((3-max_sprectral_radius)/(1+max_sprectral_radius)) |
generate_two_fluid_navier_stokes.art_dyn_visc_coeff = sympy.Symbol('art_dyn_visc_coeff') |
float generate_two_fluid_navier_stokes.artificial_mu = 0.5*h*art_dyn_visc_coeff*(vel_residual_norm/grad_v_norm) |
generate_two_fluid_navier_stokes.artificial_mu_out = OutputScalar(artificial_mu, "artificial_mu", mode) |
bool generate_two_fluid_navier_stokes.ASGS_stabilization = True |
generate_two_fluid_navier_stokes.bdf0 = sympy.Symbol('bdf0') |
Backward differences coefficients.
generate_two_fluid_navier_stokes.bdf1 = sympy.Symbol('bdf1') |
generate_two_fluid_navier_stokes.bdf2 = sympy.Symbol('bdf2') |
generate_two_fluid_navier_stokes.C = DefineSymmetricMatrix('C',strain_size,strain_size) |
Constitutive matrix definition.
tuple generate_two_fluid_navier_stokes.convective_term = (vconv_gauss.transpose()*grad_v) |
string generate_two_fluid_navier_stokes.dim_to_compute = "Both" |
list generate_two_fluid_navier_stokes.dim_vector = [2] |
bool generate_two_fluid_navier_stokes.divide_by_rho = True |
generate_two_fluid_navier_stokes.DN |
generate_two_fluid_navier_stokes.DNenr = DefineMatrix('DNenr',nnodes,dim) |
bool generate_two_fluid_navier_stokes.do_simplifications = False |
Settings explanation DIMENSION TO COMPUTE: This symbolic generator is valid for both 2D and 3D cases.
Since the element has been programed with a dimension template in Kratos, it is advised to set the dim_to_compute flag as "Both". In this case the generated .cpp file will contain both 2D and 3D implementations. LINEARISATION SETTINGS: FullNR considers the convective velocity as "v-vmesh", hence v is taken into account in the derivation of the LHS and RHS. Picard (a.k.a. QuasiNR) considers the convective velocity as "a", thus it is considered as a constant in the derivation of the LHS and RHS. DIVIDE BY RHO: If set to true, divides the mass conservation equation by rho in order to have a better conditioned matrix. Otherwise the original form is kept.
Symbolic generation settings
generate_two_fluid_navier_stokes.dofs = sympy.zeros(nnodes*(dim+1), 1) |
Define DOFs and test function vectors.
generate_two_fluid_navier_stokes.dofs_enr = sympy.zeros(nnodes,1) |
Add the stabilization terms to the original residual terms.
generate_two_fluid_navier_stokes.dt = sympy.Symbol('dt', positive = True) |
Other simbols definition.
generate_two_fluid_navier_stokes.dyn_tau = sympy.Symbol('dyn_tau', positive = True) |
string generate_two_fluid_navier_stokes.err_msg = "Wrong time_integration. Given \'" + time_integration + "\'. Available options are \'bdf2\' , \'alpha_method\'and \'theta_scheme\'." |
generate_two_fluid_navier_stokes.f = DefineMatrix('f',nnodes,dim) |
Other data definitions.
int generate_two_fluid_navier_stokes.f_gauss = f.transpose()*N |
generate_two_fluid_navier_stokes.fn = DefineMatrix('fn',nnodes,dim) |
generate_two_fluid_navier_stokes.grad_p = DN.transpose()*p |
generate_two_fluid_navier_stokes.grad_penr = DNenr.transpose()*penr |
generate_two_fluid_navier_stokes.grad_q = DN.transpose()*q |
generate_two_fluid_navier_stokes.grad_qenr = DNenr.transpose()*qenr |
int generate_two_fluid_navier_stokes.grad_v = DN.transpose()*v |
Gradients computation.
generate_two_fluid_navier_stokes.grad_v_norm = grad_v.norm() |
generate_two_fluid_navier_stokes.grad_v_norm_out = OutputScalar(grad_v_norm, "grad_v_norm", mode) |
generate_two_fluid_navier_stokes.grad_w = DN.transpose()*w |
generate_two_fluid_navier_stokes.h = sympy.Symbol('h', positive = True) |
generate_two_fluid_navier_stokes.H |
generate_two_fluid_navier_stokes.H_out = OutputMatrix_CollectingFactors(H,"H",mode) |
bool generate_two_fluid_navier_stokes.impose_partion_of_unity = False |
generate_two_fluid_navier_stokes.K_darcy = sympy.Symbol('K_darcy', positive = True) |
Data interpolation to the Gauss points.
generate_two_fluid_navier_stokes.Kee |
generate_two_fluid_navier_stokes.Kee_out = OutputMatrix_CollectingFactors(Kee,"Kee",mode) |
generate_two_fluid_navier_stokes.lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications) |
generate_two_fluid_navier_stokes.lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode) |
string generate_two_fluid_navier_stokes.linearisation = "Picard" |
generate_two_fluid_navier_stokes.mas_residual = -div_v_stabilization[0,0]+volume_error_ratio |
generate_two_fluid_navier_stokes.mas_subscale = tau2*mas_residual |
generate_two_fluid_navier_stokes.max_sprectral_radius = sympy.Symbol('max_spectral_radius', positive = True) |
string generate_two_fluid_navier_stokes.mode = "c" |
generate_two_fluid_navier_stokes.mu = sympy.Symbol('mu', positive = True) |
generate_two_fluid_navier_stokes.N |
generate_two_fluid_navier_stokes.Nenr = DefineVector('Nenr',nnodes) |
int generate_two_fluid_navier_stokes.nnodes = 3 |
generate_two_fluid_navier_stokes.nu = sympy.Symbol('nu', positive = True) |
generate_two_fluid_navier_stokes.out = open(output_filename,'w') |
string generate_two_fluid_navier_stokes.output_filename = "two_fluid_navier_stokes.cpp" |
generate_two_fluid_navier_stokes.outstring = templatefile.read() |
generate_two_fluid_navier_stokes.p = DefineVector('p',nnodes) |
generate_two_fluid_navier_stokes.p_gauss = p.transpose()*N |
Data interpolation to the Gauss points.
generate_two_fluid_navier_stokes.penr = DefineVector('penr',nnodes) |
generate_two_fluid_navier_stokes.penr_gauss = penr.transpose()*Nenr |
generate_two_fluid_navier_stokes.q = DefineVector('q',nnodes) |
generate_two_fluid_navier_stokes.q_gauss = q.transpose()*N |
generate_two_fluid_navier_stokes.qenr = DefineVector('qenr' ,nnodes) |
generate_two_fluid_navier_stokes.qenr_gauss = qenr.transpose()*Nenr |
generate_two_fluid_navier_stokes.rho = sympy.Symbol('rho', positive = True) |
generate_two_fluid_navier_stokes.rhs = Compute_RHS(rv.copy(), testfunc, do_simplifications) |
Compute LHS and RHS For the RHS computation one wants the residual of the previous iteration (residual based formulation).
By this reason the stress is included as a symbolic variable, which is assumed to be passed as an argument from the previous iteration database.
generate_two_fluid_navier_stokes.rhs_ee |
generate_two_fluid_navier_stokes.rhs_ee_out = OutputVector_CollectingFactors(rhs_ee,"rhs_ee",mode) |
generate_two_fluid_navier_stokes.rhs_eV |
K V x = b + rhs_eV H Kee penr = rhs_ee.
generate_two_fluid_navier_stokes.rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) |
tuple generate_two_fluid_navier_stokes.rv = rv_galerkin + rv_stab |
Add the stabilization terms to the original residual terms.
generate_two_fluid_navier_stokes.rv_enriched = rv_galerkin_enriched |
tuple generate_two_fluid_navier_stokes.rv_galerkin = rho*w_gauss.transpose()*f_gauss - rho*w_gauss.transpose()*accel_gauss - rho*w_gauss.transpose()*convective_term.transpose() - grad_sym_w_voigt.transpose()*stress + div_w*p_gauss |
Galerkin Functional.
generate_two_fluid_navier_stokes.rv_galerkin_enriched = div_w*penr_gauss |
tuple generate_two_fluid_navier_stokes.rv_stab = grad_q.transpose()*vel_subscale |
generate_two_fluid_navier_stokes.rv_stab_enriched = grad_qenr.transpose()*vel_subscale_enr |
generate_two_fluid_navier_stokes.stab_c1 = sympy.Symbol('stab_c1', positive = True) |
generate_two_fluid_navier_stokes.stab_c2 = sympy.Symbol('stab_c2', positive = True) |
int generate_two_fluid_navier_stokes.strain_size = 3 |
generate_two_fluid_navier_stokes.stress = DefineVector('stress',strain_size) |
Stress vector definition.
float generate_two_fluid_navier_stokes.tau1 = sympy.Symbol('tau1', positive = True) |
generate_two_fluid_navier_stokes.tau2 = sympy.Symbol('tau2', positive = True) |
string generate_two_fluid_navier_stokes.template_filename = "two_fluid_navier_stokes_template.cpp" |
generate_two_fluid_navier_stokes.templatefile = open(template_filename) |
Read the template file.
generate_two_fluid_navier_stokes.testfunc = sympy.zeros(nnodes*(dim+1), 1) |
generate_two_fluid_navier_stokes.testfunc_enr = sympy.zeros(nnodes,1) |
string generate_two_fluid_navier_stokes.time_integration = "bdf2" |
generate_two_fluid_navier_stokes.v = DefineMatrix('v',nnodes,dim) |
Unknown fields definition.
generate_two_fluid_navier_stokes.V |
int generate_two_fluid_navier_stokes.v_gauss = v.transpose()*N |
generate_two_fluid_navier_stokes.V_out = OutputMatrix_CollectingFactors(V,"V",mode) |
generate_two_fluid_navier_stokes.vconv = DefineMatrix('vconv',nnodes,dim) |
Convective velocity definition.
generate_two_fluid_navier_stokes.vconv_gauss = vconv.transpose()*N |
generate_two_fluid_navier_stokes.vconv_gauss_norm = 0.0 |
Compute the stabilization parameters.
tuple generate_two_fluid_navier_stokes.vel_residual = rho*f_gauss - rho*accel_gauss - rho*convective_term.transpose() - grad_p |
generate_two_fluid_navier_stokes.vel_residual_enr = rho*f_gauss - rho*(accel_gauss + convective_term.transpose()) - grad_p - grad_penr |
K V x = b + rhs_eV H Kee penr = rhs_ee.
tuple generate_two_fluid_navier_stokes.vel_residual_norm = vel_residual.norm() |
tuple generate_two_fluid_navier_stokes.vel_subscale = tau1*vel_residual |
generate_two_fluid_navier_stokes.vel_subscale_enr = vel_residual_enr * tau1 |
generate_two_fluid_navier_stokes.vmesh = DefineMatrix('vmesh',nnodes,dim) |
generate_two_fluid_navier_stokes.vmeshn = DefineMatrix('vmeshn',nnodes,dim) |
generate_two_fluid_navier_stokes.vn = DefineMatrix('vn',nnodes,dim) |
generate_two_fluid_navier_stokes.vnn = DefineMatrix('vnn',nnodes,dim) |
generate_two_fluid_navier_stokes.volume_error_ratio = sympy.Symbol('volume_error_ratio') |
generate_two_fluid_navier_stokes.w = DefineMatrix('w',nnodes,dim) |
Test functions definition.
generate_two_fluid_navier_stokes.w_gauss = w.transpose()*N |