Lines Matching refs:ctx
41 PetscErrorCode EventFunction(TS ts, PetscReal t, Vec U, PetscReal gval[], PetscCtx ctx);
42 …nt(TS ts, PetscInt nev_zero, PetscInt evs_zero[], PetscReal t, Vec U, PetscBool fwd, PetscCtx ctx);
54 AppCtx ctx; in main() local
59 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &ctx.rank)); in main()
60 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &ctx.size)); in main()
61 ctx.pi = PetscAcosReal(-1.0); in main()
62 ctx.cnt = 0; in main()
63 ctx.cntref = 0; in main()
64 ctx.flg = PETSC_FALSE; in main()
65 ctx.errtol = 1e-5; in main()
66 ctx.restart = PETSC_FALSE; in main()
67 ctx.dtpost = 0; in main()
68 ctx.postcnt = 0; in main()
69 ctx.F = -1; in main()
70 ctx.Fnum = 12; in main()
73 if (ctx.rank == 0) m = 2; in main()
88 if (ctx.rank == 0) { // initial conditions in main()
111 …PetscCall(PetscOptionsHasName(NULL, NULL, "-flg", &ctx.flg)); // flag for additional… in main()
112 …PetscCall(PetscOptionsGetReal(NULL, NULL, "-errtol", &ctx.errtol, NULL)); // error tolerance for… in main()
113 …PetscCall(PetscOptionsGetBool(NULL, NULL, "-restart", &ctx.restart, NULL)); // flag for TSRestartS… in main()
114 PetscCall(PetscOptionsGetReal(NULL, NULL, "-dtpost", &ctx.dtpost, NULL)); // post-event step in main()
115 …PetscCall(PetscOptionsGetInt(NULL, NULL, "-F", &ctx.F, NULL)); // event-function index in main()
116 …PetscCheck(ctx.F >= -1 && ctx.F < ctx.Fnum, PetscObjectComm((PetscObject)ts), PETSC_ERR_ARG_OUTOFR… in main()
119 if (ctx.rank == 0) { // all events -- on rank-0 in main()
120 if (ctx.F == -1) in main()
121 for (n = 0; n < ctx.Fnum; n++) { // all event-functions in main()
131 if (ctx.F == 0 || ctx.F == -1) { in main()
132 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 2.0; in main()
133 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 4.0; in main()
134 if (dir0 <= 0) ctx.ref[ctx.cntref++] = 1.0; in main()
135 if (dir0 <= 0) ctx.ref[ctx.cntref++] = 3.0; in main()
137 if (ctx.F == 1 || ctx.F == -1) in main()
138 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 1.0; in main()
139 if (ctx.F == 2 || ctx.F == -1) in main()
140 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 1.0; in main()
141 if (ctx.F == 3 || ctx.F == -1) in main()
142 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 1.696812386809752; in main()
143 if (ctx.F == 4 || ctx.F == -1) in main()
144 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 0.1; in main()
145 if (ctx.F == 5 || ctx.F == -1) in main()
146 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 1.02; in main()
147 if (ctx.F == 6 || ctx.F == -1) in main()
148 if (dir0 <= 0) ctx.ref[ctx.cntref++] = 0.90478821787302; in main()
149 if (ctx.F == 7 || ctx.F == -1) in main()
150 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 0.05; in main()
151 if (ctx.F == 8 || ctx.F == -1) in main()
152 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 0.552704666678489; in main()
153 if (ctx.F == 9 || ctx.F == -1) in main()
154 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 0.399422291710969; in main()
155 if (ctx.F == 10 || ctx.F == -1) { in main()
156 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 0.874511220376091; in main()
157 if (dir0 <= 0) ctx.ref[ctx.cntref++] = 2.388359335869107; in main()
159 if (ctx.F == 11 || ctx.F == -1) in main()
160 if (dir0 >= 0) ctx.ref[ctx.cntref++] = 2.5; in main()
162 if (ctx.cntref > 0) PetscCall(PetscSortReal(ctx.cntref, ctx.ref)); in main()
163 PetscCall(TSSetEventHandler(ts, n, dir, term, EventFunction, Postevent, &ctx)); in main()
169 for (PetscInt j = 0; j < ctx.cnt; j++) { in main()
171 if (j < ctx.cntref) err = PetscAbsReal(ctx.evres[j] - ctx.ref[j]); in main()
172 …izedPrintf(PETSC_COMM_WORLD, "%d\t%g\t%g\t%s\n", ctx.rank, (double)ctx.evres[j], (double)err, err … in main()
173 pass = (pass && err < ctx.errtol ? PETSC_TRUE : PETSC_FALSE); in main()
189 PetscErrorCode EventFunction(TS ts, PetscReal t, Vec U, PetscReal gval[], PetscCtx ctx) in EventFunction() argument
192 AppCtx *Ctx = (AppCtx *)ctx; in EventFunction()
220 …ent(TS ts, PetscInt nev_zero, PetscInt evs_zero[], PetscReal t, Vec U, PetscBool fwd, PetscCtx ctx) in Postevent() argument
222 AppCtx *Ctx = (AppCtx *)ctx; in Postevent()
226 PetscCallBack("EventFunction", EventFunction(ts, t, U, Ctx->fvals, ctx)); in Postevent()