Lines Matching refs:appctx
77 AppCtx appctx; /* user-defined application context */ in main() local
100 PetscCall(PetscOptionsHasName(NULL, NULL, "-debug", &appctx.debug)); in main()
102 appctx.m = m; in main()
103 appctx.h = 1.0 / (m - 1.0); in main()
104 appctx.norm_2 = 0.0; in main()
105 appctx.norm_max = 0.0; in main()
117 PetscCall(VecDuplicate(u, &appctx.solution)); in main()
123 PetscCall(PetscViewerDrawOpen(PETSC_COMM_SELF, 0, "", 80, 380, 400, 160, &appctx.viewer1)); in main()
124 PetscCall(PetscViewerDrawGetDraw(appctx.viewer1, 0, &draw)); in main()
126 PetscCall(PetscViewerDrawOpen(PETSC_COMM_SELF, 0, "", 80, 0, 400, 160, &appctx.viewer2)); in main()
127 PetscCall(PetscViewerDrawGetDraw(appctx.viewer2, 0, &draw)); in main()
141 PetscCall(TSMonitorSet(ts, Monitor, &appctx, NULL)); in main()
160 PetscCall(TSSetRHSFunction(ts, NULL, TSComputeRHSFunctionLinear, &appctx)); in main()
161 PetscCall(TSSetRHSJacobian(ts, A, A, RHSMatrixHeat, &appctx)); in main()
169 PetscCall(RHSMatrixHeat(ts, 0.0, u, A, A, &appctx)); in main()
170 PetscCall(TSSetRHSFunction(ts, NULL, TSComputeRHSFunctionLinear, &appctx)); in main()
171 PetscCall(TSSetRHSJacobian(ts, A, A, TSComputeRHSJacobianConstant, &appctx)); in main()
178 dt = appctx.h * appctx.h / 2.0; in main()
204 PetscCall(InitialConditions(u, &appctx)); in main()
217 …r (2 norm) = %g, avg. error (max norm) = %g\n", (double)(appctx.norm_2 / steps), (double)(appctx.n… in main()
228 PetscCall(PetscViewerDestroy(&appctx.viewer1)); in main()
229 PetscCall(PetscViewerDestroy(&appctx.viewer2)); in main()
230 PetscCall(VecDestroy(&appctx.solution)); in main()
252 PetscErrorCode InitialConditions(Vec u, AppCtx *appctx) in InitialConditions() argument
274 …or (i = 0; i < appctx->m; i++) u_localptr[i] = PetscSinReal(PETSC_PI * i * 6. * appctx->h) + 3. * … in InitialConditions()
284 if (appctx->debug) PetscCall(VecView(u, PETSC_VIEWER_STDOUT_SELF)); in InitialConditions()
299 PetscErrorCode ExactSolution(PetscReal t, Vec solution, AppCtx *appctx) in ExactSolution() argument
301 PetscScalar *s_localptr, h = appctx->h, ex1, ex2, sc1, sc2; in ExactSolution()
318 …for (i = 0; i < appctx->m; i++) s_localptr[i] = PetscSinReal(PetscRealPart(sc1) * (PetscReal)i) * … in ExactSolution()
347 AppCtx *appctx = (AppCtx *)ctx; /* user-defined application context */ in Monitor() local
355 PetscCall(VecView(u, appctx->viewer2)); in Monitor()
360 PetscCall(ExactSolution(crtime, appctx->solution, appctx)); in Monitor()
365 if (appctx->debug) { in Monitor()
369 PetscCall(VecView(appctx->solution, PETSC_VIEWER_STDOUT_SELF)); in Monitor()
375 PetscCall(VecAXPY(appctx->solution, -1.0, u)); in Monitor()
376 PetscCall(VecNorm(appctx->solution, NORM_2, &norm_2)); in Monitor()
377 norm_2 = PetscSqrtReal(appctx->h) * norm_2; in Monitor()
378 PetscCall(VecNorm(appctx->solution, NORM_MAX, &norm_max)); in Monitor()
382 appctx->norm_2 += norm_2; in Monitor()
383 appctx->norm_max += norm_max; in Monitor()
395 PetscCall(VecView(appctx->solution, appctx->viewer1)); in Monitor()
400 if (appctx->debug) { in Monitor()
402 PetscCall(VecView(appctx->solution, PETSC_VIEWER_STDOUT_SELF)); in Monitor()
428 AppCtx *appctx = (AppCtx *)ctx; /* user-defined application context */ in RHSMatrixHeat() local
430 PetscInt mend = appctx->m; in RHSMatrixHeat()
432 PetscScalar v[3], stwo = -2. / (appctx->h * appctx->h), sone = -.5 * stwo; in RHSMatrixHeat()
494 AppCtx *appctx = (AppCtx *)ctx; /* user-defined application context */ in MyBCRoutine() local
495 PetscInt m = appctx->m; in MyBCRoutine()