Lines Matching refs:user

57   AppCtx      user; /* Application context */  in main()  local
64 PetscCall(Parameter_settings(&user)); in main()
66 …te2d(PETSC_COMM_WORLD, user.bx, user.by, DMDA_STENCIL_STAR, 4, 4, PETSC_DECIDE, PETSC_DECIDE, 1, u… in main()
67 PetscCall(DMSetFromOptions(user.da)); in main()
68 PetscCall(DMSetUp(user.da)); in main()
70 PetscCall(DMDASetUniformCoordinates(user.da, user.xmin, user.xmax, user.ymin, user.ymax, 0, 0)); in main()
71 PetscCall(DMDASetCoordinateName(user.da, 0, "X - the angle")); in main()
72 PetscCall(DMDASetCoordinateName(user.da, 1, "Y - the speed")); in main()
75 PetscCall(DMCreateGlobalVector(user.da, &x)); in main()
77 PetscCall(ini_bou(x, &user)); in main()
83 PetscCall(TSSetDM(ts, user.da)); in main()
86 PetscCall(TSSetIFunction(ts, NULL, IFunction, &user)); in main()
88 PetscCall(TSSetApplicationContext(ts, &user)); in main()
99 PetscCall(DMDestroy(&user.da)); in main()
108 AppCtx *user; in PostStep() local
116 PetscCall(TSGetApplicationContext(ts, &user)); in PostStep()
120 PetscCall(DMGetCoordinateDM(user->da, &cda)); in PostStep()
122 PetscCall(DMGetCoordinates(user->da, &gc)); in PostStep()
124 PetscCall(DMDAVecGetArrayRead(user->da, X, &p)); in PostStep()
131 PetscCall(DMDAVecRestoreArrayRead(user->da, X, &p)); in PostStep()
141 PetscErrorCode ini_bou(Vec X, AppCtx *user) in ini_bou() argument
150 PetscScalar sigmax = user->sigmax, sigmay = user->sigmay; in ini_bou()
151 PetscScalar rho = user->rho; in ini_bou()
152 PetscScalar muy = user->muy, mux; in ini_bou()
158 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in ini_bou()
159 user->dx = (user->xmax - user->xmin) / (M - 1); in ini_bou()
160 user->dy = (user->ymax - user->ymin) / (N - 1); in ini_bou()
161 PetscCall(DMGetCoordinateDM(user->da, &cda)); in ini_bou()
162 PetscCall(DMGetCoordinates(user->da, &gc)); in ini_bou()
164 PetscCall(DMDAVecGetArray(user->da, X, &p)); in ini_bou()
171 …mux = user->mux = coors[0][M / 2 + 10].x; /* For -pi < x < pi, this should be some angle between 0… in ini_bou()
172 if (user->nonoiseinitial) { in ini_bou()
182 user->PM_min = user->Pmax * PetscSinScalar(mux); in ini_bou()
192 PetscCall(DMDAVecRestoreArray(user->da, X, &p)); in ini_bou()
199 …(PetscScalar **p, PetscScalar y, PetscInt i, PetscInt j, PetscInt M, PetscScalar *p1, AppCtx *user) in adv1() argument
204 f = (y - user->ws); in adv1()
207 if (user->st_width == 1) { in adv1()
208 *p1 = fpos * (p[j][i] - p[j][i - 1]) / user->dx + fneg * (p[j][i + 1] - p[j][i]) / user->dx; in adv1()
209 } else if (user->st_width == 2) { in adv1()
210 …4 * p[j][i - 1] + p[j][i - 2]) / (2 * user->dx) + fneg * (-p[j][i + 2] + 4 * p[j][i + 1] - 3 * p[j… in adv1()
211 } else if (user->st_width == 3) { in adv1()
212 …i - 1] + p[j][i - 2]) / (6 * user->dx) + fneg * (-p[j][i + 2] + 6 * p[j][i + 1] - 3 * p[j][i] - 2 … in adv1()
218 …(PetscScalar **p, PetscScalar x, PetscInt i, PetscInt j, PetscInt N, PetscScalar *p2, AppCtx *user) in adv2() argument
223 f = (user->ws / (2 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(x)); in adv2()
226 if (user->st_width == 1) { in adv2()
227 *p2 = fpos * (p[j][i] - p[j - 1][i]) / user->dy + fneg * (p[j + 1][i] - p[j][i]) / user->dy; in adv2()
228 } else if (user->st_width == 2) { in adv2()
229 …4 * p[j - 1][i] + p[j - 2][i]) / (2 * user->dy) + fneg * (-p[j + 2][i] + 4 * p[j + 1][i] - 3 * p[j… in adv2()
230 } else if (user->st_width == 3) { in adv2()
231 … 1][i] + p[j - 2][i]) / (6 * user->dy) + fneg * (-p[j + 2][i] + 6 * p[j + 1][i] - 3 * p[j][i] - 2 … in adv2()
237 …de diffuse(PetscScalar **p, PetscInt i, PetscInt j, PetscReal t, PetscScalar *p_diff, AppCtx *user) in diffuse() argument
240 if (user->st_width == 1) { in diffuse()
241 … *p_diff = user->disper_coe * ((p[j - 1][i] - 2 * p[j][i] + p[j + 1][i]) / (user->dy * user->dy)); in diffuse()
242 } else if (user->st_width == 2) { in diffuse()
243 …*p_diff = user->disper_coe * ((-p[j - 2][i] + 16 * p[j - 1][i] - 30 * p[j][i] + 16 * p[j + 1][i] -… in diffuse()
244 } else if (user->st_width == 3) { in diffuse()
245user->disper_coe * ((2 * p[j - 3][i] - 27 * p[j - 2][i] + 270 * p[j - 1][i] - 490 * p[j][i] + 270 … in diffuse()
252 AppCtx *user = (AppCtx *)ctx; in IFunction() local
262 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IFunction()
263 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IFunction()
266 PetscCall(DMGetLocalVector(user->da, &localX)); in IFunction()
267 PetscCall(DMGetLocalVector(user->da, &localXdot)); in IFunction()
269 PetscCall(DMGlobalToLocalBegin(user->da, X, INSERT_VALUES, localX)); in IFunction()
270 PetscCall(DMGlobalToLocalEnd(user->da, X, INSERT_VALUES, localX)); in IFunction()
271 PetscCall(DMGlobalToLocalBegin(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
272 PetscCall(DMGlobalToLocalEnd(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
274 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IFunction()
277 PetscCall(DMDAVecGetArrayRead(user->da, localX, &p)); in IFunction()
278 PetscCall(DMDAVecGetArrayRead(user->da, localXdot, &pdot)); in IFunction()
279 PetscCall(DMDAVecGetArray(user->da, F, &f)); in IFunction()
281user->disper_coe = PetscPowScalar((user->lambda * user->ws) / (2 * user->H), 2) * user->q * (1.0 -… in IFunction()
284 PetscCall(adv1(p, coors[j][i].y, i, j, M, &p_adv1, user)); in IFunction()
285 PetscCall(adv2(p, coors[j][i].x, i, j, N, &p_adv2, user)); in IFunction()
286 PetscCall(diffuse(p, i, j, t, &p_diff, user)); in IFunction()
290 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &p)); in IFunction()
291 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &pdot)); in IFunction()
292 PetscCall(DMRestoreLocalVector(user->da, &localX)); in IFunction()
293 PetscCall(DMRestoreLocalVector(user->da, &localXdot)); in IFunction()
294 PetscCall(DMDAVecRestoreArray(user->da, F, &f)); in IFunction()
301 AppCtx *user = (AppCtx *)ctx; in IJacobian() local
312 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IJacobian()
313 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IJacobian()
316 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IJacobian()
325 c1 = (yi - user->ws) / user->dx; in IJacobian()
328 …c3 = (user->ws / (2.0 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(xi)) / us… in IJacobian()
331 …(PetscPowScalar((user->lambda * user->ws) / (2 * user->H), 2) * user->q * (1.0 - PetscExpScalar(-t… in IJacobian()
361 PetscErrorCode Parameter_settings(AppCtx *user) in Parameter_settings() argument
367 user->ws = 1.0; in Parameter_settings()
368 user->H = 5.0; in Parameter_settings()
369 user->Pmax = 2.1; in Parameter_settings()
370 user->PM_min = 1.0; in Parameter_settings()
371 user->lambda = 0.1; in Parameter_settings()
372 user->q = 1.0; in Parameter_settings()
373 user->mux = PetscAsinScalar(user->PM_min / user->Pmax); in Parameter_settings()
374 user->sigmax = 0.1; in Parameter_settings()
375 user->sigmay = 0.1; in Parameter_settings()
376 user->rho = 0.0; in Parameter_settings()
377 user->xmin = -PETSC_PI; in Parameter_settings()
378 user->xmax = PETSC_PI; in Parameter_settings()
379 user->bx = DM_BOUNDARY_PERIODIC; in Parameter_settings()
380 user->by = DM_BOUNDARY_MIRROR; in Parameter_settings()
381 user->nonoiseinitial = PETSC_FALSE; in Parameter_settings()
387 user->ymin = -3.0; in Parameter_settings()
388 user->ymax = 10.0; in Parameter_settings()
389 user->st_width = 1; in Parameter_settings()
391 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ws", &user->ws, &flg)); in Parameter_settings()
392 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Inertia", &user->H, &flg)); in Parameter_settings()
393 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Pmax", &user->Pmax, &flg)); in Parameter_settings()
394 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-PM_min", &user->PM_min, &flg)); in Parameter_settings()
395 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-lambda", &user->lambda, &flg)); in Parameter_settings()
396 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-q", &user->q, &flg)); in Parameter_settings()
397 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-mux", &user->mux, &flg)); in Parameter_settings()
398 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-sigmax", &user->sigmax, &flg)); in Parameter_settings()
399 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-muy", &user->muy, &flg)); in Parameter_settings()
400 if (flg == 0) user->muy = user->ws; in Parameter_settings()
401 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-sigmay", &user->sigmay, &flg)); in Parameter_settings()
402 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-rho", &user->rho, &flg)); in Parameter_settings()
403 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmin", &user->xmin, &flg)); in Parameter_settings()
404 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmax", &user->xmax, &flg)); in Parameter_settings()
405 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymin", &user->ymin, &flg)); in Parameter_settings()
406 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymax", &user->ymax, &flg)); in Parameter_settings()
407 PetscCall(PetscOptionsGetInt(NULL, NULL, "-stencil_width", &user->st_width, &flg)); in Parameter_settings()
408 PetscCall(PetscOptionsGetEnum(NULL, NULL, "-bx", DMBoundaryTypes, (PetscEnum *)&user->bx, &flg)); in Parameter_settings()
409 PetscCall(PetscOptionsGetEnum(NULL, NULL, "-by", DMBoundaryTypes, (PetscEnum *)&user->by, &flg)); in Parameter_settings()
410 PetscCall(PetscOptionsGetBool(NULL, NULL, "-nonoiseinitial", &user->nonoiseinitial, &flg)); in Parameter_settings()