Lines Matching refs:ctx

59   AdvectCtx *ctx = (AdvectCtx *)vctx;  in PhysicsRiemann_Advect()  local
63 speed = ctx->a; in PhysicsRiemann_Advect()
71 AdvectCtx *ctx = (AdvectCtx *)vctx; in PhysicsCharacteristic_Advect() local
76 speeds[0] = ctx->a; in PhysicsCharacteristic_Advect()
82 AdvectCtx *ctx = (AdvectCtx *)vctx; in PhysicsSample_Advect() local
83 PetscReal a = ctx->a, x0; in PhysicsSample_Advect()
127 static PetscErrorCode PhysicsCreate_Advect(FVCtx *ctx) in PhysicsCreate_Advect() argument
133 ctx->physics2.sample2 = PhysicsSample_Advect; in PhysicsCreate_Advect()
134 ctx->physics2.riemann2 = PhysicsRiemann_Advect; in PhysicsCreate_Advect()
135 ctx->physics2.characteristic2 = PhysicsCharacteristic_Advect; in PhysicsCreate_Advect()
136 ctx->physics2.destroy = PhysicsDestroy_SimpleFree; in PhysicsCreate_Advect()
137 ctx->physics2.user = user; in PhysicsCreate_Advect()
138 ctx->physics2.dof = 1; in PhysicsCreate_Advect()
140 PetscCall(PetscStrallocpy("u", &ctx->physics2.fieldname[0])); in PhysicsCreate_Advect()
142 PetscOptionsBegin(ctx->comm, ctx->prefix, "Options for advection", ""); in PhysicsCreate_Advect()
368 FVCtx *ctx = (FVCtx *)vctx; in PhysicsInflow_Shallow() local
371 if (ctx->bctype == FVBC_INFLOW) { in PhysicsInflow_Shallow()
372 switch (ctx->initial) { in PhysicsInflow_Shallow()
410 static PetscErrorCode PhysicsSetInflowType_Shallow(FVCtx *ctx) in PhysicsSetInflowType_Shallow() argument
413 switch (ctx->initial) { in PhysicsSetInflowType_Shallow()
423 ctx->physics2.bcinflowindex[0] = PETSC_FALSE; in PhysicsSetInflowType_Shallow()
424 ctx->physics2.bcinflowindex[1] = PETSC_TRUE; in PhysicsSetInflowType_Shallow()
425 ctx->physics2.bcinflowindex[2] = PETSC_FALSE; in PhysicsSetInflowType_Shallow()
426 ctx->physics2.bcinflowindex[3] = PETSC_TRUE; in PhysicsSetInflowType_Shallow()
434 static PetscErrorCode PhysicsCreate_Shallow(FVCtx *ctx) in PhysicsCreate_Shallow() argument
442 ctx->physics2.sample2 = PhysicsSample_Shallow; in PhysicsCreate_Shallow()
443 ctx->physics2.inflow = PhysicsInflow_Shallow; in PhysicsCreate_Shallow()
444 ctx->physics2.destroy = PhysicsDestroy_SimpleFree; in PhysicsCreate_Shallow()
445 ctx->physics2.riemann2 = PhysicsRiemann_Shallow_Rusanov; in PhysicsCreate_Shallow()
446 ctx->physics2.characteristic2 = PhysicsCharacteristic_Shallow; in PhysicsCreate_Shallow()
447 ctx->physics2.user = user; in PhysicsCreate_Shallow()
448 ctx->physics2.dof = 2; in PhysicsCreate_Shallow()
450 PetscCall(PetscMalloc1(2 * (ctx->physics2.dof), &ctx->physics2.bcinflowindex)); in PhysicsCreate_Shallow()
451 PetscCall(PhysicsSetInflowType_Shallow(ctx)); in PhysicsCreate_Shallow()
453 PetscCall(PetscStrallocpy("height", &ctx->physics2.fieldname[0])); in PhysicsCreate_Shallow()
454 PetscCall(PetscStrallocpy("momentum", &ctx->physics2.fieldname[1])); in PhysicsCreate_Shallow()
462 PetscOptionsBegin(ctx->comm, ctx->prefix, "Options for Shallow", ""); in PhysicsCreate_Shallow()
467 PetscCall(RiemannListFind_2WaySplit(rlist, rname, &ctx->physics2.riemann2)); in PhysicsCreate_Shallow()
468 PetscCall(ReconstructListFind_2WaySplit(rclist, rcname, &ctx->physics2.characteristic2)); in PhysicsCreate_Shallow()
474 PetscErrorCode FVSample_2WaySplit(FVCtx *ctx, DM da, PetscReal time, Vec U) in FVSample_2WaySplit() argument
482 …PetscCheck(ctx->physics2.sample2, PETSC_COMM_SELF, PETSC_ERR_SUP, "Physics has not provided a samp… in FVSample_2WaySplit()
487 hs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in FVSample_2WaySplit()
488 hf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in FVSample_2WaySplit()
490 if (i < ctx->sf) { in FVSample_2WaySplit()
491 xi = ctx->xmin + 0.5 * hs + i * hs; in FVSample_2WaySplit()
496 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_2WaySplit()
499 } else if (i < ctx->fs) { in FVSample_2WaySplit()
500 xi = ctx->xmin + ctx->sf * hs + 0.5 * hf + (i - ctx->sf) * hf; in FVSample_2WaySplit()
505 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_2WaySplit()
509 xi = ctx->xmin + ctx->sf * hs + (ctx->fs - ctx->sf) * hf + 0.5 * hs + (i - ctx->fs) * hs; in FVSample_2WaySplit()
514 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_2WaySplit()
524 static PetscErrorCode SolutionErrorNorms_2WaySplit(FVCtx *ctx, DM da, PetscReal t, Vec X, PetscReal… in SolutionErrorNorms_2WaySplit() argument
534 PetscCall(FVSample_2WaySplit(ctx, da, t, Y)); in SolutionErrorNorms_2WaySplit()
535 hs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in SolutionErrorNorms_2WaySplit()
536 hf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in SolutionErrorNorms_2WaySplit()
540 if (i < ctx->sf || i > ctx->fs - 1) *nrm1 += hs * PetscAbs(ptr_X[i] - ptr_Y[i]); in SolutionErrorNorms_2WaySplit()
551 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunction_2WaySplit() local
552 PetscInt i, j, k, Mx, dof, xs, xm, sf = ctx->sf, fs = ctx->fs; in FVRHSFunction_2WaySplit()
562 hxs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in FVRHSFunction_2WaySplit()
563 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in FVRHSFunction_2WaySplit()
574 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunction_2WaySplit()
583 if (ctx->bctype == FVBC_INFLOW) { in FVRHSFunction_2WaySplit()
587 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmin, ctx->ub)); in FVRHSFunction_2WaySplit()
589 if (ctx->physics2.bcinflowindex[j]) { in FVRHSFunction_2WaySplit()
590 for (i = -2; i < 0; i++) x[i * dof + j] = 2.0 * ctx->ub[j] - x[-(i + 1) * dof + j]; in FVRHSFunction_2WaySplit()
597 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmax, ctx->ub)); in FVRHSFunction_2WaySplit()
599 if (ctx->physics2.bcinflowindex[dof + j]) { in FVRHSFunction_2WaySplit()
600 …for (i = Mx; i < Mx + 2; i++) x[i * dof + j] = 2.0 * ctx->ub[dof + j] - x[(2 * Mx - (i + 1)) * dof… in FVRHSFunction_2WaySplit()
612 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunction_2WaySplit()
614 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunction_2WaySplit()
615 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunction_2WaySplit()
616 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunction_2WaySplit()
622 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunction_2WaySplit()
623 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunction_2WaySplit()
630 (*ctx->limit2)(&info, cjmpL, cjmpR, ctx->sf, ctx->fs, i, ctx->cslope); in FVRHSFunction_2WaySplit()
633 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunction_2WaySplit()
641 uL = &ctx->uLR[0]; in FVRHSFunction_2WaySplit()
642 uR = &ctx->uLR[dof]; in FVRHSFunction_2WaySplit()
648 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_2WaySplit()
650 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
653 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
660 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_2WaySplit()
662 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
665 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxf; in FVRHSFunction_2WaySplit()
672 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_2WaySplit()
674 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunction_2WaySplit()
677 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxf; in FVRHSFunction_2WaySplit()
684 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_2WaySplit()
686 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunction_2WaySplit()
689 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
696 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_2WaySplit()
699 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
702 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxs; in FVRHSFunction_2WaySplit()
710 …PetscCallMPI(MPIU_Allreduce(&cfl_idt, &ctx->cfl_idt, 1, MPIU_SCALAR, MPIU_MAX, PetscObjectComm((Pe… in FVRHSFunction_2WaySplit()
716 if (dt > 0.5 / ctx->cfl_idt) { in FVRHSFunction_2WaySplit()
717 …etscCall(PetscPrintf(ctx->comm, "Stability constraint exceeded at t=%g, dt %g > %g\n", (double)tno… in FVRHSFunction_2WaySplit()
718 …ERR_PLIB, "Stability constraint exceeded, %g > %g", (double)dt, (double)(ctx->cfl / ctx->cfl_idt)); in FVRHSFunction_2WaySplit()
727 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionslow_2WaySplit() local
728 … i, j, k, Mx, dof, xs, xm, islow = 0, sf = ctx->sf, fs = ctx->fs, lsbwidth = ctx->lsbwidth, rsbw… in FVRHSFunctionslow_2WaySplit()
738 hxs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in FVRHSFunctionslow_2WaySplit()
739 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in FVRHSFunctionslow_2WaySplit()
748 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionslow_2WaySplit()
756 if (ctx->bctype == FVBC_INFLOW) { in FVRHSFunctionslow_2WaySplit()
760 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmin, ctx->ub)); in FVRHSFunctionslow_2WaySplit()
762 if (ctx->physics2.bcinflowindex[j] == PETSC_TRUE) { in FVRHSFunctionslow_2WaySplit()
763 for (i = -2; i < 0; i++) x[i * dof + j] = 2.0 * ctx->ub[j] - x[-(i + 1) * dof + j]; in FVRHSFunctionslow_2WaySplit()
770 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmax, ctx->ub)); in FVRHSFunctionslow_2WaySplit()
772 if (ctx->physics2.bcinflowindex[dof + j] == PETSC_TRUE) { in FVRHSFunctionslow_2WaySplit()
773 …for (i = Mx; i < Mx + 2; i++) x[i * dof + j] = 2.0 * ctx->ub[dof + j] - x[(2 * Mx - (i + 1)) * dof… in FVRHSFunctionslow_2WaySplit()
785 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionslow_2WaySplit()
787 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionslow_2WaySplit()
788 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionslow_2WaySplit()
789 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionslow_2WaySplit()
795 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionslow_2WaySplit()
796 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionslow_2WaySplit()
803 (*ctx->limit2)(&info, cjmpL, cjmpR, ctx->sf, ctx->fs, i, ctx->cslope); in FVRHSFunctionslow_2WaySplit()
806 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionslow_2WaySplit()
815 uL = &ctx->uLR[0]; in FVRHSFunctionslow_2WaySplit()
816 uR = &ctx->uLR[dof]; in FVRHSFunctionslow_2WaySplit()
822 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_2WaySplit()
825 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
828 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
837 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_2WaySplit()
839 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
847 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_2WaySplit()
849 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
858 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_2WaySplit()
860 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
863 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_2WaySplit()
872 …PetscCallMPI(MPIU_Allreduce(&cfl_idt, &ctx->cfl_idt, 1, MPIU_SCALAR, MPIU_MAX, PetscObjectComm((Pe… in FVRHSFunctionslow_2WaySplit()
878 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionslowbuffer_2WaySplit() local
879 … i, j, k, Mx, dof, xs, xm, islow = 0, sf = ctx->sf, fs = ctx->fs, lsbwidth = ctx->lsbwidth, rsbw… in FVRHSFunctionslowbuffer_2WaySplit()
889 hxs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in FVRHSFunctionslowbuffer_2WaySplit()
890 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in FVRHSFunctionslowbuffer_2WaySplit()
899 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionslowbuffer_2WaySplit()
907 if (ctx->bctype == FVBC_INFLOW) { in FVRHSFunctionslowbuffer_2WaySplit()
911 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmin, ctx->ub)); in FVRHSFunctionslowbuffer_2WaySplit()
913 if (ctx->physics2.bcinflowindex[j] == PETSC_TRUE) { in FVRHSFunctionslowbuffer_2WaySplit()
914 for (i = -2; i < 0; i++) x[i * dof + j] = 2.0 * ctx->ub[j] - x[-(i + 1) * dof + j]; in FVRHSFunctionslowbuffer_2WaySplit()
921 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmax, ctx->ub)); in FVRHSFunctionslowbuffer_2WaySplit()
923 if (ctx->physics2.bcinflowindex[dof + j] == PETSC_TRUE) { in FVRHSFunctionslowbuffer_2WaySplit()
924 …for (i = Mx; i < Mx + 2; i++) x[i * dof + j] = 2.0 * ctx->ub[dof + j] - x[(2 * Mx - (i + 1)) * dof… in FVRHSFunctionslowbuffer_2WaySplit()
936 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionslowbuffer_2WaySplit()
938 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionslowbuffer_2WaySplit()
939 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionslowbuffer_2WaySplit()
940 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionslowbuffer_2WaySplit()
946 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionslowbuffer_2WaySplit()
947 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionslowbuffer_2WaySplit()
954 (*ctx->limit2)(&info, cjmpL, cjmpR, ctx->sf, ctx->fs, i, ctx->cslope); in FVRHSFunctionslowbuffer_2WaySplit()
957 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionslowbuffer_2WaySplit()
966 uL = &ctx->uLR[0]; in FVRHSFunctionslowbuffer_2WaySplit()
967 uR = &ctx->uLR[dof]; in FVRHSFunctionslowbuffer_2WaySplit()
973 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
975 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
984 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
986 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
989 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
998 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
1000 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
1008 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
1010 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
1019 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
1021 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
1024 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
1033 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_2WaySplit()
1035 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_2WaySplit()
1049 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionfast_2WaySplit() local
1050 PetscInt i, j, k, Mx, dof, xs, xm, ifast = 0, sf = ctx->sf, fs = ctx->fs; in FVRHSFunctionfast_2WaySplit()
1060 hxs = (ctx->xmax - ctx->xmin) * 3.0 / 8.0 / ctx->sf; in FVRHSFunctionfast_2WaySplit()
1061 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fs - ctx->sf); in FVRHSFunctionfast_2WaySplit()
1070 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionfast_2WaySplit()
1078 if (ctx->bctype == FVBC_INFLOW) { in FVRHSFunctionfast_2WaySplit()
1082 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmin, ctx->ub)); in FVRHSFunctionfast_2WaySplit()
1084 if (ctx->physics2.bcinflowindex[j] == PETSC_TRUE) { in FVRHSFunctionfast_2WaySplit()
1085 for (i = -2; i < 0; i++) x[i * dof + j] = 2.0 * ctx->ub[j] - x[-(i + 1) * dof + j]; in FVRHSFunctionfast_2WaySplit()
1092 PetscCall(ctx->physics2.inflow(ctx, time, ctx->xmax, ctx->ub)); in FVRHSFunctionfast_2WaySplit()
1094 if (ctx->physics2.bcinflowindex[dof + j] == PETSC_TRUE) { in FVRHSFunctionfast_2WaySplit()
1095 …for (i = Mx; i < Mx + 2; i++) x[i * dof + j] = 2.0 * ctx->ub[dof + j] - x[(2 * Mx - (i + 1)) * dof… in FVRHSFunctionfast_2WaySplit()
1106 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionfast_2WaySplit()
1107 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionfast_2WaySplit()
1108 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionfast_2WaySplit()
1109 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionfast_2WaySplit()
1115 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionfast_2WaySplit()
1116 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionfast_2WaySplit()
1123 (*ctx->limit2)(&info, cjmpL, cjmpR, ctx->sf, ctx->fs, i, ctx->cslope); in FVRHSFunctionfast_2WaySplit()
1126 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionfast_2WaySplit()
1135 uL = &ctx->uLR[0]; in FVRHSFunctionfast_2WaySplit()
1136 uR = &ctx->uLR[dof]; in FVRHSFunctionfast_2WaySplit()
1142 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_2WaySplit()
1144 for (j = 0; j < dof; j++) f[ifast * dof + j] += ctx->flux[j] / hxf; in FVRHSFunctionfast_2WaySplit()
1153 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_2WaySplit()
1155 for (j = 0; j < dof; j++) f[(ifast - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunctionfast_2WaySplit()
1158 for (j = 0; j < dof; j++) f[ifast * dof + j] += ctx->flux[j] / hxf; in FVRHSFunctionfast_2WaySplit()
1167 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_2WaySplit()
1169 for (j = 0; j < dof; j++) f[(ifast - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunctionfast_2WaySplit()
1188 FVCtx ctx; in main() local
1196 PetscCall(PetscMemzero(&ctx, sizeof(ctx))); in main()
1212 ctx.comm = comm; in main()
1213 ctx.cfl = 0.9; in main()
1214 ctx.bctype = FVBC_PERIODIC; in main()
1215 ctx.xmin = -1.0; in main()
1216 ctx.xmax = 1.0; in main()
1217 ctx.initial = 1; in main()
1218 ctx.hratio = 2; in main()
1220 ctx.simulation = PETSC_FALSE; in main()
1222 PetscCall(PetscOptionsReal("-xmin", "X min", "", ctx.xmin, &ctx.xmin, NULL)); in main()
1223 PetscCall(PetscOptionsReal("-xmax", "X max", "", ctx.xmax, &ctx.xmax, NULL)); in main()
1228 …nsInt("-initial", "Initial condition (depends on the physics)", "", ctx.initial, &ctx.initial, NUL… in main()
1229 …PetscCall(PetscOptionsBool("-exact", "Compare errors with exact solution", "", ctx.exact, &ctx.exa… in main()
1230 …Bool("-simulation", "Compare errors with reference solution", "", ctx.simulation, &ctx.simulation,… in main()
1231 PetscCall(PetscOptionsReal("-cfl", "CFL number to time step at", "", ctx.cfl, &ctx.cfl, NULL)); in main()
1232 …m("-bc_type", "Boundary condition", "", FVBCTypes, (PetscEnum)ctx.bctype, (PetscEnum *)&ctx.bctype… in main()
1233 PetscCall(PetscOptionsInt("-hratio", "Spacing ratio", "", ctx.hratio, &ctx.hratio, NULL)); in main()
1237 PetscCall(PetscFunctionListFind(limiters, lname, &ctx.limit2)); in main()
1238 …PetscCheck(ctx.limit2, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE, "Limiter '%s' not found", lnam… in main()
1246 PetscCall((*r)(&ctx)); in main()
1250 PetscCall(DMDACreate1d(comm, DM_BOUNDARY_PERIODIC, 50, ctx.physics2.dof, 2, NULL, &da)); in main()
1255 …for (i = 0; i < ctx.physics2.dof; i++) PetscCall(DMDASetFieldName(da, i, ctx.physics2.fieldname[i]… in main()
1260 …tscCall(DMDASetUniformCoordinates(da, ctx.xmin + 0.5 * (ctx.xmax - ctx.xmin) / Mx, ctx.xmax + 0.5 … in main()
1263 …PetscCall(PetscMalloc4(dof * dof, &ctx.R, dof * dof, &ctx.Rinv, 2 * dof, &ctx.cjmpLR, 1 * dof, &ct… in main()
1264 PetscCall(PetscMalloc3(2 * dof, &ctx.uLR, dof, &ctx.flux, dof, &ctx.speeds)); in main()
1265 PetscCall(PetscMalloc1(2 * dof, &ctx.ub)); in main()
1274 count_slow = Mx * 3 / (3 + ctx.hratio); // compute Mx / (1.0 + ctx.hratio / 3.0); in main()
1277 ctx.sf = count_slow / 2; in main()
1278 ctx.fs = ctx.sf + count_fast; in main()
1282 ctx.lsbwidth = 4; in main()
1283 ctx.rsbwidth = 4; in main()
1286 if (i < ctx.sf - ctx.lsbwidth || i > ctx.fs + ctx.rsbwidth - 1) in main()
1288 …else if ((i >= ctx.sf - ctx.lsbwidth && i < ctx.sf) || (i > ctx.fs - 1 && i <= ctx.fs + ctx.rsbwid… in main()
1293 PetscCall(ISCreateGeneral(PETSC_COMM_WORLD, islow, index_slow, PETSC_COPY_VALUES, &ctx.iss)); in main()
1294 PetscCall(ISCreateGeneral(PETSC_COMM_WORLD, ifast, index_fast, PETSC_COPY_VALUES, &ctx.isf)); in main()
1295 …ll(ISCreateGeneral(PETSC_COMM_WORLD, islowbuffer, index_slowbuffer, PETSC_COPY_VALUES, &ctx.issb)); in main()
1300 PetscCall(TSSetRHSFunction(ts, R, FVRHSFunction_2WaySplit, &ctx)); in main()
1301 PetscCall(TSRHSSplitSetIS(ts, "slow", ctx.iss)); in main()
1302 PetscCall(TSRHSSplitSetIS(ts, "slowbuffer", ctx.issb)); in main()
1303 PetscCall(TSRHSSplitSetIS(ts, "fast", ctx.isf)); in main()
1304 PetscCall(TSRHSSplitSetRHSFunction(ts, "slow", NULL, FVRHSFunctionslow_2WaySplit, &ctx)); in main()
1305 PetscCall(TSRHSSplitSetRHSFunction(ts, "fast", NULL, FVRHSFunctionfast_2WaySplit, &ctx)); in main()
1306 …tscCall(TSRHSSplitSetRHSFunction(ts, "slowbuffer", NULL, FVRHSFunctionslowbuffer_2WaySplit, &ctx)); in main()
1313 PetscCall(FVSample_2WaySplit(&ctx, da, 0, X0)); in main()
1314 …PetscCall(FVRHSFunction_2WaySplit(ts, 0, X0, X, (void *)&ctx)); /* Initial function evaluation, on… in main()
1316 PetscCall(TSSetTimeStep(ts, ctx.cfl / ctx.cfl_idt)); in main()
1323 const PetscReal hs = (ctx.xmax - ctx.xmin) * 3.0 / 4.0 / count_slow; in main()
1324 const PetscReal hf = (ctx.xmax - ctx.xmin) / 4.0 / count_fast; in main()
1335 if (i < ctx.sf || i > ctx.fs - 1) { in main()
1353 …etscPrintf(comm, "Maximum allowable stepsize according to CFL %g\n", (double)(1.0 / ctx.cfl_idt))); in main()
1354 if (ctx.exact) { in main()
1356 PetscCall(SolutionErrorNorms_2WaySplit(&ctx, da, ptime, X, &nrm1)); in main()
1359 if (ctx.simulation) { in main()
1375 if (i < ctx.sf || i > ctx.fs - 1) in main()
1393 PetscCall(FVSample_2WaySplit(&ctx, da, ptime, Y)); in main()
1409 PetscCall((*ctx.physics2.destroy)(ctx.physics2.user)); in main()
1410 for (i = 0; i < ctx.physics2.dof; i++) PetscCall(PetscFree(ctx.physics2.fieldname[i])); in main()
1411 PetscCall(PetscFree(ctx.physics2.bcinflowindex)); in main()
1412 PetscCall(PetscFree(ctx.ub)); in main()
1413 PetscCall(PetscFree4(ctx.R, ctx.Rinv, ctx.cjmpLR, ctx.cslope)); in main()
1414 PetscCall(PetscFree3(ctx.uLR, ctx.flux, ctx.speeds)); in main()
1420 PetscCall(ISDestroy(&ctx.iss)); in main()
1421 PetscCall(ISDestroy(&ctx.isf)); in main()
1422 PetscCall(ISDestroy(&ctx.issb)); in main()