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

Functions

def DefineMatrix (name, m, n)
 This method defines a symbolic matrix. More...
 
def DefineSymmetricMatrix (name, m, n)
 This method defines a symbolic symmetric matrix. More...
 
def DefineSymmetricFourthOrderTensor (name, m, n, o, p)
 This method defines a symbolic symmetric 4th order tensor. More...
 
def DefineVector (name, m)
 This method defines a symbolic vector. More...
 
def DefineShapeFunctions (nnodes, dim, impose_partion_of_unity=False)
 This method defines shape functions and derivatives. More...
 
def StrainToVoigt (M)
 This method transform the strains matrix to Voigt notation. More...
 
def MatrixToVoigt (M)
 This method transform a symmetric matrix to Voigt notation. More...
 
def ConvertTensorToVoigtMatrix (C)
 This method converts a 4th order tensor given to a matrix in Voigt notation. More...
 
def ConvertVoigtMatrixToTensor (C)
 This method converts a matrix given in Voigt notation in a 4th order tensor. More...
 
def DoubleContraction (A, B)
 This method performs the double contraction A:B. More...
 
def MatrixB (DN)
 This method defines the deformation matrix B. More...
 
def grad_sym_voigtform (DN, x)
 This method defines a symmetric gradient. More...
 
def DfjDxi (DN, f)
 This method defines a gradient. More...
 
def DfiDxj (DN, f)
 This method defines a gradient This returns a matrix D such that D(i,j) = D(fi)/D(xj). More...
 
def div (DN, x)
 This method defines the divergence. More...
 
def SubstituteMatrixValue (where_to_substitute, what_to_substitute, substituted_value)
 This method substitutes values into a matrix. More...
 
def SubstituteScalarValue (where_to_substitute, what_to_substitute, substituted_value)
 This method substitutes values into a scalar. More...
 
def SubstituteMatrixValueByVoigtSymbols (where_to_substitute, what_to_substitute, substituted_value, is_strain)
 This method substitutes values into a matrix. More...
 
def Compute_RHS (functional, testfunc, do_simplifications=False)
 This computes the RHS vector. More...
 
def Compute_LHS (rhs, testfunc, dofs, do_simplifications=False)
 This computes the LHS matrix. More...
 
def Compute_RHS_and_LHS (functional, testfunc, dofs, do_simplifications=False)
 This computes the LHS matrix and the RHS vector. More...
 
def OutputScalar (scalar_expression, name, language, indentation_level=0, replace_indices=True, assignment_op="=")
 This function generates code to assign to a (pre-declared) scalar. More...
 
def OutputVector (vector_expression, name, language, indentation_level=0, replace_indices=True, assignment_op="=")
 This function generates code to fill a (pre-declared) vector. More...
 
def OutputMatrix (matrix_expression, name, language, indentation_level=0, replace_indices=True, assignment_op="=")
 This function generates code to fill a (pre-declared) matrix. More...
 
def OutputSymbolicVariable (expression, language, replace_indices=True)
 This function generates code from an expression. More...
 
def OutputSymbolicVariableDeclaration (expression, name, language, indentation_level=0, replace_indices=True)
 This function generates code to declare and assign an expression, such as: More...
 
def OutputMatrix_CollectingFactors (A, name, language, indentation_level=0, max_index=None, optimizations='basic', replace_indices=True, assignment_op="=")
 This method collects the constants of the replacement for matrices. More...
 
def OutputVector_CollectingFactors (A, name, language, indentation_level=0, max_index=None, optimizations='basic', replace_indices=True, assignment_op="=")
 This method collects the constants of the replacement for vectors. More...
 
def OutputScalar_CollectingFactors (A, name, language, indentation_level=0, optimizations='basic', replace_indices=True, assignment_op="=")
 This method collects the constants of the replacement for vectors. More...
 

Function Documentation

◆ Compute_LHS()

def sympy_fe_utilities.Compute_LHS (   rhs,
  testfunc,
  dofs,
  do_simplifications = False 
)

This computes the LHS matrix.

Keyword arguments:

  • rhs – The RHS vector
  • testfunc – The test functions
  • dofs – The dofs vectors
  • do_simplifications – If apply simplifications

◆ Compute_RHS()

def sympy_fe_utilities.Compute_RHS (   functional,
  testfunc,
  do_simplifications = False 
)

This computes the RHS vector.

Keyword arguments:

  • functional – The functional to derivate
  • testfunc – The test functions
  • do_simplifications – If apply simplifications

◆ Compute_RHS_and_LHS()

def sympy_fe_utilities.Compute_RHS_and_LHS (   functional,
  testfunc,
  dofs,
  do_simplifications = False 
)

This computes the LHS matrix and the RHS vector.

Keyword arguments:

  • functional – The functional to derivate
  • testfunc – The test functions
  • dofs – The dofs vectors
  • do_simplifications – If apply simplifications

◆ ConvertTensorToVoigtMatrix()

def sympy_fe_utilities.ConvertTensorToVoigtMatrix (   C)

This method converts a 4th order tensor given to a matrix in Voigt notation.

Keyword arguments:

  • C – The 4th order tensor to be converted to Voigt notation

◆ ConvertVoigtMatrixToTensor()

def sympy_fe_utilities.ConvertVoigtMatrixToTensor (   C)

This method converts a matrix given in Voigt notation in a 4th order tensor.

Keyword arguments:

  • C – The matrix in Voigt notation to be converted to 4th order tensor

◆ DefineMatrix()

def sympy_fe_utilities.DefineMatrix (   name,
  m,
  n 
)

This method defines a symbolic matrix.

Keyword arguments:

  • name – Name of variables.
  • m – Number of rows.
  • n – Number of columns.

◆ DefineShapeFunctions()

def sympy_fe_utilities.DefineShapeFunctions (   nnodes,
  dim,
  impose_partion_of_unity = False 
)

This method defines shape functions and derivatives.

Note that partition of unity is imposed the name HAS TO BE --> N and DN

Keyword arguments:

  • nnodes – Number of nodes
  • dim – Dimension of the space
  • impose_partion_of_unity – Impose the partition of unity

◆ DefineSymmetricFourthOrderTensor()

def sympy_fe_utilities.DefineSymmetricFourthOrderTensor (   name,
  m,
  n,
  o,
  p 
)

This method defines a symbolic symmetric 4th order tensor.

Keyword arguments:

  • name – Name of variables.
  • m – 1st dimension.
  • n – 2nd dimension.
  • o – 3rd dimension.
  • p – 4th dimension.

◆ DefineSymmetricMatrix()

def sympy_fe_utilities.DefineSymmetricMatrix (   name,
  m,
  n 
)

This method defines a symbolic symmetric matrix.

Keyword arguments:

  • name – Name of variables.
  • m – Number of rows.
  • n – Number of columns.

◆ DefineVector()

def sympy_fe_utilities.DefineVector (   name,
  m 
)

This method defines a symbolic vector.

Keyword arguments:

  • name – Name of variables.
  • m – Number of components.

◆ DfiDxj()

def sympy_fe_utilities.DfiDxj (   DN,
  f 
)

This method defines a gradient This returns a matrix D such that D(i,j) = D(fi)/D(xj).

This is the standard in structural mechanics, that is: D(f1)/D(x1) D(f1)/D(x2) D(f1)/D(x3) D(f2)/D(x1) D(f2)/D(x2) D(f2)/D(x3) D(f3)/D(x1) D(f3)/D(x2) D(f3)/D(x3)

Keyword arguments:

  • DN – The shape function derivatives
  • f – The variable to compute the gradient

◆ DfjDxi()

def sympy_fe_utilities.DfjDxi (   DN,
  f 
)

This method defines a gradient.

Returns a matrix D such that D(i,j) = D(fj)/D(xi)

This is the standard in fluid dynamics, that is: D(f1)/D(x1) D(f2)/D(x1) D(f3)/D(x1) D(f1)/D(x2) D(f2)/D(x2) D(f3)/D(x2) D(f1)/D(x3) D(f2)/D(x3) D(f3)/D(x3)

Keyword arguments:

  • DN – The shape function derivatives
  • f– The variable to compute the gradient

◆ div()

def sympy_fe_utilities.div (   DN,
  x 
)

This method defines the divergence.

Keyword arguments:

  • DN – The shape function derivatives
  • x – The variable to compute the gradient

◆ DoubleContraction()

def sympy_fe_utilities.DoubleContraction (   A,
  B 
)

This method performs the double contraction A:B.

Keyword arguments:

  • A – Left tensor
  • B – Right tensor

◆ grad_sym_voigtform()

def sympy_fe_utilities.grad_sym_voigtform (   DN,
  x 
)

This method defines a symmetric gradient.

Keyword arguments:

  • DN – The shape function derivatives
  • x – The variable to compute the gradient

◆ MatrixB()

def sympy_fe_utilities.MatrixB (   DN)

This method defines the deformation matrix B.

Keyword arguments:

  • DN – The shape function derivatives

◆ MatrixToVoigt()

def sympy_fe_utilities.MatrixToVoigt (   M)

This method transform a symmetric matrix to Voigt notation.

Keyword arguments:

  • M – The input matrix

◆ OutputMatrix()

def sympy_fe_utilities.OutputMatrix (   matrix_expression,
  name,
  language,
  indentation_level = 0,
  replace_indices = True,
  assignment_op = "=" 
)

This function generates code to fill a (pre-declared) matrix.

Keyword arguments:

  • matrix_expression – The matrix
  • name – The name of the variables
  • language – The language of output
  • indentation_level – The number of tabulations considered
  • replace_indices – Set to True to replace matrix_i_j with matrix[i,j] (And similarly for vectors)
  • assignment_op – The assignment operation

◆ OutputMatrix_CollectingFactors()

def sympy_fe_utilities.OutputMatrix_CollectingFactors (   A,
  name,
  language,
  indentation_level = 0,
  max_index = None,
  optimizations = 'basic',
  replace_indices = True,
  assignment_op = "=" 
)

This method collects the constants of the replacement for matrices.

Keyword arguments:

  • A – The factors
  • name – The name of the constant
  • language – The language of replacement
  • indentation_level – The depth of the indentation (4 spaces per level)
  • max_index – DEPRECATED The max number of indexes
  • optimizations – The level of optimizations
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)
  • assignment_op – The assignment operation

◆ OutputScalar()

def sympy_fe_utilities.OutputScalar (   scalar_expression,
  name,
  language,
  indentation_level = 0,
  replace_indices = True,
  assignment_op = "=" 
)

This function generates code to assign to a (pre-declared) scalar.

Keyword arguments:

  • scalar_expression – A scalar
  • name – The name of the variables
  • language – The language of output
  • indentation_level – The number of tabulations considered
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)
  • assignment_op – The assignment operation

◆ OutputScalar_CollectingFactors()

def sympy_fe_utilities.OutputScalar_CollectingFactors (   A,
  name,
  language,
  indentation_level = 0,
  optimizations = 'basic',
  replace_indices = True,
  assignment_op = "=" 
)

This method collects the constants of the replacement for vectors.

Keyword arguments:

  • A – The factors
  • name – The name of the constant
  • language – The language of replacement
  • indentation_level – The depth of the indentation (4 spaces per level)
  • optimizations – The level of optimizations
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)
  • assignment_op – The assignment operation

◆ OutputSymbolicVariable()

def sympy_fe_utilities.OutputSymbolicVariable (   expression,
  language,
  replace_indices = True 
)

This function generates code from an expression.

Keyword arguments:

  • expression – The expression to generate code from
  • language – The language of output
  • indentation_level – The number of tabulations considered
  • max_index – The maximum index
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)

◆ OutputSymbolicVariableDeclaration()

def sympy_fe_utilities.OutputSymbolicVariableDeclaration (   expression,
  name,
  language,
  indentation_level = 0,
  replace_indices = True 
)

This function generates code to declare and assign an expression, such as:

{C++}
const double variable = expression;

Keyword arguments:

  • expression – The variable to define symbolic
  • language – The language of output
  • name – The name of the variables
  • indentation_level – The number of tabulations considered
  • max_index – DEPRECATED The maximum index
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)

◆ OutputVector()

def sympy_fe_utilities.OutputVector (   vector_expression,
  name,
  language,
  indentation_level = 0,
  replace_indices = True,
  assignment_op = "=" 
)

This function generates code to fill a (pre-declared) vector.

Keyword arguments:

  • rhs – The RHS vector
  • name – The name of the variables
  • language – The language of output
  • indentation_level – The number of tabulations considered
  • replace_indices – Set to True to replace matrix_i_j with matrix[i,j] (And similarly for vectors)
  • assignment_op – The assignment operation

◆ OutputVector_CollectingFactors()

def sympy_fe_utilities.OutputVector_CollectingFactors (   A,
  name,
  language,
  indentation_level = 0,
  max_index = None,
  optimizations = 'basic',
  replace_indices = True,
  assignment_op = "=" 
)

This method collects the constants of the replacement for vectors.

Keyword arguments:

  • A – The factors
  • name – The name of the constant
  • language – The language of replacement
  • indentation_level – The depth of the indentation (4 spaces per level)
  • max_index – DEPRECATED The max number of indexes
  • optimizations – The level of optimizations
  • replace_indices – Set to True to replace matrix[i,j] with matrix_i_j (And similarly for vectors)
  • assignment_op – The assignment operation

◆ StrainToVoigt()

def sympy_fe_utilities.StrainToVoigt (   M)

This method transform the strains matrix to Voigt notation.

Keyword arguments:

  • M – The strain matrix

◆ SubstituteMatrixValue()

def sympy_fe_utilities.SubstituteMatrixValue (   where_to_substitute,
  what_to_substitute,
  substituted_value 
)

This method substitutes values into a matrix.

Keyword arguments:

  • where_to_substitute – Coordinates where to substitute
  • what_to_substitute – Components to substitute
  • substituted_value – Variable to substitute

◆ SubstituteMatrixValueByVoigtSymbols()

def sympy_fe_utilities.SubstituteMatrixValueByVoigtSymbols (   where_to_substitute,
  what_to_substitute,
  substituted_value,
  is_strain 
)

This method substitutes values into a matrix.

Note that this is intended to be used to substitute matrix indices by their corresponding Voigt ones

Keyword arguments:

  • where_to_substitute – Coordinates where to substitute
  • what_to_substitute – Components to substitute
  • substituted_value – Variable to substitute
  • is_strain – Flag indicating if substituted_value is a strain

◆ SubstituteScalarValue()

def sympy_fe_utilities.SubstituteScalarValue (   where_to_substitute,
  what_to_substitute,
  substituted_value 
)

This method substitutes values into a scalar.

Keyword arguments:

  • where_to_substitute – Coordinates where to substitute
  • what_to_substitute – Components to substitute
  • substituted_value – Variable to substitute