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
2931const char help [] = "Solve H(div)-mixed problem using PETSc and libCEED\n" ;
3032
3133#include "main.h"
@@ -42,7 +44,7 @@ int main(int argc, char **argv) {
4244 AppCtx app_ctx ;
4345 PetscCall ( PetscCalloc1 (1 , & app_ctx ) );
4446
45- ProblemData * problem_data = NULL ;
47+ ProblemData problem_data = NULL ;
4648 PetscCall ( PetscCalloc1 (1 , & problem_data ) );
4749
4850 CeedData ceed_data ;
@@ -62,13 +64,14 @@ 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
6972 // ---------------------------------------------------------------------------
7073 {
71- PetscErrorCode (* p )(ProblemData * , void * );
74+ PetscErrorCode (* p )(ProblemData , void * );
7275 PetscCall ( PetscFunctionListFind (app_ctx -> problems , app_ctx -> problem_name ,
7376 & p ) );
7477 if (!p ) SETERRQ (PETSC_COMM_SELF , 1 , "Problem '%s' not found" ,
@@ -107,12 +110,12 @@ 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 ;
114117 CeedScalar * f ;
115- CeedVector force_ceed , target ;
118+ CeedVector force_ceed , target , bc_pressure ;
116119 PetscMemType force_mem_type ;
117120 PetscCall ( DMCreateLocalVector (dm , & F_loc ) );
118121 // Local size for libCEED
@@ -121,15 +124,18 @@ int main(int argc, char **argv) {
121124 PetscCall ( VecGetArrayAndMemType (F_loc , & f , & force_mem_type ) );
122125 CeedVectorCreate (ceed , F_loc_size , & force_ceed );
123126 CeedVectorSetArray (force_ceed , MemTypeP2C (force_mem_type ), CEED_USE_POINTER , f );
124-
127+ CeedVectorCreate (ceed , F_loc_size , & bc_pressure );
128+ CeedVectorSetArray (bc_pressure , MemTypeP2C (force_mem_type ), CEED_USE_POINTER ,
129+ f );
125130 // ---------------------------------------------------------------------------
126131 // Setup libCEED - Compute local F and true solution (target)
127132 // ---------------------------------------------------------------------------
128133 // -- Set up libCEED objects
129134 PetscCall ( SetupLibceed (dm , ceed , app_ctx , problem_data ,
130135 F_loc_size , ceed_data , force_ceed , & target ) );
131136 //CeedVectorView(force_ceed, "%12.8f", stdout);
132-
137+ PetscCall ( DMAddBoundariesPressure (ceed , ceed_data , app_ctx , problem_data , dm ,
138+ bc_pressure ) );
133139 // ---------------------------------------------------------------------------
134140 // Create global F
135141 // ---------------------------------------------------------------------------
@@ -147,9 +153,10 @@ int main(int argc, char **argv) {
147153 SNES snes ;
148154 KSP ksp ;
149155 Vec U ;
156+ op_apply_ctx -> comm = comm ;
150157 PetscCall ( SNESCreate (comm , & snes ) );
151158 PetscCall ( SNESGetKSP (snes , & ksp ) );
152- PetscCall ( SetupCommonCtx (comm , dm , ceed , ceed_data , op_apply_ctx ) );
159+ PetscCall ( SetupCommonCtx (dm , ceed , ceed_data , op_apply_ctx ) );
153160 PetscCall ( PDESolver (ceed_data , vec_type , snes , ksp , F , & U , op_apply_ctx ) );
154161 //VecView(U, PETSC_VIEWER_STDOUT_WORLD);
155162
@@ -163,7 +170,7 @@ int main(int argc, char **argv) {
163170 // ---------------------------------------------------------------------------
164171 // Print output results
165172 // ---------------------------------------------------------------------------
166- PetscCall ( PrintOutput (comm , ceed , mem_type_backend ,
173+ PetscCall ( PrintOutput (ceed , mem_type_backend ,
167174 snes , ksp , U , l2_error_u , l2_error_p , app_ctx ) );
168175
169176 // ---------------------------------------------------------------------------
@@ -201,6 +208,7 @@ int main(int argc, char **argv) {
201208
202209 // Free libCEED objects
203210 CeedVectorDestroy (& force_ceed );
211+ CeedVectorDestroy (& bc_pressure );
204212 CeedVectorDestroy (& target );
205213 PetscCall ( CeedDataDestroy (ceed_data ) );
206214 CeedDestroy (& ceed );
0 commit comments