Lines Matching refs:user

42   User               user = (User)ctx;  in RHSFunctionPassive()  local
50 f[1] = user->mu * (1. - x[0] * x[0]) * x[1] - x[0]; in RHSFunctionPassive()
62 User user = (User)ctx; in RHSFunctionActive() local
63 PetscReal mu = user->mu; in RHSFunctionActive()
93 User user = (User)ctx; in RHSJacobian() local
98 PetscCall(PetscAdolcComputeRHSJacobian(1, A, x, user->adctx)); in RHSJacobian()
110 User user = (User)ctx; in Monitor() local
117 …%.1f] %" PetscInt_FMT " TS %.6f (dt = %.6f) X % 12.6e % 12.6e\n", (double)user->next_output, step,… in Monitor()
130 struct _n_User user; in main() local
148 user.mu = 1.0; in main()
149 user.next_output = 0.0; in main()
150 user.steps = 0; in main()
151 user.ftime = 0.5; in main()
155 user.adctx = adctx; in main()
157 PetscCall(PetscOptionsGetReal(NULL, NULL, "-mu", &user.mu, NULL)); in main()
163 PetscCall(MatCreate(PETSC_COMM_WORLD, &user.A)); in main()
164 PetscCall(MatSetSizes(user.A, PETSC_DECIDE, PETSC_DECIDE, 2, 2)); in main()
165 PetscCall(MatSetFromOptions(user.A)); in main()
166 PetscCall(MatSetUp(user.A)); in main()
167 PetscCall(MatCreateVecs(user.A, &user.x, NULL)); in main()
172 PetscCall(VecGetArray(user.x, &x_ptr)); in main()
175 PetscCall(VecRestoreArray(user.x, &x_ptr)); in main()
180 PetscCall(VecDuplicate(user.x, &r)); in main()
181 PetscCall(RHSFunctionActive(ts, 0., user.x, r, &user)); in main()
183 PetscCall(MatDiagonalSet(user.A, r, INSERT_VALUES)); in main()
191 PetscCall(TSSetRHSFunction(ts, NULL, RHSFunctionPassive, &user)); in main()
192 PetscCall(TSSetRHSJacobian(ts, user.A, user.A, RHSJacobian, &user)); in main()
193 PetscCall(TSSetMaxTime(ts, user.ftime)); in main()
195 if (monitor) PetscCall(TSMonitorSet(ts, Monitor, &user, NULL)); in main()
198 …ORLD, "mu %g, steps %" PetscInt_FMT ", ftime %g\n", (double)user.mu, user.steps, (double)user.ftim… in main()
213 PetscCall(TSSolve(ts, user.x)); in main()
214 PetscCall(TSGetSolveTime(ts, &user.ftime)); in main()
215 PetscCall(TSGetStepNumber(ts, &user.steps)); in main()
216 …ORLD, "mu %g, steps %" PetscInt_FMT ", ftime %g\n", (double)user.mu, user.steps, (double)user.ftim… in main()
218 PetscCall(VecGetArray(user.x, &x_ptr)); in main()
219 user.x_ob[0] = x_ptr[0]; in main()
220 user.x_ob[1] = x_ptr[1]; in main()
221 PetscCall(VecRestoreArray(user.x, &x_ptr)); in main()
223 PetscCall(MatCreateVecs(user.A, &user.lambda[0], NULL)); in main()
230 PetscCall(MatCreateVecs(user.A, &ic, NULL)); in main()
239 PetscCall(TaoSetObjectiveAndGradient(tao, NULL, FormFunctionGradient, (void *)&user)); in main()
261 PetscCall(MatDestroy(&user.A)); in main()
262 PetscCall(VecDestroy(&user.x)); in main()
263 PetscCall(VecDestroy(&user.lambda[0])); in main()
286 User user = (User)ctx; in FormFunctionGradient() local
291 PetscCall(VecCopy(IC, user->x)); in FormFunctionGradient()
298 PetscCall(TSSetRHSFunction(ts, NULL, RHSFunctionPassive, user)); in FormFunctionGradient()
300 PetscCall(TSSetRHSJacobian(ts, user->A, user->A, RHSJacobian, user)); in FormFunctionGradient()
322 PetscCall(TSSolve(ts, user->x)); in FormFunctionGradient()
323 PetscCall(TSGetSolveTime(ts, &user->ftime)); in FormFunctionGradient()
324 PetscCall(TSGetStepNumber(ts, &user->steps)); in FormFunctionGradient()
325 …D, "mu %.6f, steps %" PetscInt_FMT ", ftime %g\n", (double)user->mu, user->steps, (double)user->ft… in FormFunctionGradient()
327 PetscCall(VecGetArray(user->x, &x_ptr)); in FormFunctionGradient()
328 …*f = (x_ptr[0] - user->x_ob[0]) * (x_ptr[0] - user->x_ob[0]) + (x_ptr[1] - user->x_ob[1]) * (x_ptr… in FormFunctionGradient()
329 …f; %f], ODE solution y=[%f;%f], Cost function f=%f\n", (double)user->x_ob[0], (double)user->x_ob[1… in FormFunctionGradient()
335 PetscCall(VecGetArray(user->lambda[0], &y_ptr)); in FormFunctionGradient()
336 y_ptr[0] = 2. * (x_ptr[0] - user->x_ob[0]); in FormFunctionGradient()
337 y_ptr[1] = 2. * (x_ptr[1] - user->x_ob[1]); in FormFunctionGradient()
338 PetscCall(VecRestoreArray(user->lambda[0], &y_ptr)); in FormFunctionGradient()
339 PetscCall(VecRestoreArray(user->x, &x_ptr)); in FormFunctionGradient()
340 PetscCall(TSSetCostGradients(ts, 1, user->lambda, NULL)); in FormFunctionGradient()
344 PetscCall(VecCopy(user->lambda[0], G)); in FormFunctionGradient()