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 | Variables
generate_convection_diffusion_explicit_element Namespace Reference

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')
 

Function Documentation

◆ DefineShapeFunctionsMatrix()

def generate_convection_diffusion_explicit_element.DefineShapeFunctionsMatrix (   dim,
  n_nodes,
  n_gauss 
)

Variable Documentation

◆ alpha

generate_convection_diffusion_explicit_element.alpha = Symbol('alpha',positive= True)

◆ delta_time

generate_convection_diffusion_explicit_element.delta_time = Symbol('delta_time',positive= True)

◆ dim_to_compute

string generate_convection_diffusion_explicit_element.dim_to_compute = "Both"

◆ dim_vector

list generate_convection_diffusion_explicit_element.dim_vector = [2]

◆ div_v

generate_convection_diffusion_explicit_element.div_v = ones(1,1)*sum([DN[i]*v[i] for i in range (0,len(DN))])

◆ div_w

generate_convection_diffusion_explicit_element.div_w = ones(1,1)*sum([DN[i]*w[i] for i in range (0,len(DN))])

◆ DN

generate_convection_diffusion_explicit_element.DN = DefineMatrix('DN', nnodes, dim)

◆ do_simplifications

bool generate_convection_diffusion_explicit_element.do_simplifications = False

◆ dofs

generate_convection_diffusion_explicit_element.dofs = Matrix( zeros(nnodes*(1), 1) )

◆ dynamic_subscales

bool generate_convection_diffusion_explicit_element.dynamic_subscales = False

◆ err_msg

string generate_convection_diffusion_explicit_element.err_msg = "Wrong template_filename provided. Must be (template --> output):\n"

◆ explicit_step_coefficient

generate_convection_diffusion_explicit_element.explicit_step_coefficient = Symbol('explicit_step_coefficient')

◆ f

generate_convection_diffusion_explicit_element.f = DefineVector('f',nnodes)

◆ f_gauss

generate_convection_diffusion_explicit_element.f_gauss = f.transpose()*N

Estimate variables on gauss point ##########.

◆ grad_f

generate_convection_diffusion_explicit_element.grad_f = DfjDxi(DN,f)

◆ grad_phi

generate_convection_diffusion_explicit_element.grad_phi = DfjDxi(DN,phi)

◆ grad_q

generate_convection_diffusion_explicit_element.grad_q = DfjDxi(DN,q)

◆ grad_w

generate_convection_diffusion_explicit_element.grad_w = DfjDxi(DN,w)

◆ lhs_OSS_convective_1

generate_convection_diffusion_explicit_element.lhs_OSS_convective_1 = q_gauss * (v_gauss.transpose() * grad_phi)

◆ lhs_OSS_convective_2

generate_convection_diffusion_explicit_element.lhs_OSS_convective_2 = q_gauss * phi_gauss * div_v

◆ lhs_OSS_diffusion

generate_convection_diffusion_explicit_element.lhs_OSS_diffusion = alpha * grad_phi.transpose() * grad_q

◆ lhs_OSS_forcing

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.

◆ lhs_OSS_mass

generate_convection_diffusion_explicit_element.lhs_OSS_mass = q_gauss.transpose() * (N.transpose() * (phi-phi_old)*explicit_step_coefficient)

◆ lhs_OSS_mass_subscale

generate_convection_diffusion_explicit_element.lhs_OSS_mass_subscale = - q_gauss.transpose() * (phi_subscale_gauss[i_gauss]/delta_time)

◆ mat_N

def generate_convection_diffusion_explicit_element.mat_N = DefineShapeFunctionsMatrix(dim, nnodes, ngauss)

◆ mode

string generate_convection_diffusion_explicit_element.mode = "c"

◆ N

generate_convection_diffusion_explicit_element.N = DefineVector('N', nnodes)

◆ ngauss

int generate_convection_diffusion_explicit_element.ngauss = 3

◆ nnodes

int generate_convection_diffusion_explicit_element.nnodes = 3

◆ OSS_stabilization

bool generate_convection_diffusion_explicit_element.OSS_stabilization = True

◆ out

generate_convection_diffusion_explicit_element.out = open(output_filename,'w')

◆ output_filename

string generate_convection_diffusion_explicit_element.output_filename = "d_convection_diffusion_explicit.cpp"

◆ outstring

generate_convection_diffusion_explicit_element.outstring = templatefile.read()

◆ phi

generate_convection_diffusion_explicit_element.phi = DefineVector('phi',nnodes)

◆ phi_acceleration_old

generate_convection_diffusion_explicit_element.phi_acceleration_old = DefineVector('phi_acceleration_old',nnodes)

◆ phi_acceleration_old_gauss

generate_convection_diffusion_explicit_element.phi_acceleration_old_gauss = phi_acceleration_old.transpose()*N

◆ phi_gauss

generate_convection_diffusion_explicit_element.phi_gauss = phi.transpose()*N

◆ phi_old

generate_convection_diffusion_explicit_element.phi_old = DefineVector('phi_old',nnodes)

◆ phi_old_gauss

generate_convection_diffusion_explicit_element.phi_old_gauss = phi_old.transpose()*N

◆ phi_subscale_gauss

generate_convection_diffusion_explicit_element.phi_subscale_gauss = DefineVector('phi_subscale_gauss',ngauss)

◆ prj

generate_convection_diffusion_explicit_element.prj = DefineVector('prj',nnodes)

◆ prj_gauss

generate_convection_diffusion_explicit_element.prj_gauss = prj.transpose()*N

◆ q

generate_convection_diffusion_explicit_element.q = DefineVector('q',nnodes)

◆ q_gauss

generate_convection_diffusion_explicit_element.q_gauss = q.transpose()*N

◆ res

generate_convection_diffusion_explicit_element.res = rhs_galerkin + rhs_stabilization

◆ res_OSS

generate_convection_diffusion_explicit_element.res_OSS = lhs_OSS_forcing + lhs_OSS_mass + lhs_OSS_diffusion + lhs_OSS_convective_1 + lhs_OSS_convective_2

◆ res_OSS_tot

generate_convection_diffusion_explicit_element.res_OSS_tot = Matrix(zeros(1,1))

◆ res_tot

generate_convection_diffusion_explicit_element.res_tot = Matrix(zeros(1,1))

◆ rhs

generate_convection_diffusion_explicit_element.rhs = Compute_RHS(res_tot.copy(), testfunc, do_simplifications)

◆ rhs_convective_1

generate_convection_diffusion_explicit_element.rhs_convective_1 = - q_gauss * (v_gauss.transpose() * grad_phi)

◆ rhs_convective_2

generate_convection_diffusion_explicit_element.rhs_convective_2 = - q_gauss * phi_gauss * div_v

◆ rhs_diffusion

generate_convection_diffusion_explicit_element.rhs_diffusion = - alpha * grad_phi.transpose() * grad_q

◆ rhs_forcing

generate_convection_diffusion_explicit_element.rhs_forcing = q_gauss.transpose() * f_gauss

Estimate residuals on gauss point ##########.

Galerkin functional terms #####

◆ rhs_galerkin

generate_convection_diffusion_explicit_element.rhs_galerkin = rhs_forcing + rhs_diffusion + rhs_convective_1 + rhs_convective_2

◆ rhs_out

generate_convection_diffusion_explicit_element.rhs_out = OutputVector_CollectingFactors(rhs, "rhs", mode)

◆ rhs_stab_1

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

◆ rhs_stab_1_convection_1

generate_convection_diffusion_explicit_element.rhs_stab_1_convection_1 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * (v_gauss.transpose() * grad_phi)

◆ rhs_stab_1_convection_2

generate_convection_diffusion_explicit_element.rhs_stab_1_convection_2 = - tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_gauss * div_v

◆ rhs_stab_1_dynamic

generate_convection_diffusion_explicit_element.rhs_stab_1_dynamic = tau[i_gauss] * (v_gauss.transpose() * grad_q) * phi_subscale_gauss[i_gauss]/delta_time

◆ rhs_stab_1_forcing

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.

◆ rhs_stab_1_mass

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

◆ rhs_stab_1_oss

generate_convection_diffusion_explicit_element.rhs_stab_1_oss = tau[i_gauss] * (v_gauss.transpose() * grad_q) * prj_gauss

◆ rhs_stab_2

◆ rhs_stab_2_convection_1

generate_convection_diffusion_explicit_element.rhs_stab_2_convection_1 = tau[i_gauss] * q_gauss * (v_gauss.transpose() * grad_phi)

◆ rhs_stab_2_convection_2

generate_convection_diffusion_explicit_element.rhs_stab_2_convection_2 = tau[i_gauss] * q_gauss * phi_gauss * div_v

◆ rhs_stab_2_diffusion

generate_convection_diffusion_explicit_element.rhs_stab_2_diffusion = tau[i_gauss] * alpha * grad_phi.transpose() * grad_q

◆ rhs_stab_2_forcing

generate_convection_diffusion_explicit_element.rhs_stab_2_forcing = - tau[i_gauss] * q_gauss.transpose() * f_gauss

◆ rhs_stab_2_mass

generate_convection_diffusion_explicit_element.rhs_stab_2_mass = tau[i_gauss] * q_gauss.transpose() * N.transpose() * (phi-phi_old)*explicit_step_coefficient

◆ rhs_stab_2_mass_subgrid_old

generate_convection_diffusion_explicit_element.rhs_stab_2_mass_subgrid_old = q_gauss.transpose() * phi_subscale_gauss[i_gauss] / delta_time

◆ rhs_stab_2_oss

generate_convection_diffusion_explicit_element.rhs_stab_2_oss = - tau[i_gauss] * q_gauss.transpose() * prj_gauss

◆ rhs_stab_2_subgrid_old

generate_convection_diffusion_explicit_element.rhs_stab_2_subgrid_old = - tau[i_gauss] * q_gauss.transpose() * phi_subscale_gauss[i_gauss]

◆ rhs_stabilization

generate_convection_diffusion_explicit_element.rhs_stabilization = rhs_stab_1

◆ stabilization

bool generate_convection_diffusion_explicit_element.stabilization = True

◆ substituted_value

string generate_convection_diffusion_explicit_element.substituted_value = 'DN_DX_' + str(i_node) + '_' + str(j_dim)

◆ tau

generate_convection_diffusion_explicit_element.tau = DefineVector('tau',ngauss)

◆ template_filename

string generate_convection_diffusion_explicit_element.template_filename = "d_convection_diffusion_explicit_cpp_template.cpp"

◆ templatefile

generate_convection_diffusion_explicit_element.templatefile = open(template_filename)

◆ testfunc

generate_convection_diffusion_explicit_element.testfunc = Matrix( zeros(nnodes*(1), 1) )

◆ to_substitute

string generate_convection_diffusion_explicit_element.to_substitute = 'DN(' + str(i_node) + ',' + str(j_dim) + ')'

◆ v

generate_convection_diffusion_explicit_element.v = DefineMatrix('v',nnodes,dim)

◆ v_gauss

generate_convection_diffusion_explicit_element.v_gauss = v.transpose()*N

◆ w

generate_convection_diffusion_explicit_element.w = DefineMatrix('w',nnodes,dim)

◆ w_gauss

generate_convection_diffusion_explicit_element.w_gauss = w.transpose()*N