Loading...
Searching...
No Matches
integrands.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "terra/dense/mat.hpp"
5#include "terra/dense/vec.hpp"
6
7/// @namespace terra::fe::wedge
8/// @brief Features for wedge elements.
9///
10/// \section geometry Geometry
11///
12/// \f$ \xi, \eta \in [0, 1] \f$ (lateral reference coords)
13///
14/// \f$ \zeta \in [-1, 1] \f$ (radial reference coords)
15///
16/// \f$ 0 \leq \xi + \eta \leq 1 \f$
17///
18/// \section enumeration Node enumeration
19///
20/// \code
21///
22/// r_node_idx = r_cell_idx + 1 (outer):
23///
24/// 5
25/// |\
26/// | \
27/// 3--4
28/// \endcode
29///
30/// \code
31///
32/// r_node_idx = r_cell_idx (inner):
33///
34/// 2
35/// |\
36/// | \
37/// 0--1
38/// \endcode
39///
40/// \section shape Shape functions
41///
42/// Lateral:
43///
44/// \f[
45/// \begin{align}
46/// N^\mathrm{lat}_0 = N^\mathrm{lat}_3 &= 1 - \xi - \eta \\
47/// N^\mathrm{lat}_1 = N^\mathrm{lat}_4 &= \xi \\
48/// N^\mathrm{lat}_2 = N^\mathrm{lat}_5 &= \eta
49/// \end{align}
50/// \f]
51///
52/// Radial:
53///
54/// \f[
55/// \begin{align}
56/// N^\mathrm{rad}_0 = N^\mathrm{rad}_1 = N^\mathrm{rad}_2 &= \frac{1}{2} ( 1 - \zeta ) \\
57/// N^\mathrm{rad}_3 = N^\mathrm{rad}_4 = N^\mathrm{rad}_5 &= \frac{1}{2} ( 1 + \zeta ) \\
58/// \end{align}
59/// \f]
60///
61/// Full:
62///
63/// \f[
64/// N_i = N^\mathrm{lat}_i * N^\mathrm{rad}_i
65/// \f]
66///
67///
68/// \section phy Physical coordinates
69///
70/// \code
71/// r_1, r_2 radii of bottom and top (r_1 < r_2)
72/// p1_phy, p2_phy, p3_phy coords of triangle on unit sphere
73/// \endcode
74namespace terra::fe::wedge {
75
76/// @brief Radial shape function.
77///
78/// \f[
79/// \begin{align}
80/// N^\mathrm{rad}_0 = N^\mathrm{rad}_1 = N^\mathrm{rad}_2 &= \frac{1}{2} ( 1 - \zeta ) \\
81/// N^\mathrm{rad}_3 = N^\mathrm{rad}_4 = N^\mathrm{rad}_5 &= \frac{1}{2} ( 1 + \zeta ) \\
82/// \end{align}
83/// \f]
84///
85template < std::floating_point T >
86KOKKOS_INLINE_FUNCTION constexpr T shape_rad( const int node_idx, const T zeta )
87{
88 const T N_rad[2] = { static_cast< T >( 0.5 ) * ( 1 - zeta ), static_cast< T >( 0.5 ) * ( 1 + zeta ) };
89 return N_rad[node_idx / 3];
90}
91
92/// @brief Radial shape function.
93///
94/// \f[
95/// \begin{align}
96/// N^\mathrm{rad}_0 = N^\mathrm{rad}_1 = N^\mathrm{rad}_2 &= \frac{1}{2} ( 1 - \zeta ) \\
97/// N^\mathrm{rad}_3 = N^\mathrm{rad}_4 = N^\mathrm{rad}_5 &= \frac{1}{2} ( 1 + \zeta ) \\
98/// \end{align}
99/// \f]
100///
101template < std::floating_point T >
102KOKKOS_INLINE_FUNCTION constexpr T shape_rad( const int node_idx, const dense::Vec< T, 3 >& xi_eta_zeta )
103{
104 return shape_rad( node_idx, xi_eta_zeta( 2 ) );
105}
106
107/// @brief Lateral shape function.
108///
109/// \f[
110/// \begin{align}
111/// N^\mathrm{lat}_0 = N^\mathrm{lat}_3 &= 1 - \xi - \eta \\
112/// N^\mathrm{lat}_1 = N^\mathrm{lat}_4 &= \xi \\
113/// N^\mathrm{lat}_2 = N^\mathrm{lat}_5 &= \eta
114/// \end{align}
115/// \f]
116///
117template < std::floating_point T >
118KOKKOS_INLINE_FUNCTION constexpr T shape_lat( const int node_idx, const T xi, const T eta )
119{
120 const T N_lat[3] = { static_cast< T >( 1.0 ) - xi - eta, xi, eta };
121 return N_lat[node_idx % 3];
122}
123
124/// @brief Lateral shape function.
125///
126/// \f[
127/// \begin{align}
128/// N^\mathrm{lat}_0 = N^\mathrm{lat}_3 &= 1 - \xi - \eta \\
129/// N^\mathrm{lat}_1 = N^\mathrm{lat}_4 &= \xi \\
130/// N^\mathrm{lat}_2 = N^\mathrm{lat}_5 &= \eta
131/// \end{align}
132/// \f]
133///
134template < std::floating_point T >
135KOKKOS_INLINE_FUNCTION constexpr T shape_lat( const int node_idx, const dense::Vec< T, 3 >& xi_eta_zeta )
136{
137 return shape_lat( node_idx, xi_eta_zeta( 0 ), xi_eta_zeta( 1 ) );
138}
139
140/// @brief (Tensor-product) Shape function.
141/// \f[
142/// N_i = N^\mathrm{lat}_i * N^\mathrm{rad}_i
143/// \f]
144///
145template < std::floating_point T >
146KOKKOS_INLINE_FUNCTION constexpr T shape( const int node_idx, const T xi, const T eta, const T zeta )
147{
148 return shape_lat( node_idx, xi, eta ) * shape_rad( node_idx, zeta );
149}
150
151/// @brief (Tensor-product) Shape function.
152/// \f[
153/// N_i = N^\mathrm{lat}_i * N^\mathrm{rad}_i
154/// \f]
155///
156template < std::floating_point T >
157KOKKOS_INLINE_FUNCTION constexpr T shape( const int node_idx, const dense::Vec< T, 3 >& xi_eta_zeta )
158{
159 return shape_lat( node_idx, xi_eta_zeta ) * shape_rad( node_idx, xi_eta_zeta );
160}
161
162/// @brief Gradient of the radial part of the shape function, in the radial direction
163/// \f$ \frac{\partial}{\partial \zeta} N^\mathrm{rad}_j \f$
164///
165/// This is different from the radial part of the gradient of the full shape function!
166///
167/// That would be
168///
169/// \f$ \frac{\partial}{\partial \zeta} N_j = N^\mathrm{lat}_j \frac{\partial}{\partial \zeta} N^\mathrm{rad}_j \f$
170///
171template < std::floating_point T >
172KOKKOS_INLINE_FUNCTION constexpr T grad_shape_rad( const int node_idx )
173{
174 constexpr T grad_N_rad[2] = { -0.5, 0.5 };
175 return grad_N_rad[node_idx / 3];
176}
177
178/// @brief Gradient of the lateral part of the shape function, in xi direction
179/// \f$ \frac{\partial}{\partial \xi} N^\mathrm{lat}_j \f$
180///
181/// This is different from the \f$ \xi \f$ part (first entry) of the gradient of the full shape function!
182///
183/// That would be
184///
185/// \f$ \frac{\partial}{\partial \xi} N_j = N^\mathrm{rad}_j \frac{\partial}{\partial \xi} N^\mathrm{lat}_j \f$
186///
187template < std::floating_point T >
188KOKKOS_INLINE_FUNCTION constexpr T grad_shape_lat_xi( const int node_idx )
189{
190 constexpr T grad_N_lat_xi[3] = { -1.0, 1.0, 0.0 };
191 return grad_N_lat_xi[node_idx % 3];
192}
193
194/// @brief Gradient of the lateral part of the shape function, in eta direction
195/// \f$ \frac{\partial}{\partial \eta} N^\mathrm{lat}_j \f$
196///
197/// This is different from the \f$ \eta \f$ part (second entry) of the gradient of the full shape function!
198///
199/// That would be
200///
201/// \f$ \frac{\partial}{\partial \eta} N_j = N^\mathrm{rad}_j \frac{\partial}{\partial \eta} N^\mathrm{lat}_j \f$
202///
203template < std::floating_point T >
204KOKKOS_INLINE_FUNCTION constexpr T grad_shape_lat_eta( const int node_idx )
205{
206 constexpr T grad_N_lat_eta[3] = { -1.0, 0.0, 1.0 };
207 return grad_N_lat_eta[node_idx % 3];
208}
209
210/// @brief Gradient of the full shape function:
211///
212/// \f[
213/// \nabla N_j =
214/// \begin{bmatrix}
215/// \frac{\partial}{\partial \xi} N_j \\
216/// \frac{\partial}{\partial \eta} N_j \\
217/// \frac{\partial}{\partial \zeta} N_j
218/// \end{bmatrix}
219/// =
220/// \begin{bmatrix}
221/// N^\mathrm{rad}_j \frac{\partial}{\partial \xi} N^\mathrm{lat}_j \\
222/// N^\mathrm{rad}_j \frac{\partial}{\partial \eta} N^\mathrm{lat}_j \\
223/// N^\mathrm{lat}_j \frac{\partial}{\partial \zeta} N^\mathrm{rad}_j
224/// \end{bmatrix}
225/// \f]
226template < std::floating_point T >
227KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 >
228 grad_shape( const int node_idx, const T xi, const T eta, const T zeta )
229{
230 dense::Vec< T, 3 > grad_N;
231 grad_N( 0 ) = grad_shape_lat_xi< T >( node_idx ) * shape_rad( node_idx, zeta );
232 grad_N( 1 ) = grad_shape_lat_eta< T >( node_idx ) * shape_rad( node_idx, zeta );
233 grad_N( 2 ) = shape_lat( node_idx, xi, eta ) * grad_shape_rad< T >( node_idx );
234 return grad_N;
235}
236
237/// @brief Gradient of the full shape function:
238///
239/// \f[
240/// \nabla N_j =
241/// \begin{bmatrix}
242/// \frac{\partial}{\partial \xi} N_j \\
243/// \frac{\partial}{\partial \eta} N_j \\
244/// \frac{\partial}{\partial \zeta} N_j
245/// \end{bmatrix}
246/// =
247/// \begin{bmatrix}
248/// N^\mathrm{rad}_j \frac{\partial}{\partial \xi} N^\mathrm{lat}_j \\
249/// N^\mathrm{rad}_j \frac{\partial}{\partial \eta} N^\mathrm{lat}_j \\
250/// N^\mathrm{lat}_j \frac{\partial}{\partial \zeta} N^\mathrm{rad}_j
251/// \end{bmatrix}
252/// \f]
253template < std::floating_point T >
254KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 >
255 grad_shape( const int node_idx, const dense::Vec< T, 3 >& xi_eta_zeta )
256{
257 return grad_shape( node_idx, xi_eta_zeta( 0 ), xi_eta_zeta( 1 ), xi_eta_zeta( 2 ) );
258}
259
260/// @brief Returns the coarse grid radial shape function evaluated at a point of the reference fine grid wedge.
261///
262/// @param coarse_node_idx wedge node index of the coarse grid shape function ("which coarse grid shape function to
263/// evaluate") (in {0, ..., 5})
264/// @param fine_radial_wedge_idx 0 for inner fine wedge, 1 for outer fine wedge
265/// @param zeta_fine coordinate in the reference fine-wedge (in [-1, 1])
266template < std::floating_point T >
267KOKKOS_INLINE_FUNCTION constexpr T
268 shape_rad_coarse( const int coarse_node_idx, const int fine_radial_wedge_idx, const T zeta_fine )
269{
270 switch ( coarse_node_idx / 3 )
271 {
272 case 0:
273 switch ( fine_radial_wedge_idx )
274 {
275 case 0:
276 // coarse node at bottom (in {0, 1, 2}), evaluated in bottom fine wedge
277 // 0.5 at 1
278 // 1 at -1,
279 return 0.25 * ( 3 - zeta_fine );
280 case 1:
281 // coarse node at bottom (in {0, 1, 2}), evaluated in top fine wedge
282 // 0 at 1
283 // 0.5 at -1,
284 return 0.25 * ( 1 - zeta_fine );
285 default:
286 return 0.0;
287 }
288 case 1:
289 switch ( fine_radial_wedge_idx )
290 {
291 case 0:
292 // coarse node at top (in {3, 4, 5}), evaluated in bottom fine wedge
293 // 0.5 at 1
294 // 0 at -1,
295 return 0.25 * ( 1 + zeta_fine );
296 case 1:
297 // coarse node at top (in {3, 4, 5}), evaluated in top fine wedge
298 // 1 at 1
299 // 0.5 at -1
300 return 0.25 * ( 3 + zeta_fine );
301 default:
302 return 0.0;
303 }
304 default:
305 return 0.0;
306 }
307}
308
309/// @brief Returns the coarse grid lateral shape function evaluated at a point of the reference fine grid wedge.
310///
311/// @param coarse_node_idx wedge node index of the coarse grid shape function ("which coarse grid shape function
312/// to evaluate") (in {0, ..., 5})
313/// @param fine_lateral_wedge_idx index of the lateral wedge index in a (once) refined coarse mesh, in {0, 1, 2, 3}
314/// 0: bottom left triangle (orientation up)
315/// 1: bottom right triangle (orientation: up)
316/// 2: top triangle (orientation: up)
317/// 3: center triangle (orientation: down)
318/// @param xi_fine xi-coordinate in the reference fine-wedge (in [0, 1])
319/// @param eta_fine eta-coordinate in the reference fine-wedge (in [0, 1])
320template < std::floating_point T >
321KOKKOS_INLINE_FUNCTION constexpr T
322 shape_lat_coarse( const int coarse_node_idx, const int fine_lateral_wedge_idx, const T xi_fine, const T eta_fine )
323{
324 switch ( coarse_node_idx % 3 )
325 {
326 case 0:
327 switch ( fine_lateral_wedge_idx )
328 {
329 case 0:
330 return -0.5 * eta_fine - 0.5 * xi_fine + 1.0;
331 case 1:
332 return -0.5 * eta_fine - 0.5 * xi_fine + 0.5;
333 case 2:
334 return -0.5 * eta_fine - 0.5 * xi_fine + 0.5;
335 case 3:
336 return 0.5 * eta_fine + 0.5 * xi_fine;
337 default:
338 return 0.0;
339 }
340 case 1:
341 switch ( fine_lateral_wedge_idx )
342 {
343 case 0:
344 return 0.5 * xi_fine;
345 case 1:
346 return 0.5 * xi_fine + 0.5;
347 case 2:
348 return 0.5 * xi_fine;
349 case 3:
350 return 0.5 - 0.5 * xi_fine;
351 default:
352 return 0.0;
353 }
354 case 2:
355 switch ( fine_lateral_wedge_idx )
356 {
357 case 0:
358 return 0.5 * eta_fine;
359 case 1:
360 return 0.5 * eta_fine;
361 case 2:
362 return 0.5 * eta_fine + 0.5;
363 case 3:
364 return 0.5 - 0.5 * eta_fine;
365 default:
366 return 0.0;
367 }
368 default:
369 return 0.0;
370 }
371}
372template < std::floating_point T >
373KOKKOS_INLINE_FUNCTION constexpr T shape_coarse(
374 const int coarse_node_idx,
375 const int fine_radial_wedge_idx,
376 const int fine_lateral_wedge_idx,
377 const T xi_fine,
378 const T eta_fine,
379 const T zeta_fine )
380{
381 return shape_lat_coarse( coarse_node_idx, fine_lateral_wedge_idx, xi_fine, eta_fine ) *
382 shape_rad_coarse( coarse_node_idx, fine_radial_wedge_idx, zeta_fine );
383}
384template < std::floating_point T >
385KOKKOS_INLINE_FUNCTION constexpr T shape_coarse(
386 const int coarse_node_idx,
387 const int fine_radial_wedge_idx,
388 const int fine_lateral_wedge_idx,
389 const dense::Vec< T, 3 >& xi_eta_zeta_fine )
390{
391 return shape_lat_coarse( coarse_node_idx, fine_lateral_wedge_idx, xi_eta_zeta_fine( 0 ), xi_eta_zeta_fine( 1 ) ) *
392 shape_rad_coarse( coarse_node_idx, fine_radial_wedge_idx, xi_eta_zeta_fine( 2 ) );
393}
394template < std::floating_point T >
395KOKKOS_INLINE_FUNCTION constexpr T grad_shape_rad_coarse( const int coarse_node_idx, const int fine_radial_wedge_idx )
396{
397 switch ( coarse_node_idx / 3 )
398 {
399 case 0:
400 switch ( fine_radial_wedge_idx )
401 {
402 case 0:
403 // coarse node at bottom (in {0, 1, 2}), evaluated in bottom fine wedge
404 // 0.5 at 1
405 // 1 at -1,
406 return -0.25;
407 case 1:
408 // coarse node at bottom (in {0, 1, 2}), evaluated in top fine wedge
409 // 0 at 1
410 // 0.5 at -1,
411 return -0.25;
412 default:
413 return 0.0;
414 }
415 case 1:
416 switch ( fine_radial_wedge_idx )
417 {
418 case 0:
419 // coarse node at top (in {3, 4, 5}), evaluated in bottom fine wedge
420 // 0.5 at 1
421 // 0 at -1,
422 return 0.25;
423 case 1:
424 // coarse node at top (in {3, 4, 5}), evaluated in top fine wedge
425 // 1 at 1
426 // 0.5 at -1
427 return 0.25;
428 default:
429 return 0.0;
430 }
431 default:
432 return 0.0;
433 }
434}
435template < std::floating_point T >
436KOKKOS_INLINE_FUNCTION constexpr T
437 grad_shape_lat_coarse_xi( const int coarse_node_idx, const int fine_lateral_wedge_idx )
438{
439 // derivatives in xi_fine direction
440 switch ( coarse_node_idx % 3 )
441 {
442 case 0:
443 switch ( fine_lateral_wedge_idx )
444 {
445 case 0:
446 return -0.5;
447 case 1:
448 return -0.5;
449 case 2:
450 return -0.5;
451 case 3:
452 return 0.5;
453 default:
454 return 0.0;
455 }
456 case 1:
457 switch ( fine_lateral_wedge_idx )
458 {
459 case 0:
460 return 0.5;
461 case 1:
462 return 0.5;
463 case 2:
464 return 0.5;
465 case 3:
466 return -0.5;
467 default:
468 return 0.0;
469 }
470 case 2:
471 switch ( fine_lateral_wedge_idx )
472 {
473 case 0:
474 return 0;
475 case 1:
476 return 0;
477 case 2:
478 return 0;
479 case 3:
480 return 0;
481 default:
482 return 0.0;
483 }
484 default:
485 return 0.0;
486 }
487}
488
489template < std::floating_point T >
490KOKKOS_INLINE_FUNCTION constexpr T
491 grad_shape_lat_coarse_eta( const int coarse_node_idx, const int fine_lateral_wedge_idx )
492{
493 // derivatives in eta_fine direction
494 switch ( coarse_node_idx % 3 )
495 {
496 case 0:
497 switch ( fine_lateral_wedge_idx )
498 {
499 case 0:
500 return -0.5;
501 case 1:
502 return -0.5;
503 case 2:
504 return -0.5;
505 case 3:
506 return 0.5;
507 default:
508 return 0.0;
509 }
510 case 1:
511 switch ( fine_lateral_wedge_idx )
512 {
513 case 0:
514 return 0;
515 case 1:
516 return 0;
517 case 2:
518 return 0;
519 case 3:
520 return 0;
521 default:
522 return 0.0;
523 }
524 case 2:
525 switch ( fine_lateral_wedge_idx )
526 {
527 case 0:
528 return 0.5;
529 case 1:
530 return 0.5;
531 case 2:
532 return 0.5;
533 case 3:
534 return -0.5;
535 default:
536 return 0.0;
537 }
538 default:
539 return 0.0;
540 }
541}
542
543template < std::floating_point T >
544KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > grad_shape_coarse(
545 const int node_idx,
546 const int fine_radial_wedge_idx,
547 const int fine_lateral_wedge_idx,
548 const T xi,
549 const T eta,
550 const T zeta )
551{
552 dense::Vec< T, 3 > grad_N;
553 grad_N( 0 ) = grad_shape_lat_coarse_xi< T >( node_idx, fine_lateral_wedge_idx ) *
554 shape_rad_coarse( node_idx, fine_radial_wedge_idx, zeta );
555 grad_N( 1 ) = grad_shape_lat_coarse_eta< T >( node_idx, fine_lateral_wedge_idx ) *
556 shape_rad_coarse( node_idx, fine_radial_wedge_idx, zeta );
557 grad_N( 2 ) = shape_lat_coarse( node_idx, fine_lateral_wedge_idx, xi, eta ) *
558 grad_shape_rad_coarse< T >( node_idx, fine_radial_wedge_idx );
559 return grad_N;
560}
561
562template < std::floating_point T >
563KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > grad_shape_coarse(
564 const int node_idx,
565 const int fine_radial_wedge_idx,
566 const int fine_lateral_wedge_idx,
567 const dense::Vec< T, 3 >& xi_eta_zeta_fine )
568{
569 return grad_shape_coarse(
570 node_idx,
571 fine_radial_wedge_idx,
573 xi_eta_zeta_fine( 0 ),
574 xi_eta_zeta_fine( 1 ),
575 xi_eta_zeta_fine( 2 ) );
576}
577
578template < std::floating_point T >
579KOKKOS_INLINE_FUNCTION constexpr T forward_map_rad( const T r_1, const T r_2, const T zeta )
580{
581 return r_1 + 0.5 * ( r_2 - r_1 ) * ( 1 + zeta );
582}
583
584template < std::floating_point T >
585KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > forward_map_lat(
586 const dense::Vec< T, 3 >& p1_phy,
587 const dense::Vec< T, 3 >& p2_phy,
588 const dense::Vec< T, 3 >& p3_phy,
589 const T xi,
590 const T eta )
591{
592 return ( 1 - xi - eta ) * p1_phy + xi * p2_phy + eta * p3_phy;
593}
594
595template < std::floating_point T >
596KOKKOS_INLINE_FUNCTION constexpr T grad_forward_map_rad( const T r_1, const T r_2 )
597{
598 return 0.5 * ( r_2 - r_1 );
599}
600
601template < std::floating_point T >
602KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > grad_forward_map_lat_xi(
603 const dense::Vec< T, 3 >& p1_phy,
604 const dense::Vec< T, 3 >& p2_phy,
605 const dense::Vec< T, 3 >& /* p3_phy */ )
606{
607 return p2_phy - p1_phy;
608}
609
610template < std::floating_point T >
611KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > grad_forward_map_lat_eta(
612 const dense::Vec< T, 3 >& p1_phy,
613 const dense::Vec< T, 3 >& /* p2_phy */,
614 const dense::Vec< T, 3 >& p3_phy )
615{
616 return p3_phy - p1_phy;
617}
618
619template < std::floating_point T >
620KOKKOS_INLINE_FUNCTION constexpr dense::Mat< T, 3, 3 > jac_lat(
621 const dense::Vec< T, 3 >& p1_phy,
622 const dense::Vec< T, 3 >& p2_phy,
623 const dense::Vec< T, 3 >& p3_phy,
624 const T xi,
625 const T eta )
626{
627 const auto col_0 = grad_forward_map_lat_xi( p1_phy, p2_phy, p3_phy );
628 const auto col_1 = grad_forward_map_lat_eta( p1_phy, p2_phy, p3_phy );
629 const auto col_2 = forward_map_lat( p1_phy, p2_phy, p3_phy, xi, eta );
630 return dense::Mat< T, 3, 3 >::from_col_vecs( col_0, col_1, col_2 );
631}
632
633template < std::floating_point T >
634KOKKOS_INLINE_FUNCTION constexpr dense::Vec< T, 3 > jac_rad( const T r_1, const T r_2, const T zeta )
635{
636 const auto r = forward_map_rad( r_1, r_2, zeta );
637 const auto grad_r = grad_forward_map_rad( r_1, r_2 );
638 return dense::Vec< T, 3 >{ r, r, grad_r };
639}
640
641template < std::floating_point T >
642KOKKOS_INLINE_FUNCTION constexpr dense::Mat< T, 3, 3 >
643 jac( const dense::Vec< T, 3 >& p1_phy,
644 const dense::Vec< T, 3 >& p2_phy,
645 const dense::Vec< T, 3 >& p3_phy,
646 const T r_1,
647 const T r_2,
648 const T xi,
649 const T eta,
650 const T zeta )
651{
652 return jac_lat( p1_phy, p2_phy, p3_phy, xi, eta ) *
654}
655
656template < std::floating_point T >
657KOKKOS_INLINE_FUNCTION constexpr dense::Mat< T, 3, 3 >
658 jac( const dense::Vec< T, 3 > p_phy[3], const T r_1, const T r_2, const dense::Vec< T, 3 >& xi_eta_zeta_fine )
659{
660 return jac(
661 p_phy[0], p_phy[1], p_phy[2], r_1, r_2, xi_eta_zeta_fine( 0 ), xi_eta_zeta_fine( 1 ), xi_eta_zeta_fine( 2 ) );
662}
663
664/// @brief Returns the symmetric gradient of the shape function of a dof at a quadrature point.
665///
666/// @param J_inv_transposed inverse transposed jacobian to map to physical element
667/// @param quad_point quadrature point on the reference element
668/// @param dof local index of the shape function a wedge
669/// @param dim dimension of the vectorial shape function, of which the gradient should be computed
670template < std::floating_point T >
671KOKKOS_INLINE_FUNCTION constexpr dense::Mat< T, 3, 3 > symmetric_grad(
672 const dense::Mat< T, 3, 3 >& J_inv_transposed,
673 const dense::Vec< T, 3 >& quad_point,
674 const int dof,
675 const int dim )
676{
678 J_inv_transposed * dense::Mat< T, 3, 3 >::from_single_col_vec( grad_shape( dof, quad_point ), dim );
679 return ( grad + grad.transposed() ) * 0.5;
680}
681
682} // namespace terra::fe::wedge
Features for wedge elements.
constexpr T grad_shape_lat_xi(const int node_idx)
Gradient of the lateral part of the shape function, in xi direction .
Definition integrands.hpp:188
constexpr T grad_shape_lat_coarse_eta(const int coarse_node_idx, const int fine_lateral_wedge_idx)
Definition integrands.hpp:491
constexpr dense::Vec< T, 3 > forward_map_lat(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &p2_phy, const dense::Vec< T, 3 > &p3_phy, const T xi, const T eta)
Definition integrands.hpp:585
constexpr dense::Vec< T, 3 > grad_forward_map_lat_xi(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &p2_phy, const dense::Vec< T, 3 > &)
Definition integrands.hpp:602
constexpr dense::Mat< T, 3, 3 > symmetric_grad(const dense::Mat< T, 3, 3 > &J_inv_transposed, const dense::Vec< T, 3 > &quad_point, const int dof, const int dim)
Returns the symmetric gradient of the shape function of a dof at a quadrature point.
Definition integrands.hpp:671
constexpr int fine_lateral_wedge_idx(const int x_cell_fine, const int y_cell_fine, const int wedge_idx_fine)
Returns the lateral wedge index with respect to a coarse grid wedge from the fine wedge indices.
Definition kernel_helpers.hpp:601
constexpr T grad_forward_map_rad(const T r_1, const T r_2)
Definition integrands.hpp:596
constexpr T shape_rad(const int node_idx, const T zeta)
Radial shape function.
Definition integrands.hpp:86
constexpr T shape_lat(const int node_idx, const T xi, const T eta)
Lateral shape function.
Definition integrands.hpp:118
constexpr T forward_map_rad(const T r_1, const T r_2, const T zeta)
Definition integrands.hpp:579
constexpr T shape_coarse(const int coarse_node_idx, const int fine_radial_wedge_idx, const int fine_lateral_wedge_idx, const T xi_fine, const T eta_fine, const T zeta_fine)
Definition integrands.hpp:373
constexpr dense::Vec< T, 3 > jac_rad(const T r_1, const T r_2, const T zeta)
Definition integrands.hpp:634
constexpr T grad_shape_lat_eta(const int node_idx)
Gradient of the lateral part of the shape function, in eta direction .
Definition integrands.hpp:204
constexpr dense::Mat< T, 3, 3 > jac_lat(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &p2_phy, const dense::Vec< T, 3 > &p3_phy, const T xi, const T eta)
Definition integrands.hpp:620
constexpr T grad_shape_lat_coarse_xi(const int coarse_node_idx, const int fine_lateral_wedge_idx)
Definition integrands.hpp:437
constexpr dense::Vec< T, 3 > grad_forward_map_lat_eta(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &, const dense::Vec< T, 3 > &p3_phy)
Definition integrands.hpp:611
constexpr T shape_rad_coarse(const int coarse_node_idx, const int fine_radial_wedge_idx, const T zeta_fine)
Returns the coarse grid radial shape function evaluated at a point of the reference fine grid wedge.
Definition integrands.hpp:268
constexpr dense::Vec< T, 3 > grad_shape(const int node_idx, const T xi, const T eta, const T zeta)
Gradient of the full shape function:
Definition integrands.hpp:228
constexpr dense::Vec< T, 3 > grad_shape_coarse(const int node_idx, const int fine_radial_wedge_idx, const int fine_lateral_wedge_idx, const T xi, const T eta, const T zeta)
Definition integrands.hpp:544
constexpr T grad_shape_rad(const int node_idx)
Gradient of the radial part of the shape function, in the radial direction .
Definition integrands.hpp:172
constexpr T shape(const int node_idx, const T xi, const T eta, const T zeta)
(Tensor-product) Shape function.
Definition integrands.hpp:146
constexpr T grad_shape_rad_coarse(const int coarse_node_idx, const int fine_radial_wedge_idx)
Definition integrands.hpp:395
constexpr dense::Mat< T, 3, 3 > jac(const dense::Vec< T, 3 > &p1_phy, const dense::Vec< T, 3 > &p2_phy, const dense::Vec< T, 3 > &p3_phy, const T r_1, const T r_2, const T xi, const T eta, const T zeta)
Definition integrands.hpp:643
constexpr T shape_lat_coarse(const int coarse_node_idx, const int fine_lateral_wedge_idx, const T xi_fine, const T eta_fine)
Returns the coarse grid lateral shape function evaluated at a point of the reference fine grid wedge.
Definition integrands.hpp:322
Definition mat.hpp:10
static constexpr Mat diagonal_from_vec(const Vec< T, Rows > &diagonal)
Definition mat.hpp:79
static constexpr Mat from_col_vecs(const Vec< T, Rows > &col0, const Vec< T, Rows > &col1)
Definition mat.hpp:36
constexpr Mat< T, Cols, Rows > transposed() const
Definition mat.hpp:187
static constexpr Mat from_single_col_vec(const Vec< T, Cols > &col, const int d)
Definition mat.hpp:66