Lines Matching refs:ctx
69 subroutine FormFunction(snesIn, X, F, ctx, ierr) argument
74 type(AppCtx) ctx
84 PetscCall(DMGetLocalVector(ctx%da, localX, ierr))
85 PetscCall(DMGlobalToLocalBegin(ctx%da, X, INSERT_VALUES, localX, ierr))
86 PetscCall(DMGlobalToLocalEnd(ctx%da, X, INSERT_VALUES, localX, ierr))
97 PetscCall(FormFunctionLocal(lx_v, lf_v, ctx, ierr))
105 PetscCall(DMRestoreLocalVector(ctx%da, localX, ierr))
106 PetscCall(PetscLogFlops(11.0d0*ctx%ym*ctx%xm, ierr))
174 subroutine InitialGuessLocal(ctx, x, ierr) argument
176 type(AppCtx) ctx local
177 PetscScalar x(ctx%xs:ctx%xe, ctx%ys:ctx%ye)
189 hx = one/(PetscIntToReal(ctx%mx - 1))
190 hy = one/(PetscIntToReal(ctx%my - 1))
191 temp1 = ctx%lambda/(ctx%lambda + one)
193 do j = ctx%ys, ctx%ye
194 temp = PetscIntToReal(min(j - 1, ctx%my - j))*hy
195 do i = ctx%xs, ctx%xe
196 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
199 x(i, j) = temp1*sqrt(min(PetscIntToReal(min(i - 1, ctx%mx - i)*hx), PetscIntToReal(temp)))
221 subroutine FormFunctionLocal(x, f, ctx, ierr) argument
223 type(AppCtx) ctx local
224 PetscScalar x(ctx%gxs:ctx%gxe, ctx%gys:ctx%gye)
225 PetscScalar f(ctx%xs:ctx%xe, ctx%ys:ctx%ye)
235 hx = one/PetscIntToReal(ctx%mx - 1)
236 hy = one/PetscIntToReal(ctx%my - 1)
237 sc = hx*hy*ctx%lambda
243 do j = ctx%ys, ctx%ye
244 do i = ctx%xs, ctx%xe
245 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
302 subroutine FormJacobian(mysnes, X, jac, jac_prec, ctx, ierr) argument
307 type(AppCtx) ctx local
319 PetscCallA(DMGetLocalVector(ctx%da, localX, ierr))
320 PetscCallA(DMGlobalToLocalBegin(ctx%da, X, INSERT_VALUES, localX, ierr))
321 PetscCallA(DMGlobalToLocalEnd(ctx%da, X, INSERT_VALUES, localX, ierr))
327 PetscCallA(FormJacobianLocal(lx_v, jac_prec, ctx, ierr))
339 PetscCallA(DMRestoreLocalVector(ctx%da, localX, ierr))
386 subroutine FormJacobianLocal(x, jac_prec, ctx, ierr) argument
388 type(AppCtx) ctx local
389 PetscScalar x(ctx%gxs:ctx%gxe, ctx%gys:ctx%gye)
404 hx = one/PetscIntToReal(ctx%mx - 1)
405 hy = one/PetscIntToReal(ctx%my - 1)
422 do j = ctx%ys, ctx%ye
423 row = (j - ctx%gys)*ctx%gxm + ctx%xs - ctx%gxs - 1
424 do i = ctx%xs, ctx%xe
427 if (i == 1 .or. j == 1 .or. i == ctx%mx .or. j == ctx%my) then
435 v(3) = two*(hydhx + hxdhy) - sc*ctx%lambda*exp(x(i, j))
438 col(1) = row - ctx%gxm
442 col(5) = row + ctx%gxm
476 type(AppCtx) ctx
483 PetscCallMPIA(MPI_Comm_rank(PETSC_COMM_WORLD, ctx%rank, ierr))
489 ctx%lambda = 6.0
492 PetscCallA(PetscOptionsGetReal(options, PETSC_NULL_CHARACTER, '-par', ctx%lambda, flg, ierr))
493 …PetscCheckA(ctx%lambda < lambda_max .and. ctx%lambda > lambda_min, PETSC_COMM_SELF, PETSC_ERR_USER…
508 …ECIDE, PETSC_DECIDE, ione, ione, PETSC_NULL_INTEGER_ARRAY, PETSC_NULL_INTEGER_ARRAY, ctx%da, ierr))
509 PetscCallA(DMSetFromOptions(ctx%da, ierr))
510 PetscCallA(DMSetUp(ctx%da, ierr))
511 …PetscCallA(DMDAGetInfo(ctx%da, PETSC_NULL_INTEGER, ctx%mx, ctx%my, PETSC_NULL_INTEGER, PETSC_NULL_…
520 PetscCallA(DMCreateGlobalVector(ctx%da, x, ierr))
524 …PetscCallA(DMDAGetCorners(ctx%da, ctx%xs, ctx%ys, PETSC_NULL_INTEGER, ctx%xm, ctx%ym, PETSC_NULL_I…
525 …PetscCallA(DMDAGetGhostCorners(ctx%da, ctx%gxs, ctx%gys, PETSC_NULL_INTEGER, ctx%gxm, ctx%gym, PET…
529 ctx%xs = ctx%xs + 1
530 ctx%ys = ctx%ys + 1
531 ctx%gxs = ctx%gxs + 1
532 ctx%gys = ctx%gys + 1
534 ctx%ye = ctx%ys + ctx%ym - 1
535 ctx%xe = ctx%xs + ctx%xm - 1
536 ctx%gye = ctx%gys + ctx%gym - 1
537 ctx%gxe = ctx%gxs + ctx%gxm - 1
539 PetscCallA(SNESSetApplicationContext(mysnes, ctx, ierr))
542 PetscCallA(SNESSetFunction(mysnes, r, FormFunction, ctx, ierr))
570 PetscCallA(DMSetMatType(ctx%da, MATAIJ, ierr))
571 PetscCallA(DMCreateMatrix(ctx%da, J, ierr))
572 PetscCallA(SNESSetJacobian(mysnes, J, J, FormJacobian, ctx, ierr))
592 if (ctx%rank == 0) then
605 PetscCallA(DMDestroy(ctx%da, ierr))