Lines Matching refs:ctx
69 subroutine FormFunction(snes, X, F, ctx, ierr) argument
76 type(AppCtx) ctx
103 PetscCall(FormFunctionLocal(lx_v, lf_v, ctx, ierr))
112 PetscCall(PetscLogFlops(11.0d0*ctx%ym*ctx%xm, ierr))
139 type(AppCtx), pointer:: ctx
149 PetscCallA(SNESGetApplicationContext(snes, ctx, ierr))
160 PetscCallA(InitialGuessLocal(ctx, lx_v, ierr))
184 subroutine InitialGuessLocal(ctx, x, ierr) argument
186 type(AppCtx) ctx local
187 PetscScalar x(ctx%xs:ctx%xe, ctx%ys:ctx%ye)
199 hx = one/(ctx%mx - 1)
200 hy = one/(ctx%my - 1)
201 temp1 = ctx%lambda/(ctx%lambda + one)
203 do j = ctx%ys, ctx%ye
204 temp = min(j - 1, ctx%my - j)*hy
205 do i = ctx%xs, ctx%xe
206 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
209 x(i, j) = temp1*sqrt(min(hx*min(i - 1, ctx%mx - i), temp))
231 subroutine FormFunctionLocal(x, f, ctx, ierr) argument
233 type(AppCtx) ctx local
234 PetscScalar x(ctx%gxs:ctx%gxe, ctx%gys:ctx%gye)
235 PetscScalar f(ctx%xs:ctx%xe, ctx%ys:ctx%ye)
245 hx = one/(ctx%mx - 1)
246 hy = one/(ctx%my - 1)
247 sc = hx*hy*ctx%lambda
253 do j = ctx%ys, ctx%ye
254 do i = ctx%xs, ctx%xe
255 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
310 subroutine FormJacobian(snes, X, jac, jac_prec, ctx, ierr) argument
315 type(AppCtx) ctx
337 PetscCallA(FormJacobianLocal(lx_v, jac_prec, ctx, ierr))
397 subroutine FormJacobianLocal(x, jac_prec, ctx, ierr) argument
399 type(AppCtx) ctx local
400 PetscScalar x(ctx%gxs:ctx%gxe, ctx%gys:ctx%gye)
415 hx = one/(ctx%mx - 1)
416 hy = one/(ctx%my - 1)
433 do j = ctx%ys, ctx%ye
434 row = (j - ctx%gys)*ctx%gxm + ctx%xs - ctx%gxs - 1
435 do i = ctx%xs, ctx%xe
438 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
446 v(3) = two*(hydhx + hxdhy) - sc*ctx%lambda*exp(x(i, j))
449 col(1) = row - ctx%gxm
453 col(5) = row + ctx%gxm
488 type(AppCtx) ctx
495 PetscCallMPIA(MPI_Comm_rank(PETSC_COMM_WORLD, ctx%rank, ierr))
500 ctx%lambda = 6.0
503 …PetscCallA(PetscOptionsGetReal(PETSC_NULL_OPTIONS, PETSC_NULL_CHARACTER, '-par', ctx%lambda, flg, …
504 …PetscCheckA(ctx%lambda < lambda_max .and. ctx%lambda > lambda_min, PETSC_COMM_SELF, PETSC_ERR_USER…
523 …PetscCallA(DMDAGetInfo(da, PETSC_NULL_INTEGER, ctx%mx, ctx%my, PETSC_NULL_INTEGER, PETSC_NULL_INTE…
536 …PetscCallA(DMDAGetCorners(da, ctx%xs, ctx%ys, PETSC_NULL_INTEGER, ctx%xm, ctx%ym, PETSC_NULL_INTEG…
537 …PetscCallA(DMDAGetGhostCorners(da, ctx%gxs, ctx%gys, PETSC_NULL_INTEGER, ctx%gxm, ctx%gym, PETSC_N…
541 ctx%xs = ctx%xs + 1
542 ctx%ys = ctx%ys + 1
543 ctx%gxs = ctx%gxs + 1
544 ctx%gys = ctx%gys + 1
546 ctx%ye = ctx%ys + ctx%ym - 1
547 ctx%xe = ctx%xs + ctx%xm - 1
548 ctx%gye = ctx%gys + ctx%gym - 1
549 ctx%gxe = ctx%gxs + ctx%gxm - 1
551 PetscCallA(SNESSetApplicationContext(snes, ctx, ierr))
554 PetscCallA(SNESSetFunction(snes, r, FormFunction, ctx, ierr))
584 PetscCallA(SNESSetJacobian(snes, J, J, FormJacobian, ctx, ierr))
605 if (ctx%rank == 0) then