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.
|
Functions | |
def | DefineShapeFunctionsMatrix (dim, n_nodes, n_gauss) |
Variables | |
bool | do_simplifications = False |
string | dim_to_compute = "Both" |
bool | stabilization = True |
bool | OSS_stabilization = True |
bool | dynamic_subscales = False |
string | mode = "c" |
list | dim_vector = [2] |
string | template_filename = "d_convection_diffusion_explicit_cpp_template.cpp" |
templatefile = open(template_filename) | |
outstring = templatefile.read() | |
string | output_filename = "d_convection_diffusion_explicit.cpp" |
string | err_msg = "Wrong template_filename provided. Must be (template --> output):\n" |
int | nnodes = 3 |
int | ngauss = 3 |
DN = DefineMatrix('DN', nnodes, dim) | |
def | mat_N = DefineShapeFunctionsMatrix(dim, nnodes, ngauss) |
phi = DefineVector('phi',nnodes) | |
phi_old = DefineVector('phi_old',nnodes) | |
phi_subscale_gauss = DefineVector('phi_subscale_gauss',ngauss) | |
phi_acceleration_old = DefineVector('phi_acceleration_old',nnodes) | |
w = DefineMatrix('w',nnodes,dim) | |
q = DefineVector('q',nnodes) | |
f = DefineVector('f',nnodes) | |
alpha = Symbol('alpha',positive= True) | |
v = DefineMatrix('v',nnodes,dim) | |
tau = DefineVector('tau',ngauss) | |
delta_time = Symbol('delta_time',positive= True) | |
explicit_step_coefficient = Symbol('explicit_step_coefficient') | |
prj = DefineVector('prj',nnodes) | |
res_tot = Matrix(zeros(1,1)) | |
res_OSS_tot = Matrix(zeros(1,1)) | |
N = DefineVector('N', nnodes) | |
f_gauss = f.transpose()*N | |
Estimate variables on gauss point ##########. More... | |
w_gauss = w.transpose()*N | |
q_gauss = q.transpose()*N | |
v_gauss = v.transpose()*N | |
phi_gauss = phi.transpose()*N | |
phi_old_gauss = phi_old.transpose()*N | |
phi_acceleration_old_gauss = phi_acceleration_old.transpose()*N | |
prj_gauss = prj.transpose()*N | |
grad_w = DfjDxi(DN,w) | |
grad_q = DfjDxi(DN,q) | |
grad_phi = DfjDxi(DN,phi) | |
grad_f = DfjDxi(DN,f) | |
div_w = ones(1,1)*sum([DN[i]*w[i] for i in range (0,len(DN))]) | |
div_v = ones(1,1)*sum([DN[i]*v[i] for i in range (0,len(DN))]) | |
rhs_forcing = q_gauss.transpose() * f_gauss | |
Estimate residuals on gauss point ##########. More... | |
rhs_diffusion = - alpha * grad_phi.transpose() * grad_q | |
rhs_convective_1 = - q_gauss * (v_gauss.transpose() * grad_phi) | |
rhs_convective_2 = - q_gauss * phi_gauss * div_v | |
rhs_galerkin = rhs_forcing + rhs_diffusion + rhs_convective_1 + rhs_convective_2 | |
rhs_stab_1_forcing = tau[i_gauss] * (v_gauss.transpose() * grad_q) * f_gauss | |
Stabilization ASGS/OSS functional terms ##### ASGS/OSS Convective term. More... | |
rhs_stab_1_mass = - tau[i_gauss] * (grad_q.transpose() * v_gauss) * N.transpose() * (phi-phi_old)*explicit_step_coefficient | |
rhs_stab_1_convection_1 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * (v_gauss.transpose() * grad_phi) | |
rhs_stab_1_convection_2 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_gauss * div_v | |
rhs_stab_1 = rhs_stab_1_forcing + rhs_stab_1_convection_1 + rhs_stab_1_convection_2 + rhs_stab_1_mass | |
rhs_stab_1_oss = tau[i_gauss] * (v_gauss.transpose() * grad_q) * prj_gauss | |
rhs_stab_1_dynamic = tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_subscale_gauss[i_gauss]/delta_time | |
rhs_stab_2_forcing = - tau[i_gauss] * q_gauss.transpose() * f_gauss | |
rhs_stab_2_mass = tau[i_gauss] * q_gauss.transpose() * N.transpose() * (phi-phi_old)*explicit_step_coefficient | |
rhs_stab_2_convection_1 = tau[i_gauss] * q_gauss * (v_gauss.transpose() * grad_phi) | |
rhs_stab_2_convection_2 = tau[i_gauss] * q_gauss * phi_gauss * div_v | |
rhs_stab_2_diffusion = tau[i_gauss] * alpha * grad_phi.transpose() * grad_q | |
rhs_stab_2_subgrid_old = - tau[i_gauss] * q_gauss.transpose() * phi_subscale_gauss[i_gauss] | |
rhs_stab_2_mass_subgrid_old = q_gauss.transpose() * phi_subscale_gauss[i_gauss] / delta_time | |
rhs_stab_2 = rhs_stab_2_forcing + rhs_stab_2_mass + rhs_stab_2_convection_1 + rhs_stab_2_convection_2 + rhs_stab_2_diffusion + rhs_stab_2_subgrid_old + rhs_stab_2_mass_subgrid_old | |
rhs_stab_2_oss = - tau[i_gauss] * q_gauss.transpose() * prj_gauss | |
rhs_stabilization = rhs_stab_1 | |
lhs_OSS_forcing = - q_gauss.transpose() * f_gauss | |
OSS step ##### with lhs we refer to the fact we take the strong equation on the left side. More... | |
lhs_OSS_mass = q_gauss.transpose() * (N.transpose() * (phi-phi_old)*explicit_step_coefficient) | |
lhs_OSS_mass_subscale = - q_gauss.transpose() * (phi_subscale_gauss[i_gauss]/delta_time) | |
lhs_OSS_diffusion = alpha * grad_phi.transpose() * grad_q | |
lhs_OSS_convective_1 = q_gauss * (v_gauss.transpose() * grad_phi) | |
lhs_OSS_convective_2 = q_gauss * phi_gauss * div_v | |
res_OSS = lhs_OSS_forcing + lhs_OSS_mass + lhs_OSS_diffusion + lhs_OSS_convective_1 + lhs_OSS_convective_2 | |
res = rhs_galerkin + rhs_stabilization | |
dofs = Matrix( zeros(nnodes*(1), 1) ) | |
testfunc = Matrix( zeros(nnodes*(1), 1) ) | |
rhs = Compute_RHS(res_tot.copy(), testfunc, do_simplifications) | |
rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) | |
string | to_substitute = 'DN(' + str(i_node) + ',' + str(j_dim) + ')' |
string | substituted_value = 'DN_DX_' + str(i_node) + '_' + str(j_dim) |
out = open(output_filename,'w') | |
def generate_convection_diffusion_explicit_element.DefineShapeFunctionsMatrix | ( | dim, | |
n_nodes, | |||
n_gauss | |||
) |
generate_convection_diffusion_explicit_element.alpha = Symbol('alpha',positive= True) |
generate_convection_diffusion_explicit_element.delta_time = Symbol('delta_time',positive= True) |
string generate_convection_diffusion_explicit_element.dim_to_compute = "Both" |
list generate_convection_diffusion_explicit_element.dim_vector = [2] |
generate_convection_diffusion_explicit_element.div_v = ones(1,1)*sum([DN[i]*v[i] for i in range (0,len(DN))]) |
generate_convection_diffusion_explicit_element.div_w = ones(1,1)*sum([DN[i]*w[i] for i in range (0,len(DN))]) |
generate_convection_diffusion_explicit_element.DN = DefineMatrix('DN', nnodes, dim) |
bool generate_convection_diffusion_explicit_element.do_simplifications = False |
generate_convection_diffusion_explicit_element.dofs = Matrix( zeros(nnodes*(1), 1) ) |
bool generate_convection_diffusion_explicit_element.dynamic_subscales = False |
string generate_convection_diffusion_explicit_element.err_msg = "Wrong template_filename provided. Must be (template --> output):\n" |
generate_convection_diffusion_explicit_element.explicit_step_coefficient = Symbol('explicit_step_coefficient') |
generate_convection_diffusion_explicit_element.f = DefineVector('f',nnodes) |
generate_convection_diffusion_explicit_element.f_gauss = f.transpose()*N |
Estimate variables on gauss point ##########.
generate_convection_diffusion_explicit_element.lhs_OSS_convective_1 = q_gauss * (v_gauss.transpose() * grad_phi) |
generate_convection_diffusion_explicit_element.lhs_OSS_diffusion = alpha * grad_phi.transpose() * grad_q |
generate_convection_diffusion_explicit_element.lhs_OSS_forcing = - q_gauss.transpose() * f_gauss |
OSS step ##### with lhs we refer to the fact we take the strong equation on the left side.
generate_convection_diffusion_explicit_element.lhs_OSS_mass = q_gauss.transpose() * (N.transpose() * (phi-phi_old)*explicit_step_coefficient) |
generate_convection_diffusion_explicit_element.lhs_OSS_mass_subscale = - q_gauss.transpose() * (phi_subscale_gauss[i_gauss]/delta_time) |
def generate_convection_diffusion_explicit_element.mat_N = DefineShapeFunctionsMatrix(dim, nnodes, ngauss) |
string generate_convection_diffusion_explicit_element.mode = "c" |
generate_convection_diffusion_explicit_element.N = DefineVector('N', nnodes) |
int generate_convection_diffusion_explicit_element.ngauss = 3 |
int generate_convection_diffusion_explicit_element.nnodes = 3 |
bool generate_convection_diffusion_explicit_element.OSS_stabilization = True |
generate_convection_diffusion_explicit_element.out = open(output_filename,'w') |
string generate_convection_diffusion_explicit_element.output_filename = "d_convection_diffusion_explicit.cpp" |
generate_convection_diffusion_explicit_element.outstring = templatefile.read() |
generate_convection_diffusion_explicit_element.phi = DefineVector('phi',nnodes) |
generate_convection_diffusion_explicit_element.phi_acceleration_old = DefineVector('phi_acceleration_old',nnodes) |
generate_convection_diffusion_explicit_element.phi_acceleration_old_gauss = phi_acceleration_old.transpose()*N |
generate_convection_diffusion_explicit_element.phi_gauss = phi.transpose()*N |
generate_convection_diffusion_explicit_element.phi_old = DefineVector('phi_old',nnodes) |
generate_convection_diffusion_explicit_element.phi_old_gauss = phi_old.transpose()*N |
generate_convection_diffusion_explicit_element.phi_subscale_gauss = DefineVector('phi_subscale_gauss',ngauss) |
generate_convection_diffusion_explicit_element.prj = DefineVector('prj',nnodes) |
generate_convection_diffusion_explicit_element.prj_gauss = prj.transpose()*N |
generate_convection_diffusion_explicit_element.q = DefineVector('q',nnodes) |
generate_convection_diffusion_explicit_element.q_gauss = q.transpose()*N |
generate_convection_diffusion_explicit_element.res = rhs_galerkin + rhs_stabilization |
generate_convection_diffusion_explicit_element.res_OSS = lhs_OSS_forcing + lhs_OSS_mass + lhs_OSS_diffusion + lhs_OSS_convective_1 + lhs_OSS_convective_2 |
generate_convection_diffusion_explicit_element.res_OSS_tot = Matrix(zeros(1,1)) |
generate_convection_diffusion_explicit_element.res_tot = Matrix(zeros(1,1)) |
generate_convection_diffusion_explicit_element.rhs = Compute_RHS(res_tot.copy(), testfunc, do_simplifications) |
generate_convection_diffusion_explicit_element.rhs_convective_1 = - q_gauss * (v_gauss.transpose() * grad_phi) |
generate_convection_diffusion_explicit_element.rhs_diffusion = - alpha * grad_phi.transpose() * grad_q |
generate_convection_diffusion_explicit_element.rhs_forcing = q_gauss.transpose() * f_gauss |
Estimate residuals on gauss point ##########.
Galerkin functional terms #####
generate_convection_diffusion_explicit_element.rhs_galerkin = rhs_forcing + rhs_diffusion + rhs_convective_1 + rhs_convective_2 |
generate_convection_diffusion_explicit_element.rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode) |
generate_convection_diffusion_explicit_element.rhs_stab_1 = rhs_stab_1_forcing + rhs_stab_1_convection_1 + rhs_stab_1_convection_2 + rhs_stab_1_mass |
generate_convection_diffusion_explicit_element.rhs_stab_1_convection_1 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * (v_gauss.transpose() * grad_phi) |
generate_convection_diffusion_explicit_element.rhs_stab_1_convection_2 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_gauss * div_v |
generate_convection_diffusion_explicit_element.rhs_stab_1_dynamic = tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_subscale_gauss[i_gauss]/delta_time |
generate_convection_diffusion_explicit_element.rhs_stab_1_forcing = tau[i_gauss] * (v_gauss.transpose() * grad_q) * f_gauss |
Stabilization ASGS/OSS functional terms ##### ASGS/OSS Convective term.
generate_convection_diffusion_explicit_element.rhs_stab_1_mass = - tau[i_gauss] * (grad_q.transpose() * v_gauss) * N.transpose() * (phi-phi_old)*explicit_step_coefficient |
generate_convection_diffusion_explicit_element.rhs_stab_1_oss = tau[i_gauss] * (v_gauss.transpose() * grad_q) * prj_gauss |
generate_convection_diffusion_explicit_element.rhs_stab_2 = rhs_stab_2_forcing + rhs_stab_2_mass + rhs_stab_2_convection_1 + rhs_stab_2_convection_2 + rhs_stab_2_diffusion + rhs_stab_2_subgrid_old + rhs_stab_2_mass_subgrid_old |
generate_convection_diffusion_explicit_element.rhs_stab_2_convection_1 = tau[i_gauss] * q_gauss * (v_gauss.transpose() * grad_phi) |
generate_convection_diffusion_explicit_element.rhs_stab_2_convection_2 = tau[i_gauss] * q_gauss * phi_gauss * div_v |
generate_convection_diffusion_explicit_element.rhs_stab_2_diffusion = tau[i_gauss] * alpha * grad_phi.transpose() * grad_q |
generate_convection_diffusion_explicit_element.rhs_stab_2_forcing = - tau[i_gauss] * q_gauss.transpose() * f_gauss |
generate_convection_diffusion_explicit_element.rhs_stab_2_mass = tau[i_gauss] * q_gauss.transpose() * N.transpose() * (phi-phi_old)*explicit_step_coefficient |
generate_convection_diffusion_explicit_element.rhs_stab_2_mass_subgrid_old = q_gauss.transpose() * phi_subscale_gauss[i_gauss] / delta_time |
generate_convection_diffusion_explicit_element.rhs_stab_2_oss = - tau[i_gauss] * q_gauss.transpose() * prj_gauss |
generate_convection_diffusion_explicit_element.rhs_stab_2_subgrid_old = - tau[i_gauss] * q_gauss.transpose() * phi_subscale_gauss[i_gauss] |
generate_convection_diffusion_explicit_element.rhs_stabilization = rhs_stab_1 |
bool generate_convection_diffusion_explicit_element.stabilization = True |
string generate_convection_diffusion_explicit_element.substituted_value = 'DN_DX_' + str(i_node) + '_' + str(j_dim) |
generate_convection_diffusion_explicit_element.tau = DefineVector('tau',ngauss) |
string generate_convection_diffusion_explicit_element.template_filename = "d_convection_diffusion_explicit_cpp_template.cpp" |
generate_convection_diffusion_explicit_element.templatefile = open(template_filename) |
generate_convection_diffusion_explicit_element.testfunc = Matrix( zeros(nnodes*(1), 1) ) |
string generate_convection_diffusion_explicit_element.to_substitute = 'DN(' + str(i_node) + ',' + str(j_dim) + ')' |
generate_convection_diffusion_explicit_element.v = DefineMatrix('v',nnodes,dim) |
generate_convection_diffusion_explicit_element.v_gauss = v.transpose()*N |
generate_convection_diffusion_explicit_element.w = DefineMatrix('w',nnodes,dim) |
generate_convection_diffusion_explicit_element.w_gauss = w.transpose()*N |