1 // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 /// @file 9 /// Geometric factors (2D) for Navier-Stokes example using PETSc 10 #include <ceed.h> 11 #include <math.h> 12 #include "setupgeo_helpers.h" 13 #include "utils.h" 14 15 // ***************************************************************************** 16 // This QFunction sets up the geometric factors required for integration and coordinate transformations 17 // 18 // Reference (parent) coordinates: X 19 // Physical (current) coordinates: x 20 // Change of coordinate matrix: dxdX_{i,j} = x_{i,j} (indicial notation) 21 // Inverse of change of coordinate matrix: dXdx_{i,j} = (detJ^-1) * X_{i,j} 22 // 23 // All quadrature data is stored in 10 field vector of quadrature data. 24 // 25 // We require the determinant of the Jacobian to properly compute integrals of the form: int( v u ) 26 // 27 // Determinant of Jacobian: 28 // detJ = J11*J22 - J21*J12 29 // Jij = Jacobian entry ij 30 // 31 // Stored: w detJ 32 // in q_data[0] 33 // 34 // We require the transpose of the inverse of the Jacobian to properly compute integrals of the form: int( gradv u ) 35 // 36 // Inverse of Jacobian: 37 // dXdx_i,j = Aij / detJ 38 // Aij = Adjugate ij 39 // 40 // Stored: Aij / detJ 41 // in q_data[1:4] as 42 // (detJ^-1) * [A11 A12] 43 // [A21 A22] 44 // ***************************************************************************** 45 CEED_QFUNCTION(Setup2d)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 46 const CeedScalar(*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[0]; 47 const CeedScalar(*w) = in[1]; 48 CeedScalar(*q_data) = out[0]; 49 50 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 51 CeedScalar dXdx[2][2], detJ; 52 InvertMappingJacobian_2D(Q, i, J, dXdx, &detJ); 53 const CeedScalar wdetJ = w[i] * detJ; 54 55 StoredValuesPack(Q, i, 0, 1, &wdetJ, q_data); 56 StoredValuesPack(Q, i, 1, 4, (const CeedScalar *)dXdx, q_data); 57 } 58 return 0; 59 } 60 61 // ***************************************************************************** 62 // This QFunction sets up the geometric factor required for integration when reference coordinates are in 1D and the physical coordinates are in 2D 63 // 64 // Reference (parent) 1D coordinates: X 65 // Physical (current) 2D coordinates: x 66 // Change of coordinate vector: 67 // J1 = dx_1/dX 68 // J2 = dx_2/dX 69 // 70 // detJb is the magnitude of (J1,J2) 71 // 72 // All quadrature data is stored in 3 field vector of quadrature data. 73 // 74 // We require the determinant of the Jacobian to properly compute integrals of the form: int( u v ) 75 // 76 // Stored: w detJb 77 // in q_data_sur[0] 78 // 79 // Normal vector is given by the cross product of (J1,J2)/detJ and ẑ 80 // 81 // Stored: (J1,J2,0) x (0,0,1) / detJb 82 // in q_data_sur[1:2] as 83 // (detJb^-1) * [ J2 ] 84 // [-J1 ] 85 // ***************************************************************************** 86 CEED_QFUNCTION(SetupBoundary2d)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 87 const CeedScalar(*J)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 88 const CeedScalar(*w) = in[1]; 89 CeedScalar(*q_data_sur) = out[0]; 90 91 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 92 CeedScalar normal[2], detJb; 93 NormalVectorFromdxdX_2D(Q, i, J, normal, &detJb); 94 const CeedScalar wdetJ = w[i] * detJb; 95 96 StoredValuesPack(Q, i, 0, 1, &wdetJ, q_data_sur); 97 StoredValuesPack(Q, i, 1, 2, normal, q_data_sur); 98 } 99 return 0; 100 } 101