##~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~##
## ##
## This file forms part of the Underworld geophysics modelling application. ##
## ##
## For full license and copyright information, please refer to the LICENSE.md file ##
## located at the project root, or contact the authors. ##
## ##
##~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~##
"""
This module provides functions relating to tensor operations.
All Underworld2 functions return 1d array type objects. For tensor objects,
the following convention is used:
Full tensors:
2D:
.. math::
\\left[ a_{00}, a_{01}, \\\\
a_{10}, a_{11} \\right]
3D:
.. math::
\\left[ a_{00}, a_{01}, a_{02}, \\\\
a_{10}, a_{11}, a_{12}, \\\\
a_{20}, a_{21}, a_{22} \\right]
Symmetric tensors:
2D:
.. math::
\\left[ a_{00}, a_{11}, a_{01} \\right]
3D:
.. math::
\\left[ a_{00}, a_{11}, a_{22}, a_{01}, a_{02}, a_{12} \\right]
"""
import underworld.libUnderworld.libUnderworldPy.Function as _cfn
from ._function import Function as _Function
[docs]class symmetric(_Function):
"""
This function calculates the symmetric part of a tensor and returns
it as a symmetric tensor. The function generated by this class returns
objects of type SymmetricTensorType.
.. math::
v_{ij} = \\tfrac{1}{2} ( u_{ij} + u_{ji} )
Parameters
----------
fn: underworld.function.Function
The function which provides the required tensor. This function
must return objects of type TensorType.
"""
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.TensorFunc( self._fn._fncself, _cfn.TensorFunc.get_symmetric )
# build parent
super(symmetric,self).__init__(argument_fns=[fn,],**kwargs)
[docs]class antisymmetric(_Function):
"""
This function calculates the anti-symmetric part of a tensor, returning it
as a tensor. The function generated by this class returns objects of
type TensorType.
.. math::
v_{ij} = \\tfrac{1}{2} ( u_{ij} - u_{ji} )
Parameters
----------
fn: underworld.function.Function
The function which provides the required tensor. This function
must return objects of type TensorType.
"""
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.TensorFunc( self._fn._fncself, _cfn.TensorFunc.get_antisymmetric )
# build parent
super(antisymmetric,self).__init__(argument_fns=[fn,],**kwargs)
[docs]class second_invariant(_Function):
"""
This function calculates the second invariant of (symmetric)tensor provided
by the subject function. The function generated by this class returns
objects of type ScalarType.
.. math::
u = \\sqrt{ \\tfrac{1}{2} u_{ij} u_{ij} }
Parameters
----------
fn: underworld.function.Function
The function which provides the required tensor. This function
must return objects of type TensorType or SymmetricTensorType.
"""
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.TensorFunc( self._fn._fncself, _cfn.TensorFunc.second_invariant )
# build parent
super(second_invariant,self).__init__(argument_fns=[fn,],**kwargs)
[docs]class deviatoric(_Function):
"""
This function calculates the deviatoric stress tensor from the provided
symmetric tensor. The function generated by this class returns objects of
type SymmetricTensorType.
.. math::
\\tau_{ij} = \\sigma_{ij} - \\frac{\\sigma_{kk}}{\\delta_{ll}}\\delta_{ij}
Parameters
----------
fn: underworld.function.Function
The function which provides the required stress symmetric tensor. This
function must return objects of type SymmetricTensorType.
"""
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.TensorFunc( self._fn._fncself, _cfn.TensorFunc.get_deviatoric )
# build parent
super(deviatoric,self).__init__(argument_fns=[fn,],**kwargs)