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
generate_axisymmetric_navier_stokes_element Namespace Reference

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...
 

Variable Documentation

◆ accel_gauss

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.

◆ add_incompressibility_error

bool generate_axisymmetric_navier_stokes_element.add_incompressibility_error = False

◆ ASGS_stabilization

bool generate_axisymmetric_navier_stokes_element.ASGS_stabilization = True

◆ aux_functional

generate_axisymmetric_navier_stokes_element.aux_functional = sympy.Matrix([[functional]])

Compute LHS and RHS.

◆ bdf0

generate_axisymmetric_navier_stokes_element.bdf0 = sympy.Symbol('bdf0')

Backward differences coefficients.

◆ bdf1

generate_axisymmetric_navier_stokes_element.bdf1 = sympy.Symbol('bdf1')

◆ bdf2

generate_axisymmetric_navier_stokes_element.bdf2 = sympy.Symbol('bdf2')

◆ dim_vector

list generate_axisymmetric_navier_stokes_element.dim_vector = [2, 2]

◆ divide_by_rho

bool generate_axisymmetric_navier_stokes_element.divide_by_rho = True

◆ DN

generate_axisymmetric_navier_stokes_element.DN

◆ do_simplifications

bool generate_axisymmetric_navier_stokes_element.do_simplifications = False

◆ dofs

generate_axisymmetric_navier_stokes_element.dofs = sympy.zeros(n_nodes*(dim+1), 1)

Define DOFs and test function vectors.

◆ dt

generate_axisymmetric_navier_stokes_element.dt = sympy.Symbol('dt', positive = True)

◆ dyn_tau

generate_axisymmetric_navier_stokes_element.dyn_tau = sympy.Symbol('dyn_tau', positive = True)

◆ f

generate_axisymmetric_navier_stokes_element.f = DefineMatrix('f',n_nodes,dim)

Other data definitions.

◆ f_gauss

generate_axisymmetric_navier_stokes_element.f_gauss = f.transpose()*N

Data interpolation to the Gauss points.

◆ functional

tuple generate_axisymmetric_navier_stokes_element.functional = galerkin_functional

Add the stabilization terms to the original residual terms.

◆ galerkin_functional

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.

◆ gauss_weight

generate_axisymmetric_navier_stokes_element.gauss_weight = sympy.Symbol('w_gauss', positive = True)

◆ grad_p

generate_axisymmetric_navier_stokes_element.grad_p = DfjDxi(DN,p)

◆ grad_q

generate_axisymmetric_navier_stokes_element.grad_q = DfjDxi(DN,q)

◆ grad_v

generate_axisymmetric_navier_stokes_element.grad_v = DfjDxi(DN,v)

◆ grad_v_conv

generate_axisymmetric_navier_stokes_element.grad_v_conv = DfjDxi(DN,v_conv)

◆ grad_w

generate_axisymmetric_navier_stokes_element.grad_w = DfjDxi(DN,w)

Gradients computation (fluid dynamics gradient)

◆ h

generate_axisymmetric_navier_stokes_element.h = sympy.Symbol('h', positive = True)

◆ impose_partion_of_unity

bool generate_axisymmetric_navier_stokes_element.impose_partion_of_unity = False

Define shape functions, shape function gradients and integration weight.

◆ info_msg

string generate_axisymmetric_navier_stokes_element.info_msg = f"\n"

◆ lhs

generate_axisymmetric_navier_stokes_element.lhs = Compute_LHS(rhs, test_func, dofs, do_simplifications)

◆ lhs_out

generate_axisymmetric_navier_stokes_element.lhs_out = OutputMatrix_CollectingFactors(gauss_weight * lhs, "rLHS", mode, assignment_op='+=')

◆ mas_residual

generate_axisymmetric_navier_stokes_element.mas_residual = - v_gauss[1]/y - grad_v[1,1] - grad_v[0,0]

◆ mode

string generate_axisymmetric_navier_stokes_element.mode = "c"

Symbolic generation settings.

◆ mu

generate_axisymmetric_navier_stokes_element.mu = sympy.Symbol('mu', positive = True)

Fluid properties.

◆ N

generate_axisymmetric_navier_stokes_element.N

◆ n_nodes_vector

list generate_axisymmetric_navier_stokes_element.n_nodes_vector = [3, 4]

◆ out

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

Write the modified template.

◆ output_filename

string generate_axisymmetric_navier_stokes_element.output_filename = "axisymmetric_navier_stokes.cpp"

◆ outstring

generate_axisymmetric_navier_stokes_element.outstring = templatefile.read()

Replace the computed RHS and LHS in the template outstring.

◆ p

generate_axisymmetric_navier_stokes_element.p = DefineVector('p',n_nodes)

◆ p_gauss

generate_axisymmetric_navier_stokes_element.p_gauss = p.transpose()*N

◆ pres_subscale

generate_axisymmetric_navier_stokes_element.pres_subscale = tau2*mas_residual

◆ q

generate_axisymmetric_navier_stokes_element.q = DefineVector('q',n_nodes)

◆ q_gauss

generate_axisymmetric_navier_stokes_element.q_gauss = q.transpose()*N

◆ rho

generate_axisymmetric_navier_stokes_element.rho = sympy.Symbol('rho', positive = True)

◆ rhs

generate_axisymmetric_navier_stokes_element.rhs = Compute_RHS(aux_functional.copy(), test_func, do_simplifications)

◆ rhs_out

generate_axisymmetric_navier_stokes_element.rhs_out = OutputVector_CollectingFactors(gauss_weight * rhs, "rRHS", mode, assignment_op='+=')

◆ stab_c1

generate_axisymmetric_navier_stokes_element.stab_c1 = sympy.Symbol('stab_c1', positive = True)

◆ stab_c2

generate_axisymmetric_navier_stokes_element.stab_c2 = sympy.Symbol('stab_c2', positive = True)

◆ stab_norm_a

generate_axisymmetric_navier_stokes_element.stab_norm_a = 0.0

Compute the stabilization parameters.

◆ stabilization_functional

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

◆ tau1

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

◆ tau2

generate_axisymmetric_navier_stokes_element.tau2 = mu + (stab_c2*rho*stab_norm_a*h)/stab_c1

◆ template_filename

string generate_axisymmetric_navier_stokes_element.template_filename = "axisymmetric_navier_stokes_cpp_template.cpp"

◆ templatefile

generate_axisymmetric_navier_stokes_element.templatefile = open(template_filename)

Initialize the outstring to be filled with the template .cpp file.

◆ test_func

generate_axisymmetric_navier_stokes_element.test_func = sympy.zeros(n_nodes*(dim+1), 1)

◆ v

generate_axisymmetric_navier_stokes_element.v = DefineMatrix('v',n_nodes,dim)

Unknown fields definition.

◆ v_conv

generate_axisymmetric_navier_stokes_element.v_conv = DefineMatrix('v_conv', n_nodes, dim)

Convective velocity definition.

◆ v_conv_gauss

generate_axisymmetric_navier_stokes_element.v_conv_gauss = v_conv.transpose()*N

◆ v_gauss

generate_axisymmetric_navier_stokes_element.v_gauss = v.transpose()*N

◆ v_n

generate_axisymmetric_navier_stokes_element.v_n = DefineMatrix('v_n',n_nodes,dim)

◆ v_nn

generate_axisymmetric_navier_stokes_element.v_nn = DefineMatrix('v_nn',n_nodes,dim)

◆ vel_residual_x

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.

◆ vel_residual_y

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]

◆ vel_subscale_x

float generate_axisymmetric_navier_stokes_element.vel_subscale_x = tau1*vel_residual_x

◆ vel_subscale_y

float generate_axisymmetric_navier_stokes_element.vel_subscale_y = tau1*vel_residual_y

◆ w

generate_axisymmetric_navier_stokes_element.w = DefineMatrix('w',n_nodes,dim)

Test functions definition.

◆ w_gauss

generate_axisymmetric_navier_stokes_element.w_gauss = w.transpose()*N

◆ y

generate_axisymmetric_navier_stokes_element.y = sympy.Symbol('y', positive = True)

Other simbols definition.