[petsc-users] Copy solution and function from one SNES to another
Matthew Knepley
knepley at gmail.com
Thu May 28 06:25:05 CDT 2015
On Thu, May 28, 2015 at 12:34 AM, Harshad Sahasrabudhe <hsahasra at purdue.edu>
wrote:
> 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);
>
If you want to use the same vector
SNESGetFunction(newton, &f)
SNESSetFunction(shell, f)
otherwise for a copy
SNESGetFunction(newton, &f)
VecDuplicate(f, &sf)
SNESSetFunction(shell, sf)
VecDestroy(&sf)
Thanks,
Matt
> 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
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150528/64b38512/attachment-0001.html>
More information about the petsc-users
mailing list