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 // libCEED + PETSc Example: Navier-Stokes 18 // 19 // This example demonstrates a simple usage of libCEED with PETSc to solve a 20 // Navier-Stokes problem. 21 // 22 // The code is intentionally "raw", using only low-level communication 23 // primitives. 24 // 25 // Build with: 26 // 27 // make [PETSC_DIR=</path/to/petsc>] [CEED_DIR=</path/to/libceed>] navierstokes 28 // 29 // Sample runs: 30 // 31 // ./navierstokes -ceed /cpu/self -problem density_current -degree 1 32 // ./navierstokes -ceed /gpu/cuda -problem advection -degree 1 33 // 34 //TESTARGS(name="dc_explicit") -ceed {ceed_resource} -test -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -bc_slip_x 5,6 -bc_slip_y 3,4 -bc_Slip_z 1,2 -units_kilogram 1e-9 -center 62.5,62.5,187.5 -rc 100. -thetaC -35. -ts_dt 1e-3 -compare_final_state_atol 1E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-dc-explicit.bin 35 //TESTARGS(name="dc_implicit_stab_none") -ceed {ceed_resource} -test -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -bc_slip_x 5,6 -bc_slip_y 3,4 -bc_Slip_z 1,2 -units_kilogram 1e-9 -center 62.5,62.5,187.5 -rc 100. -thetaC -35. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-dc-implicit-stab-none.bin 36 //TESTARGS(name="adv_rotation_explicit_strong") -ceed {ceed_resource} -test -problem advection -strong_form 1 -degree 3 -dm_plex_box_faces 2,2,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -bc_wall 1,2,3,4,5,6 -wall_comps 4 -units_kilogram 1e-9 -rc 100. -ts_dt 1e-3 -compare_final_state_atol 1E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv-rotation-explicit-strong.bin 37 //TESTARGS(name="adv_rotation_implicit_sharp_cylinder") -ceed {ceed_resource} -test -problem advection -bubble_type cylinder -bubble_continuity back_sharp -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -bc_Slip_z 1,2 -bc_wall 3,4,5,6 -wall_comps 4 -units_kilogram 1e-9 -rc 100. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv-rotation-implicit-sharp-cylinder.bin 38 //TESTARGS(name="adv_rotation_implicit_stab_supg") -ceed {ceed_resource} -test -problem advection -CtauS .3 -stab supg -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -bc_wall 1,2,3,4,5,6 -wall_comps 4 -units_kilogram 1e-9 -rc 100. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv-rotation-implicit-stab-supg.bin 39 //TESTARGS(name="adv_translation_implicit_stab_su") -ceed {ceed_resource} -test -problem advection -CtauS .3 -stab su -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -units_kilogram 1e-9 -rc 100. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -wind_type translation -wind_translation .53,-1.33,-2.65 -bc_inflow 1,2,3,4,5,6 -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv-translation-implicit-stab-su.bin 40 //TESTARGS(name="adv2d_rotation_explicit_strong") -ceed {ceed_resource} -test -problem advection2d -strong_form 1 -degree 3 -dm_plex_box_faces 2,2 -dm_plex_box_lower 0,0 -dm_plex_box_upper 125,125 -bc_wall 1,2,3,4 -wall_comps 4 -units_kilogram 1e-9 -rc 100. -ts_dt 1e-3 -compare_final_state_atol 1E-11 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv2d-rotation-explicit-strong.bin 41 //TESTARGS(name="adv2d_rotation_implicit_stab_supg") -ceed {ceed_resource} -test -problem advection2d -CtauS .3 -stab supg -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0 -dm_plex_box_upper 125,125 -bc_wall 1,2,3,4 -wall_comps 4 -units_kilogram 1e-9 -rc 100. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv2d-rotation-implicit-stab-supg.bin 42 //TESTARGS(name="adv2d_translation_implicit_stab_su") -ceed {ceed_resource} -test -problem advection2d -CtauS .3 -stab su -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0 -dm_plex_box_upper 125,125 -units_kilogram 1e-9 -rc 100. -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -wind_type translation -wind_translation .53,-1.33,0 -bc_inflow 1,2,3,4 -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-adv2d-translation-implicit-stab-su.bin 43 //TESTARGS(name="euler_implicit") -ceed {ceed_resource} -test -problem euler_vortex -degree 3 -dm_plex_box_faces 1,1,2 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -units_meter 1e-4 -units_second 1e-4 -mean_velocity 1.4,-2.,0 -bc_inflow 4,6 -bc_outflow 3,5 -bc_slip_z 1,2 -vortex_strength 2 -ksp_atol 1e-4 -ksp_rtol 1e-3 -ksp_type bcgs -snes_atol 1e-3 -snes_lag_jacobian 100 -snes_lag_jacobian_persists -snes_mf_operator -ts_dt 1e-3 -implicit -ts_type alpha -compare_final_state_atol 5E-4 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-euler-implicit.bin 44 //TESTARGS(name="euler_explicit") -ceed {ceed_resource} -test -problem euler_vortex -degree 3 -dm_plex_box_faces 2,2,1 -dm_plex_box_lower 0,0,0 -dm_plex_box_upper 125,125,250 -dm_plex_dim 3 -units_meter 1e-4 -units_second 1e-4 -mean_velocity 1.4,-2.,0 -bc_inflow 4,6 -bc_outflow 3,5 -bc_slip_z 1,2 -vortex_strength 2 -ts_dt 1e-7 -ts_rk_type 5bs -ts_rtol 1e-10 -ts_atol 1e-10 -compare_final_state_atol 1E-7 -compare_final_state_filename examples/fluids/tests-output/fluids-navierstokes-euler-explicit.bin 45 46 /// @file 47 /// Navier-Stokes example using PETSc 48 49 const char help[] = "Solve Navier-Stokes using PETSc and libCEED\n"; 50 51 #include "navierstokes.h" 52 53 int main(int argc, char **argv) { 54 // --------------------------------------------------------------------------- 55 // Initialize PETSc 56 // --------------------------------------------------------------------------- 57 PetscInt ierr; 58 ierr = PetscInitialize(&argc, &argv, NULL, help); 59 if (ierr) return ierr; 60 61 // --------------------------------------------------------------------------- 62 // Create structs 63 // --------------------------------------------------------------------------- 64 AppCtx app_ctx; 65 ierr = PetscCalloc1(1, &app_ctx); CHKERRQ(ierr); 66 67 ProblemData *problem = NULL; 68 ierr = PetscCalloc1(1, &problem); CHKERRQ(ierr); 69 70 User user; 71 ierr = PetscCalloc1(1, &user); CHKERRQ(ierr); 72 73 CeedData ceed_data; 74 ierr = PetscCalloc1(1, &ceed_data); CHKERRQ(ierr); 75 76 SimpleBC bc; 77 ierr = PetscCalloc1(1, &bc); CHKERRQ(ierr); 78 79 SetupContext setup_ctx; 80 ierr = PetscCalloc1(1, &setup_ctx); CHKERRQ(ierr); 81 82 Physics phys_ctx; 83 ierr = PetscCalloc1(1, &phys_ctx); CHKERRQ(ierr); 84 85 Units units; 86 ierr = PetscCalloc1(1, &units); CHKERRQ(ierr); 87 88 user->app_ctx = app_ctx; 89 user->units = units; 90 user->phys = phys_ctx; 91 92 // --------------------------------------------------------------------------- 93 // Process command line options 94 // --------------------------------------------------------------------------- 95 // -- Register problems to be available on the command line 96 ierr = RegisterProblems_NS(app_ctx); CHKERRQ(ierr); 97 98 // -- Process general command line options 99 MPI_Comm comm = PETSC_COMM_WORLD; 100 user->comm = comm; 101 ierr = ProcessCommandLineOptions(comm, app_ctx, bc); CHKERRQ(ierr); 102 103 // --------------------------------------------------------------------------- 104 // Initialize libCEED 105 // --------------------------------------------------------------------------- 106 // -- Initialize backend 107 Ceed ceed; 108 CeedInit(app_ctx->ceed_resource, &ceed); 109 user->ceed = ceed; 110 111 // -- Check preferred MemType 112 CeedMemType mem_type_backend; 113 CeedGetPreferredMemType(ceed, &mem_type_backend); 114 115 // --------------------------------------------------------------------------- 116 // Set up global mesh 117 // --------------------------------------------------------------------------- 118 // -- Create DM 119 DM dm; 120 ierr = CreateDM(comm, problem, &dm); CHKERRQ(ierr); 121 VecType vec_type = NULL; 122 switch (mem_type_backend) { 123 case CEED_MEM_HOST: vec_type = VECSTANDARD; break; 124 case CEED_MEM_DEVICE: { 125 const char *resolved; 126 CeedGetResource(ceed, &resolved); 127 if (strstr(resolved, "/gpu/cuda")) vec_type = VECCUDA; 128 else if (strstr(resolved, "/gpu/hip")) vec_type = VECHIP; 129 else vec_type = VECSTANDARD; 130 } 131 } 132 ierr = DMSetVecType(dm, vec_type); CHKERRQ(ierr); 133 user->dm = dm; 134 135 // --------------------------------------------------------------------------- 136 // Choose the problem from the list of registered problems 137 // --------------------------------------------------------------------------- 138 { 139 PetscErrorCode (*p)(ProblemData *, DM, void *, void *); 140 ierr = PetscFunctionListFind(app_ctx->problems, app_ctx->problem_name, &p); 141 CHKERRQ(ierr); 142 if (!p) SETERRQ(PETSC_COMM_SELF, 1, "Problem '%s' not found", 143 app_ctx->problem_name); 144 ierr = (*p)(problem, dm, &setup_ctx, &user); CHKERRQ(ierr); 145 } 146 147 // -- Set up DM 148 ierr = SetUpDM(dm, problem, app_ctx->degree, bc, phys_ctx, setup_ctx); 149 CHKERRQ(ierr); 150 151 // -- Refine DM for high-order viz 152 if (app_ctx->viz_refine) { 153 ierr = VizRefineDM(dm, user, problem, bc, phys_ctx, setup_ctx); 154 CHKERRQ(ierr); 155 } 156 157 // --------------------------------------------------------------------------- 158 // Set up libCEED 159 // --------------------------------------------------------------------------- 160 // -- Set up libCEED objects 161 ierr = SetupLibceed(ceed, ceed_data, dm, user, app_ctx, problem, bc); 162 CHKERRQ(ierr); 163 164 // -- Set up context for QFunctions 165 ierr = problem->setup_ctx(ceed, ceed_data, app_ctx, setup_ctx, phys_ctx); 166 CHKERRQ(ierr); 167 168 // --------------------------------------------------------------------------- 169 // Set up ICs 170 // --------------------------------------------------------------------------- 171 // -- Set up global state vector Q 172 Vec Q; 173 ierr = DMCreateGlobalVector(dm, &Q); CHKERRQ(ierr); 174 ierr = VecZeroEntries(Q); CHKERRQ(ierr); 175 176 // -- Set up local state vector Q_loc 177 Vec Q_loc; 178 ierr = DMGetLocalVector(dm, &Q_loc); CHKERRQ(ierr); 179 180 // -- Fix multiplicity for ICs 181 ierr = ICs_FixMultiplicity(dm, ceed_data, Q_loc, Q, 0.0); CHKERRQ(ierr); 182 183 // --------------------------------------------------------------------------- 184 // Set up lumped mass matrix 185 // --------------------------------------------------------------------------- 186 // -- Set up global mass vector 187 ierr = VecDuplicate(Q, &user->M); CHKERRQ(ierr); 188 189 // -- Compute lumped mass matrix 190 ierr = ComputeLumpedMassMatrix(ceed, dm, ceed_data, user->M); CHKERRQ(ierr); 191 192 // --------------------------------------------------------------------------- 193 // Record boundary values from initial condition 194 // --------------------------------------------------------------------------- 195 // -- This overrides DMPlexInsertBoundaryValues(). 196 // We use this for the main simulation DM because the reference 197 // DMPlexInsertBoundaryValues() is very slow. If we disable this, we should 198 // still get the same results due to the problem->bc function, but with 199 // potentially much slower execution. 200 if (1) {ierr = SetBCsFromICs_NS(dm, Q, Q_loc); CHKERRQ(ierr);} 201 202 // --------------------------------------------------------------------------- 203 // Create output directory 204 // --------------------------------------------------------------------------- 205 PetscMPIInt rank; 206 MPI_Comm_rank(comm, &rank); 207 if (!rank) {ierr = PetscMkdir(app_ctx->output_dir); CHKERRQ(ierr);} 208 209 // --------------------------------------------------------------------------- 210 // Gather initial Q values in case of continuation of simulation 211 // --------------------------------------------------------------------------- 212 // -- Set up initial values from binary file 213 if (app_ctx->cont_steps) { 214 ierr = SetupICsFromBinary(comm, app_ctx, Q); CHKERRQ(ierr); 215 } 216 217 // --------------------------------------------------------------------------- 218 // Print problem summary 219 // --------------------------------------------------------------------------- 220 if (!app_ctx->test_mode) { 221 // Header and rank 222 char host_name[PETSC_MAX_PATH_LEN]; 223 int comm_size; 224 ierr = PetscGetHostName(host_name, sizeof host_name); CHKERRQ(ierr); 225 ierr = MPI_Comm_size(comm, &comm_size); CHKERRQ(ierr); 226 ierr = PetscPrintf(comm, 227 "\n-- Navier-Stokes solver - libCEED + PETSc --\n" 228 " MPI:\n" 229 " Host Name : %s\n" 230 " Total ranks : %d\n", 231 host_name, comm_size); CHKERRQ(ierr); 232 233 // Problem specific info 234 ierr = problem->print_info(phys_ctx, setup_ctx, app_ctx); CHKERRQ(ierr); 235 236 // libCEED 237 const char *used_resource; 238 CeedGetResource(ceed, &used_resource); 239 ierr = PetscPrintf(comm, 240 " libCEED:\n" 241 " libCEED Backend : %s\n" 242 " libCEED Backend MemType : %s\n", 243 used_resource, CeedMemTypes[mem_type_backend]); CHKERRQ(ierr); 244 // PETSc 245 char box_faces_str[PETSC_MAX_PATH_LEN] = "3,3,3"; 246 if (problem->dim == 2) box_faces_str[3] = '\0'; 247 ierr = PetscOptionsGetString(NULL, NULL, "-dm_plex_box_faces", box_faces_str, 248 sizeof(box_faces_str), NULL); CHKERRQ(ierr); 249 ierr = PetscPrintf(comm, 250 " PETSc:\n" 251 " Box Faces : %s\n" 252 " Time Stepping Scheme : %s\n", 253 box_faces_str, phys_ctx->implicit ? "implicit" : "explicit"); CHKERRQ(ierr); 254 // Mesh 255 const PetscInt num_comp_q = 5; 256 CeedInt glob_dofs, owned_dofs; 257 PetscInt glob_nodes, owned_nodes; 258 const CeedInt num_P = app_ctx->degree + 1, 259 num_Q = num_P + app_ctx->q_extra; 260 // -- Get global size 261 ierr = VecGetSize(Q, &glob_dofs); CHKERRQ(ierr); 262 ierr = VecGetLocalSize(Q, &owned_dofs); CHKERRQ(ierr); 263 glob_nodes = glob_dofs/num_comp_q; 264 // -- Get local size 265 ierr = VecGetSize(Q_loc, &owned_nodes); CHKERRQ(ierr); 266 owned_nodes /= num_comp_q; 267 ierr = PetscPrintf(comm, 268 " Mesh:\n" 269 " Number of 1D Basis Nodes (P) : %d\n" 270 " Number of 1D Quadrature Points (Q) : %d\n" 271 " Global DoFs : %D\n" 272 " Owned DoFs : %D\n" 273 " DoFs per node : %D\n" 274 " Global nodes : %D\n" 275 " Owned nodes : %D\n", 276 num_P, num_Q, glob_dofs, owned_dofs, num_comp_q, 277 glob_nodes, owned_nodes); CHKERRQ(ierr); 278 } 279 // -- Restore Q_loc 280 ierr = DMRestoreLocalVector(dm, &Q_loc); CHKERRQ(ierr); 281 282 // --------------------------------------------------------------------------- 283 // TS: Create, setup, and solve 284 // --------------------------------------------------------------------------- 285 TS ts; 286 PetscScalar final_time; 287 ierr = TSSolve_NS(dm, user, app_ctx, phys_ctx, &Q, &final_time, &ts); 288 CHKERRQ(ierr); 289 290 // --------------------------------------------------------------------------- 291 // Post-processing 292 // --------------------------------------------------------------------------- 293 ierr = PostProcess_NS(ts, ceed_data, dm, problem, app_ctx, Q, final_time); 294 CHKERRQ(ierr); 295 296 // --------------------------------------------------------------------------- 297 // Destroy libCEED objects 298 // --------------------------------------------------------------------------- 299 // -- Vectors 300 CeedVectorDestroy(&ceed_data->x_coord); 301 CeedVectorDestroy(&ceed_data->q_data); 302 CeedVectorDestroy(&user->q_ceed); 303 CeedVectorDestroy(&user->q_dot_ceed); 304 CeedVectorDestroy(&user->g_ceed); 305 306 // -- Contexts 307 CeedQFunctionContextDestroy(&ceed_data->setup_context); 308 CeedQFunctionContextDestroy(&ceed_data->newt_ig_context); 309 CeedQFunctionContextDestroy(&ceed_data->advection_context); 310 CeedQFunctionContextDestroy(&ceed_data->euler_context); 311 312 // -- QFunctions 313 CeedQFunctionDestroy(&ceed_data->qf_setup_vol); 314 CeedQFunctionDestroy(&ceed_data->qf_ics); 315 CeedQFunctionDestroy(&ceed_data->qf_rhs_vol); 316 CeedQFunctionDestroy(&ceed_data->qf_ifunction_vol); 317 CeedQFunctionDestroy(&ceed_data->qf_setup_sur); 318 CeedQFunctionDestroy(&ceed_data->qf_apply_inflow); 319 CeedQFunctionDestroy(&ceed_data->qf_apply_outflow); 320 321 // -- Bases 322 CeedBasisDestroy(&ceed_data->basis_q); 323 CeedBasisDestroy(&ceed_data->basis_x); 324 CeedBasisDestroy(&ceed_data->basis_xc); 325 CeedBasisDestroy(&ceed_data->basis_q_sur); 326 CeedBasisDestroy(&ceed_data->basis_x_sur); 327 328 // -- Restrictions 329 CeedElemRestrictionDestroy(&ceed_data->elem_restr_q); 330 CeedElemRestrictionDestroy(&ceed_data->elem_restr_x); 331 CeedElemRestrictionDestroy(&ceed_data->elem_restr_qd_i); 332 333 // -- Operators 334 CeedOperatorDestroy(&ceed_data->op_setup_vol); 335 CeedOperatorDestroy(&ceed_data->op_ics); 336 CeedOperatorDestroy(&user->op_rhs_vol); 337 CeedOperatorDestroy(&user->op_ifunction_vol); 338 CeedOperatorDestroy(&user->op_rhs); 339 CeedOperatorDestroy(&user->op_ifunction); 340 341 // -- Ceed 342 CeedDestroy(&ceed); 343 344 // --------------------------------------------------------------------------- 345 // Clean up PETSc 346 // --------------------------------------------------------------------------- 347 // -- Vectors 348 ierr = VecDestroy(&Q); CHKERRQ(ierr); 349 ierr = VecDestroy(&user->M); CHKERRQ(ierr); 350 351 // -- Matrices 352 ierr = MatDestroy(&user->interp_viz); CHKERRQ(ierr); 353 354 // -- DM 355 ierr = DMDestroy(&dm); CHKERRQ(ierr); 356 ierr = DMDestroy(&user->dm_viz); CHKERRQ(ierr); 357 358 // -- TS 359 ierr = TSDestroy(&ts); CHKERRQ(ierr); 360 361 // -- Function list 362 ierr = PetscFunctionListDestroy(&app_ctx->problems); CHKERRQ(ierr); 363 364 // -- Structs 365 ierr = PetscFree(units); CHKERRQ(ierr); 366 ierr = PetscFree(user); CHKERRQ(ierr); 367 ierr = PetscFree(problem); CHKERRQ(ierr); 368 ierr = PetscFree(bc); CHKERRQ(ierr); 369 ierr = PetscFree(setup_ctx); CHKERRQ(ierr); 370 ierr = PetscFree(phys_ctx->newtonian_ig_ctx); CHKERRQ(ierr); 371 ierr = PetscFree(phys_ctx->euler_ctx); CHKERRQ(ierr); 372 ierr = PetscFree(phys_ctx->advection_ctx); CHKERRQ(ierr); 373 ierr = PetscFree(phys_ctx); CHKERRQ(ierr); 374 ierr = PetscFree(app_ctx); CHKERRQ(ierr); 375 ierr = PetscFree(ceed_data); CHKERRQ(ierr); 376 377 return PetscFinalize(); 378 } 379