.. _element_basics:

##############
Element Basics
##############

*****************************
Properties of Shape Functions
*****************************

In this chapter we explore the basic issues associated with the design of finite elements, which are the building blocks of the methods we have discussed.
In particular we will discuss how definitions and manipulations are done at the local level to produce the elemental quantities, like :math:`\mathbf{m}^e`, :math:`\mathbf{f}^\text{int}_e`, and :math:`\mathbf{k}^e`, that are needed for assembly and solution of the global equations of motion.
We concentrate in this chapter on one-field problems, i.e., where only the deformation mapping :math:`\varphi_t` is discretized.
It will turn out that many nonlinear solid mechanics applications of interest, including nearly incompressible elasticity and metal plasticity, require more sophisticated approximations in which other variables (like pressure) must be explicitly included in the formulation.

.. %Discussion of such advanced methods is deferred to :numref:`element_advanced`.

To start, we discuss in general terms the requirements usually placed upon shape function definitions.
It should be noted that these conditions are sufficient but not necessary, so that many formulations exist that violate one or more of them.
However, it is also fair to say that most finite elements in wide use satisfy the conditions we will discuss.

The first condition relates to convergence of the finite element method in general, and the implication on properties of shape functions for elements.
We begin by defining :math:`m`, which will denote the highest order shape function spatial derivative present in the expression for the stiffness matrix.
For the class of problems we have considered so far, we find from :numref:`nonlinear_solve` that the element stiffness takes the form

.. math::
   :label: element_basics:eq:01

    k^e_{pq} \left( \mathbf{d}^{e^i}_{n+1} \right) = \frac{ \partial f^{\text{int}}_p }{\partial d^e_q} \left( \mathbf{d}^{e^i}_{n+1} \right)


The internal force vector required in :eq:`element_basics:eq:01` was given generically in :numref:`discretization`, equations :eq:`discretization:eq:43` and :eq:`discretization:eq:44`, as:

.. math::
   :label: element_basics:eq:02

    f^{\mathrm{int},e}_p = \int_{\varphi^h_t(\Omega^e)} \left[ \sum_{j=1}^3 N_{a,j} \left( \varphi^{-1}_t(\mathbf{x}) \right) T^h_{ij} \right] \mathrm{d}v


Performing the differentiation indicated in :eq:`element_basics:eq:01` will produce no higher than first-order derivatives of the shape functions; therefore :math:`m=1`.

The three general convergence requirements we need to mention are as follows:

- The global shape function :math:`N_J` should have global continuity  of the order :math:`m-1`. In mathematical terms, they should be :math:`C^{m-1}` on :math:`\Omega^h`.  
- The restriction of the global shape functions to individual elements (i.e., the :math:`\left\{ N_J \right\}`) should be :math:`C^m` on the element interiors.
- The elemental shape functions :math:`\left\{ N_J \right\}` should be complete.

The first two of these requirements are fairly simple to understand.
The first, :math:`C^{m-1}` continuity requirement, simply means that all derivatives up to :math:`m-1` of the shape functions should not undergo jumps as element boundaries are crossed.
In the current case this means that all :math:`N_J` should be :math:`C^0` continuous.
Since the approximation to the configuration mapping :math:`\varphi^h_t` is a linear combination of these shape functions, we
see that the physical restriction placed by this condition amounts to no more that a requirement that the displacement
be single-valued throughout the domain (i.e., gaps and interpenetrations at element boundaries may not occur).

The second requirement on element interiors simply states that the shape functions should be sufficiently smooth so that the element stiffness expressions are integrable.
Physically speaking, the first derivatives of the configuration mapping produces strain measures, so we simply require that the strains be well-behaved on element interiors by this restriction.
Note that global smoothness of the strains (and therefore stresses) is *not* required.
This point is of some importance in the reporting of results, as we discuss later.

The third requirement, the completeness requirement, is somewhat more involved to explain and yet corresponds fairly directly to physical ideas.
We say that a given element is complete when setting the element degrees of freedom according to a given low-order polynomial forces the solution :math:`\varphi^h_t` to be interpolated according to the same polynomial point wise in the element.
The degree of polynomials for which we place this requirement is referred to as the degree of completeness for the element.

In the current case where we deal with solid continua, the usual degree of completeness demanded is 1.
This means that all global solutions representable by polynomials, up to and including order 1, should be exactly representable by the element.
It is worthwhile to consider an example of this point. Suppose we are in three dimensions and set element degrees of freedom via

.. math::
   :label: element_basics:eq:03

   \mathbf{d}^e_a = c_0 + c_1 X^e_a \mathbf{e}_x + c_2 Y^e_a \mathbf{e}_y + c_3 Z^e_a \mathbf{e}_z,


where :math:`c_0`, :math:`c_1`, :math:`c_2`, :math:`c_3` are arbitrary constants and :math:`X^e_a`, :math:`Y^e_a`, :math:`Z^e_a` are the reference coordinates for local node number :math:`a`.
The completeness condition requires that

.. math::
   :label: element_basics:eq:04

   \varphi^h_t \left( \mathbf{X}^e \right) = \sum_{a=1}^{nen} N_a (\mathbf{X}^e) \mathbf{d}^e_a = \left( c_0 + c_1 X^e \mathbf{e}_x + c_2 Y^e \mathbf{e}_y + c_3 Z^e \mathbf{e}_z \right)


hold for all :math:`\mathbf{X}^e \in \Omega^e` and for all values of the arbitrary constants.

Element patch test
==================

As mentioned above, the completeness requirement has a physical interpretation as well.
In solid mechanics we have already pointed out that the first spatial derivatives of the displacements produce strains.
Since we require that an element be able to reproduce arbitrary global solutions that are linear polynomials, this also
implies that any state where the first derivatives (i.e., strains) are constant should be exactly representable.
Thus a complete element should be able to exactly represent any uniform strain state.
A practical way to test for this condition is to impose a boundary value problem on an arbitrary patch of elements having a constant strain (and thus stress) solution and then demand exactness of the numerical solution.
Such a test is called a patch test and has become one of the standard benchmarks by which any new proposed element formulation is tested and evaluated.

A particularly useful instantiation of the patch test is to prescribe a combined rigid body rotation and stretch, making use of all of the constants :math:`c_0`, :math:`c_1`, ..., as depicted graphically in :numref:`element_basics-fig-patch_test`.
Here a piecewise combination of global linear function are specified.

.. _element_basics-fig-patch_test:

.. figure:: ../_static/figures/element_basics-fig01.png
   :align: center
   :scale: 75 %

   Element Patch test in 2D.

****************
Parameterization
****************

With these three criteria in hand for element definitions, we proceed to define a recipe through which element definitions and manipulations can be systematically performed.
The most basic definition to be made toward this end is the concept of the local (or parent) parameterization of an element.
In effect we seek to define a local coordinate system that will be the same for every element in a problem, which contributes in great part to the modularity we will desire for element level operations.

We will denote a vector of these local variables by :math:`\mathbf{r}`, with :math:`\mathbf{r}` being a 2-vector in two dimensions and a 3-vector in three dimensions.
Specifically, we define :math:`\mathbf{r}` as

.. math::
   :label: element_basics:eq:05

   \mathbf{r} = 
   \left[ 
   \begin{array} {l}
   r \\  s  
   \end{array}
   \right]  \text{two dimensions}, \quad
   \left[
   \begin{array} {l}
   r \\ s \\ t 
   \end{array}
   \right]  \text{three dimensions}

The local variables :math:`r`, :math:`s`, and :math:`t` are all assumed to range between :math:`-1` and :math:`1`, so that the domain definition is likewise standardized among all elements of the same type in a given problem.
The domain of :math:`\mathbf{r}` is often referred to as the parent domain.
As shown in :numref:`element_basics-fig-element_parameterization`, the two dimension parent domain is a bi-unit square, and in three dimensions a bi-unit cube.

.. _element_basics-fig-element_parameterization:

.. figure:: ../_static/figures/element_basics-fig02.png
   :align: center
   :scale: 75 %

   Local parameterization and coordinate mappings in two and three dimensions.

Of course, for this alternative element coordinate system to be of practical use, its relationship with the global coordinate system must be defined.
This is accomplished through a shape function expansion via

.. math::
   :label: element_basics:eq:06

   \mathbf{X}^e (\mathbf{r}) = \sum_{a=1}^{nen} \tilde{N}_a (\mathbf{r}) \mathbf{X}^e_a ,


where :math:`\mathbf{X}^e` is the global (reference) coordinate mapping covering element :math:`e` and where :math:`\mathbf{X}^e_a` are the element nodal (reference) coordinates, as before.
Note also in :eq:`element_basics:eq:06` that the shape functions have been written using the parent coordinates as the independent variables.
This is the reason for the superposed tilde on the shape function.
One could think of :math:`\mathbf{r}` as a material point label within the element, so that :math:`\mathbf{X}^e` and :math:`\mathbf{r}` are two reference coordinate systems for the element that are related according to :eq:`element_basics:eq:06`.
The most important generic class of finite elements is comprised of **isoparametric elements**.
Such elements are defined by utilizing the same shape functions for definition of deformation :math:`\varphi_t^h \left( \mathbf{X}^e \right)` as for the element coordinates :math:`\mathbf{X}^e`.
One can show that, providing all element shape functions sum to one at any point in the element, an isoparametric element automatically satisfies the completeness condition.
Furthermore, provided the shape functions are also suitably smooth on the element interior and match neighboring element descriptions on element boundaries, all three of the conditions required for convergence are met by isoparametric shape functions.

There are important implications of the isoparametric approach for the Lagrangian description of large deformation solid mechanics. The implications are related to the restrictions imposed on the mapping from the parent domain to the physical domain.
So that we may distinguish carefully between mappings taking :math:`\mathbf{r}` as an argument and those taking :math:`\mathbf{X}`, we will use the superposed tildes for the former, as in :eq:`element_basics:eq:06`.
If an element is isoparametric, then by definition the configuration mapping over an element is given by

.. math::
   :label: element_basics:eq:07

   \tilde{\varphi}_t^h (\mathbf{r}) = \sum_{I=1}^{nen} \tilde{N}_I (\mathbf{r}) \mathbf{d}^e_I ,


where the shape functions :math:`\tilde{N}_I (\mathbf{r})` are exactly the same as in :eq:`element_basics:eq:06`.
However, it should also be the case that the function :math:`\tilde{\varphi}_t^h (\mathbf{r})` should be obtainable from the
composition of :math:`\tilde{\varphi}_t^h (\mathbf{X}^e)` defined according to :eq:`element_basics:eq:04` with
:math:`\mathbf{X}^e(\mathbf{r})` defined according to :eq:`element_basics:eq:06`.  Thus we can write:

.. math::
   :label: element_basics:eq:08

   \sum_{I=1}^{nen} \tilde{N}_I (\mathbf{r}) \mathbf{d}^e_I = \tilde{\varphi}_t^h (\mathbf{r}) = \sum_{I=1}^{nen} N_I \left( \mathbf{X}^e (\mathbf{r}) \right) \mathbf{d}^e_I .


Comparing the leftmost and rightmost expressions of :eq:`element_basics:eq:08` and realizing that the
equality must hold for any given combination of the element degrees of freedom :math:`\mathbf{d}_I^e`, we are led to conclude
that the alternative shape function expressions :math:`\tilde{N}_I (\mathbf{r})` and :math:`N_I \left( \mathbf{X}^e \right)` must
be related by composition via

.. math::
   :label: element_basics:eq:09

   \tilde{N}_I = N_I \circ \mathbf{X}^e .


Thus we have the option of defining the shape functions over whatever domain is convenient, and since the parent domain
is the one that is standardized, we typically begin with an expression for :math:`\tilde{N}_I` and then derive the implied
expression for :math:`N_I` according to

.. math::
   :label: element_basics:eq:10

   N_I = \tilde{N}_I \circ \left(\mathbf{X}^e\right)^{-1}.


:eq:`element_basics:eq:10` reveals the important implications as a practical condition on the inverse mapping
:math:`\left(\mathbf{X}^e\right)^{-1}` of :math:`\mathbf{X}^e`. It must be well behaved for the shape function :math:`N_I` to make sense.

Fortunately, according to the implicit function theorem, the inverse function to :eq:`element_basics:eq:06`
is smooth and one-to-one provided the Jacobian of the indicated transformation is nonzero.  This essentially amounts to
a geometric restriction on elements in the reference domain.  In two dimensions, e.g., the implication is that all
interior angles in each 4-noded element must be less than 180 degrees.

Finally, let us consider shape functions that take the current coordinates, :math:`\mathbf{x}^e = \varphi_t^h \left(\mathbf{X}^e \right)`. Such an expression is needed in :eq:`element_basics:eq:02` where the spatial
derivatives in the current configuration are needed:

.. math::
   :label: element_basics:eq:11

   \hat{N}_{I,i} = \frac{\partial}{\partial \mathbf{x}_i^e} \hat{N}_I


where we have temporarily introduced the additional notation :math:`\hat{N}` to indicate that the shape function takes the current coordinate.

Following similar reasoning as above, one can conclude that the functions :math:`\hat{N}` must obey

.. math::
   :label: element_basics:eq:12

   N_I= \hat{N}_I \circ \left(\tilde{\varphi}_t^h\right) ^{-1}


Again for the needed function :math:`\left(\tilde{\varphi}_t^h\right)^{-1}` to be well-behaved, the Jacobian of the transformation (:eq:`element_basics:eq:07` must be non-zero. This amounts to:

.. math::
   :label: element_basics:eq:13

   \det \left[ \frac{\partial \tilde{\varphi}_t^h}{ \partial \mathbf{r}} \right] = \det \left[ \frac{\partial
   \tilde{\varphi}_t^h}{ \partial \mathbf{X}^e} \right] \det \left[ \frac{\partial \mathbf{X}^e}{ \partial \mathbf{r}} \right] \neq 0 


Provided the original element definitions are not overly distorted, the second term on the right hand side of
:eq:`element_basics:eq:13` will be non-zero. Thus the well-posedness of the spatial shape functions
:math:`\tilde{N}_I` requires that :math:`\det \left[ \frac{\partial \tilde{\varphi}_t^h}{ \partial \mathbf{X}^e} \right]` be
non-zero.  Notice, though, that this is an approximation of the determinant, :math:`J`, of the deformation gradient, as
defined in :numref:`deformation_measures`. According to :eq:`deformation_measure:eq:11`, :math:`J` must be
positive point wise for the concept of volume change to have any physical meaning.  Thus, provided the approximated
deformation mapping remains kinematically admissible (i.e., :math:`J>0`), the spatially defined shape functions are guaranteed
to be well-behaved.

With this discussion as background, we now turn our attention to definition of the shape functions according to the
parent domain. To keep the notation complexity to a minimum, we will drop the explicit distinction between :math:`N_I`,
:math:`\tilde{N}_I`, and :math:`\hat{N}_I`, referring to all these objects as simply :math:`N_I`.

.. %\section{Shape Functions}

.. %To be written.  See Chapter 3 of Reference
.. % [:footcite:`hughes:00`].

.. %\section{Integration in local coordinates}

.. %To be written.  See Chapter 3 of Reference [:footcite:`hughes:00`].
.. %\section{Gauss quadrature}
.. %To be written.  See Chapter 3 of Reference [:footcite:`hughes:00`].
.. %\section{Local Element Calculations}

.. %To be written.

.. %\bibliographystyle{unsrtnat}
.. %\bibliography{master}

