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 | |
string | mode = "c" |
Symbolic generation settings. More... | |
bool | divide_by_rho = True |
bool | ASGS_stabilization = True |
bool | add_incompressibility_error = False |
bool | do_simplifications = False |
string | output_filename = "axisymmetric_navier_stokes.cpp" |
string | template_filename = "axisymmetric_navier_stokes_cpp_template.cpp" |
string | info_msg = f"\n" |
list | dim_vector = [2, 2] |
list | n_nodes_vector = [3, 4] |
templatefile = open(template_filename) | |
Initialize the outstring to be filled with the template .cpp file. More... | |
outstring = templatefile.read() | |
Replace the computed RHS and LHS in the template outstring. More... | |
bool | impose_partion_of_unity = False |
Define shape functions, shape function gradients and integration weight. More... | |
gauss_weight = sympy.Symbol('w_gauss', positive = True) | |
N | |
DN | |
v = DefineMatrix('v',n_nodes,dim) | |
Unknown fields definition. More... | |
v_n = DefineMatrix('v_n',n_nodes,dim) | |
v_nn = DefineMatrix('v_nn',n_nodes,dim) | |
p = DefineVector('p',n_nodes) | |
mu = sympy.Symbol('mu', positive = True) | |
Fluid properties. More... | |
rho = sympy.Symbol('rho', positive = True) | |
w = DefineMatrix('w',n_nodes,dim) | |
Test functions definition. More... | |
q = DefineVector('q',n_nodes) | |
f = DefineMatrix('f',n_nodes,dim) | |
Other data definitions. More... | |
y = sympy.Symbol('y', positive = True) | |
Other simbols definition. More... | |
h = sympy.Symbol('h', positive = True) | |
dt = sympy.Symbol('dt', 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) | |
bdf0 = sympy.Symbol('bdf0') | |
Backward differences coefficients. More... | |
bdf1 = sympy.Symbol('bdf1') | |
bdf2 = sympy.Symbol('bdf2') | |
f_gauss = f.transpose()*N | |
Data interpolation to the Gauss points. More... | |
v_gauss = v.transpose()*N | |
p_gauss = p.transpose()*N | |
w_gauss = w.transpose()*N | |
q_gauss = q.transpose()*N | |
v_conv = DefineMatrix('v_conv', n_nodes, dim) | |
Convective velocity definition. More... | |
v_conv_gauss = v_conv.transpose()*N | |
float | stab_norm_a = 0.0 |
Compute the stabilization parameters. More... | |
float | tau1 = 1.0/((rho*dyn_tau)/dt + (stab_c2*rho*stab_norm_a)/h + (stab_c1*mu)/(h*h)) |
tau2 = mu + (stab_c2*rho*stab_norm_a*h)/stab_c1 | |
tuple | accel_gauss = (bdf0*v + bdf1*v_n + bdf2*v_nn).transpose()*N |
Compute the rest of magnitudes at the Gauss points. More... | |
grad_w = DfjDxi(DN,w) | |
Gradients computation (fluid dynamics gradient) More... | |
grad_q = DfjDxi(DN,q) | |
grad_p = DfjDxi(DN,p) | |
grad_v = DfjDxi(DN,v) | |
grad_v_conv = DfjDxi(DN,v_conv) | |
tuple | galerkin_functional = rho*w_gauss[0]*f_gauss[0] - rho*w_gauss[0]*accel_gauss[0] - rho*w_gauss[0]*v_conv_gauss[1]*grad_v[1,0] - rho*w_gauss[0]*v_conv_gauss[0]*grad_v[0,0] + grad_w[0,0]*p_gauss[0] - mu*grad_w[1,0]*grad_v[1,0] - mu*grad_w[0,0]*grad_v[0,0] |
Compute galerkin functional Navier-Stokes functional. More... | |
tuple | vel_residual_x = rho*f_gauss[0] - rho*accel_gauss[0] - rho*v_conv_gauss[1]*grad_v[1,0] - rho*v_conv_gauss[0]*grad_v[0,0] - grad_p[0] + (mu/y)*grad_v[1,0] |
Stabilization functional terms Momentum conservation residual Note that the second order viscous stress terms are dropped since linear elements are used. More... | |
tuple | vel_residual_y = rho*f_gauss[1] - rho*accel_gauss[1] - rho*v_conv_gauss[1]*grad_v[1,1] - rho*v_conv_gauss[0]*grad_v[0,1] - grad_p[1] - mu*v_gauss[1]/y**2 + (mu/y)*grad_v[1,1] |
mas_residual = - v_gauss[1]/y - grad_v[1,1] - grad_v[0,0] | |
float | vel_subscale_x = tau1*vel_residual_x |
float | vel_subscale_y = tau1*vel_residual_y |
pres_subscale = tau2*mas_residual | |
float | stabilization_functional = - q_gauss[0]*vel_subscale_y/y + grad_q[1]*vel_subscale_y + grad_q[0]*vel_subscale_x |
tuple | functional = galerkin_functional |
Add the stabilization terms to the original residual terms. More... | |
dofs = sympy.zeros(n_nodes*(dim+1), 1) | |
Define DOFs and test function vectors. More... | |
test_func = sympy.zeros(n_nodes*(dim+1), 1) | |
aux_functional = sympy.Matrix([[functional]]) | |
Compute LHS and RHS. More... | |
rhs = Compute_RHS(aux_functional.copy(), test_func, do_simplifications) | |
rhs_out = OutputVector_CollectingFactors(gauss_weight * rhs, "rRHS", mode, assignment_op='+=') | |
lhs = Compute_LHS(rhs, test_func, dofs, do_simplifications) | |
lhs_out = OutputMatrix_CollectingFactors(gauss_weight * lhs, "rLHS", mode, assignment_op='+=') | |
out = open(output_filename,'w') | |
Write the modified template. More... | |
tuple generate_axisymmetric_navier_stokes_element.accel_gauss = (bdf0*v + bdf1*v_n + bdf2*v_nn).transpose()*N |
Compute the rest of magnitudes at the Gauss points.
bool generate_axisymmetric_navier_stokes_element.add_incompressibility_error = False |
bool generate_axisymmetric_navier_stokes_element.ASGS_stabilization = True |
generate_axisymmetric_navier_stokes_element.aux_functional = sympy.Matrix([[functional]]) |
Compute LHS and RHS.
generate_axisymmetric_navier_stokes_element.bdf0 = sympy.Symbol('bdf0') |
Backward differences coefficients.
generate_axisymmetric_navier_stokes_element.bdf1 = sympy.Symbol('bdf1') |
generate_axisymmetric_navier_stokes_element.bdf2 = sympy.Symbol('bdf2') |
list generate_axisymmetric_navier_stokes_element.dim_vector = [2, 2] |
bool generate_axisymmetric_navier_stokes_element.divide_by_rho = True |
generate_axisymmetric_navier_stokes_element.DN |
bool generate_axisymmetric_navier_stokes_element.do_simplifications = False |
generate_axisymmetric_navier_stokes_element.dofs = sympy.zeros(n_nodes*(dim+1), 1) |
Define DOFs and test function vectors.
generate_axisymmetric_navier_stokes_element.dt = sympy.Symbol('dt', positive = True) |
generate_axisymmetric_navier_stokes_element.dyn_tau = sympy.Symbol('dyn_tau', positive = True) |
generate_axisymmetric_navier_stokes_element.f = DefineMatrix('f',n_nodes,dim) |
Other data definitions.
generate_axisymmetric_navier_stokes_element.f_gauss = f.transpose()*N |
Data interpolation to the Gauss points.
tuple generate_axisymmetric_navier_stokes_element.functional = galerkin_functional |
Add the stabilization terms to the original residual terms.
tuple generate_axisymmetric_navier_stokes_element.galerkin_functional = rho*w_gauss[0]*f_gauss[0] - rho*w_gauss[0]*accel_gauss[0] - rho*w_gauss[0]*v_conv_gauss[1]*grad_v[1,0] - rho*w_gauss[0]*v_conv_gauss[0]*grad_v[0,0] + grad_w[0,0]*p_gauss[0] - mu*grad_w[1,0]*grad_v[1,0] - mu*grad_w[0,0]*grad_v[0,0] |
Compute galerkin functional Navier-Stokes functional.
generate_axisymmetric_navier_stokes_element.gauss_weight = sympy.Symbol('w_gauss', positive = True) |
Gradients computation (fluid dynamics gradient)
generate_axisymmetric_navier_stokes_element.h = sympy.Symbol('h', positive = True) |
bool generate_axisymmetric_navier_stokes_element.impose_partion_of_unity = False |
Define shape functions, shape function gradients and integration weight.
string generate_axisymmetric_navier_stokes_element.info_msg = f"\n" |
generate_axisymmetric_navier_stokes_element.lhs = Compute_LHS(rhs, test_func, dofs, do_simplifications) |
generate_axisymmetric_navier_stokes_element.lhs_out = OutputMatrix_CollectingFactors(gauss_weight * lhs, "rLHS", mode, assignment_op='+=') |
generate_axisymmetric_navier_stokes_element.mas_residual = - v_gauss[1]/y - grad_v[1,1] - grad_v[0,0] |
string generate_axisymmetric_navier_stokes_element.mode = "c" |
Symbolic generation settings.
generate_axisymmetric_navier_stokes_element.mu = sympy.Symbol('mu', positive = True) |
Fluid properties.
generate_axisymmetric_navier_stokes_element.N |
list generate_axisymmetric_navier_stokes_element.n_nodes_vector = [3, 4] |
generate_axisymmetric_navier_stokes_element.out = open(output_filename,'w') |
Write the modified template.
string generate_axisymmetric_navier_stokes_element.output_filename = "axisymmetric_navier_stokes.cpp" |
generate_axisymmetric_navier_stokes_element.outstring = templatefile.read() |
Replace the computed RHS and LHS in the template outstring.
generate_axisymmetric_navier_stokes_element.p = DefineVector('p',n_nodes) |
generate_axisymmetric_navier_stokes_element.p_gauss = p.transpose()*N |
generate_axisymmetric_navier_stokes_element.pres_subscale = tau2*mas_residual |
generate_axisymmetric_navier_stokes_element.q = DefineVector('q',n_nodes) |
generate_axisymmetric_navier_stokes_element.q_gauss = q.transpose()*N |
generate_axisymmetric_navier_stokes_element.rho = sympy.Symbol('rho', positive = True) |
generate_axisymmetric_navier_stokes_element.rhs = Compute_RHS(aux_functional.copy(), test_func, do_simplifications) |
generate_axisymmetric_navier_stokes_element.rhs_out = OutputVector_CollectingFactors(gauss_weight * rhs, "rRHS", mode, assignment_op='+=') |
generate_axisymmetric_navier_stokes_element.stab_c1 = sympy.Symbol('stab_c1', positive = True) |
generate_axisymmetric_navier_stokes_element.stab_c2 = sympy.Symbol('stab_c2', positive = True) |
generate_axisymmetric_navier_stokes_element.stab_norm_a = 0.0 |
Compute the stabilization parameters.
float generate_axisymmetric_navier_stokes_element.stabilization_functional = - q_gauss[0]*vel_subscale_y/y + grad_q[1]*vel_subscale_y + grad_q[0]*vel_subscale_x |
float generate_axisymmetric_navier_stokes_element.tau1 = 1.0/((rho*dyn_tau)/dt + (stab_c2*rho*stab_norm_a)/h + (stab_c1*mu)/(h*h)) |
string generate_axisymmetric_navier_stokes_element.template_filename = "axisymmetric_navier_stokes_cpp_template.cpp" |
generate_axisymmetric_navier_stokes_element.templatefile = open(template_filename) |
Initialize the outstring to be filled with the template .cpp file.
generate_axisymmetric_navier_stokes_element.test_func = sympy.zeros(n_nodes*(dim+1), 1) |
generate_axisymmetric_navier_stokes_element.v = DefineMatrix('v',n_nodes,dim) |
Unknown fields definition.
generate_axisymmetric_navier_stokes_element.v_conv = DefineMatrix('v_conv', n_nodes, dim) |
Convective velocity definition.
generate_axisymmetric_navier_stokes_element.v_conv_gauss = v_conv.transpose()*N |
generate_axisymmetric_navier_stokes_element.v_gauss = v.transpose()*N |
generate_axisymmetric_navier_stokes_element.v_n = DefineMatrix('v_n',n_nodes,dim) |
generate_axisymmetric_navier_stokes_element.v_nn = DefineMatrix('v_nn',n_nodes,dim) |
tuple generate_axisymmetric_navier_stokes_element.vel_residual_x = rho*f_gauss[0] - rho*accel_gauss[0] - rho*v_conv_gauss[1]*grad_v[1,0] - rho*v_conv_gauss[0]*grad_v[0,0] - grad_p[0] + (mu/y)*grad_v[1,0] |
Stabilization functional terms Momentum conservation residual Note that the second order viscous stress terms are dropped since linear elements are used.
tuple generate_axisymmetric_navier_stokes_element.vel_residual_y = rho*f_gauss[1] - rho*accel_gauss[1] - rho*v_conv_gauss[1]*grad_v[1,1] - rho*v_conv_gauss[0]*grad_v[0,1] - grad_p[1] - mu*v_gauss[1]/y**2 + (mu/y)*grad_v[1,1] |
float generate_axisymmetric_navier_stokes_element.vel_subscale_x = tau1*vel_residual_x |
float generate_axisymmetric_navier_stokes_element.vel_subscale_y = tau1*vel_residual_y |
generate_axisymmetric_navier_stokes_element.w = DefineMatrix('w',n_nodes,dim) |
Test functions definition.
generate_axisymmetric_navier_stokes_element.w_gauss = w.transpose()*N |
generate_axisymmetric_navier_stokes_element.y = sympy.Symbol('y', positive = True) |
Other simbols definition.