|
| 1 | +// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at |
| 2 | +// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights |
| 3 | +// reserved. See files LICENSE and NOTICE for details. |
| 4 | +// |
| 5 | +// This file is part of CEED, a collection of benchmarks, miniapps, software |
| 6 | +// libraries and APIs for efficient high-order finite element and spectral |
| 7 | +// element discretizations for exascale applications. For more information and |
| 8 | +// source code availability see http://github.com/ceed. |
| 9 | +// |
| 10 | +// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, |
| 11 | +// a collaborative effort of two U.S. Department of Energy organizations (Office |
| 12 | +// of Science and the National Nuclear Security Administration) responsible for |
| 13 | +// the planning and preparation of a capable exascale ecosystem, including |
| 14 | +// software, applications, hardware, advanced system engineering and early |
| 15 | +// testbed platforms, in support of the nation's exascale computing imperative. |
| 16 | + |
| 17 | +/// @file |
| 18 | +/// Utility functions for setting up Richard problem in 3D |
| 19 | + |
| 20 | +#include "../include/register-problem.h" |
| 21 | +#include "../qfunctions/richard-system3d.h" |
| 22 | +#include "../qfunctions/richard-true3d.h" |
| 23 | +#include "../qfunctions/richard-ics3d.h" |
| 24 | +#include "../qfunctions/darcy-error3d.h" |
| 25 | +#include "../qfunctions/post-processing3d.h" |
| 26 | +//#include "../qfunctions/pressure-boundary2d.h" |
| 27 | +#include "petscsystypes.h" |
| 28 | + |
| 29 | +PetscErrorCode Hdiv_RICHARD3D(Ceed ceed, ProblemData problem_data, void *ctx) { |
| 30 | + AppCtx app_ctx = *(AppCtx *)ctx; |
| 31 | + RICHARDContext richard_ctx; |
| 32 | + CeedQFunctionContext richard_context; |
| 33 | + |
| 34 | + PetscFunctionBeginUser; |
| 35 | + |
| 36 | + PetscCall( PetscCalloc1(1, &richard_ctx) ); |
| 37 | + |
| 38 | + // ------------------------------------------------------ |
| 39 | + // SET UP POISSON_QUAD2D |
| 40 | + // ------------------------------------------------------ |
| 41 | + problem_data->dim = 3; |
| 42 | + problem_data->elem_node = 8; |
| 43 | + problem_data->q_data_size_face = 4; |
| 44 | + problem_data->quadrature_mode = CEED_GAUSS; |
| 45 | + problem_data->true_solution = RichardTrue3D; |
| 46 | + problem_data->true_solution_loc = RichardTrue3D_loc; |
| 47 | + problem_data->rhs_u0 = RichardRhsU03D; |
| 48 | + problem_data->rhs_u0_loc = RichardRhsU03D_loc; |
| 49 | + problem_data->ics_u = RichardICsU3D; |
| 50 | + problem_data->ics_u_loc = RichardICsU3D_loc; |
| 51 | + problem_data->rhs_p0 = RichardRhsP03D; |
| 52 | + problem_data->rhs_p0_loc = RichardRhsP03D_loc; |
| 53 | + problem_data->ics_p = RichardICsP3D; |
| 54 | + problem_data->ics_p_loc = RichardICsP3D_loc; |
| 55 | + problem_data->residual = RichardSystem3D; |
| 56 | + problem_data->residual_loc = RichardSystem3D_loc; |
| 57 | + //problem_data->jacobian = JacobianRichardSystem2D; |
| 58 | + //problem_data->jacobian_loc = JacobianRichardSystem2D_loc; |
| 59 | + problem_data->error = DarcyError3D; |
| 60 | + problem_data->error_loc = DarcyError3D_loc; |
| 61 | + //problem_data->bc_pressure = BCPressure2D; |
| 62 | + //problem_data->bc_pressure_loc = BCPressure2D_loc; |
| 63 | + problem_data->post_rhs = PostProcessingRhs3D; |
| 64 | + problem_data->post_rhs_loc = PostProcessingRhs3D_loc; |
| 65 | + problem_data->post_mass = PostProcessingMass3D; |
| 66 | + problem_data->post_mass_loc = PostProcessingMass3D_loc; |
| 67 | + problem_data->has_ts = PETSC_TRUE; |
| 68 | + problem_data->view_solution = app_ctx->view_solution; |
| 69 | + |
| 70 | + // ------------------------------------------------------ |
| 71 | + // Command line Options |
| 72 | + // ------------------------------------------------------ |
| 73 | + CeedScalar kappa = 10., alpha_a = 1., b_a = 10., rho_a0 = 998.2, |
| 74 | + beta = 0., g = 9.8, p0 = 101325; |
| 75 | + |
| 76 | + PetscOptionsBegin(app_ctx->comm, NULL, "Options for Hdiv-mixed problem", NULL); |
| 77 | + PetscCall( PetscOptionsScalar("-kappa", "Hydraulic Conductivity", NULL, |
| 78 | + kappa, &kappa, NULL)); |
| 79 | + PetscCall( PetscOptionsScalar("-alpha_a", "Parameter for relative permeability", |
| 80 | + NULL, |
| 81 | + alpha_a, &alpha_a, NULL)); |
| 82 | + PetscCall( PetscOptionsScalar("-b_a", "Parameter for relative permeability", |
| 83 | + NULL, |
| 84 | + b_a, &b_a, NULL)); |
| 85 | + PetscCall( PetscOptionsScalar("-rho_a0", "Density at p0", NULL, |
| 86 | + rho_a0, &rho_a0, NULL)); |
| 87 | + PetscCall( PetscOptionsScalar("-beta", "Water compressibility", NULL, |
| 88 | + beta, &beta, NULL)); |
| 89 | + app_ctx->t_final = 0.5; |
| 90 | + PetscCall( PetscOptionsScalar("-t_final", "End time", NULL, |
| 91 | + app_ctx->t_final, &app_ctx->t_final, NULL)); |
| 92 | + PetscOptionsEnd(); |
| 93 | + |
| 94 | + richard_ctx->kappa = kappa; |
| 95 | + richard_ctx->alpha_a = alpha_a; |
| 96 | + richard_ctx->b_a = b_a; |
| 97 | + richard_ctx->rho_a0 = rho_a0; |
| 98 | + richard_ctx->beta = beta; |
| 99 | + richard_ctx->g = g; |
| 100 | + richard_ctx->p0 = p0; |
| 101 | + richard_ctx->gamma = 5.; |
| 102 | + richard_ctx->t = 0.; |
| 103 | + richard_ctx->t_final = app_ctx->t_final; |
| 104 | + CeedQFunctionContextCreate(ceed, &richard_context); |
| 105 | + CeedQFunctionContextSetData(richard_context, CEED_MEM_HOST, CEED_COPY_VALUES, |
| 106 | + sizeof(*richard_ctx), richard_ctx); |
| 107 | + //CeedQFunctionContextSetDataDestroy(richard_context, CEED_MEM_HOST, |
| 108 | + // FreeContextPetsc); |
| 109 | + CeedQFunctionContextRegisterDouble(richard_context, "time", |
| 110 | + offsetof(struct RICHARDContext_, t), 1, "current solver time"); |
| 111 | + CeedQFunctionContextRegisterDouble(richard_context, "final_time", |
| 112 | + offsetof(struct RICHARDContext_, t_final), 1, "final time"); |
| 113 | + CeedQFunctionContextRegisterDouble(richard_context, "time_step", |
| 114 | + offsetof(struct RICHARDContext_, dt), 1, "time step"); |
| 115 | + problem_data->true_qfunction_ctx = richard_context; |
| 116 | + CeedQFunctionContextReferenceCopy(richard_context, |
| 117 | + &problem_data->rhs_u0_qfunction_ctx); |
| 118 | + CeedQFunctionContextReferenceCopy(richard_context, |
| 119 | + &problem_data->residual_qfunction_ctx); |
| 120 | + CeedQFunctionContextReferenceCopy(richard_context, |
| 121 | + &problem_data->error_qfunction_ctx); |
| 122 | + PetscCall( PetscFree(richard_ctx) ); |
| 123 | + |
| 124 | + PetscFunctionReturn(0); |
| 125 | +} |
0 commit comments