Lines Matching refs:ctx

33   AdvectCtx *ctx = (AdvectCtx *)vctx;  in PhysicsRiemann_Advect()  local
37 speed = ctx->a; in PhysicsRiemann_Advect()
45 AdvectCtx *ctx = (AdvectCtx *)vctx; in PhysicsCharacteristic_Advect() local
50 speeds[0] = ctx->a; in PhysicsCharacteristic_Advect()
56 AdvectCtx *ctx = (AdvectCtx *)vctx; in PhysicsSample_Advect() local
57 PetscReal a = ctx->a, x0; in PhysicsSample_Advect()
101 static PetscErrorCode PhysicsCreate_Advect(FVCtx *ctx) in PhysicsCreate_Advect() argument
107 ctx->physics2.sample2 = PhysicsSample_Advect; in PhysicsCreate_Advect()
108 ctx->physics2.riemann2 = PhysicsRiemann_Advect; in PhysicsCreate_Advect()
109 ctx->physics2.characteristic2 = PhysicsCharacteristic_Advect; in PhysicsCreate_Advect()
110 ctx->physics2.destroy = PhysicsDestroy_SimpleFree; in PhysicsCreate_Advect()
111 ctx->physics2.user = user; in PhysicsCreate_Advect()
112 ctx->physics2.dof = 1; in PhysicsCreate_Advect()
113 PetscCall(PetscStrallocpy("u", &ctx->physics2.fieldname[0])); in PhysicsCreate_Advect()
115 PetscOptionsBegin(ctx->comm, ctx->prefix, "Options for advection", ""); in PhysicsCreate_Advect()
123 PetscErrorCode FVSample_3WaySplit(FVCtx *ctx, DM da, PetscReal time, Vec U) in FVSample_3WaySplit() argument
131 …PetscCheck(ctx->physics2.sample2, PETSC_COMM_SELF, PETSC_ERR_SUP, "Physics has not provided a samp… in FVSample_3WaySplit()
137 hs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVSample_3WaySplit()
138 hm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVSample_3WaySplit()
139 hf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVSample_3WaySplit()
141 if (i < ctx->sm) { in FVSample_3WaySplit()
142 xi = ctx->xmin + 0.5 * hs + i * hs; in FVSample_3WaySplit()
147 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_3WaySplit()
150 } else if (i < ctx->mf) { in FVSample_3WaySplit()
151 xi = ctx->xmin + ctx->sm * hs + 0.5 * hm + (i - ctx->sm) * hm; in FVSample_3WaySplit()
156 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_3WaySplit()
159 } else if (i < ctx->fm) { in FVSample_3WaySplit()
160 xi = ctx->xmin + ctx->sm * hs + (ctx->mf - ctx->sm) * hm + 0.5 * hf + (i - ctx->mf) * hf; in FVSample_3WaySplit()
165 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_3WaySplit()
168 } else if (i < ctx->ms) { in FVSample_3WaySplit()
169 …xi = ctx->xmin + ctx->sm * hs + (ctx->mf - ctx->sm) * hm + (ctx->fm - ctx->mf) * hf + 0.5 * hm + (… in FVSample_3WaySplit()
174 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_3WaySplit()
178 …xi = ctx->xmin + ctx->sm * hs + (ctx->mf - ctx->sm) * hm + (ctx->fm - ctx->mf) * hf + (ctx->ms - c… in FVSample_3WaySplit()
183 …PetscCall((*ctx->physics2.sample2)(ctx->physics2.user, ctx->initial, ctx->bctype, ctx->xmin, ctx->… in FVSample_3WaySplit()
193 static PetscErrorCode SolutionErrorNorms_3WaySplit(FVCtx *ctx, DM da, PetscReal t, Vec X, PetscReal… in SolutionErrorNorms_3WaySplit() argument
202 hs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in SolutionErrorNorms_3WaySplit()
203 hm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in SolutionErrorNorms_3WaySplit()
204 hf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in SolutionErrorNorms_3WaySplit()
206 PetscCall(FVSample_3WaySplit(ctx, da, t, Y)); in SolutionErrorNorms_3WaySplit()
210 if (i < ctx->sm || i > ctx->ms - 1) *nrm1 += hs * PetscAbs(ptr_X[i] - ptr_Y[i]); in SolutionErrorNorms_3WaySplit()
211 else if (i < ctx->mf || i > ctx->fm - 1) *nrm1 += hm * PetscAbs(ptr_X[i] - ptr_Y[i]); in SolutionErrorNorms_3WaySplit()
222 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunction_3WaySplit() local
223 PetscInt i, j, k, Mx, dof, xs, xm, sm = ctx->sm, mf = ctx->mf, fm = ctx->fm, ms = ctx->ms; in FVRHSFunction_3WaySplit()
233 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunction_3WaySplit()
234 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunction_3WaySplit()
235 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunction_3WaySplit()
247 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunction_3WaySplit()
259 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunction_3WaySplit()
261 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunction_3WaySplit()
262 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunction_3WaySplit()
263 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunction_3WaySplit()
269 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunction_3WaySplit()
270 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunction_3WaySplit()
278 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunction_3WaySplit()
281 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunction_3WaySplit()
289 uL = &ctx->uLR[0]; in FVRHSFunction_3WaySplit()
290 uR = &ctx->uLR[dof]; in FVRHSFunction_3WaySplit()
296 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
298 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunction_3WaySplit()
301 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxs; in FVRHSFunction_3WaySplit()
308 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
310 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunction_3WaySplit()
313 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
320 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
322 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
325 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxs; in FVRHSFunction_3WaySplit()
332 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
334 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
337 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
344 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
346 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
349 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxf; in FVRHSFunction_3WaySplit()
356 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
358 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunction_3WaySplit()
361 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxm; in FVRHSFunction_3WaySplit()
368 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunction_3WaySplit()
371 for (j = 0; j < dof; j++) f[(i - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunction_3WaySplit()
374 for (j = 0; j < dof; j++) f[i * dof + j] += ctx->flux[j] / hxf; in FVRHSFunction_3WaySplit()
382 …PetscCallMPI(MPIU_Allreduce(&cfl_idt, &ctx->cfl_idt, 1, MPIU_SCALAR, MPIU_MAX, PetscObjectComm((Pe… in FVRHSFunction_3WaySplit()
388 …/ ctx->cfl_idt) PetscCall(PetscPrintf(ctx->comm, "Stability constraint exceeded at t=%g, dt %g > %… in FVRHSFunction_3WaySplit()
396 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionslow_3WaySplit() local
397 … i, j, k, Mx, dof, xs, xm, islow = 0, sm = ctx->sm, ms = ctx->ms, lsbwidth = ctx->lsbwidth, rsbw… in FVRHSFunctionslow_3WaySplit()
407 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunctionslow_3WaySplit()
408 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunctionslow_3WaySplit()
409 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunctionslow_3WaySplit()
418 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionslow_3WaySplit()
431 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionslow_3WaySplit()
433 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionslow_3WaySplit()
434 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionslow_3WaySplit()
435 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionslow_3WaySplit()
441 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionslow_3WaySplit()
442 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionslow_3WaySplit()
450 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunctionslow_3WaySplit()
453 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionslow_3WaySplit()
462 uL = &ctx->uLR[0]; in FVRHSFunctionslow_3WaySplit()
463 uR = &ctx->uLR[dof]; in FVRHSFunctionslow_3WaySplit()
469 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_3WaySplit()
472 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
475 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
484 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_3WaySplit()
486 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
494 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_3WaySplit()
496 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
505 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslow_3WaySplit()
508 for (j = 0; j < dof; j++) f[(islow - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
511 for (j = 0; j < dof; j++) f[islow * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslow_3WaySplit()
520 …PetscCallMPI(MPIU_Allreduce(&cfl_idt, &ctx->cfl_idt, 1, MPIU_SCALAR, MPIU_MAX, PetscObjectComm((Pe… in FVRHSFunctionslow_3WaySplit()
526 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionslowbuffer_3WaySplit() local
527 …j, k, Mx, dof, xs, xm, islowbuffer = 0, sm = ctx->sm, ms = ctx->ms, lsbwidth = ctx->lsbwidth, rsbw… in FVRHSFunctionslowbuffer_3WaySplit()
537 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunctionslowbuffer_3WaySplit()
538 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunctionslowbuffer_3WaySplit()
539 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunctionslowbuffer_3WaySplit()
548 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionslowbuffer_3WaySplit()
561 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionslowbuffer_3WaySplit()
563 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionslowbuffer_3WaySplit()
564 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionslowbuffer_3WaySplit()
565 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionslowbuffer_3WaySplit()
571 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionslowbuffer_3WaySplit()
572 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionslowbuffer_3WaySplit()
580 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunctionslowbuffer_3WaySplit()
583 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionslowbuffer_3WaySplit()
592 uL = &ctx->uLR[0]; in FVRHSFunctionslowbuffer_3WaySplit()
593 uR = &ctx->uLR[dof]; in FVRHSFunctionslowbuffer_3WaySplit()
599 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
601 for (j = 0; j < dof; j++) f[islowbuffer * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
610 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
612 for (j = 0; j < dof; j++) f[(islowbuffer - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
615 for (j = 0; j < dof; j++) f[islowbuffer * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
624 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
626 for (j = 0; j < dof; j++) f[(islowbuffer - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
634 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
636 for (j = 0; j < dof; j++) f[islowbuffer * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
645 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
647 for (j = 0; j < dof; j++) f[(islowbuffer - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
650 for (j = 0; j < dof; j++) f[islowbuffer * dof + j] += ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
659 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionslowbuffer_3WaySplit()
661 for (j = 0; j < dof; j++) f[(islowbuffer - 1) * dof + j] -= ctx->flux[j] / hxs; in FVRHSFunctionslowbuffer_3WaySplit()
675 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionmedium_3WaySplit() local
676 …dof, xs, xm, imedium = 0, sm = ctx->sm, mf = ctx->mf, fm = ctx->fm, ms = ctx->ms, lmbwidth = ctx->… in FVRHSFunctionmedium_3WaySplit()
686 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunctionmedium_3WaySplit()
687 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunctionmedium_3WaySplit()
688 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunctionmedium_3WaySplit()
697 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionmedium_3WaySplit()
710 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionmedium_3WaySplit()
712 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionmedium_3WaySplit()
713 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionmedium_3WaySplit()
714 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionmedium_3WaySplit()
720 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionmedium_3WaySplit()
721 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionmedium_3WaySplit()
729 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunctionmedium_3WaySplit()
732 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionmedium_3WaySplit()
741 uL = &ctx->uLR[0]; in FVRHSFunctionmedium_3WaySplit()
742 uR = &ctx->uLR[dof]; in FVRHSFunctionmedium_3WaySplit()
748 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
750 for (j = 0; j < dof; j++) f[imedium * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
759 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
761 for (j = 0; j < dof; j++) f[(imedium - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
764 for (j = 0; j < dof; j++) f[imedium * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
773 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
775 for (j = 0; j < dof; j++) f[(imedium - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
783 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
785 for (j = 0; j < dof; j++) f[imedium * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
794 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
796 for (j = 0; j < dof; j++) f[(imedium - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
799 for (j = 0; j < dof; j++) f[imedium * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
808 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmedium_3WaySplit()
810 for (j = 0; j < dof; j++) f[(imedium - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmedium_3WaySplit()
823 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionmediumbuffer_3WaySplit() local
824 … k, Mx, dof, xs, xm, imediumbuffer = 0, mf = ctx->mf, fm = ctx->fm, lmbwidth = ctx->lmbwidth, rmbw… in FVRHSFunctionmediumbuffer_3WaySplit()
834 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunctionmediumbuffer_3WaySplit()
835 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunctionmediumbuffer_3WaySplit()
836 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunctionmediumbuffer_3WaySplit()
845 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionmediumbuffer_3WaySplit()
858 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionmediumbuffer_3WaySplit()
860 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionmediumbuffer_3WaySplit()
861 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionmediumbuffer_3WaySplit()
862 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionmediumbuffer_3WaySplit()
868 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionmediumbuffer_3WaySplit()
869 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionmediumbuffer_3WaySplit()
877 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunctionmediumbuffer_3WaySplit()
880 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionmediumbuffer_3WaySplit()
889 uL = &ctx->uLR[0]; in FVRHSFunctionmediumbuffer_3WaySplit()
890 uR = &ctx->uLR[dof]; in FVRHSFunctionmediumbuffer_3WaySplit()
896 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
898 for (j = 0; j < dof; j++) f[imediumbuffer * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
907 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
909 for (j = 0; j < dof; j++) f[(imediumbuffer - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
912 for (j = 0; j < dof; j++) f[imediumbuffer * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
921 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
923 for (j = 0; j < dof; j++) f[(imediumbuffer - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
931 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
933 for (j = 0; j < dof; j++) f[imediumbuffer * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
942 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
944 for (j = 0; j < dof; j++) f[(imediumbuffer - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
947 for (j = 0; j < dof; j++) f[imediumbuffer * dof + j] += ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
956 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionmediumbuffer_3WaySplit()
958 for (j = 0; j < dof; j++) f[(imediumbuffer - 1) * dof + j] -= ctx->flux[j] / hxm; in FVRHSFunctionmediumbuffer_3WaySplit()
972 FVCtx *ctx = (FVCtx *)vctx; in FVRHSFunctionfast_3WaySplit() local
973 PetscInt i, j, k, Mx, dof, xs, xm, ifast = 0, mf = ctx->mf, fm = ctx->fm; in FVRHSFunctionfast_3WaySplit()
983 hxs = (ctx->xmax - ctx->xmin) / 8.0 / ctx->sm; in FVRHSFunctionfast_3WaySplit()
984 hxm = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->mf - ctx->sm); in FVRHSFunctionfast_3WaySplit()
985 hxf = (ctx->xmax - ctx->xmin) / 4.0 / (ctx->fm - ctx->mf); in FVRHSFunctionfast_3WaySplit()
994 if (ctx->bctype == FVBC_OUTFLOW) { in FVRHSFunctionfast_3WaySplit()
1006 …PetscCall((*ctx->physics2.characteristic2)(ctx->physics2.user, dof, &x[i * dof], ctx->R, ctx->Rinv… in FVRHSFunctionfast_3WaySplit()
1007 PetscCall(PetscArrayzero(ctx->cjmpLR, 2 * dof)); in FVRHSFunctionfast_3WaySplit()
1008 cjmpL = &ctx->cjmpLR[0]; in FVRHSFunctionfast_3WaySplit()
1009 cjmpR = &ctx->cjmpLR[dof]; in FVRHSFunctionfast_3WaySplit()
1015 cjmpL[k] += ctx->Rinv[k + j * dof] * jmpL; in FVRHSFunctionfast_3WaySplit()
1016 cjmpR[k] += ctx->Rinv[k + j * dof] * jmpR; in FVRHSFunctionfast_3WaySplit()
1024 (*ctx->limit3)(&info, cjmpL, cjmpR, ctx->sm, ctx->mf, ctx->fm, ctx->ms, i, ctx->cslope); in FVRHSFunctionfast_3WaySplit()
1027 for (k = 0; k < dof; k++) tmp += ctx->R[j + k * dof] * ctx->cslope[k]; in FVRHSFunctionfast_3WaySplit()
1036 uL = &ctx->uLR[0]; in FVRHSFunctionfast_3WaySplit()
1037 uR = &ctx->uLR[dof]; in FVRHSFunctionfast_3WaySplit()
1043 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_3WaySplit()
1045 for (j = 0; j < dof; j++) f[ifast * dof + j] += ctx->flux[j] / hxf; in FVRHSFunctionfast_3WaySplit()
1054 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_3WaySplit()
1056 for (j = 0; j < dof; j++) f[(ifast - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunctionfast_3WaySplit()
1059 for (j = 0; j < dof; j++) f[ifast * dof + j] += ctx->flux[j] / hxf; in FVRHSFunctionfast_3WaySplit()
1068 PetscCall((*ctx->physics2.riemann2)(ctx->physics2.user, dof, uL, uR, ctx->flux, &maxspeed)); in FVRHSFunctionfast_3WaySplit()
1070 for (j = 0; j < dof; j++) f[(ifast - 1) * dof + j] -= ctx->flux[j] / hxf; in FVRHSFunctionfast_3WaySplit()
1089 FVCtx ctx; in main() local
1097 PetscCall(PetscMemzero(&ctx, sizeof(ctx))); in main()
1112 ctx.comm = comm; in main()
1113 ctx.cfl = 0.9; in main()
1114 ctx.bctype = FVBC_PERIODIC; in main()
1115 ctx.xmin = -1.0; in main()
1116 ctx.xmax = 1.0; in main()
1118 PetscCall(PetscOptionsReal("-xmin", "X min", "", ctx.xmin, &ctx.xmin, NULL)); in main()
1119 PetscCall(PetscOptionsReal("-xmax", "X max", "", ctx.xmax, &ctx.xmax, NULL)); in main()
1123 …nsInt("-initial", "Initial condition (depends on the physics)", "", ctx.initial, &ctx.initial, NUL… in main()
1124 …PetscCall(PetscOptionsBool("-exact", "Compare errors with exact solution", "", ctx.exact, &ctx.exa… in main()
1125 …Bool("-simulation", "Compare errors with reference solution", "", ctx.simulation, &ctx.simulation,… in main()
1126 PetscCall(PetscOptionsReal("-cfl", "CFL number to time step at", "", ctx.cfl, &ctx.cfl, NULL)); in main()
1127 …m("-bc_type", "Boundary condition", "", FVBCTypes, (PetscEnum)ctx.bctype, (PetscEnum *)&ctx.bctype… in main()
1128 PetscCall(PetscOptionsInt("-hratio", "Spacing ratio", "", ctx.hratio, &ctx.hratio, NULL)); in main()
1132 PetscCall(PetscFunctionListFind(limiters, lname, &ctx.limit3)); in main()
1133 …PetscCheck(ctx.limit3, PETSC_COMM_SELF, PETSC_ERR_ARG_UNKNOWN_TYPE, "Limiter '%s' not found", lnam… in main()
1141 PetscCall((*r)(&ctx)); in main()
1145 PetscCall(DMDACreate1d(comm, DM_BOUNDARY_PERIODIC, 50, ctx.physics2.dof, 2, NULL, &da)); in main()
1150 …for (i = 0; i < ctx.physics2.dof; i++) PetscCall(DMDASetFieldName(da, i, ctx.physics2.fieldname[i]… in main()
1155 …tscCall(DMDASetUniformCoordinates(da, ctx.xmin + 0.5 * (ctx.xmax - ctx.xmin) / Mx, ctx.xmax + 0.5 … in main()
1158 …PetscCall(PetscMalloc4(dof * dof, &ctx.R, dof * dof, &ctx.Rinv, 2 * dof, &ctx.cjmpLR, 1 * dof, &ct… in main()
1159 PetscCall(PetscMalloc3(2 * dof, &ctx.uLR, dof, &ctx.flux, dof, &ctx.speeds)); in main()
1168 count_slow = Mx / (1 + ctx.hratio) / (1 + ctx.hratio); in main()
1169 count_medium = 2 * ctx.hratio * count_slow; in main()
1171 count_fast = ctx.hratio * ctx.hratio * count_slow; in main()
1172 ctx.sm = count_slow / 2; in main()
1173 ctx.mf = ctx.sm + count_medium / 2; in main()
1174 ctx.fm = ctx.mf + count_fast; in main()
1175 ctx.ms = ctx.fm + count_medium / 2; in main()
1181 if (((AdvectCtx *)ctx.physics2.user)->a > 0) { in main()
1182 ctx.lsbwidth = 2; in main()
1183 ctx.rsbwidth = 4; in main()
1184 ctx.lmbwidth = 2; in main()
1185 ctx.rmbwidth = 4; in main()
1187 ctx.lsbwidth = 4; in main()
1188 ctx.rsbwidth = 2; in main()
1189 ctx.lmbwidth = 4; in main()
1190 ctx.rmbwidth = 2; in main()
1194 if (i < ctx.sm - ctx.lsbwidth || i > ctx.ms + ctx.rsbwidth - 1) in main()
1196 …else if ((i >= ctx.sm - ctx.lsbwidth && i < ctx.sm) || (i > ctx.ms - 1 && i <= ctx.ms + ctx.rsbwid… in main()
1198 else if (i < ctx.mf - ctx.lmbwidth || i > ctx.fm + ctx.rmbwidth - 1) in main()
1200 …else if ((i >= ctx.mf - ctx.lmbwidth && i < ctx.mf) || (i > ctx.fm - 1 && i <= ctx.fm + ctx.rmbwid… in main()
1205 PetscCall(ISCreateGeneral(PETSC_COMM_WORLD, islow, index_slow, PETSC_COPY_VALUES, &ctx.iss)); in main()
1206 PetscCall(ISCreateGeneral(PETSC_COMM_WORLD, imedium, index_medium, PETSC_COPY_VALUES, &ctx.ism)); in main()
1207 PetscCall(ISCreateGeneral(PETSC_COMM_WORLD, ifast, index_fast, PETSC_COPY_VALUES, &ctx.isf)); in main()
1208 …ll(ISCreateGeneral(PETSC_COMM_WORLD, islowbuffer, index_slowbuffer, PETSC_COPY_VALUES, &ctx.issb)); in main()
1209 …SCreateGeneral(PETSC_COMM_WORLD, imediumbuffer, index_mediumbuffer, PETSC_COPY_VALUES, &ctx.ismb)); in main()
1214 PetscCall(TSSetRHSFunction(ts, R, FVRHSFunction_3WaySplit, &ctx)); in main()
1215 PetscCall(TSRHSSplitSetIS(ts, "slow", ctx.iss)); in main()
1216 PetscCall(TSRHSSplitSetIS(ts, "medium", ctx.ism)); in main()
1217 PetscCall(TSRHSSplitSetIS(ts, "fast", ctx.isf)); in main()
1218 PetscCall(TSRHSSplitSetIS(ts, "slowbuffer", ctx.issb)); in main()
1219 PetscCall(TSRHSSplitSetIS(ts, "mediumbuffer", ctx.ismb)); in main()
1220 PetscCall(TSRHSSplitSetRHSFunction(ts, "slow", NULL, FVRHSFunctionslow_3WaySplit, &ctx)); in main()
1221 PetscCall(TSRHSSplitSetRHSFunction(ts, "medium", NULL, FVRHSFunctionmedium_3WaySplit, &ctx)); in main()
1222 PetscCall(TSRHSSplitSetRHSFunction(ts, "fast", NULL, FVRHSFunctionfast_3WaySplit, &ctx)); in main()
1223 …tscCall(TSRHSSplitSetRHSFunction(ts, "slowbuffer", NULL, FVRHSFunctionslowbuffer_3WaySplit, &ctx)); in main()
1224 …all(TSRHSSplitSetRHSFunction(ts, "mediumbuffer", NULL, FVRHSFunctionmediumbuffer_3WaySplit, &ctx)); in main()
1232 PetscCall(FVSample_3WaySplit(&ctx, da, 0, X0)); in main()
1233 …PetscCall(FVRHSFunction_3WaySplit(ts, 0, X0, X, (void *)&ctx)); /* Initial function evaluation, on… in main()
1235 PetscCall(TSSetTimeStep(ts, ctx.cfl / ctx.cfl_idt)); in main()
1242 const PetscReal hs = (ctx.xmax - ctx.xmin) / 4.0 / count_slow; in main()
1243 const PetscReal hm = (ctx.xmax - ctx.xmin) / 2.0 / count_medium; in main()
1244 const PetscReal hf = (ctx.xmax - ctx.xmin) / 4.0 / count_fast; in main()
1255 if (i < ctx.sm || i > ctx.ms - 1) in main()
1260 else if (i < ctx.mf || i > ctx.fm - 1) in main()
1278 …(PetscPrintf(comm, "Maximum allowable stepsize according to CFL %g\n", (double)(1 / ctx.cfl_idt))); in main()
1279 if (ctx.exact) { in main()
1281 PetscCall(SolutionErrorNorms_3WaySplit(&ctx, da, ptime, X, &nrm1)); in main()
1284 if (ctx.simulation) { in main()
1300 if (i < ctx.sm || i > ctx.ms - 1) in main()
1302 else if (i < ctx.mf || i < ctx.fm - 1) in main()
1320 PetscCall(FVSample_3WaySplit(&ctx, da, ptime, Y)); in main()
1336 PetscCall((*ctx.physics2.destroy)(ctx.physics2.user)); in main()
1337 for (i = 0; i < ctx.physics2.dof; i++) PetscCall(PetscFree(ctx.physics2.fieldname[i])); in main()
1338 PetscCall(PetscFree4(ctx.R, ctx.Rinv, ctx.cjmpLR, ctx.cslope)); in main()
1339 PetscCall(PetscFree3(ctx.uLR, ctx.flux, ctx.speeds)); in main()
1345 PetscCall(ISDestroy(&ctx.iss)); in main()
1346 PetscCall(ISDestroy(&ctx.ism)); in main()
1347 PetscCall(ISDestroy(&ctx.isf)); in main()
1348 PetscCall(ISDestroy(&ctx.issb)); in main()
1349 PetscCall(ISDestroy(&ctx.ismb)); in main()