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

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 = "droplet_dynamics_element.cpp"
 
string template_filename = "droplet_dynamics_template.cpp"
 
string err_msg = "Wrong time_integration. Given \'" + time_integration + "\'. Available option is \'bdf2\'."
 
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)
 
 pn = DefineVector('pn',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)
 
 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...
 
 bdf0 = sympy.Symbol('bdf0')
 Data interpolation to the Gauss points. 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
 
 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_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[0,0]
 
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)
 
 out = open(output_filename,'w')
 

Variable Documentation

◆ accel_gauss

tuple generate_droplet_dynamics.accel_gauss = acceleration.transpose()*N

◆ acceleration

tuple generate_droplet_dynamics.acceleration = (bdf0*v +bdf1*vn + bdf2*vnn)

◆ ASGS_stabilization

bool generate_droplet_dynamics.ASGS_stabilization = True

◆ bdf0

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

Data interpolation to the Gauss points.

Backward differences coefficients

◆ bdf1

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

◆ bdf2

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

◆ C

generate_droplet_dynamics.C = DefineSymmetricMatrix('C',strain_size,strain_size)

Constitutive matrix definition.

◆ convective_term

tuple generate_droplet_dynamics.convective_term = (vconv_gauss.transpose()*grad_v)

◆ dim_to_compute

string generate_droplet_dynamics.dim_to_compute = "Both"

◆ dim_vector

list generate_droplet_dynamics.dim_vector = [2]

◆ div_v

generate_droplet_dynamics.div_v = div(DN,v)

◆ div_vconv

generate_droplet_dynamics.div_vconv = div(DN,vconv)

◆ div_w

generate_droplet_dynamics.div_w = div(DN,w)

◆ divide_by_rho

bool generate_droplet_dynamics.divide_by_rho = True

◆ DN

generate_droplet_dynamics.DN

◆ DNenr

generate_droplet_dynamics.DNenr = DefineMatrix('DNenr',nnodes,dim)

◆ do_simplifications

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

◆ dofs

generate_droplet_dynamics.dofs = sympy.zeros(nnodes*(dim+1), 1)

Define DOFs and test function vectors.

◆ dofs_enr

generate_droplet_dynamics.dofs_enr = sympy.zeros(nnodes,1)

Add the stabilization terms to the original residual terms.

◆ dt

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

Other simbols definition.

◆ dyn_tau

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

◆ err_msg

string generate_droplet_dynamics.err_msg = "Wrong time_integration. Given \'" + time_integration + "\'. Available option is \'bdf2\'."

◆ f

generate_droplet_dynamics.f = DefineMatrix('f',nnodes,dim)

Other data definitions.

◆ f_gauss

generate_droplet_dynamics.f_gauss = f.transpose()*N

◆ fn

generate_droplet_dynamics.fn = DefineMatrix('fn',nnodes,dim)

◆ grad_p

generate_droplet_dynamics.grad_p = DN.transpose()*p

◆ grad_penr

generate_droplet_dynamics.grad_penr = DNenr.transpose()*penr

◆ grad_q

generate_droplet_dynamics.grad_q = DN.transpose()*q

◆ grad_qenr

generate_droplet_dynamics.grad_qenr = DNenr.transpose()*qenr

◆ grad_sym_v_voigt

generate_droplet_dynamics.grad_sym_v_voigt = grad_sym_voigtform(DN,v)

◆ grad_sym_w_voigt

generate_droplet_dynamics.grad_sym_w_voigt = grad_sym_voigtform(DN,w)

◆ grad_v

generate_droplet_dynamics.grad_v = DN.transpose()*v

Gradients computation.

◆ grad_w

generate_droplet_dynamics.grad_w = DN.transpose()*w

◆ h

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

◆ H

generate_droplet_dynamics.H

◆ H_out

generate_droplet_dynamics.H_out = OutputMatrix_CollectingFactors(H,"H",mode)

◆ impose_partion_of_unity

bool generate_droplet_dynamics.impose_partion_of_unity = False

◆ Kee

generate_droplet_dynamics.Kee

◆ Kee_out

generate_droplet_dynamics.Kee_out = OutputMatrix_CollectingFactors(Kee,"Kee",mode)

◆ lhs

generate_droplet_dynamics.lhs = Compute_LHS(rhs, testfunc, dofs, do_simplifications)

◆ lhs_out

generate_droplet_dynamics.lhs_out = OutputMatrix_CollectingFactors(lhs, "lhs", mode)

◆ linearisation

string generate_droplet_dynamics.linearisation = "Picard"

◆ mas_residual

generate_droplet_dynamics.mas_residual = -div_v[0,0]

◆ mas_subscale

generate_droplet_dynamics.mas_subscale = tau2*mas_residual

◆ mode

string generate_droplet_dynamics.mode = "c"

◆ mu

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

◆ N

generate_droplet_dynamics.N

◆ Nenr

generate_droplet_dynamics.Nenr = DefineVector('Nenr',nnodes)

◆ nnodes

int generate_droplet_dynamics.nnodes = 3

◆ nu

generate_droplet_dynamics.nu = sympy.Symbol('nu', positive = True)

◆ out

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

◆ output_filename

string generate_droplet_dynamics.output_filename = "droplet_dynamics_element.cpp"

◆ outstring

generate_droplet_dynamics.outstring = templatefile.read()

◆ p

generate_droplet_dynamics.p = DefineVector('p',nnodes)

◆ p_gauss

generate_droplet_dynamics.p_gauss = p.transpose()*N

Data interpolation to the Gauss points.

◆ penr

generate_droplet_dynamics.penr = DefineVector('penr',nnodes)

◆ penr_gauss

generate_droplet_dynamics.penr_gauss = penr.transpose()*Nenr

◆ pn

generate_droplet_dynamics.pn = DefineVector('pn',nnodes)

◆ q

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

◆ q_gauss

generate_droplet_dynamics.q_gauss = q.transpose()*N

◆ qenr

generate_droplet_dynamics.qenr = DefineVector('qenr' ,nnodes)

◆ qenr_gauss

generate_droplet_dynamics.qenr_gauss = qenr.transpose()*Nenr

◆ rho

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

◆ rhs

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

◆ rhs_ee

generate_droplet_dynamics.rhs_ee

◆ rhs_ee_out

generate_droplet_dynamics.rhs_ee_out = OutputVector_CollectingFactors(rhs_ee,"rhs_ee",mode)

◆ rhs_eV

generate_droplet_dynamics.rhs_eV

K V x = b + rhs_eV H Kee penr = rhs_ee.

◆ rhs_out

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

◆ rv

tuple generate_droplet_dynamics.rv = rv_galerkin + rv_stab

Add the stabilization terms to the original residual terms.

◆ rv_enriched

generate_droplet_dynamics.rv_enriched = rv_galerkin_enriched

◆ rv_galerkin

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

◆ rv_galerkin_enriched

generate_droplet_dynamics.rv_galerkin_enriched = div_w*penr_gauss

◆ rv_stab

tuple generate_droplet_dynamics.rv_stab = grad_q.transpose()*vel_subscale

◆ rv_stab_enriched

generate_droplet_dynamics.rv_stab_enriched = grad_qenr.transpose()*vel_subscale_enr

◆ stab_c1

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

◆ stab_c2

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

◆ strain_size

int generate_droplet_dynamics.strain_size = 3

◆ stress

generate_droplet_dynamics.stress = DefineVector('stress',strain_size)

Stress vector definition.

◆ tau1

float generate_droplet_dynamics.tau1 = sympy.Symbol('tau1', positive = True)

◆ tau2

generate_droplet_dynamics.tau2 = sympy.Symbol('tau2', positive = True)

◆ template_filename

string generate_droplet_dynamics.template_filename = "droplet_dynamics_template.cpp"

◆ templatefile

generate_droplet_dynamics.templatefile = open(template_filename)

Read the template file.

◆ testfunc

generate_droplet_dynamics.testfunc = sympy.zeros(nnodes*(dim+1), 1)

◆ testfunc_enr

generate_droplet_dynamics.testfunc_enr = sympy.zeros(nnodes,1)

◆ time_integration

string generate_droplet_dynamics.time_integration = "bdf2"

◆ v

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

Unknown fields definition.

◆ V

generate_droplet_dynamics.V

◆ v_gauss

generate_droplet_dynamics.v_gauss = v.transpose()*N

◆ V_out

generate_droplet_dynamics.V_out = OutputMatrix_CollectingFactors(V,"V",mode)

◆ vconv

generate_droplet_dynamics.vconv = DefineMatrix('vconv',nnodes,dim)

Convective velocity definition.

◆ vconv_gauss

generate_droplet_dynamics.vconv_gauss = vconv.transpose()*N

◆ vconv_gauss_norm

generate_droplet_dynamics.vconv_gauss_norm = 0.0

Compute the stabilization parameters.

◆ vel_residual

tuple generate_droplet_dynamics.vel_residual = rho*f_gauss - rho*accel_gauss - rho*convective_term.transpose() - grad_p

◆ vel_residual_enr

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

◆ vel_subscale

tuple generate_droplet_dynamics.vel_subscale = tau1*vel_residual

◆ vel_subscale_enr

generate_droplet_dynamics.vel_subscale_enr = vel_residual_enr * tau1

◆ vmesh

generate_droplet_dynamics.vmesh = DefineMatrix('vmesh',nnodes,dim)

◆ vmeshn

generate_droplet_dynamics.vmeshn = DefineMatrix('vmeshn',nnodes,dim)

◆ vn

generate_droplet_dynamics.vn = DefineMatrix('vn',nnodes,dim)

◆ vnn

generate_droplet_dynamics.vnn = DefineMatrix('vnn',nnodes,dim)

◆ w

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

Test functions definition.

◆ w_gauss

generate_droplet_dynamics.w_gauss = w.transpose()*N