Lines Matching refs:rectx
140 …tNone(TS ts, Vec X, PetscInt stepi, PetscReal time, PetscBool islast, LandauCtx *ctx, REctx *rectx) in testNone() argument
146 …itzer(TS ts, Vec X, PetscInt stepi, PetscReal time, PetscBool islast, LandauCtx *ctx, REctx *rectx) in testSpitzer() argument
217 if (rectx->use_spitzer_eta) { in testSpitzer()
218 E = ctx->Ez = spit_eta * (rectx->j - J_re); in testSpitzer()
221 rectx->j = J; /* cache */ in testSpitzer()
225 if (stepi > 10 && !rectx->use_spitzer_eta && (old_ratio - ratio < 1.e-6)) { in testSpitzer()
226 rectx->pulse_start = time + 0.98 * dt; in testSpitzer()
227 rectx->use_spitzer_eta = PETSC_TRUE; in testSpitzer()
231 if (rectx->plotting || stepi == 0 || reason || rectx->pulse_start == time + 0.98 * dt) { in testSpitzer()
233 …uble)ratio, (double)(old_ratio - ratio), rectx->use_spitzer_eta ? "using Spitzer eta*J E" : "const… in testSpitzer()
234 …PetscCheck(rectx->pulse_start != (time + 0.98 * dt), PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG, "Spitz… in testSpitzer()
244 REctx *rectx = (REctx *)ctx->data; in f0_0_diff_lp() local
245 PetscInt ii = rectx->idx, i; in f0_0_diff_lp()
258 REctx *rectx = (REctx *)ctx->data; in f0_0_maxwellian_lp() local
259 PetscInt ii = rectx->idx, i; in f0_0_maxwellian_lp()
268 …table(TS ts, Vec X, PetscInt stepi, PetscReal time, PetscBool islast, LandauCtx *ctx, REctx *rectx) in testStable() argument
281 if (!rectx->X_0) { in testStable()
282 PetscCall(VecDuplicate(X, &rectx->X_0)); in testStable()
283 PetscCall(VecCopy(X, rectx->X_0)); in testStable()
285 PetscCall(VecAXPY(X, -1.0, rectx->X_0)); in testStable()
287 rectx->idx = 0; in testStable()
295 rectx->idx = 1; in testStable()
308 PetscCall(VecDestroy(&rectx->X_0)); in testStable()
309 rectx->X_0 = NULL; in testStable()
316 REctx *rectx = (REctx *)ctx->data; in EInduction() local
335 *a_E = -rectx->L * dJ_dt + rectx->Ez_initial; in EInduction()
372 REctx *rectx; in FormSource() local
377 rectx = (REctx *)ctx->data; in FormSource()
379 PetscCall(rectx->impuritySrcRate(ftime, &new_imp_rate, ctx)); in FormSource()
381 if (new_imp_rate != rectx->current_rate) { in FormSource()
385 rectx->current_rate = new_imp_rate; in FormSource()
389 dne_dt = new_imp_rate * rectx->Ne_ion /* *ctx->t_0 */; in FormSource()
391 tilda_ns[rectx->imp_idx] = dni_dt; in FormSource()
392 temps[0] = rectx->T_cold; in FormSource()
393 temps[rectx->imp_idx] = rectx->T_cold; in FormSource()
405 rectx->current_rate = 0; in FormSource()
413 REctx *rectx = (REctx *)ctx->data; in Monitor() local
420 if (rectx->grid_view_idx != -1 || (reason && ctx->verbose > 3)) { in Monitor()
424 if (stepi > rectx->plotStep && rectx->plotting) { in Monitor()
425 rectx->plotting = PETSC_FALSE; /* was doing diagnostics, now done */ in Monitor()
426 rectx->plotIdx++; in Monitor()
429 if (time / rectx->plotDt >= (PetscReal)rectx->plotIdx || reason) { in Monitor()
430 if ((reason || stepi == 0 || rectx->plotIdx % rectx->print_period == 0) && ctx->verbose > 1) { in Monitor()
434 if (!rectx->plotting) { /* first step of possible backtracks */ in Monitor()
435 rectx->plotting = PETSC_TRUE; in Monitor()
437 PetscCall(rectx->test(ts, X, stepi, time, reason ? PETSC_TRUE : PETSC_FALSE, ctx, rectx)); in Monitor()
440 rectx->plotting = PETSC_TRUE; in Monitor()
442 if (rectx->grid_view_idx != -1) { in Monitor()
443 …me((PetscObject)globXArray[LAND_PACK_IDX(ctx->batch_view_idx, rectx->grid_view_idx)], rectx->grid_… in Monitor()
445 …PetscCall(DMSetOutputSequenceNumber(ctx->plex[rectx->grid_view_idx], rectx->plotIdx, time * ctx->t… in Monitor()
446 …PetscCall(VecViewFromOptions(globXArray[LAND_PACK_IDX(ctx->batch_view_idx, rectx->grid_view_idx)],… in Monitor()
448 rectx->plotStep = stepi; in Monitor()
450 …if (rectx->plotting) PetscCall(PetscPrintf(PETSC_COMM_WORLD, " ERROR rectx->plotting=%s step %" Pe… in Monitor()
452 PetscCall(rectx->test(ts, X, stepi, time, reason ? PETSC_TRUE : PETSC_FALSE, ctx, rectx)); in Monitor()
476 rectx->idx = 0; in Monitor()
477 …if (rectx->grid_view_idx != -1 || (reason && ctx->verbose > 3)) PetscCall(DMCompositeRestoreAccess… in Monitor()
484 REctx *rectx; in PreStep() local
496 rectx = (REctx *)ctx->data; in PreStep()
499 PetscCall(rectx->E(X, NULL, stepi, time, ctx, &ctx->Ez)); in PreStep()
506 REctx *rectx = (REctx *)ctx->data; in stepSrc() local
509 if (time >= rectx->pulse_start) *rho = rectx->pulse_rate; in stepSrc()
522 REctx *rectx = (REctx *)ctx->data; in pulseSrc() local
525 …PetscCheck(rectx->pulse_start != PETSC_MAX_REAL, PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG, "'-ex2_pul… in pulseSrc()
526 if (time < rectx->pulse_start || time > rectx->pulse_start + 3 * rectx->pulse_width) *rho = 0; in pulseSrc()
528 …double x = PetscSinReal((time - rectx->pulse_start) / (3 * rectx->pulse_width) * 2 * PETSC_PI - PE… in pulseSrc()
529 *rho = rectx->pulse_rate * x / (3 * rectx->pulse_width); in pulseSrc()
530 if (!rectx->use_spitzer_eta) rectx->use_spitzer_eta = PETSC_TRUE; /* use it next time */ in pulseSrc()
535 static PetscErrorCode ProcessREOptions(REctx *rectx, const LandauCtx *ctx, DM dm, const char prefix… in ProcessREOptions() argument
544 rectx->Ne_ion = 1; /* number of electrons given up by impurity ion */ in ProcessREOptions()
545 rectx->T_cold = .005; /* kev */ in ProcessREOptions()
546 rectx->ion_potential = 15; /* ev */ in ProcessREOptions()
547 rectx->L = 2; in ProcessREOptions()
548 rectx->X_0 = NULL; in ProcessREOptions()
549 rectx->imp_idx = ctx->num_species - 1; /* default ionized impurity as last one */ in ProcessREOptions()
550 rectx->pulse_start = PETSC_MAX_REAL; in ProcessREOptions()
551 rectx->pulse_width = 1; in ProcessREOptions()
552 rectx->plotStep = PETSC_INT_MAX; in ProcessREOptions()
553 rectx->pulse_rate = 1.e-1; in ProcessREOptions()
554 rectx->current_rate = 0; in ProcessREOptions()
555 rectx->plotIdx = 0; in ProcessREOptions()
556 rectx->j = 0; in ProcessREOptions()
557 rectx->plotDt = 1.0; in ProcessREOptions()
558 rectx->plotting = PETSC_FALSE; in ProcessREOptions()
559 rectx->use_spitzer_eta = PETSC_FALSE; in ProcessREOptions()
560 rectx->idx = 0; in ProcessREOptions()
561 rectx->print_period = 10; in ProcessREOptions()
562 rectx->grid_view_idx = -1; // do not get if not needed in ProcessREOptions()
578 …PetscCall(PetscOptionsReal("-ex2_plot_dt", "Plotting interval", "ex2.c", rectx->plotDt, &rectx->pl… in ProcessREOptions()
579 if (rectx->plotDt < 0) rectx->plotDt = 1e30; in ProcessREOptions()
580 if (rectx->plotDt == 0) rectx->plotDt = 1e-30; in ProcessREOptions()
581 …cOptionsInt("-ex2_print_period", "Plotting interval", "ex2.c", rectx->print_period, &rectx->print_… in ProcessREOptions()
582 …tscOptionsInt("-ex2_grid_view_idx", "grid_view_idx", "ex2.c", rectx->grid_view_idx, &rectx->grid_v… in ProcessREOptions()
583 …rectx->grid_view_idx < ctx->num_grids || rectx->grid_view_idx == -1, PETSC_COMM_WORLD, PETSC_ERR_A… in ProcessREOptions()
586 …t("-ex2_impurity_index", "index of sink for impurities", "none", rectx->imp_idx, &rectx->imp_idx, … in ProcessREOptions()
587 …rectx->imp_idx < ctx->num_species && rectx->imp_idx >= 1) || ctx->num_species <= 1, PETSC_COMM_WOR… in ProcessREOptions()
589 rectx->Ne_ion = -ctx->charges[rectx->imp_idx] / ctx->charges[0]; in ProcessREOptions()
590 …ature of cold electron and ions after ionization in keV", "none", rectx->T_cold, &rectx->T_cold, N… in ProcessREOptions()
591 …me", "Time at which pulse happens for 'pulse' source", "none", rectx->pulse_start, &rectx->pulse_s… in ProcessREOptions()
592 …x2_pulse_width_time", "Width of pulse 'pulse' source", "none", rectx->pulse_width, &rectx->pulse_w… in ProcessREOptions()
593 …se_rate", "Number density of pulse for 'pulse' source", "none", rectx->pulse_rate, &rectx->pulse_r… in ProcessREOptions()
594 rectx->T_cold *= 1.16e7; /* convert to Kelvin */ in ProcessREOptions()
595 …otential to ionize impurity (should be array) in ev", "none", rectx->ion_potential, &rectx->ion_po… in ProcessREOptions()
596 …PetscCall(PetscOptionsReal("-ex2_inductance", "Inductance E field", "none", rectx->L, &rectx->L, N… in ProcessREOptions()
598 …otential=%10.3e, E_z=%10.3e v_0=%10.3e\n", (double)rectx->Ne_ion, (double)rectx->T_cold, (double)r… in ProcessREOptions()
601 PetscCall(PetscFunctionListFind(plist, pname, &rectx->impuritySrcRate)); in ProcessREOptions()
602 …PetscCheck(rectx->impuritySrcRate, PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG, "No impurity source func… in ProcessREOptions()
603 PetscCall(PetscFunctionListFind(testlist, testname, &rectx->test)); in ProcessREOptions()
604 PetscCheck(rectx->test, PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG, "No test found '%s'", testname); in ProcessREOptions()
605 PetscCall(PetscFunctionListFind(elist, ename, &rectx->E)); in ProcessREOptions()
606 …PetscCheck(rectx->E, PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG, "No E field function found '%s'", enam… in ProcessREOptions()
630 REctx *rectx; in main() local
653 PetscCall(PetscNew(&rectx)); in main()
654 ctx->data = rectx; in main()
655 PetscCall(ProcessREOptions(rectx, ctx, pack, "")); in main()
657 if (rectx->grid_view_idx != -1) { in main()
661 …ame((PetscObject)XsubArray[LAND_PACK_IDX(ctx->batch_view_idx, rectx->grid_view_idx)], rectx->grid_… in main()
662 PetscCall(DMSetOutputSequenceNumber(ctx->plex[rectx->grid_view_idx], 0, 0.0)); in main()
663 PetscCall(DMViewFromOptions(ctx->plex[rectx->grid_view_idx], NULL, "-ex2_dm_view")); in main()
664 PetscCall(DMViewFromOptions(ctx->plex[rectx->grid_view_idx], NULL, "-ex2_dm_view_init")); in main()
665 …PetscCall(VecViewFromOptions(XsubArray[LAND_PACK_IDX(ctx->batch_view_idx, rectx->grid_view_idx)], … in main()
666 …PetscCall(VecViewFromOptions(XsubArray[LAND_PACK_IDX(ctx->batch_view_idx, rectx->grid_view_idx)], … in main()
681 rectx->Ez_initial = ctx->Ez; /* cache for induction calculation - applied E field */ in main()
698 rectx->plotIdx = 0; in main()
699 rectx->plotting = PETSC_FALSE; in main()
721 PetscCall(PetscFree(rectx)); in main()