[petsc-users] Copy solution and function from one SNES to another

Harshad Sahasrabudhe hsahasra at purdue.edu
Thu May 28 00:34:08 CDT 2015


Hi,

I'm trying to copy the solution and functions vecs from a Newton SNES to a
Shell SNES. I'm doing it like this:

  SNES newton_snes, shell_snes;
  Vec newton_function, newton_solution;
  Vec shell_function, shell_solution;
  .
  .
  Newton SNES initialized and solved here. Shell SNES initialized.
  .
  .
  SNESGetFunction(newton_snes, &newton_function, 0, 0);
  SNESGetFunction(shell_snes, &shell_function, 0, 0);
  VecDestroy(&shell_function);
  VecDuplicate(newton_function, &shell_function);

  SNESGetSolution(newton_snes, &newton_solution);
  SNESGetSolution(shell_snes, &shell_solution);
  VecDestroy(&shell_solution);
  VecDuplicate(newton_solution, &shell_solution);

But I get this error on first VecDuplicate line:

[0]PETSC ERROR: VecDuplicate() line 511 in
/home/hsahasra/NEMO5/libs/petsc/build-real/src/vec/vec/interface/vector.c
Null Object: Parameter # 1

Is there any other better way to do this?

Thanks,
Harshad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150528/fb438457/attachment.html>


More information about the petsc-users mailing list