#. # Parametric study on a cantilevered beam
#.
#. If an external loop successively calls FeenoX with extra command-line arguments, a parametric run is obtained.
#. This file `cantilever.fee` fixes the face called "left" and sets a load in the negative\ $z$ direction
#. of a mesh called `cantilever-$1-$2.msh`, where `$1` is the first argument after the inpt file and `$2` the second one.
#. The output is a single line containing the number of nodes of the mesh and the displacement in the
#. vertical direction\ $w(500,0,0)$ at the center of the cantilever's free face.
#.
#. The following Bash script first calls Gmsh to create the meshes.
#. To do so, it first starts with a base [`cantilever.geo`](https://github.com/seamplex/feenox/blob/main/examples/cantilever.geo) file that creates the CAD:
#.
#. ```{.c include="cantilever.geo"}
#. ```
#. Then another `.geo` file is merged to build `cantilever-${element}-${c}.msh` where
#.
#.  * `${element}`: [tet4](https://github.com/seamplex/feenox/blob/main/examples/cantilever-tet4.geo),
#.                  [tet10](https://github.com/seamplex/feenox/blob/main/examples/cantilever-tet10.geo),
#.                  [hex8](https://github.com/seamplex/feenox/blob/main/examples/cantilever-hex8.geo),
#.                  [hex20](https://github.com/seamplex/feenox/blob/main/examples/cantilever-hex20.geo),
#.                  [hex27](https://github.com/seamplex/feenox/blob/main/examples/cantilever-hex27.geo)
#.  * `${c}`: 1,2,$\dots$,10
#. 
#. ::: {#fig:cantilever-mesh}
#. ![Tetrahedra](cantilever-tet.png){width=45%}
#. ![Hexahedra](cantilever-hex.png){width=45%}
#.
#. Cantilevered beam meshed with structured tetrahedra and hexahedra
#. :::
#.
#. It then calls FeenoX with the input [`cantilever.fee`](https://github.com/seamplex/feenox/blob/main/examples/cantilever.fee) and passes `${element}` and `${c}` as extra arguments, which then are expanded as `$1` and `$2` respectively.
#.
#.
#. ```{.bash include="cantilever.sh"}
#. ```
#.
#. After the execution of the Bash script, thanks to the design decision that output is 100% defined by the user
#. (in this case with the `PRINT` instruction), one has several files `cantilever-${element}.dat` files.
#. When plotted, these show the shear locking effect of fully-integrated first-order elements.
#. The theoretical Euler-Bernoulli result is just a reference as, among other things, it does not take into account the effect of the material's Poisson's ratio.
#. Note that the abscissa shows the number of _nodes_, which are proportional to the number of degrees of freedom (i.e. the size of the problem matrix)
#. and not the number of _elements_, which is irrelevant here and in most problems.
PROBLEM elastic 3D
READ_MESH cantilever-$1-$2.msh   # in meters

E = 2.1e11         # Young modulus in Pascals
nu = 0.3           # Poisson's ratio

BC left   fixed
BC right  tz=-1e5  # traction in Pascals, negative z
 
SOLVE_PROBLEM

# z-displacement (components are u,v,w) at the tip vs. number of nodes
PRINT nodes %e w(500,0,0) "\# $1 $2"

#$ $ ./cantilever.sh
#$ 102     -7.641572e-05   # tet4 1
#$ 495     -2.047389e-04   # tet4 2
#$ 1372    -3.149658e-04   # tet4 3
#$ [...]
#$ 19737   -5.916234e-04   # hex27 8
#$ 24795   -5.916724e-04   # hex27 9
#$ 37191   -5.917163e-04   # hex27 10
#$ $ pyxplot cantilever.ppl
#> ![Displacement at the free tip of a cantilevered beam vs. number of nodes for different element types](cantilever-displacement.svg){width=100%}
