-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b46c93
commit 5e0f655
Showing
7 changed files
with
273 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at | ||
// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights | ||
// reserved. See files LICENSE and NOTICE for details. | ||
// | ||
// This file is part of CEED, a collection of benchmarks, miniapps, software | ||
// libraries and APIs for efficient high-order finite element and spectral | ||
// element discretizations for exascale applications. For more information and | ||
// source code availability see http://github.com/ceed. | ||
// | ||
// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, | ||
// a collaborative effort of two U.S. Department of Energy organizations (Office | ||
// of Science and the National Nuclear Security Administration) responsible for | ||
// the planning and preparation of a capable exascale ecosystem, including | ||
// software, applications, hardware, advanced system engineering and early | ||
// testbed platforms, in support of the nation's exascale computing imperative. | ||
|
||
/// @file | ||
/// Force of Richard problem 2D (quad element) using PETSc | ||
|
||
#ifndef RICHARD_FORCE2D_H | ||
#define RICHARD_FORCE2D_H | ||
|
||
#include <math.h> | ||
#include "utils.h" | ||
|
||
// See Matthew Farthing, Christopher Kees, Cass Miller (2003) | ||
// https://www.sciencedirect.com/science/article/pii/S0309170802001872 | ||
// ----------------------------------------------------------------------------- | ||
// Strong form: | ||
// k*K^{-1} * u = -\grad(p) + rho*g in \Omega x [0,T] | ||
// -\div(u) = -f + d (rho/rho_0*theta)/dt in \Omega x [0,T] | ||
// p = p_b on \Gamma_D x [0,T] | ||
// u.n = u_b on \Gamma_N x [0,T] | ||
// p = p_0 in \Omega, t = 0 | ||
// | ||
// Where g is gravity vector, rho = rho_0*exp(beta * (p - p0)), p0 = 101325 Pa is atmospheric pressure | ||
// f = fs/rho_0, where g is gravity, rho_0 is the density at p_0, K = kappa*I, and | ||
// k_r = b_a + alpha_a * (\psi - x2), where \psi = p / (rho_0 * norm(g)) and x2 is vertical axis | ||
// | ||
// Weak form: Find (u, p) \in VxQ (V=H(div), Q=L^2) on \Omega | ||
// (v, k*K^{-1} * u) -(v, rho*g) - (\div(v), p) = - <v, p_b*n>_{\Gamma_D} | ||
// -(q, \div(u)) = -(q, f) + (v, d (rho/rho_0*theta)/dt ) | ||
// | ||
// where k*K^{-1} = (rho_0^2*norm(g)/rho*k_r)*K^{-1} | ||
// This QFunction sets up the force | ||
// Inputs: | ||
// x : interpolation of the physical coordinate | ||
// w : weight of quadrature | ||
// J : dx/dX. x physical coordinate, X reference coordinate [-1,1]^dim | ||
// | ||
// Output: | ||
// force_u : which is 0.0 for this problem (-<v, p0 n> is in pressure-boundary qfunction) | ||
// force_p : -(q, f) = -\int( q * f * w*detJ)dx | ||
// ----------------------------------------------------------------------------- | ||
// We have 3 experiment parameters as described in Table 1:P1, P2, P3 | ||
// Matthew Farthing, Christopher Kees, Cass Miller (2003) | ||
// https://www.sciencedirect.com/science/article/pii/S0309170802001872 | ||
#ifndef RICHARD_CTX | ||
#define RICHARD_CTX | ||
typedef struct RICHARDContext_ *RICHARDContext; | ||
struct RICHARDContext_ { | ||
CeedScalar kappa; | ||
CeedScalar alpha_a; | ||
CeedScalar b_a; | ||
CeedScalar rho_0; | ||
CeedScalar beta; | ||
CeedScalar g; | ||
CeedScalar p0; | ||
}; | ||
#endif | ||
// ----------------------------------------------------------------------------- | ||
// Force evaluation for Richard problem | ||
// ----------------------------------------------------------------------------- | ||
CEED_QFUNCTION(RichardForce2D)(void *ctx, const CeedInt Q, | ||
const CeedScalar *const *in, | ||
CeedScalar *const *out) { | ||
// *INDENT-OFF* | ||
// Inputs | ||
const CeedScalar (*coords) = in[0], | ||
(*w) = in[1], | ||
(*dxdX)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[2]; | ||
// Outputs | ||
CeedScalar (*rhs_u) = out[0], (*rhs_p) = out[1], | ||
(*true_soln) = out[2]; | ||
// Context | ||
RICHARDContext context = (RICHARDContext)ctx; | ||
const CeedScalar kappa = context->kappa;//10.; | ||
// Quadrature Point Loop | ||
CeedPragmaSIMD | ||
for (CeedInt i=0; i<Q; i++) { | ||
// Setup, (x,y) and J = dx/dX | ||
CeedScalar x = coords[i+0*Q], y = coords[i+1*Q]; | ||
const CeedScalar J[2][2] = {{dxdX[0][0][i], dxdX[1][0][i]}, | ||
{dxdX[0][1][i], dxdX[1][1][i]}}; | ||
const CeedScalar det_J = MatDet2x2(J); | ||
// *INDENT-ON* | ||
CeedScalar pe = sin(PI_DOUBLE*x) * sin(PI_DOUBLE*y); | ||
CeedScalar grad_pe[2] = {PI_DOUBLE*cos(PI_DOUBLE*x) *sin(PI_DOUBLE*y), PI_DOUBLE*sin(PI_DOUBLE*x) *cos(PI_DOUBLE*y)}; | ||
CeedScalar K[2][2] = {{kappa, 0.},{0., kappa}}; | ||
CeedScalar ue[2]; | ||
AlphaMatVecMult2x2(-1., K, grad_pe, ue); | ||
CeedScalar f = 2*PI_DOUBLE*PI_DOUBLE*sin(PI_DOUBLE*x)*sin(PI_DOUBLE*y); | ||
|
||
// 1st eq: component 1 | ||
rhs_u[i+0*Q] = 0.; | ||
// 1st eq: component 2 | ||
rhs_u[i+1*Q] = 0.; | ||
// 2nd eq | ||
rhs_p[i] = -f*w[i]*det_J; | ||
// True solution Ue=[p,u] | ||
true_soln[i+0*Q] = pe; | ||
true_soln[i+1*Q] = ue[0]; | ||
true_soln[i+2*Q] = ue[1]; | ||
} // End of Quadrature Point Loop | ||
return 0; | ||
} | ||
// ----------------------------------------------------------------------------- | ||
|
||
#endif //End of RICHARD_FORCE2D_H |
Oops, something went wrong.