specfem::jacobian¶
-
namespace jacobian¶
The jacobian namespace contains functions for computing the Jacobian matrix and global coordinates from local coordinates.
specfem::jacobian::compute_locations¶
2D Overload¶
-
specfem::point::global_coordinates<specfem::element::dimension_tag::dim2> specfem::jacobian::compute_locations(const Kokkos::View<specfem::point::global_coordinates<specfem::element::dimension_tag::dim2>*, Kokkos::HostSpace> &coorg, const int ngnod, const type_real xi, const type_real gamma)¶
Compute global locations \((x, z)\) from shape function matrix calculated at \((\xi, \gamma)\).
- Parameters:
coorg – Global control node locations \((x_a, z_a)\).
ngnod – Total number of control nodes per element.
xi – \(\xi\) value of the point.
gamma – \(\gamma\) value of the point.
- Returns:
specfem::point::global_coordinates<specfem::element::dimension_tag::dim2> The computed \((x, z)\) coordinates for the point.
3D Overload¶
-
specfem::point::global_coordinates<specfem::element::dimension_tag::dim3> specfem::jacobian::compute_locations(const Kokkos::View<specfem::point::global_coordinates<specfem::element::dimension_tag::dim3>*, Kokkos::HostSpace> &coorg, const int ngnod, const type_real xi, const type_real eta, const type_real gamma)¶
Compute global locations \((x, y, z)\) from shape function matrix calculated at \((\xi, \eta, \gamma)\).
- Parameters:
coorg – Global control node locations.
ngnod – Total number of control nodes per element.
xi – \(\xi\) value of the point.
eta – \(\eta\) value of the point.
gamma – \(\gamma\) value of the point.
- Returns:
specfem::point::global_coordinates<specfem::element::dimension_tag::dim3> The computed \((x, y, z)\) coordinates.
specfem::jacobian::compute_jacobian¶
2D Overloads¶
-
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim2, true, false> specfem::jacobian::compute_jacobian(const Kokkos::View<specfem::point::global_coordinates<specfem::element::dimension_tag::dim2>*, Kokkos::HostSpace> &coorg, const int ngnod, const type_real xi, const type_real gamma)¶
Compute Jacobian matrix at reference coordinates \((\xi, \gamma)\).
Calculates the inverse partial derivatives (metrics) and the determinant of the Jacobian.
The Jacobian matrix \( \mathbf{J} \) is defined as:
\[\begin{split} \mathbf{J} = \begin{pmatrix} \frac{\partial x}{\partial \xi} & \frac{\partial x}{\partial \gamma} \\ \frac{\partial z}{\partial \xi} & \frac{\partial z}{\partial \gamma} \end{pmatrix} \end{split}\]The function returns the determinant \( j = \det(\mathbf{J}) \) and the terms of the inverse Jacobian:
\[\begin{split} \mathbf{J}^{-1} = \begin{pmatrix} \frac{\partial \xi}{\partial x} & \frac{\partial \xi}{\partial z} \\ \frac{\partial \gamma}{\partial x} & \frac{\partial \gamma}{\partial z} \end{pmatrix} = \frac{1}{j} \begin{pmatrix} \frac{\partial z}{\partial \gamma} & -\frac{\partial x}{\partial \gamma} \\ -\frac{\partial z}{\partial \xi} & \frac{\partial x}{\partial \xi} \end{pmatrix} \end{split}\]- Parameters:
coorg – View of coordinates required for the element.
ngnod – Total number of control nodes per element.
xi – \(\xi\) value of the point.
gamma – \(\gamma\) value of the point.
- Returns:
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim2, true, false> Structure containing partial derivatives \((\partial \xi / \partial x, \partial \gamma / \partial x, \partial \xi / \partial z, \partial \gamma / \partial z)\) and the Jacobian determinant.
-
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim2, true, false> specfem::jacobian::compute_jacobian(const Kokkos::View<specfem::point::global_coordinates<specfem::element::dimension_tag::dim2>*, Kokkos::HostSpace> &coorg, const int ngnod, const std::vector<std::vector<type_real>> &dershape2D)¶
Compute Jacobian matrix using precomputed shape function derivatives.
- Parameters:
coorg – View of coordinates required for the element.
ngnod – Total number of control nodes per element.
dershape2D – Derivative of shape function matrix.
- Returns:
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim2, true, false> Computed Jacobian matrix and determinant.
3D Overloads¶
-
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim3, true, false> specfem::jacobian::compute_jacobian(const Kokkos::View<specfem::point::global_coordinates<specfem::element::dimension_tag::dim3>*, Kokkos::HostSpace> &coorg, const int ngnod, const type_real xi, const type_real eta, const type_real gamma)¶
Compute Jacobian matrix at reference coordinates \((\xi, \eta, \gamma)\).
Calculates the inverse partial derivatives (metrics) and the determinant of the Jacobian.
The Jacobian matrix \( \mathbf{J} \) is defined as:
\[\begin{split} \mathbf{J} = \begin{pmatrix} \frac{\partial x}{\partial \xi} & \frac{\partial x}{\partial \eta} & \frac{\partial x}{\partial \gamma} \\ \frac{\partial y}{\partial \xi} & \frac{\partial y}{\partial \eta} & \frac{\partial y}{\partial \gamma} \\ \frac{\partial z}{\partial \xi} & \frac{\partial z}{\partial \eta} & \frac{\partial z}{\partial \gamma} \end{pmatrix} \end{split}\]The function returns the determinant \( j = \det(\mathbf{J}) \) and the terms of the inverse Jacobian matrix \( \mathbf{J}^{-1} \):
\[\begin{split} \mathbf{J}^{-1} = \begin{pmatrix} \frac{\partial \xi}{\partial x} & \frac{\partial \xi}{\partial y} & \frac{\partial \xi}{\partial z} \\ \frac{\partial \eta}{\partial x} & \frac{\partial \eta}{\partial y} & \frac{\partial \eta}{\partial z} \\ \frac{\partial \gamma}{\partial x} & \frac{\partial \gamma}{\partial y} & \frac{\partial \gamma}{\partial z} \end{pmatrix} = \frac{1}{j} \begin{pmatrix} \left(\frac{\partial y}{\partial \eta}\frac{\partial z}{\partial \gamma} - \frac{\partial y}{\partial \gamma}\frac{\partial z}{\partial \eta}\right) & \left(\frac{\partial x}{\partial \gamma}\frac{\partial z}{\partial \eta} - \frac{\partial x}{\partial \eta}\frac{\partial z}{\partial \gamma}\right) & \left(\frac{\partial x}{\partial \eta}\frac{\partial y}{\partial \gamma} - \frac{\partial x}{\partial \gamma}\frac{\partial y}{\partial \eta}\right) \\ \left(\frac{\partial y}{\partial \gamma}\frac{\partial z}{\partial \xi} - \frac{\partial y}{\partial \xi}\frac{\partial z}{\partial \gamma}\right) & \left(\frac{\partial x}{\partial \xi}\frac{\partial z}{\partial \gamma} - \frac{\partial x}{\partial \gamma}\frac{\partial z}{\partial \xi}\right) & \left(\frac{\partial x}{\partial \gamma}\frac{\partial y}{\partial \xi} - \frac{\partial x}{\partial \xi}\frac{\partial y}{\partial \gamma}\right) \\ \left(\frac{\partial y}{\partial \xi}\frac{\partial z}{\partial \eta} - \frac{\partial y}{\partial \eta}\frac{\partial z}{\partial \xi}\right) & \left(\frac{\partial x}{\partial \eta}\frac{\partial z}{\partial \xi} - \frac{\partial x}{\partial \xi}\frac{\partial z}{\partial \eta}\right) & \left(\frac{\partial x}{\partial \xi}\frac{\partial y}{\partial \eta} - \frac{\partial x}{\partial \eta}\frac{\partial y}{\partial \xi}\right) \end{pmatrix} \end{split}\]- Parameters:
coorg – View of coordinates required for the element.
ngnod – Total number of control nodes per element.
xi – \(\xi\) coordinate of the point.
eta – \(\eta\) coordinate of the point.
gamma – \(\gamma\) coordinate of the point.
- Returns:
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim3, true, false> Structure containing inverse partial derivatives and the Jacobian determinant.
-
template<typename CoordinateView, typename ShapeDerivativesView>
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim3, true, false> specfem::jacobian::compute_jacobian(const CoordinateView coordinates, const ShapeDerivativesView shape_derivatives)¶ Compute Jacobian matrix for 3D elements using generic views.
This function calculates the Jacobian matrix and its determinant given nodal coordinates and shape function derivatives.
- Template Parameters:
CoordinateView – Type of the coordinate view (e.g., Kokkos::View).
ShapeDerivativesView – Type of the shape function derivatives view.
- Parameters:
coordinates – View of nodal coordinates.
shape_derivatives – View of shape function derivatives.
- Returns:
specfem::point::jacobian_matrix<specfem::element::dimension_tag::dim3, true, false> Computed Jacobian matrix and determinant.