| bps.c (ce74dcefbddf8db3528d9019b9e2fecff9c01924) | bps.c (c70bd2a06d03e12fc2c14da071036320dac2cfb2) |
|---|---|
| 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. --- 51 unchanged lines hidden (view full) --- 60 PetscBool test_mode, benchmark_mode, read_mesh, write_solution; 61 Vec X, Xloc, rhs, rhsloc; 62 Mat matO; 63 KSP ksp; 64 DM dm; 65 UserO userO; 66 Ceed ceed; 67 CeedData ceeddata; | 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. --- 51 unchanged lines hidden (view full) --- 60 PetscBool test_mode, benchmark_mode, read_mesh, write_solution; 61 Vec X, Xloc, rhs, rhsloc; 62 Mat matO; 63 KSP ksp; 64 DM dm; 65 UserO userO; 66 Ceed ceed; 67 CeedData ceeddata; |
| 68 CeedQFunction qf_error; 69 CeedOperator op_error; | 68 CeedQFunction qferror; 69 CeedOperator operror; |
| 70 CeedVector rhsceed, target; 71 bpType bpChoice; 72 73 ierr = PetscInitialize(&argc, &argv, NULL, help); 74 if (ierr) return ierr; 75 comm = PETSC_COMM_WORLD; 76 77 // Read command line options --- 119 unchanged lines hidden (view full) --- 197 ierr = VecRestoreArray(rhsloc, &r); CHKERRQ(ierr); 198 ierr = VecZeroEntries(rhs); CHKERRQ(ierr); 199 ierr = DMLocalToGlobalBegin(dm, rhsloc, ADD_VALUES, rhs); CHKERRQ(ierr); 200 ierr = DMLocalToGlobalEnd(dm, rhsloc, ADD_VALUES, rhs); CHKERRQ(ierr); 201 CeedVectorDestroy(&rhsceed); 202 203 // Create the error Q-function 204 CeedQFunctionCreateInterior(ceed, 1, bpOptions[bpChoice].error, | 70 CeedVector rhsceed, target; 71 bpType bpChoice; 72 73 ierr = PetscInitialize(&argc, &argv, NULL, help); 74 if (ierr) return ierr; 75 comm = PETSC_COMM_WORLD; 76 77 // Read command line options --- 119 unchanged lines hidden (view full) --- 197 ierr = VecRestoreArray(rhsloc, &r); CHKERRQ(ierr); 198 ierr = VecZeroEntries(rhs); CHKERRQ(ierr); 199 ierr = DMLocalToGlobalBegin(dm, rhsloc, ADD_VALUES, rhs); CHKERRQ(ierr); 200 ierr = DMLocalToGlobalEnd(dm, rhsloc, ADD_VALUES, rhs); CHKERRQ(ierr); 201 CeedVectorDestroy(&rhsceed); 202 203 // Create the error Q-function 204 CeedQFunctionCreateInterior(ceed, 1, bpOptions[bpChoice].error, |
| 205 bpOptions[bpChoice].errorfname, &qf_error); 206 CeedQFunctionAddInput(qf_error, "u", ncompu, CEED_EVAL_INTERP); 207 CeedQFunctionAddInput(qf_error, "true_soln", ncompu, CEED_EVAL_NONE); 208 CeedQFunctionAddOutput(qf_error, "error", ncompu, CEED_EVAL_NONE); | 205 bpOptions[bpChoice].errorfname, &qferror); 206 CeedQFunctionAddInput(qferror, "u", ncompu, CEED_EVAL_INTERP); 207 CeedQFunctionAddInput(qferror, "true_soln", ncompu, CEED_EVAL_NONE); 208 CeedQFunctionAddOutput(qferror, "error", ncompu, CEED_EVAL_NONE); |
| 209 210 // Create the error operator | 209 210 // Create the error operator |
| 211 CeedOperatorCreate(ceed, qf_error, CEED_QFUNCTION_NONE, CEED_QFUNCTION_NONE, 212 &op_error); 213 CeedOperatorSetField(op_error, "u", ceeddata->Erestrictu, | 211 CeedOperatorCreate(ceed, qferror, CEED_QFUNCTION_NONE, CEED_QFUNCTION_NONE, 212 &operror); 213 CeedOperatorSetField(operror, "u", ceeddata->Erestrictu, |
| 214 ceeddata->basisu, CEED_VECTOR_ACTIVE); | 214 ceeddata->basisu, CEED_VECTOR_ACTIVE); |
| 215 CeedOperatorSetField(op_error, "true_soln", ceeddata->Erestrictui, | 215 CeedOperatorSetField(operror, "true_soln", ceeddata->Erestrictui, |
| 216 CEED_BASIS_COLLOCATED, target); | 216 CEED_BASIS_COLLOCATED, target); |
| 217 CeedOperatorSetField(op_error, "error", ceeddata->Erestrictui, | 217 CeedOperatorSetField(operror, "error", ceeddata->Erestrictui, |
| 218 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE); 219 220 // Set up Mat 221 userO->comm = comm; 222 userO->dm = dm; 223 userO->Xloc = Xloc; 224 ierr = VecDuplicate(Xloc, &userO->Yloc); CHKERRQ(ierr); 225 userO->xceed = ceeddata->xceed; 226 userO->yceed = ceeddata->yceed; | 218 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE); 219 220 // Set up Mat 221 userO->comm = comm; 222 userO->dm = dm; 223 userO->Xloc = Xloc; 224 ierr = VecDuplicate(Xloc, &userO->Yloc); CHKERRQ(ierr); 225 userO->xceed = ceeddata->xceed; 226 userO->yceed = ceeddata->yceed; |
| 227 userO->op = ceeddata->op_apply; | 227 userO->op = ceeddata->opapply; |
| 228 userO->ceed = ceed; 229 230 ierr = KSPCreate(comm, &ksp); CHKERRQ(ierr); 231 { 232 PC pc; 233 ierr = KSPGetPC(ksp, &pc); CHKERRQ(ierr); 234 if (bpChoice == CEED_BP1 || bpChoice == CEED_BP2) { 235 ierr = PCSetType(pc, PCJACOBI); CHKERRQ(ierr); --- 55 unchanged lines hidden (view full) --- 291 ksptype, KSPConvergedReasons[reason], its, 292 (double)rnorm); CHKERRQ(ierr); 293 } 294 if (!test_mode) { 295 ierr = PetscPrintf(comm," Performance:\n"); CHKERRQ(ierr); 296 } 297 { 298 PetscReal maxerror; | 228 userO->ceed = ceed; 229 230 ierr = KSPCreate(comm, &ksp); CHKERRQ(ierr); 231 { 232 PC pc; 233 ierr = KSPGetPC(ksp, &pc); CHKERRQ(ierr); 234 if (bpChoice == CEED_BP1 || bpChoice == CEED_BP2) { 235 ierr = PCSetType(pc, PCJACOBI); CHKERRQ(ierr); --- 55 unchanged lines hidden (view full) --- 291 ksptype, KSPConvergedReasons[reason], its, 292 (double)rnorm); CHKERRQ(ierr); 293 } 294 if (!test_mode) { 295 ierr = PetscPrintf(comm," Performance:\n"); CHKERRQ(ierr); 296 } 297 { 298 PetscReal maxerror; |
| 299 ierr = ComputeErrorMax(userO, op_error, X, target, &maxerror); | 299 ierr = ComputeErrorMax(userO, operror, X, target, &maxerror); |
| 300 CHKERRQ(ierr); 301 PetscReal tol = 5e-2; 302 if (!test_mode || maxerror > tol) { 303 ierr = MPI_Allreduce(&my_rt, &rt_min, 1, MPI_DOUBLE, MPI_MIN, comm); 304 CHKERRQ(ierr); 305 ierr = MPI_Allreduce(&my_rt, &rt_max, 1, MPI_DOUBLE, MPI_MAX, comm); 306 CHKERRQ(ierr); 307 ierr = PetscPrintf(comm, --- 28 unchanged lines hidden (view full) --- 336 ierr = PetscFree(userO); CHKERRQ(ierr); 337 ierr = CeedDataDestroy(0, ceeddata); CHKERRQ(ierr); 338 ierr = DMDestroy(&dm); CHKERRQ(ierr); 339 340 ierr = VecDestroy(&rhs); CHKERRQ(ierr); 341 ierr = VecDestroy(&rhsloc); CHKERRQ(ierr); 342 ierr = KSPDestroy(&ksp); CHKERRQ(ierr); 343 CeedVectorDestroy(&target); | 300 CHKERRQ(ierr); 301 PetscReal tol = 5e-2; 302 if (!test_mode || maxerror > tol) { 303 ierr = MPI_Allreduce(&my_rt, &rt_min, 1, MPI_DOUBLE, MPI_MIN, comm); 304 CHKERRQ(ierr); 305 ierr = MPI_Allreduce(&my_rt, &rt_max, 1, MPI_DOUBLE, MPI_MAX, comm); 306 CHKERRQ(ierr); 307 ierr = PetscPrintf(comm, --- 28 unchanged lines hidden (view full) --- 336 ierr = PetscFree(userO); CHKERRQ(ierr); 337 ierr = CeedDataDestroy(0, ceeddata); CHKERRQ(ierr); 338 ierr = DMDestroy(&dm); CHKERRQ(ierr); 339 340 ierr = VecDestroy(&rhs); CHKERRQ(ierr); 341 ierr = VecDestroy(&rhsloc); CHKERRQ(ierr); 342 ierr = KSPDestroy(&ksp); CHKERRQ(ierr); 343 CeedVectorDestroy(&target); |
| 344 CeedQFunctionDestroy(&qf_error); 345 CeedOperatorDestroy(&op_error); | 344 CeedQFunctionDestroy(&qferror); 345 CeedOperatorDestroy(&operror); |
| 346 CeedDestroy(&ceed); 347 return PetscFinalize(); 348} | 346 CeedDestroy(&ceed); 347 return PetscFinalize(); 348} |