On Thu, May 28, 2015 at 12:34 AM, Harshad Sahasrabudhe <[email protected]>
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

Reply via email to