(section:generalCoord)=
# General Element Coordinate System

The [input deck](/tests/Salinas_rtest/training/exampleproblem/material/generalCoord/coord.inp) for this model is attached. Orthotropic materials, such as fiber reinforced
composites, are common structural materials. In some cases the orthotropic directions align with simple geometric
shapes such as cylinders or spheres. In those cases the coordinate system can be defined via cylindrical, spherical,
rectangular, or other simple coordinate systems. However, in general cases the coordinate system will have
no such simple alignment. In this case an element-by-element coordinate system can be defined in the
mesh file and then used for the coordinate system.

An extremely common case is orthotropic directions that line up with the geometry of the body. For example
fiber reinforced composites that wrap around the exterior of a shape. A python script exists to define coordinate
systems for this case, and is demonstrated in this example along with the Sierra/SD inputs to use those directions.

The [mesh geometry](/tests/Salinas_rtest/training/exampleproblem/material/generalCoord/turbine_section.g) is shown in Figure {numref}`%s <fig:generalCoordGeom>`. Block 1 will be an orthotropic material with its coordinate
system aligned with the exterior boundary. The 'elemToSidesetDirections.py' script will setup the coordinate system
via:

:::{command}
export PATH=/projects/sierra/toolset/5.22/contrib/testTools/adagio/:$PATH
elemToSidesetDirections.py --input turbine_section.g \
                           --output turbine_section_coord.g \
                           --blocks 1 --sideset 1 --variable matCoord \
                           --zdir 0 0 1
:::

:::{subfigure} AB
:subcaptions: below
:name: fig:generalCoordGeom

![](coord_geom.png)
![](coord_sideset.png)

Mesh Geometry. Block 1 in lavender (left) sideset 1 in red (right.)
:::

This script uses exodus.py to populate an element coordinate system on block 1 such that at each element the local X
direction points towards the sideset, the local Z direction is orthogonal to X and points towards the provided
zdir, and the local Y direction is the remaining orthogonal direction. The three direction vectors will be output
per element in the matCoord_1, matCoord_2, and matCoord_3 variables, as shown in Figure {numref}`%s <fig:generalCoordSystem>`.

:::{figure-md} fig:generalCoordSystem

![](coord_system.png)

Coordinate system vectors X (red), Y(green), and Z(blue.)
:::

The coordinate system is imported form the mesh file by populating the internal variables `material_direction_1`, `material_direction_2`,
and `material_direction_3` via:

:::{input}
geometry_file turbine_section_coord.g
  initialize variable name = material_direction_1
   read variable = matCoord_2_
    variable type = element
  initialize variable name = material_direction_2
    read variable = matCoord_1_
    variable type = element
  initialize variable name = material_direction_3
    read variable = matCoord_3_
    variable type = element
:::

And then those imported coordinate directions are used by the element via:

:::{input}
coordinate from_transfer
:::

In this case the orthotropic material represents carbon reinforced composite and has a strong "E1" axis of the material.
This strong E1 axis is aligned with the local Y coordinate system defined in the mesh file giving a strong
axis that wraps around the wing structure. A modal solution
is then solved. In the Eigen output file the correct application of the material coordinate system can be confirmed
by requesting the `material_direction` output
in the OUTPUTS section.
