Lines Matching refs:user
63 AppCtx user; /* Application context */ in main() local
70 PetscCall(Parameter_settings(&user)); in main()
72 …te2d(PETSC_COMM_WORLD, user.bx, user.by, DMDA_STENCIL_STAR, 4, 4, PETSC_DECIDE, PETSC_DECIDE, 1, u… in main()
73 PetscCall(DMSetFromOptions(user.da)); in main()
74 PetscCall(DMSetUp(user.da)); in main()
76 PetscCall(DMDASetUniformCoordinates(user.da, user.xmin, user.xmax, user.ymin, user.ymax, 0, 0)); in main()
77 PetscCall(DMDASetCoordinateName(user.da, 0, "X - the angle")); in main()
78 PetscCall(DMDASetCoordinateName(user.da, 1, "Y - the speed")); in main()
81 PetscCall(DMCreateGlobalVector(user.da, &x)); in main()
83 PetscCall(ini_bou(x, &user)); in main()
89 PetscCall(TSSetDM(ts, user.da)); in main()
92 PetscCall(TSSetIFunction(ts, NULL, IFunction, &user)); in main()
94 PetscCall(TSSetApplicationContext(ts, &user)); in main()
105 PetscCall(DMDestroy(&user.da)); in main()
114 AppCtx *user; in PostStep() local
119 PetscCall(TSGetApplicationContext(ts, &user)); in PostStep()
130 …if ((t > user->tf) && (t < user->tcl)) user->Pmax = 0.0; /* A short-circuit that drives the electr… in PostStep()
131 else user->Pmax = user->Pmax_s; in PostStep()
138 PetscErrorCode ini_bou(Vec X, AppCtx *user) in ini_bou() argument
149 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in ini_bou()
150 user->dx = (user->xmax - user->xmin) / (M - 1); in ini_bou()
151 user->dy = (user->ymax - user->ymin) / (N - 1); in ini_bou()
152 PetscCall(DMGetCoordinateDM(user->da, &cda)); in ini_bou()
153 PetscCall(DMGetCoordinates(user->da, &gc)); in ini_bou()
155 PetscCall(DMDAVecGetArray(user->da, X, &p)); in ini_bou()
158 …user->mux = %f, user->muy = %f\n", (double)PetscRealPart(user->mux), (double)PetscRealPart(user->m… in ini_bou()
159 …PetscCall(DMDAGetLogicalCoordinate(user->da, user->mux, user->muy, 0.0, &Ir, &J, NULL, &user->mux,… in ini_bou()
160 user->PM_min = user->Pmax * PetscSinScalar(user->mux); in ini_bou()
162 …(double)PetscRealPart(user->mux), (double)PetscRealPart(user->muy), (double)PetscRealPart(user->PM… in ini_bou()
166 PetscCall(DMDAVecRestoreArray(user->da, X, &p)); in ini_bou()
171 …(PetscScalar **p, PetscScalar y, PetscInt i, PetscInt j, PetscInt M, PetscScalar *p1, AppCtx *user) in adv1() argument
173 PetscScalar f = (y - user->ws), fpos = PetscMax(f, 0), fneg = PetscMin(f, 0); in adv1()
176 if (user->st_width == 1) { in adv1()
177 *p1 = fpos * (p[j][i] - p[j][i - 1]) / user->dx + fneg * (p[j][i + 1] - p[j][i]) / user->dx; in adv1()
178 } else if (user->st_width == 2) { in adv1()
179 …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()
180 } else if (user->st_width == 3) { in adv1()
181 …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()
188 …p, PetscScalar x, PetscScalar y, PetscInt i, PetscInt j, PetscInt N, PetscScalar *p2, AppCtx *user) in adv2() argument
193 …f = (user->ws / (2 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(x) - user->D * (y … in adv2()
196 if (user->st_width == 1) { in adv2()
197 *p2 = fpos * (p[j][i] - p[j - 1][i]) / user->dy + fneg * (p[j + 1][i] - p[j][i]) / user->dy; in adv2()
198 } else if (user->st_width == 2) { in adv2()
199 …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()
200 } else if (user->st_width == 3) { in adv2()
201 … 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()
209 …de diffuse(PetscScalar **p, PetscInt i, PetscInt j, PetscReal t, PetscScalar *p_diff, AppCtx *user) in diffuse() argument
212 if (user->st_width == 1) { in diffuse()
213 … *p_diff = user->disper_coe * ((p[j - 1][i] - 2 * p[j][i] + p[j + 1][i]) / (user->dy * user->dy)); in diffuse()
214 } else if (user->st_width == 2) { in diffuse()
215 …*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()
216 } else if (user->st_width == 3) { in diffuse()
217 …user->disper_coe * ((2 * p[j - 3][i] - 27 * p[j - 2][i] + 270 * p[j - 1][i] - 490 * p[j][i] + 270 … in diffuse()
224 AppCtx *user = (AppCtx *)ctx; in IFunction() local
235 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IFunction()
236 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IFunction()
239 PetscCall(DMGetLocalVector(user->da, &localX)); in IFunction()
240 PetscCall(DMGetLocalVector(user->da, &localXdot)); in IFunction()
242 PetscCall(DMGlobalToLocalBegin(user->da, X, INSERT_VALUES, localX)); in IFunction()
243 PetscCall(DMGlobalToLocalEnd(user->da, X, INSERT_VALUES, localX)); in IFunction()
244 PetscCall(DMGlobalToLocalBegin(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
245 PetscCall(DMGlobalToLocalEnd(user->da, Xdot, INSERT_VALUES, localXdot)); in IFunction()
247 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IFunction()
250 PetscCall(DMDAVecGetArrayRead(user->da, localX, &p)); in IFunction()
251 PetscCall(DMDAVecGetArrayRead(user->da, localXdot, &pdot)); in IFunction()
252 PetscCall(DMDAVecGetArray(user->da, F, &f)); in IFunction()
254 gamma = user->D * user->ws / (2 * user->H); in IFunction()
255 …iffuse1 = user->lambda * user->lambda * user->q / (user->lambda * gamma + 1) * (1.0 - Pets… in IFunction()
256 user->disper_coe = user->ws * user->ws / (4 * user->H * user->H) * diffuse1; in IFunction()
260 PetscCall(adv1(p, coors[j][i].y, i, j, M, &p_adv1, user)); in IFunction()
261 PetscCall(adv2(p, coors[j][i].x, coors[j][i].y, i, j, N, &p_adv2, user)); in IFunction()
262 PetscCall(diffuse(p, i, j, t, &p_diff, user)); in IFunction()
266 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &p)); in IFunction()
267 PetscCall(DMDAVecRestoreArrayRead(user->da, localX, &pdot)); in IFunction()
268 PetscCall(DMRestoreLocalVector(user->da, &localX)); in IFunction()
269 PetscCall(DMRestoreLocalVector(user->da, &localXdot)); in IFunction()
270 PetscCall(DMDAVecRestoreArray(user->da, F, &f)); in IFunction()
277 AppCtx *user = (AppCtx *)ctx; in IJacobian() local
288 …PetscCall(DMDAGetInfo(user->da, NULL, &M, &N, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL… in IJacobian()
289 PetscCall(DMGetCoordinateDM(user->da, &cda)); in IJacobian()
292 PetscCall(DMGetCoordinatesLocal(user->da, &gc)); in IJacobian()
301 c1 = (yi - user->ws) / user->dx; in IJacobian()
304 …c3 = (user->ws / (2.0 * user->H)) * (user->PM_min - user->Pmax * PetscSinScalar(xi) - use… in IJacobian()
307 …(PetscPowScalar((user->lambda * user->ws) / (2 * user->H), 2) * user->q * (1.0 - PetscExpScalar(-t… in IJacobian()
337 PetscErrorCode Parameter_settings(AppCtx *user) in Parameter_settings() argument
343 user->ws = 1.0; in Parameter_settings()
344 user->H = 5.0; in Parameter_settings()
345 user->D = 0.0; in Parameter_settings()
346 user->Pmax = user->Pmax_s = 2.1; in Parameter_settings()
347 user->PM_min = 1.0; in Parameter_settings()
348 user->lambda = 0.1; in Parameter_settings()
349 user->q = 1.0; in Parameter_settings()
350 user->mux = PetscAsinScalar(user->PM_min / user->Pmax); in Parameter_settings()
351 user->sigmax = 0.1; in Parameter_settings()
352 user->sigmay = 0.1; in Parameter_settings()
353 user->rho = 0.0; in Parameter_settings()
354 user->xmin = -PETSC_PI; in Parameter_settings()
355 user->xmax = PETSC_PI; in Parameter_settings()
356 user->bx = DM_BOUNDARY_PERIODIC; in Parameter_settings()
357 user->by = DM_BOUNDARY_GHOSTED; in Parameter_settings()
358 user->tf = user->tcl = -1; in Parameter_settings()
359 user->ymin = -2.0; in Parameter_settings()
360 user->ymax = 2.0; in Parameter_settings()
361 user->st_width = 1; in Parameter_settings()
363 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ws", &user->ws, &flg)); in Parameter_settings()
364 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Inertia", &user->H, &flg)); in Parameter_settings()
365 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-D", &user->D, &flg)); in Parameter_settings()
366 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-Pmax", &user->Pmax, &flg)); in Parameter_settings()
367 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-PM_min", &user->PM_min, &flg)); in Parameter_settings()
368 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-lambda", &user->lambda, &flg)); in Parameter_settings()
369 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-q", &user->q, &flg)); in Parameter_settings()
370 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-mux", &user->mux, &flg)); in Parameter_settings()
371 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-muy", &user->muy, &flg)); in Parameter_settings()
372 if (flg == 0) user->muy = user->ws; in Parameter_settings()
373 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmin", &user->xmin, &flg)); in Parameter_settings()
374 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-xmax", &user->xmax, &flg)); in Parameter_settings()
375 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymin", &user->ymin, &flg)); in Parameter_settings()
376 PetscCall(PetscOptionsGetScalar(NULL, NULL, "-ymax", &user->ymax, &flg)); in Parameter_settings()
377 PetscCall(PetscOptionsGetInt(NULL, NULL, "-stencil_width", &user->st_width, &flg)); in Parameter_settings()
378 PetscCall(PetscOptionsGetEnum(NULL, NULL, "-bx", DMBoundaryTypes, (PetscEnum *)&user->bx, &flg)); in Parameter_settings()
379 PetscCall(PetscOptionsGetEnum(NULL, NULL, "-by", DMBoundaryTypes, (PetscEnum *)&user->by, &flg)); in Parameter_settings()
380 PetscCall(PetscOptionsGetReal(NULL, NULL, "-tf", &user->tf, &flg)); in Parameter_settings()
381 PetscCall(PetscOptionsGetReal(NULL, NULL, "-tcl", &user->tcl, &flg)); in Parameter_settings()