%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%    Juha Ruokolainen, Thomas Zwinger                           %
%    Olivier Gagliardini, Fabien Gillet                         %
%                                                               %
%                                                               %
%                                                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
\newcommand{\Matg}[2]{{^{#2}\!{\boldsymbol{#1}}}}
\newcommand{\Mat}[1]{{{\boldsymbol{#1}}}}
\newcommand{\Matgb}[2]{{^{#2}\!\bar{{\boldsymbol{#1}}}}}
\newcommand{\sur}[2]{\frac{\textstyle{\strut #1}}{\textstyle{\strut #2}}}
\newcommand{\Matb}[1]{{\bar{{\boldsymbol{#1}}}}}
\newcommand{\tr}{\operatorname{tr}}
\newcommand{\bphi}{\bar \varphi}
\newcommand{\btheta}{\bar \theta}
\newcommand{\bomega}{\bar \omega}
%--------------------------------------------------------------
\chapter{Anisotropic Ice Flow Solver (AIFlowSolver)}\\

\modinfo{Module name}{AIFlow}
\modinfo{Module subroutines~:}{AIFlowSolve}
\modinfo{Module authors~:}{Juha Ruokolainen}
\modinfo{Documentation by~:}{Olivier Gagliardini and Fabien Gillet}
\modinfo{Document edited~:}{\date{\today}}

\section{Introduction}
The Anisotropic Ice Flow Solver solves the Navier-Stokes type flow of an \textit{orthotropic linear viscous
incompressible } material, which constitutive macroscopic relation writes~:
\begin{equation} \label{polylawinv}
\Mat{s} = \sur{1}{{B}(T)} \sum_{i=1}^3 \left[ {\eta}_i \tr(\Matg{M}{o}_i \,\Mat{d}) \, \Matg{M}{o}_i^D + {\eta}_{i+3} (
\Mat{d} \, \Matg{M}{o}_i + \Matg{M}{o}_i \, \Mat{d})^D \right] \textrm{,}
\end{equation}
which derives from the macroscopic viscous potential~:
\begin{equation}
{\Phi}_d =  \sur{1}{{B}(T)} \sum_{i=1}^3 \left[ \sur{1}{2} {\eta}_i [\tr(\Matg{M}{o}_i \,\Mat{d})]^2  + {\eta}_{i+3}
\tr(\Matg{M}{o}_i \Mat{d}^2)\right] \textrm{,}
\end{equation}
%
Where~:\\
- $\Mat{s}$ is the deviatoric stress tensor,\\
%
- $\Mat{d}$ is the strain-rate tensor,\\
%
- $()^D$ denotes the deviatoric part,\\
%
- the six $\eta_i$ are the viscosities function of the fabric, \\
and the fluidity of isotropic ice at temperature $T$ follows Arrh\'{e}nius law~:
\begin{equation} {B}(T) = {B} (T_0) \exp{{Q}({1}/{T_0}-{1}/{T})/R}
\end{equation}
 where
$Q$ is the activation energy, $R$ is the gas constant and  $T_0$ the reference temperatures in Kelvin,\\
%
- $\Matg{M}{o}_i$ are the 3 structure tensors of the material, which define the 3 preferential symmetry planes of the
material. The expression of the 3 tensors $\Matg{M}{o}_i$ in the reference frame are given as a function of the 3 Euler
angles $(\theta,\phi,\omega)$.\\

\noindent \textbf{Convention:} Note that in ELMER the isotropic pressure is defined as $p = - tr (\Mat{\sigma}) /3 $,
so that $\sigma_{ij} = s_{ij} - p \delta_{ij}$. \\

\noindent \textbf{FabricSolver:} Note that the AIFlowSolver cannot be used alone except if the material is isotropic (See Keywords section). Even if the Fabric variables are constants, the FabricSolver must be declared (but not executed). For
details, see the FabricSolver model manual.\\

\noindent \textbf{Heat Equation Solver:} Same remarks for the temperature variable.


 \section{Keywords}

 \sifbegin \sifitemnt{Constants}{} \sifbegin \sifitem{Gas Constant}{Real }
 To specify the value of the Gas constant ($R=8.314\,Joule.K/mol$)
%
 \sifend

 \sifitemnt{Material}{mat id}

 The following material parameters may be set in AIFlow equations~:
%
 \sifbegin
%
 \sifitem{Isotropic}{Logical}
%
 Set to True if the material is isotropic in the whole domain. The fabricSolver as well as the Viscosity File is then not needed. Default value is false. 
%
 \sifitem{Density}{Real}
%
 The value of the density is given with this keyword.
%
 \sifitem{Fluidity Parameter}{Real}
%
 The value of the fluidity parameter $B(T_0)$ of isotropic ice given for the
 Reference Temperature $T_0$.
%
 \sifitem{Powerlaw Exponent}{Real}
%
 The power law exponent in the viscoplastic law. If the material is Isotropic, can take any value, else $n=1$.
%
 \sifitem{Activation Energy 1}{Real}
%
 The activation energy (Joule/mol) used if the temperature is lower than the Limit
 Temperature.
%
 \sifitem{Activation Energy 2}{Real}
%
 The activation energy (Joule/mol) used if the temperature is larger than the Limit
 Temperature.
%
 \sifitem{Reference Temperature}{Real}
%
 The reference temperature $T_0$ is the temperature corresponding to the  fluidity
 parameter $B(T_0)$.
%
 \sifitem{Limit Temperature}{Real}
%
 If the temperature is lower than the limit temperature, the value of the activation
 energy~1 is used, else the value of the energy activation~2.
%
 \sifitem{Viscosity File}{String}
%
 Gives the name of the file which contains the $813 \times 6$ relative viscosities
 calculated on the fabric grid.
%
%
 \sifitem{Min Second Invariant}{Real}
%
 The minimal value for the second invariant of the strain-rate. Only used for non-linear isotropic behaviour.
 \sifend



 \sifitemnt{Solver}{solver id}
\sifbegin
%
\sifitemnt{Equation}{= String  [AIFlow]}

\sifitemnt{Variable}{= String  [AIFlow]}

\sifitem{Variable DOFs}{= Integer  [3 in 2D and 4 in 3D]}
%
It is important to give the DOFs right~: in 2D (plane strain or axisymmetric) the variables are  $u_1$, $u_2$ and $p$
and in 3D they are $u_1$, $u_2$, $u_3$ and $p$.



  \sifend
 The following variables can be exported~:
 \sifbegin
 \sifitemnt{Exported Variable 1}{= String  [StrainRate]}
 \sifitem{Exported Variable 1 DOFS}{= Integer [4 in 2D and 6 in 3D]}
%
 The strain-rate (in 2D~: $[d_{11}, d_{22}, d_{33},
d_{12}]$ and in 3D~: $[d_{11}, d_{22}, d_{33}, d_{12}, d_{23}, d_{31}]$).
 \sifend

%
 \sifbegin
 \sifitemnt{Exported Variable 2}{= String  [DevStress]}
 \sifitem{Exported Variable 2 DOFS}{= Integer [4 in 2D and 6 in 3D]}
%
The deviatoric stress (in 2D~: $[s_{11}, s_{22}, s_{33}, s_{12}]$ and in 3D~: $[s_{11}, s_{22}, s_{33}, s_{12}, s_{23},
s_{31}]$).
 \sifend

%
 \sifbegin
 \sifitemnt{Exported Variable 3}{= String  [Spin]}
 \sifitem{Exported Variable 3 DOFS}{ = Integer [1 in 2D and 3 in 3D]}
%
 The spin (in 2D~: $[w_{12}]$ and in 3D~: $[w_{12}, w_{23}, w_{31}]$).

\sifend


\sifitemnt{Body Force}{bd id}


The body force section is used to specify a body force (gravity for example).
 \sifbegin
 \sifitem{AIFlow Force i}{= Real }
%
A body force in the given direction $i=1,2,3$. Contrary to the Navier-Stokes Solver, the AIFlow Force is not multiplied
by the density (You have to give here directly $\rho \times g$).
 \sifend


\sifitemnt{Initial Condition}{ic id}


The initial condition section may be used to set initial values for the field variables. The following variables are
active (assuming that both the Fabric and Heat Equation solvers are declared):
 \sifbegin
 \sifitemnt{Temperature}{= Real }
 \sifitem{Fabric i}{= Real }
%
 For each of the Fabric Solver variables $i=1,2,3,4,5$ ($[a_1 , a_2 , \theta, \phi, \omega]$). For isotropic ice,
 $a_1=a_2=1/3$ and $\theta=\phi=\omega=0$.

 \sifitem{AIFlow i}{= Real }
%
or each of the AIFlow Solver variables (in 2D (plane strain or axisymmetric) the vector variables is $[u_1, u_2, p]$
and in 3D it is $[u_1, u_2, u_3, p]$).
%
 \sifend

 \sifitemnt{Boundary Condition}{bc id}
\sifbegin

\sifitem{AIFlow i}{= Real }
%
Dirichlet boundary conditions for each of the variables (in 2D (plane strain or axisymmetric) the vector variables is
$[u_1, u_2, p]$ and in 3D it is $[u_1, u_2, u_3, p]$).
%
\sifitem{Normal-Tangential AIFlow}{= Logical }
%
Velocity may be given in normal-tangential coordinate system.

\sifitem{Force i}{= Real }
%
A pressure force in the given direction $i=1,2,3$.

\sifitem{Normal Force }{= Real }
%
A pressure boundary condition directed normal to the surface.
%
\sifitem{AIFlow Slip Coeff i}{= Real }
%
Used to prescribe a sliding boundary condition of the form $C_i u_i = \sigma_{ij}n_j$ where $\Mat{n}$ is the surface normal vector.
\sifend

\sifbegin
%
\sifitemnt{Periodic BC}{= [number of the other boundary] }

\sifitemnt{Periodic BC Rotate (3)}{=   [x y z]}
%
 \sifitemnt{Periodic BC Scale (3)}{=   [x y z]}
%
\sifitemnt{Periodic BC NameVariable}{= Logical }
%
\sifitem{Anti Periodic BC NameVariable}{= Logical }
%
Translate, rotate, scale the other boundary so that it will be placed on top of this boundary. After the transformation
the boundary meshes must match (same number of points, same locations). Finally give names of the variables that are
periodic or anti-periodic.



  \sifend

 \sifend
