Lines Matching refs:user

55   AppCtx      user; /* Application context */  in main()  local
62 PetscCall(Parameter_settings(&user)); in main()
64 …M_BOUNDARY_NONE, DMDA_STENCIL_STAR, 4, 4, PETSC_DECIDE, PETSC_DECIDE, 1, 1, NULL, NULL, &user.da)); in main()
65 PetscCall(DMSetFromOptions(user.da)); in main()
66 PetscCall(DMSetUp(user.da)); in main()
68 …PetscCall(DMDASetUniformCoordinates(user.da, user.xmin, user.xmax, user.ymin, user.ymax, 0.0, 1.0)… in main()
71 PetscCall(DMCreateGlobalVector(user.da, &x)); in main()
73 PetscCall(ini_bou(x, &user)); in main()
79 PetscCall(DMSetMatType(user.da, MATAIJ)); in main()
80 PetscCall(DMCreateMatrix(user.da, &J)); in main()
84 PetscCall(TSSetIFunction(ts, NULL, IFunction, &user)); in main()
85 PetscCall(TSSetIJacobian(ts, J, J, IJacobian, &user)); in main()
86 PetscCall(TSSetApplicationContext(ts, &user)); in main()
87 PetscCall(TSSetMaxTime(ts, user.tmax)); in main()
89 PetscCall(TSSetTime(ts, user.t0)); in main()
101 PetscCall(DMDestroy(&user.da)); in main()
110 AppCtx *user; in PostStep() local
115 PetscCall(TSGetApplicationContext(ts, &user)); in PostStep()
119 …WORLD, "sum(p)*dw*dtheta at t = %3.2f = %3.6f\n", (double)t, (double)(sum * user->dx * user->dy))); in PostStep()
123 PetscErrorCode ini_bou(Vec X, AppCtx *user) in ini_bou() argument
132 PetscScalar sigmax = user->sigmax, sigmay = user->sigmay; in ini_bou()
133 PetscScalar rho = user->rho; in ini_bou()
134 PetscScalar mux = user->mux, muy = user->muy; in ini_bou()
139 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in ini_bou()
140 user->dx = (user->xmax - user->xmin) / (M - 1); in ini_bou()
141 user->dy = (user->ymax - user->ymin) / (N - 1); in ini_bou()
142 PetscCall(DMGetCoordinateDM(user->da, &cda)); in ini_bou()
143 PetscCall(DMGetCoordinates(user->da, &gc)); in ini_bou()
145 PetscCall(DMDAVecGetArray(user->da, X, &p)); in ini_bou()
159 PetscCall(DMDAVecRestoreArray(user->da, X, &p)); in ini_bou()
164 …(PetscScalar **p, PetscScalar y, PetscInt i, PetscInt j, PetscInt M, PetscScalar *p1, AppCtx *user) in adv1() argument
182 f = (y - user->ws); in adv1()
183 *p1 = f * (p[j][i + 1] - p[j][i - 1]) / (2 * user->dx); in adv1()
188 …(PetscScalar **p, PetscScalar x, PetscInt i, PetscInt j, PetscInt N, PetscScalar *p2, AppCtx *user) in adv2() argument
206 f = (user->ws / (2 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(x)); in adv2()
207 *p2 = f * (p[j + 1][i] - p[j - 1][i]) / (2 * user->dy); in adv2()
212 …de diffuse(PetscScalar **p, PetscInt i, PetscInt j, PetscReal t, PetscScalar *p_diff, AppCtx *user) in diffuse() argument
215 *p_diff = user->disper_coe * ((p[j - 1][i] - 2 * p[j][i] + p[j + 1][i]) / (user->dy * user->dy)); in diffuse()
219 … DMDACoor2d **coors, PetscInt i, PetscInt j, PetscInt M, PetscInt N, PetscScalar **f, AppCtx *user) in BoundaryConditions() argument
225 if (user->bc == 0) { /* Natural boundary condition */ in BoundaryConditions()
228 fthetac = user->ws / (2 * user->H) * (user->PM_min - user->Pmax * PetscSinScalar(theta)); in BoundaryConditions()
229 fwc = (w * w / 2.0 - user->ws * w); in BoundaryConditions()
231 …] = fwc * (p[j][i + 1] - p[j][i]) / user->dx + fthetac * p[j][i] - user->disper_coe * (p[j + 1][i]… in BoundaryConditions()
233 …] = fwc * (p[j][i + 1] - p[j][i]) / user->dx + fthetac * p[j][i] - user->disper_coe * (p[j][i] - p… in BoundaryConditions()
235 …] = fwc * (p[j][i] - p[j][i - 1]) / user->dx + fthetac * p[j][i] - user->disper_coe * (p[j + 1][i]… in BoundaryConditions()
237 …] = fwc * (p[j][i] - p[j][i - 1]) / user->dx + fthetac * p[j][i] - user->disper_coe * (p[j][i] - p… in BoundaryConditions()
239 …c * (p[j][i + 1] - p[j][i]) / (user->dx) + fthetac * p[j][i] - user->disper_coe * (p[j + 1][i] - p… in BoundaryConditions()
241 …c * (p[j][i] - p[j][i - 1]) / (user->dx) + fthetac * p[j][i] - user->disper_coe * (p[j + 1][i] - p… in BoundaryConditions()
243 …(p[j][i + 1] - p[j][i - 1]) / (2 * user->dx) + fthetac * p[j][i] - user->disper_coe * (p[j + 1][i]… in BoundaryConditions()
245 …(p[j][i + 1] - p[j][i - 1]) / (2 * user->dx) + fthetac * p[j][i] - user->disper_coe * (p[j][i] - p… in BoundaryConditions()
253 AppCtx *user = (AppCtx *)ctx; in IFunction() local
263 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IFunction()
264 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IFunction()
267 PetscCall(DMGetLocalVector(user->da, &localX)); in IFunction()
268 PetscCall(DMGetLocalVector(user->da, &localXdot)); in IFunction()
270 PetscCall(DMGlobalToLocalBegin(user->da, X, INSERT_VALUES, localX)); in IFunction()
271 PetscCall(DMGlobalToLocalEnd(user->da, X, INSERT_VALUES, localX)); in IFunction()
272 PetscCall(DMGlobalToLocalBegin(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
273 PetscCall(DMGlobalToLocalEnd(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
275 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IFunction()
278 PetscCall(DMDAVecGetArrayRead(user->da, localX, &p)); in IFunction()
279 PetscCall(DMDAVecGetArrayRead(user->da, localXdot, &pdot)); in IFunction()
280 PetscCall(DMDAVecGetArray(user->da, F, &f)); in IFunction()
282user->disper_coe = PetscPowScalar((user->lambda * user->ws) / (2 * user->H), 2) * user->q * (1.0 -… in IFunction()
286 PetscCall(BoundaryConditions(p, coors, i, j, M, N, f, user)); in IFunction()
288 PetscCall(adv1(p, coors[j][i].y, i, j, M, &p_adv1, user)); in IFunction()
289 PetscCall(adv2(p, coors[j][i].x, i, j, N, &p_adv2, user)); in IFunction()
290 PetscCall(diffuse(p, i, j, t, &p_diff, user)); in IFunction()
295 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &p)); in IFunction()
296 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &pdot)); in IFunction()
297 PetscCall(DMRestoreLocalVector(user->da, &localX)); in IFunction()
298 PetscCall(DMRestoreLocalVector(user->da, &localXdot)); in IFunction()
299 PetscCall(DMDAVecRestoreArray(user->da, F, &f)); in IFunction()
306 AppCtx *user = (AppCtx *)ctx; in IJacobian() local
317 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IJacobian()
318 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IJacobian()
321 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IJacobian()
331 if (user->bc == 0) { in IJacobian()
337 fthetac = user->ws / (2 * user->H) * (user->PM_min - user->Pmax * PetscSinScalar(xi)); in IJacobian()
338 fwc = (yi * yi / 2.0 - user->ws * yi); in IJacobian()
342 val[nc++] = fwc / user->dx; in IJacobian()
345 val[nc++] = -user->disper_coe / user->dy; in IJacobian()
348 val[nc++] = -fwc / user->dx + fthetac + user->disper_coe / user->dy; in IJacobian()
352 val[nc++] = fwc / user->dx; in IJacobian()
355 val[nc++] = user->disper_coe / user->dy; in IJacobian()
358 val[nc++] = -fwc / user->dx + fthetac - user->disper_coe / user->dy; in IJacobian()
362 val[nc++] = -fwc / user->dx; in IJacobian()
365 val[nc++] = -user->disper_coe / user->dy; in IJacobian()
368 val[nc++] = fwc / user->dx + fthetac + user->disper_coe / user->dy; in IJacobian()
372 val[nc++] = -fwc / user->dx; in IJacobian()
375 val[nc++] = user->disper_coe / user->dy; in IJacobian()
378 val[nc++] = fwc / user->dx + fthetac - user->disper_coe / user->dy; in IJacobian()
382 val[nc++] = fwc / user->dx; in IJacobian()
385 val[nc++] = -user->disper_coe / (2 * user->dy); in IJacobian()
388 val[nc++] = user->disper_coe / (2 * user->dy); in IJacobian()
391 val[nc++] = -fwc / user->dx + fthetac; in IJacobian()
395 val[nc++] = -fwc / user->dx; in IJacobian()
398 val[nc++] = -user->disper_coe / (2 * user->dy); in IJacobian()
401 val[nc++] = user->disper_coe / (2 * user->dy); in IJacobian()
404 val[nc++] = fwc / user->dx + fthetac; in IJacobian()
408 val[nc++] = fwc / (2 * user->dx); in IJacobian()
411 val[nc++] = -fwc / (2 * user->dx); in IJacobian()
414 val[nc++] = -user->disper_coe / user->dy; in IJacobian()
417 val[nc++] = user->disper_coe / user->dy + fthetac; in IJacobian()
421 val[nc++] = fwc / (2 * user->dx); in IJacobian()
424 val[nc++] = -fwc / (2 * user->dx); in IJacobian()
427 val[nc++] = user->disper_coe / user->dy; in IJacobian()
430 val[nc++] = -user->disper_coe / user->dy + fthetac; in IJacobian()
434 c1 = (yi - user->ws) / (2 * user->dx); in IJacobian()
435 …c3 = (user->ws / (2.0 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(xi)) / (2 *… in IJacobian()
436 …(PetscPowScalar((user->lambda * user->ws) / (2 * user->H), 2) * user->q * (1.0 - PetscExpScalar(-t… in IJacobian()
467 PetscErrorCode Parameter_settings(AppCtx *user) in Parameter_settings() argument
473 user->ws = 1.0; in Parameter_settings()
474 user->H = 5.0; in Parameter_settings()
475 user->Pmax = 2.1; in Parameter_settings()
476 user->PM_min = 1.0; in Parameter_settings()
477 user->lambda = 0.1; in Parameter_settings()
478 user->q = 1.0; in Parameter_settings()
479 user->mux = PetscAsinScalar(user->PM_min / user->Pmax); in Parameter_settings()
480 user->sigmax = 0.1; in Parameter_settings()
481 user->sigmay = 0.1; in Parameter_settings()
482 user->rho = 0.0; in Parameter_settings()
483 user->t0 = 0.0; in Parameter_settings()
484 user->tmax = 2.0; in Parameter_settings()
485 user->xmin = -1.0; in Parameter_settings()
486 user->xmax = 10.0; in Parameter_settings()
487 user->ymin = -1.0; in Parameter_settings()
488 user->ymax = 10.0; in Parameter_settings()
489 user->bc = 0; in Parameter_settings()
491 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ws", &user->ws, &flg)); in Parameter_settings()
492 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Inertia", &user->H, &flg)); in Parameter_settings()
493 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Pmax", &user->Pmax, &flg)); in Parameter_settings()
494 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-PM_min", &user->PM_min, &flg)); in Parameter_settings()
495 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-lambda", &user->lambda, &flg)); in Parameter_settings()
496 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-q", &user->q, &flg)); in Parameter_settings()
497 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-mux", &user->mux, &flg)); in Parameter_settings()
498 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-sigmax", &user->sigmax, &flg)); in Parameter_settings()
499 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-muy", &user->muy, &flg)); in Parameter_settings()
500 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-sigmay", &user->sigmay, &flg)); in Parameter_settings()
501 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-rho", &user->rho, &flg)); in Parameter_settings()
502 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-t0", &user->t0, &flg)); in Parameter_settings()
503 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-tmax", &user->tmax, &flg)); in Parameter_settings()
504 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmin", &user->xmin, &flg)); in Parameter_settings()
505 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmax", &user->xmax, &flg)); in Parameter_settings()
506 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymin", &user->ymin, &flg)); in Parameter_settings()
507 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymax", &user->ymax, &flg)); in Parameter_settings()
508 PetscCall(PetscOptionsGetInt(NULL, NULL, "-bc_type", &user->bc, &flg)); in Parameter_settings()
509 user->muy = user->ws; in Parameter_settings()