[petsc-users] low dimensional sub-problem
Gideon Simpson
gideon.simpson at gmail.com
Sat Feb 25 09:32:25 CST 2017
I’ve been continuing working on implementing a projection method problem, which, loosely, looks like the following. Vec y contains the state vector for my system, y’ = f(y) which is solved with a TS, using, for now, rk4.
I have added to this a TSPostStep which does root finding on the nonlinear problem
f(lambda) = f(lambda; y, w) = g(y + lambda * w) - g0
y and w are vectors that are the size of the system (numbers of mesh points), and lambda is a scalar perturbation.
Right now, the snes function for solving this amounts to:
PetscErrorCode projector(SNES snes, Vec lam, Vec f, void *ctx){
AppCtx * user = (AppCtx *) ctx;
const PetscScalar *lam_value;
PetscScalar *f_value;
VecGetArrayRead(lam, &lam_value);
VecGetArray(f, &f_value);
VecCopy(user->y, user->w);
VecAXPY(user->w, lam_value[0], user->gradMy);
f_value[0] = g(user->w) -user->g0;
VecRestoreArrayRead(lam, &lam_value);
VecRestoreArray(f, &f_value);
return 0;
}
To get this all to work, I constructed the SNES and Vec lam with PETSC_COMM_SELF, effectively putting a copy of the nonlinear problem on each process. Basically, the nonlinear problem is low dimensional, but it parametrically depends on the high dimensional, distributed, vectors y and w.
The one thing that bothers me about this is:
1. It would seem that each process is is doing all of these vector operations, which is entirely redundant, as the only thing that really needs to be shared amongst the processes is the value of lambda. Is that correct?
2. Is there an obvious way around this redundancy?
-gideon
More information about the petsc-users
mailing list