Peano 4
Loading...
Searching...
No Matches
CurvilinearDerivatives.h
Go to the documentation of this file.
1#ifndef EXASEIS_TEMPLATE_CURVILINEAR_DERIVATIVES
2#define EXASEIS_TEMPLATE_CURVILINEAR_DERIVATIVES
3// #include "kernels/KernelUtils.h"
5
6namespace ExaSeis {
7 template <class Shortcuts, int num_nodes>
8 class Derivatives {
9 public:
10 static void metricDerivatives(
11 double dudx[][num_nodes], const double* const coordinates, const double* const dx, double* derivatives
12 ) {
13 Shortcuts s;
14
15 double x_der_x, x_der_y, x_der_z;
16 double y_der_x, y_der_y, y_der_z;
17 double z_der_x, z_der_y, z_der_z;
18
19 kernels::idx4 id_der(num_nodes, num_nodes, num_nodes, 10);
20
21 for (int k = 0; k < num_nodes; k++) {
22 for (int j = 0; j < num_nodes; j++) {
23 for (int i = 0; i < num_nodes; i++) {
24
25 computeDerivatives_x_3D(dudx, k, j, i, coordinates, s.curve_grid + 0, x_der_x, dx[0]);
26 computeDerivatives_y_3D(dudx, k, j, i, coordinates, s.curve_grid + 0, x_der_y, dx[1]);
27 computeDerivatives_z_3D(dudx, k, j, i, coordinates, s.curve_grid + 0, x_der_z, dx[2]);
28 computeDerivatives_x_3D(dudx, k, j, i, coordinates, s.curve_grid + 1, y_der_x, dx[0]);
29 computeDerivatives_y_3D(dudx, k, j, i, coordinates, s.curve_grid + 1, y_der_y, dx[1]);
30 computeDerivatives_z_3D(dudx, k, j, i, coordinates, s.curve_grid + 1, y_der_z, dx[2]);
31 computeDerivatives_x_3D(dudx, k, j, i, coordinates, s.curve_grid + 2, z_der_x, dx[0]);
32 computeDerivatives_y_3D(dudx, k, j, i, coordinates, s.curve_grid + 2, z_der_y, dx[1]);
33 computeDerivatives_z_3D(dudx, k, j, i, coordinates, s.curve_grid + 2, z_der_z, dx[2]);
34
35 double jacobian = x_der_x * (y_der_y * z_der_z - y_der_z * z_der_y)
36 - x_der_y * (y_der_x * z_der_z - y_der_z * z_der_x)
37 + x_der_z * (y_der_x * z_der_y - y_der_y * z_der_x);
38
39 derivatives[id_der(k, j, i, 0)] = jacobian;
40 derivatives[id_der(k, j, i, 1)] = (1.0 / jacobian) * (y_der_y * z_der_z - z_der_y * y_der_z);
41 derivatives[id_der(k, j, i, 4)] = (1.0 / jacobian) * (z_der_x * y_der_z - y_der_x * z_der_z);
42 derivatives[id_der(k, j, i, 7)] = (1.0 / jacobian) * (y_der_x * z_der_y - z_der_x * y_der_y);
43
44 derivatives[id_der(k, j, i, 2)] = (1.0 / jacobian) * (z_der_y * x_der_z - x_der_y * z_der_z);
45 derivatives[id_der(k, j, i, 5)] = (1.0 / jacobian) * (x_der_x * z_der_z - z_der_x * x_der_z);
46 derivatives[id_der(k, j, i, 8)] = (1.0 / jacobian) * (z_der_x * x_der_y - x_der_x * z_der_y);
47
48 derivatives[id_der(k, j, i, 3)] = (1.0 / jacobian) * (x_der_y * y_der_z - y_der_y * x_der_z);
49 derivatives[id_der(k, j, i, 6)] = (1.0 / jacobian) * (y_der_x * x_der_z - x_der_x * y_der_z);
50 derivatives[id_der(k, j, i, 9)] = (1.0 / jacobian) * (x_der_x * y_der_y - y_der_x * x_der_y);
51 }
52 }
53 }
54 }
55
56 private:
58 double dudx[][num_nodes], int k, int j, int i, const double* values, int coordinate, double& der_x, const double dx
59 ) {
60 Shortcuts s;
61
62 kernels::idx4 id_xyz(num_nodes, num_nodes, num_nodes, s.Size);
63 der_x = 0.0;
64 for (int n = 0; n < num_nodes; n++) {
65 der_x += dudx[i][n] * values[id_xyz(k, j, n, coordinate)] / dx;
66 }
67 }
68
70 double dudx[][num_nodes], int k, int j, int i, const double* values, int coordinate, double& der_y, const double dy
71 ) {
72 Shortcuts s;
73 kernels::idx4 id_xyz(num_nodes, num_nodes, num_nodes, s.Size);
74 der_y = 0.0;
75 for (int n = 0; n < num_nodes; n++) {
76 der_y += dudx[j][n] * values[id_xyz(k, n, i, coordinate)] / dy;
77 }
78 }
79
81 double dudx[][num_nodes], int k, int j, int i, const double* values, int coordinate, double& der_z, const double dz
82 ) {
83 Shortcuts s;
84 kernels::idx4 id_xyz(num_nodes, num_nodes, num_nodes, s.Size);
85
86 der_z = 0.0;
87 for (int n = 0; n < num_nodes; n++) {
88 der_z += dudx[k][n] * values[id_xyz(n, j, i, coordinate)] / dz;
89 }
90 }
91 };
92} // namespace ExaSeis
93
94#endif
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ our matrix elements will nabla phi_i dx f By this will be a sparse as these basis functions are chosen to not overlap with each other almost everywhere In other they have only local support We can read off the right hand side values
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ j
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ k
we integrate over each cell and then take the sum across each of the cells We also consider the terms that enter the f$ so we are integrating with f$ phi_k phi_k dx
static void computeDerivatives_z_3D(double dudx[][num_nodes], int k, int j, int i, const double *values, int coordinate, double &der_z, const double dz)
static void computeDerivatives_x_3D(double dudx[][num_nodes], int k, int j, int i, const double *values, int coordinate, double &der_x, const double dx)
static void computeDerivatives_y_3D(double dudx[][num_nodes], int k, int j, int i, const double *values, int coordinate, double &der_y, const double dy)
static void metricDerivatives(double dudx[][num_nodes], const double *const coordinates, const double *const dx, double *derivatives)
examples::exahype2::elastic::VariableShortcuts s
Definition loh.cpp:10