Lines Matching +full:test +full:- +full:basic

8                      "y_dot = -0.2*x\n"
9 "Using one or several event functions (on rank-0)\n"
10 …"This program is mostly intended to test the Anderson-Bjorck iteration with challenging event-func…
12 "-dir d : zero-crossing direction for events\n"
13 "-flg : additional output in Postevent\n"
14 … "-errtol e : error tolerance, for printing 'pass/fail' for located events (1e-5 by default)\n"
15 "-restart : flag for TSRestartStep() in PostEvent\n"
16 … "-dtpost x : if x > 0, then on even PostEvent calls 1st-post-event-step = x is set,\n"
17 … " on odd PostEvent calls 1st-post-event-step = PETSC_DECIDE is set,\n"
19 …"-func F : selects the event function [0, ..., 11], if F == -1 (default) is set, all event funct…
28 PetscReal evres[MAX_NEV]; // times of found zero-crossings
29 PetscReal ref[MAX_NEV]; // reference times of zero-crossings, for checking
33 …errtol; // error tolerance, for printing 'pass/fail' for located events (1e-5 by default)
35 PetscReal dtpost; // post-event step
37 PetscInt F; // event-function index
61 ctx.pi = PetscAcosReal(-1.0); in main()
65 ctx.errtol = 1e-5; in main()
69 ctx.F = -1; in main()
78 vals[2] = -0.2; in main()
110 …PetscCall(PetscOptionsGetInt(NULL, NULL, "-dir", &dir0, NULL)); // desired zero-crossi… 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()
125 else { // single event-function in main()
131 if (ctx.F == 0 || ctx.F == -1) { in main()
137 if (ctx.F == 1 || ctx.F == -1) in main()
139 if (ctx.F == 2 || ctx.F == -1) in main()
141 if (ctx.F == 3 || ctx.F == -1) in main()
143 if (ctx.F == 4 || ctx.F == -1) in main()
145 if (ctx.F == 5 || ctx.F == -1) in main()
147 if (ctx.F == 6 || ctx.F == -1) in main()
149 if (ctx.F == 7 || ctx.F == -1) in main()
151 if (ctx.F == 8 || ctx.F == -1) in main()
153 if (ctx.F == 9 || ctx.F == -1) in main()
155 if (ctx.F == 10 || ctx.F == -1) { in main()
159 if (ctx.F == 11 || ctx.F == -1) in main()
171 if (j < ctx.cntref) err = PetscAbsReal(ctx.evres[j] - ctx.ref[j]); in main()
176 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "This test: %s\n", pass ? "PASSED" : "FAILED")); in main()
187 User callback for defining the event-functions
195 // for the test purposes, event-functions are defined based on t in EventFunction()
196 // all events -- on rank-0 in EventFunction()
197 if (Ctx->rank == 0) { in EventFunction()
198 …if (Ctx->F == 0 || Ctx->F == -1) gval[n++] = PetscSinReal(Ctx->pi * t) / Ctx->pi; // FUNC-0, roots… in EventFunction()
199 …if (Ctx->F == 1 || Ctx->F == -1) gval[n++] = PetscLogReal(t); // FUNC-2, root 1 in EventFunction()
200 …if (Ctx->F == 2 || Ctx->F == -1) { // FUNC-3, root 1 in EventFunction()
201 if (t < 2) gval[n++] = (1 - PetscPowReal(t - 2, 12)) / 12.0; in EventFunction()
204 … (Ctx->F == 3 || Ctx->F == -1) gval[n++] = t - PetscExpReal(PetscSinReal(t)) + 1; … in EventFunction()
205 … (Ctx->F == 4 || Ctx->F == -1) gval[n++] = (1e10 * PetscPowReal(t, 1 / t) - 1) / 100; … in EventFunction()
206 … (Ctx->F == 5 || Ctx->F == -1) gval[n++] = PetscLogReal(t - 0.02) * PetscLogReal(t - 0.02) * Petsc… in EventFunction()
207 … (Ctx->F == 6 || Ctx->F == -1) gval[n++] = 4 * PetscCosReal(t) - PetscExpReal(t); … in EventFunction()
208 … (Ctx->F == 7 || Ctx->F == -1) gval[n++] = (20.0 * t - 1) / (19.0 * t) / 10; … in EventFunction()
209 … (Ctx->F == 8 || Ctx->F == -1) gval[n++] = ((t - 1) * PetscExpReal(-20 * t) + PetscPowReal(t, 20))… in EventFunction()
210 … (Ctx->F == 9 || Ctx->F == -1) gval[n++] = (t * t * (t * t / 3.0 + PetscSqrtReal(2.0) * PetscSinRe… in EventFunction()
211 … (Ctx->F == 10 || Ctx->F == -1) gval[n++] = ((t * t + 1) * PetscSinReal(t) - PetscExpReal(PetscSqr… in EventFunction()
212 … (Ctx->F == 11 || Ctx->F == -1) gval[n++] = 2 * t - 5; … in EventFunction()
218 User callback for the post-event stuff
225 if (Ctx->flg) { in Postevent()
226 PetscCallBack("EventFunction", EventFunction(ts, t, U, Ctx->fvals, ctx)); in Postevent()
227 …, "[%d] At t = %20.16g : %" PetscInt_FMT " events triggered, fvalues =", Ctx->rank, (double)t, nev… in Postevent()
228 …j++) PetscCall(PetscSynchronizedPrintf(PETSC_COMM_WORLD, "\t%g", (double)Ctx->fvals[evs_zero[j]])); in Postevent()
233 if (Ctx->cnt + nev_zero < MAX_NEV) in Postevent()
234 …for (PetscInt i = 0; i < nev_zero; i++) Ctx->evres[Ctx->cnt++] = t; // save the repeating zeros se… in Postevent()
237 Ctx->postcnt++; // sync in Postevent()
238 if (Ctx->dtpost > 0) { in Postevent()
239 if (Ctx->postcnt % 2 == 0) PetscCall(TSSetPostEventStep(ts, Ctx->dtpost)); in Postevent()
244 if (Ctx->restart) PetscCall(TSRestartStep(ts)); in Postevent()
247 /*---------------------------------------------------------------------------------------------*/
249 Note, in the tests below, -ts_event_post_event_step is occasionally set to -1,
251 explicitly specify -1 in this option. Rather, if PETSC_DECIDE behaviour is needed,
255 /*TEST
256 test:
260 args: -dir 0
261 args: -ts_adapt_dt_min 1e-10 -ts_event_dt_min 1e-10
262 args: -ts_time_step 0.25
263 args: -restart 0
264 args: -ts_event_tol {{1e-8 1e-15}}
265 args: -errtol 1e-7
266 args: -ts_adapt_type {{none basic}}
267 args: -dtpost 0
268 args: -ts_event_post_event_step -1
269 args: -ts_type rk
274 test:
278 args: -dir 0
279 args: -ts_adapt_dt_min 1e-6 -ts_event_dt_min 1e-6
280 args: -ts_time_step 0.3
281 args: -ts_event_tol {{1e-7 1e-10}}
282 args: -ts_adapt_type {{none basic}}
283 args: -dtpost 0.23
284 args: -ts_event_post_event_step -1
285 args: -ts_type beuler
290 test:
293 args: -dir 0
294 args: -ts_adapt_dt_min 1e-10 -ts_event_dt_min 1e-6
295 args: -ts_time_step 0.4
296 args: -F 7
297 args: -ts_event_tol {{1e-8 1e-15}}
298 args: -ts_adapt_type {{none basic}}
299 args: -ts_type rk
302 test:
305 args: -ts_event_monitor -F 7 -ts_time_step 0.04 -ts_event_dt_min 0.016 -errtol 0.005
308 test:
311 args: -dir 0
312 args: -F {{-1 0 1 2 3 4 5 6 7 8 9 10 11}}
313 args: -ts_event_dt_min 1e-6 -ts_time_step 0.4 -ts_event_tol 1e-8
314 args: -ts_adapt_type {{none basic}}
315 args: -dtpost 0.35
316 args: -ts_type rk
317 filter: grep "This test"
320 test:
323 args: -dir 1
324 args: -F {{-1 0 1 2 3 4 5 7 8 9 10 11}}
325 args: -ts_event_dt_min 1e-6 -ts_time_step 0.4 -ts_event_tol 1e-8
326 args: -ts_adapt_type none
327 args: -dtpost 0.34
328 args: -ts_type beuler
329 filter: grep "This test"
332 test:
335 args: -dir -1
336 args: -F {{-1 0 6 10}}
337 args: -ts_event_dt_min 1e-6 -ts_time_step 0.4 -ts_event_tol 1e-8
338 args: -ts_adapt_type {{none basic}}
339 args: -dtpost 0.33
340 args: -ts_type rk
341 filter: grep "This test"
344 test:
347 args: -dir 1
348 args: -ts_adapt_dt_min 1e-10 -ts_event_dt_min 1e-6
349 args: -ts_time_step 0.4
350 args: -restart 0
351 args: -ts_event_tol {{1e-8 1e-15}}
352 args: -ts_adapt_type {{none basic}}
353 args: -dtpost 0.25
354 args: -ts_event_post_event_step -1
355 args: -ts_type {{beuler rk}}
358 test:
361 args: -dir -1
362 args: -ts_adapt_dt_min 1e-10 -ts_event_dt_min 1e-6
363 args: -ts_time_step 0.4
364 args: -restart 1
365 args: -ts_event_tol {{1e-8 1e-15}}
366 args: -ts_adapt_type {{none basic}}
367 args: -dtpost 0.25
368 args: -ts_event_post_event_step 0.35
369 args: -ts_type rk
373 TEST*/