.. _boundary_conditions:

###################
Boundary Conditions
###################

This chapter describes the theoretical and mathematical basis for some common boundary conditions.

.. _distforce:

****************************
Distributed Force and Moment
****************************

Boundary Condition Purpose
==========================

The purpose of the distributed force boundary condition is to distribute a known set of forces and moments onto a meshed body of :math:`N` nodes in a smooth manner.  The force distribution is formulated to have the following properties:

- The provided force distribution exactly reproduces three XYZ net target translational forces and three XYZ net target moments.
- The distribution avoids concentrated forces that may cause high local deformation.
- The force distribution uses translational forces only.  Net moments are applied via translational force couples.

There are likely infinitely many force distributions that meet the above properties.  The distributed force BC aims to find and apply at least one reasonable such distribution.

Boundary Condition Implementation
=================================

The distributed force boundary condition applies nodal forces constructed by a linear combination of six assumed distributions. Each of these force distributions provide a contribution predominately aligned with each of the net forces and net moments. The distributions are essentially a weight for dividing a net global force over the :math:`N`-node set.

Three translational force distributions :math:`\mathbf{D}_{x}`, :math:`\mathbf{D}_{y}` and :math:`\mathbf{D}_{z}` are given in :eq:`eq:transforce`. The :math:`x`, :math:`y`, and :math:`z` subscripts denote the force direction, and :math:`\hat{\mathbf x} = (1, 0, 0)`, :math:`\hat{\mathbf y} = (0, 1, 0)`, and :math:`\hat{\mathbf z} = (0, 0, 1)`. The :math:`I^{th}` subscript denotes the :math:`I^{th}` node in the :math:`N`-node set. :math:`m_I` is the mass at node :math:`I`. The translational force distributions are unitless.

.. math::
   :label: eq:transforce

   \begin{aligned}
   \mathbf{D}_{xI} &= \left( \frac{m_I}{\sum_{I=1}^{N} m_I} \right) \hat{\mathbf x}\\
   \mathbf{D}_{yI} &=  \left( \frac{m_I}{\sum_{I=1}^{N} m_I} \right) \hat{\mathbf y} \\
   \mathbf{D}_{zI} &=  \left( \frac{m_I}{\sum_{I=1}^{N} m_I} \right) \hat{\mathbf z}
   \end{aligned}

Note, the translational distributions have an identical shape to a gravity load. This choice to weight the nodal forces by mass is somewhat arbitrary, but does a good job of minimizing artificial force concentration. Also, note that a gravity load applies no net moment about the center of mass of the node set.

The moment distributions apply a net moment about the node set center of mass.  The center of mass of the node set :math:`\mathbf{C}` is calculated by :eq:`eq:centerofmass`.  :math:`\mathbf{p}_I` represents the coordinates of node :math:`I`. The three trial moment distributions :math:`\mathbf{D}_{rx}'`, :math:`\mathbf{D}_{ry}'`, :math:`\mathbf{D}_{rz}'`  are given by :eq:`eq:rotmoment`.  The :math:`rx`, :math:`ry`, and :math:`rz` subscripts denote the torques about :math:`\mathbf{\hat{x}}`, :math:`\mathbf{\hat{y}}`, and :math:`\mathbf{\hat{z}}`.

.. math::
   :label: eq:centerofmass

   \mathbf{C} = \frac{\sum_{I=1}^{N} m_I \mathbf{p}_I}{\sum_{I=1}^{N} m_I}

.. math::
   :label: eq:rotmoment

   \begin{aligned}
   \mathbf{D}_{rxI}' &= m_I (\hat{\mathbf x} \times (\mathbf{p}_I - \mathbf{C}))\\
   \mathbf{D}_{ryI}' &= m_I (\hat{\mathbf y} \times (\mathbf{p}_I - \mathbf{C}))\\
   \mathbf{D}_{rzI}' &= m_I (\hat{\mathbf z} \times (\mathbf{p}_I - \mathbf{C}))
   \end{aligned}

The constructed trial moment distributions may produce a net translational force. This is corrected by first computing the net translational force produced by each trial moment distribution, and subtracting off a scaled translational force distribution. The corrected pure moment distributions are given in :eq:`final_r`.

.. math::
   :label: final_r

   \begin{aligned}
   \mathbf{D}_{rxI} &= \mathbf{D}_{rxI}' - \left(\sum_{I=1}^{N} \mathbf{D}_{rxI}' \cdot \hat{\mathbf x}\right) \mathbf{D}_{xI} &- \left(\sum_{I=1}^{N} \mathbf{D}_{rxI}' \cdot \hat{\mathbf y}\right) \mathbf{D}_{yI} - \left(\sum_{I=1}^{N} \mathbf{D}_{rxI}' \cdot \hat{\mathbf z}\right) \mathbf{D}_{zI}\\
   \mathbf{D}_{ryI} &= \mathbf{D}_{ryI}' - \left(\sum_{I=1}^{N} \mathbf{D}_{ryI}' \cdot \hat{\mathbf x}\right) \mathbf{D}_{xI} &- \left(\sum_{I=1}^{N} \mathbf{D}_{ryI}' \cdot \hat{\mathbf y}\right) \mathbf{D}_{yI} - \left(\sum_{I=1}^{N} \mathbf{D}_{ryI}' \cdot \hat{\mathbf z}\right) \mathbf{D}_{zI}\\
   \mathbf{D}_{rzI} &= \mathbf{D}_{rzI}' - \left(\sum_{I=1}^{N} \mathbf{D}_{rzI}' \cdot \hat{\mathbf x}\right) \mathbf{D}_{xI} &- \left(\sum_{I=1}^{N} \mathbf{D}_{rzI}' \cdot \hat{\mathbf y}\right) \mathbf{D}_{yI} - \left(\sum_{I=1}^{N} \mathbf{D}_{rzI}' \cdot \hat{\mathbf z}\right) \mathbf{D}_{zI}
   \end{aligned}

The total forces to be applied are a weighted sum of the six force distributions  :math:`\mathbf{D}_{rx}`, :math:`\mathbf{D}_{ry}`, :math:`\mathbf{D}_{rz}`, :math:`\mathbf{D}_x`, :math:`\mathbf{D}_y`, and :math:`\mathbf{D}_z`. Note the moment force :math:`\mathbf{D}_{rx}`, :math:`\mathbf{D}_{ry}`, and :math:`\mathbf{D}_{rz}` distribution values have units of mass times length while the translational force distributions :math:`\mathbf{D}_x`, :math:`\mathbf{D}_y`, :math:`\mathbf{D}_z` are unitless.

The translational force distributions apply no moment. The corrected moment force distributions apply no net translational force. However, a moment distribution applied in one direction may cause a secondary moment in different direction.  These moment coupling terms are computed in :eq:`eq:mom_coup`. The :math:`M_{xy}` term, as an example, represents the net moment generated about :math:`\mathbf{\hat{y}}`, given that a nodal force distribution :math:`\mathbf{D}_{rx}` is applied.

.. math::
   :label: eq:mom_coup

   \begin{aligned}
   M_{xx} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rxI}) \cdot \hat{\mathbf x})\\
   M_{xy} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rxI}) \cdot \hat{\mathbf y})\\
   M_{xz} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rxI}) \cdot \hat{\mathbf z})\\
   M_{yx} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{ryI}) \cdot \hat{\mathbf x})\\
   M_{yy} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{ryI}) \cdot \hat{\mathbf y})\\
   M_{yz} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{ryI}) \cdot \hat{\mathbf z})\\
   M_{zx} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rzI}) \cdot \hat{\mathbf x})\\
   M_{zy} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rzI}) \cdot \hat{\mathbf y})\\
   M_{zz} &= \sum_{I=1}^{N} (((\mathbf{p}_I - \mathbf{C}) \times \mathbf{D}_{rzI}) \cdot \hat{\mathbf z})
   \end{aligned}

It is observed (but not proven) that the :math:`3 \times 3` moment coupling matrix :math:`\mathbf{M}` is symmetric. Approximate symmetry of the moment coupling matrix is assumed during the solution process. If the moment coupling matrix is not symmetric, then the net moments applied by the distributed force and moment boundary condition may be off in an amount proportional to the lack of symmetry.

To achieve the target net forces and moments :math:`\mathbf{b}`, :eq:`eq:force_solve` is solved to find the force distribution multipliers :math:`\mathbf{w}`. :math:`b_x`, :math:`b_y`, and :math:`b_z` have units of force and :math:`b_{rx}`, :math:`b_{ry}`, and :math:`b_{rz}` have units of moment. For the units to work out, :math:`w_x`, :math:`w_y`, and :math:`w_z` have units of force, while :math:`w_{rx}`, :math:`w_{ry}`, and :math:`w_{rz}` have units of one over time squared.

.. math::
   :label: eq:force_solve

   \begin{bmatrix}
   1 & 0 & 0 & 0 & 0 & 0 \\
   0 & 1 & 0 & 0 & 0 & 0 \\
   0 & 0 & 1 & 0 & 0 & 0 \\
   0 & 0 & 0 & M_{xx}                & 0.5*(M_{xy} + M_{yx}) & 0.5*(M_{xz} + M_{zx}) \\
   0 & 0 & 0 & 0.5*(M_{xy} + M_{yx}) & M_{yy}                & 0.5*(M_{yz} + M_{zy}) \\
   0 & 0 & 0 & 0.5*(M_{xz} + M_{zx}) & 0.5*(M_{yz} + M_{zy}) & M_{zz}              
   \end{bmatrix}
   \begin{bmatrix}
   w_x \\
   w_y \\
   w_z \\
   w_{rx} \\
   w_{ry} \\
   w_{rz}
   \end{bmatrix}
   =
   \begin{bmatrix} 
   b_x \\
   b_y \\
   b_z \\
   b_{rx} \\
   b_{ry} \\
   b_{rz}
   \end{bmatrix}

The actual final force :math:`\mathbf{F}` to apply to each node :math:`I` is given by :eq:`eq:net_force`.

.. math::
   :label: eq:net_force

   \mathbf{F}_I = w_x \mathbf{D}_{xI} + w_y \mathbf{D}_{yI} + w_z \mathbf{D}_{zI} + w_{rx} \mathbf{D}_{rxI} + w_{ry} \mathbf{D}_{ryI} + w_{rz} \mathbf{D}_{rzI}

Limitations and Special Cases
=============================

The distributed force and moment boundary conditions apply moments via translational force couples to a set of nodes. Special cases of node sets exist such that the application of distributed moments is not well-posed.

One example of these use cases is if the node set contains a single node, or a set of nodes in the same exact position. In this scenario, no force applied to the nodes will result in any moments.   This manifests as a zero matrix for the moment coupling terms given by :eq:`eq:mom_coup`. The resulting zero sub-matrix in :eq:`eq:force_solve` renders its solution impossible. Such a case should be avoided. However, if encountered in the code, the distributed moments will be ignored.

A second pathological node arrangement is a collinear set of nodes.  No set of forces on a collinear node set can produce a torque around the collinear axis.  Such a case will manifest as a singular system in :eq:`eq:force_solve`.  This node configuration should be avoided.  However, if detected, the target torque around the collinear node axis will be ignored and the other two orthogonal moments returned correctly.

.. _inertiarelief:

**************
Inertia Relief
**************

The inertia relief boundary condition is used to balance the free body diagram of forces acting on a body such that the net force external force acting on the body is zero.  The inertia relief boundary condition heavily leverages the distributed force and moment capability :numref:`distforce`.

Inertia relief computes the net external forces :math:`\mathbf{F}_{\mathrm{sum}}` and moments :math:`\mathbf{M}_{\mathrm{sum}}` acting on a body. These net external forces include forces from pressures, tractions, gravity, and other boundary conditions. :math:`\mathbf{F}_{\mathrm{sum}}` and :math:`\mathbf{M}_{\mathrm{sum}}` are computed using Equations :eq:`eq:net_force_ext` and :eq:`eq:net_moment_ext`.  The :math:`I` index is the :math:`I^{th}` node in the set.  :math:`\mathbf{F}_{ext}` is the translation external force acting on a node, :math:`\mathbf{M}_{ext}` is the external moment acting on a node, and :math:`\mathbf{p}` represents the coordinates of the node.  The moments on the body are computed around the body center of mass :math:`C` as computed in :eq:`eq:centerofmass`.

.. math::
   :label: eq:net_force_ext

   \mathbf{F}_{\mathrm{sum}} = {\sum \mathbf{F}_{ext_I}}


.. math::
   :label: eq:net_moment_ext

   \mathbf{M}_{\mathrm{sum}} = \sum ((\mathbf{p}_I - \mathbf{C}) \times \mathbf{F}_{ext_I}  + \mathbf{M}_{ext_I})

In order to compute the inertia relief forces, the distributed force boundary condition is leveraged, ultimately solving :eq:`eq:force_solve` for the :math:`\mathbf{b}` given in :eq:`eq:interial_b`.

.. math::
   :label: eq:interial_b

   \mathbf{b} = 
   \begin{bmatrix}
   -F_{\mathrm{sum}_x} \\
   -F_{\mathrm{sum}_y} \\
   -F_{\mathrm{sum}_z} \\
   -M_{\mathrm{sum}_x} \\
   -M_{\mathrm{sum}_y} \\
   -M_{\mathrm{sum}_z}
   \end{bmatrix}

***************
Viscous Damping
***************

.. %Much more theory detail should be fleshed out here in the future.

Rigid Body Invariant Damping
============================

The rigid body invariant damping option heavily leverages the inertia relief boundary condition :numref:`inertiarelief`.  Rigid body invariant damping automatically applies an inertia relief boundary condition that counterbalances just the damping forces being applied by the viscous damping BC.  This counterbalancing force ensures the total applied damping has no effect on the rigid body motion of parts and thus only effects the vibration models of the part.
