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