Skip to content

Commit 82713b0

Browse files
committed
Pressure boundary condition added.Its qfunction doesn't get called.
1 parent 5c51868 commit 82713b0

26 files changed

Lines changed: 363 additions & 405 deletions

examples/Hdiv-mixed/basis/Hdiv-hex.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef Hdiv_hex_h
2+
#define Hdiv_hex_h
13
// Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
24
// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
35
// All Rights reserved. See files LICENSE and NOTICE for details.
@@ -159,4 +161,4 @@ static void HdivBasisHex(CeedInt Q, CeedScalar *q_ref, CeedScalar *q_weights,
159161
}
160162
}
161163

162-
164+
#endif // Hdiv_hex_h

examples/Hdiv-mixed/basis/Hdiv-quad.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef Hdiv_quad_h
2+
#define Hdiv_quad_h
13
// Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
24
// Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
35
// All Rights reserved. See files LICENSE and NOTICE for details.
@@ -84,4 +86,4 @@ static void HdivBasisQuad(CeedInt Q, CeedScalar *q_ref, CeedScalar *q_weights,
8486
}
8587
}
8688

87-
89+
#endif // Hdiv_quad_h
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef cloptions_h
22
#define cloptions_h
33

4-
#include "../include/structs.h"
4+
#include "structs.h"
55

66
// Process general command line options
7-
PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx);
7+
PetscErrorCode ProcessCommandLineOptions(AppCtx app_ctx);
88

99
#endif // cloptions_h

examples/Hdiv-mixed/include/register-problem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef register_problems_h
22
#define register_problems_h
33

4-
#include "../include/structs.h"
4+
#include "structs.h"
55

66
// Register problems to be available on the command line
77
PetscErrorCode RegisterProblems_Hdiv(AppCtx app_ctx);

examples/Hdiv-mixed/include/setup-boundary.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <petscdmplex.h>
66
#include <petscsys.h>
77
#include <ceed.h>
8-
#include "../include/structs.h"
8+
#include "structs.h"
99

1010
// ---------------------------------------------------------------------------
1111
// Create boundary label
@@ -19,4 +19,6 @@ PetscErrorCode DMAddBoundariesDirichlet(DM dm);
1919
PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t,
2020
const PetscReal coords[],
2121
PetscInt num_comp_u, PetscScalar *u, void *ctx);
22+
PetscErrorCode DMAddBoundariesPressure(Ceed ceed, CeedData ceed_data,
23+
AppCtx app_ctx, ProblemData *problem_data, DM dm);
2224
#endif // register_boundary_h

examples/Hdiv-mixed/include/setup-dm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <petscdmplex.h>
66
#include <petscsys.h>
77
#include <ceed.h>
8-
#include "../include/structs.h"
8+
#include "structs.h"
99

1010
// ---------------------------------------------------------------------------
1111
// Set-up DM

examples/Hdiv-mixed/include/setup-libceed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef setuplibceed_h
22
#define setuplibceed_h
33

4-
#include "../include/structs.h"
4+
#include "structs.h"
55

66
// Convert PETSc MemType to libCEED MemType
77
CeedMemType MemTypeP2C(PetscMemType mtype);

examples/Hdiv-mixed/include/setup-solvers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "structs.h"
88

9-
PetscErrorCode SetupCommonCtx(MPI_Comm comm, DM dm, Ceed ceed,
9+
PetscErrorCode SetupCommonCtx(DM dm, Ceed ceed,
1010
CeedData ceed_data,
1111
OperatorApplyContext op_apply_ctx);
1212
PetscErrorCode SetupJacobianOperatorCtx(CeedData ceed_data,
@@ -24,7 +24,7 @@ PetscErrorCode PDESolver(CeedData ceed_data, VecType vec_type, SNES snes,
2424
PetscErrorCode ComputeL2Error(CeedData ceed_data, Vec U, CeedVector target,
2525
CeedScalar *l2_error_u, CeedScalar *l2_error_p,
2626
OperatorApplyContext op_apply_ctx);
27-
PetscErrorCode PrintOutput(MPI_Comm comm, Ceed ceed,
27+
PetscErrorCode PrintOutput(Ceed ceed,
2828
CeedMemType mem_type_backend,
2929
SNES snes, KSP ksp,
3030
Vec U, CeedScalar l2_error_u,

examples/Hdiv-mixed/include/structs.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
// Application context from user command line options
88
typedef struct AppCtx_ *AppCtx;
99
struct AppCtx_ {
10+
MPI_Comm comm;
1011
// Degree of polynomial (1 only), extra quadrature pts
1112
PetscInt degree;
1213
PetscInt q_extra;
1314
// For applying traction BCs
14-
PetscInt bc_traction_count;
15-
PetscInt bc_traction_faces[16];
16-
PetscScalar bc_traction_vector[16][3];
15+
PetscInt bc_pressure_count;
16+
PetscInt bc_pressure_faces[16];
17+
PetscScalar bc_pressure_vector[16][3];
1718
// Problem type arguments
1819
PetscFunctionList problems;
1920
char problem_name[PETSC_MAX_PATH_LEN];
@@ -23,7 +24,7 @@ struct AppCtx_ {
2324
// libCEED data struct
2425
typedef struct CeedData_ *CeedData;
2526
struct CeedData_ {
26-
CeedBasis basis_x, basis_u, basis_p;
27+
CeedBasis basis_x, basis_u, basis_p, basis_u_face;
2728
CeedElemRestriction elem_restr_x, elem_restr_u, elem_restr_U_i,
2829
elem_restr_p;
2930
CeedQFunction qf_residual, qf_jacobian, qf_error;
@@ -72,13 +73,12 @@ struct OperatorApplyContext_ {
7273

7374
// Problem specific data
7475
typedef struct {
75-
CeedQFunctionUser setup_rhs, residual, jacobian, setup_error,
76-
setup_true, setup_face_geo;
77-
const char *setup_rhs_loc, *residual_loc, *jacobian_loc,
78-
*setup_error_loc, *setup_true_loc, *setup_face_geo_loc;
76+
CeedQFunctionUser force, residual, jacobian, error,
77+
setup_true, bc_pressure;
78+
const char *force_loc, *residual_loc, *jacobian_loc,
79+
*error_loc, *setup_true_loc, *bc_pressure_loc;
7980
CeedQuadMode quadrature_mode;
8081
CeedInt elem_node, dim, q_data_size_face;
81-
PetscErrorCode (*setup_ctx)(Ceed, CeedData, Physics);
8282

8383
} ProblemData;
8484

examples/Hdiv-mixed/main.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
//
2424
// Build with: make
2525
// Run with:
26-
// ./main -pc_type svd -problem darcy2d -dm_plex_dim 2 -dm_plex_box_faces 4,4
27-
// ./main -pc_type svd -problem darcy3d -dm_plex_dim 3 -dm_plex_box_faces 4,4,4
28-
// ./main -pc_type svd -problem darcy3d -dm_plex_filename /path to the mesh file
26+
// ./main -pc_type svd -problem darcy2d -dm_plex_dim 2 -dm_plex_box_faces 4,4
27+
// ./main -pc_type svd -problem darcy3d -dm_plex_dim 3 -dm_plex_box_faces 4,4,4
28+
// ./main -pc_type svd -problem darcy3d -dm_plex_filename /path to the mesh file
29+
// ./main -pc_type svd -problem darcy2d -dm_plex_dim 2 -dm_plex_box_faces 4,4 -bc_pressure 1
30+
// ./main -pc_type svd -problem darcy2d -dm_plex_dim 2 -dm_plex_box_faces 4,4 -bc_pressure 1,2,3,4
2931
const char help[] = "Solve H(div)-mixed problem using PETSc and libCEED\n";
3032

3133
#include "main.h"
@@ -62,7 +64,8 @@ int main(int argc, char **argv) {
6264

6365
// -- Process general command line options
6466
MPI_Comm comm = PETSC_COMM_WORLD;
65-
PetscCall( ProcessCommandLineOptions(comm, app_ctx) );
67+
app_ctx->comm = comm;
68+
PetscCall( ProcessCommandLineOptions(app_ctx) );
6669

6770
// ---------------------------------------------------------------------------
6871
// Choose the problem from the list of registered problems
@@ -107,7 +110,7 @@ int main(int argc, char **argv) {
107110

108111

109112
// ---------------------------------------------------------------------------
110-
// Create local RHS vector
113+
// Create local Force vector
111114
// ---------------------------------------------------------------------------
112115
Vec F_loc;
113116
PetscInt F_loc_size;
@@ -147,9 +150,10 @@ int main(int argc, char **argv) {
147150
SNES snes;
148151
KSP ksp;
149152
Vec U;
153+
op_apply_ctx->comm = comm;
150154
PetscCall( SNESCreate(comm, &snes) );
151155
PetscCall( SNESGetKSP(snes, &ksp) );
152-
PetscCall( SetupCommonCtx(comm, dm, ceed, ceed_data, op_apply_ctx) );
156+
PetscCall( SetupCommonCtx(dm, ceed, ceed_data, op_apply_ctx) );
153157
PetscCall( PDESolver(ceed_data, vec_type, snes, ksp, F, &U, op_apply_ctx) );
154158
//VecView(U, PETSC_VIEWER_STDOUT_WORLD);
155159

@@ -163,7 +167,7 @@ int main(int argc, char **argv) {
163167
// ---------------------------------------------------------------------------
164168
// Print output results
165169
// ---------------------------------------------------------------------------
166-
PetscCall( PrintOutput(comm, ceed, mem_type_backend,
170+
PetscCall( PrintOutput(ceed, mem_type_backend,
167171
snes, ksp, U, l2_error_u, l2_error_p, app_ctx) );
168172

169173
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)