[petsc-dev] Putting solver state into vectors

Matthew Knepley knepley at gmail.com
Sat Jan 17 06:50:45 CST 2015


On Wed, Jan 14, 2015 at 4:09 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
>   I don't buy that this is good code. 1) It is strange to keep solver
> state in the vector instead of the solver object and 2) it is very
> dangerous as anybody who calls VecGetArray() on the vector in, for example,
> a monitor breaks the code and gets the wrong answer. Using VecGetArray()
> might slow down code because things need to be recalculated but assuming
> the user did not write into the array it should not change the progress of
> the code.
>
>    I vote that this code is refactored to not use this hairy storage of
> solver state in "some vector that is lying around".
>
>   if (ts->equation_type >= TS_EQ_IMPLICIT && tab->explicit_first_stage) {
>     PetscReal valid_time;
>     PetscBool isvalid;
>     ierr =
> PetscObjectComposedDataGetReal((PetscObject)ts->vec_sol,explicit_stage_time_id,valid_time,isvalid);CHKERRQ(ierr);
>     if (!isvalid || valid_time != ts->ptime) {
>

I agree completely. If we need more state, it should go in the solver.

  Matt

-- 
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-dev/attachments/20150117/207f8064/attachment.html>


More information about the petsc-dev mailing list