[petsc-dev] Putting solver state into vectors

Barry Smith bsmith at mcs.anl.gov
Wed Jan 14 16:09:48 CST 2015


  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) {





More information about the petsc-dev mailing list