From da12e016b046f7681b55779c4ab9ab6734637994 Mon Sep 17 00:00:00 2001 From: Leila Ghaffari Date: Wed, 17 Mar 2021 11:51:23 -0600 Subject: [PATCH] SWE: some comments on the div operations --- .../shallow-water/qfunctions/advection.h | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/fluids/shallow-water/qfunctions/advection.h b/examples/fluids/shallow-water/qfunctions/advection.h index 6ba216fe6a..b12daa4c98 100644 --- a/examples/fluids/shallow-water/qfunctions/advection.h +++ b/examples/fluids/shallow-water/qfunctions/advection.h @@ -185,13 +185,13 @@ CEED_QFUNCTION(SWExplicit_Advection)(void *ctx, CeedInt Q, // -- Height: // Evaluate the strong form using // div((h + H0) u) = u . grad(h) + (h + H0) div(u), with H0 constant - // or in index notation: (u_j h)_{,j} = u_j h_j + (h + H0) u_{j,j} + // or in index notation: (u_j h)_{,j} = u_j h_{,j} + (h + H0) u_{j,j} CeedScalar div_u = 0, u_dot_grad_h = 0; - for (CeedInt j=0; j<2; j++) { + for (CeedInt j=0; j<2; j++) { // we skip j=2 since dqdx[2] is zero CeedScalar dhdx_j = 0; - for (CeedInt k=0; k<2; k++) { // TODO: check indices! in this case dXdx is 2x3 + for (CeedInt k=0; k<2; k++) { div_u += du[j][k] * dXdx[k][j]; // u_{j,j} = u_{j,K} X_{K,j} - dhdx_j += dh[k] * dXdx[k][j]; + dhdx_j += dh[k] * dXdx[k][j]; // h_{,j} = h_K X_{K,j} } u_dot_grad_h += u[j] * dhdx_j; } @@ -310,13 +310,13 @@ CEED_QFUNCTION(SWImplicit_Advection)(void *ctx, CeedInt Q, // -- Height: // Evaluate the strong form using // div((h + H0) u) = u . grad(h) + (h + H0) div(u), with H0 constant - // or in index notation: (u_j h)_{,j} = u_j h_j + (h + H0) u_{j,j} + // or in index notation: (u_j h)_{,j} = u_j h_{,j} + (h + H0) u_{j,j} CeedScalar div_u = 0, u_dot_grad_h = 0; - for (CeedInt j=0; j<2; j++) { + for (CeedInt j=0; j<2; j++) { // we skip j=2 since dqdx[2] is zero CeedScalar dhdx_j = 0; - for (CeedInt k=0; k<2; k++) { // TODO: check indices! in this case dXdx is 2x3 + for (CeedInt k=0; k<2; k++) { div_u += du[j][k] * dXdx[k][j]; // u_{j,j} = u_{j,K} X_{K,j} - dhdx_j += dh[k] * dXdx[k][j]; + dhdx_j += dh[k] * dXdx[k][j]; // h_{,j} = h_K X_{K,j} } u_dot_grad_h += u[j] * dhdx_j; } @@ -461,13 +461,13 @@ CEED_QFUNCTION(SWJacobian_Advection)(void *ctx, CeedInt Q, // -- Height: // Evaluate the strong form of the action of the Jacobian using // div((h + H0) delta u) = delta u . grad(h) + (h + H0) div(delta u), with H0 constant - // or in index notation: (delta u_j h)_{,j} = delta u_j h_j + (h + H0) delta u_{j,j} + // or in index notation: (delta u_j h)_{,j} = delta u_j h_{,j} + (h + H0) delta u_{j,j} CeedScalar div_deltau = 0, deltau_dot_grad_h = 0; - for (CeedInt j=0; j<2; j++) { + for (CeedInt j=0; j<2; j++) { // we skip j=2 since dqdx[2] is zero CeedScalar dhdx_j = 0; - for (CeedInt k=0; k<2; k++) { // TODO: check indices! in this case dXdx is 2x3 - div_deltau += deltadu[j][k] * dXdx[k][j]; // u_{j,j} = u_{j,K} X_{K,j} - dhdx_j += dh[k] * dXdx[k][j]; + for (CeedInt k=0; k<2; k++) { + div_deltau += deltadu[j][k] * dXdx[k][j]; // deltau_{j,j} = deltau_{j,K} X_{K,j} + dhdx_j += dh[k] * dXdx[k][j]; // h_{,j} = h_K X_{K,j} } deltau_dot_grad_h += deltau[j] * dhdx_j; }