[petsc-users] accessing fields from previous, converged solution.
Maximilian Hartig
imilian.hartig at gmail.com
Wed Aug 16 08:56:27 CDT 2017
Hello,
I have a problem with several fields that I solve with PetscFE and TS. I now need to access the solution from the previous timestep to compute the residual for the current timestep.
I tried a TSMonitor with the following code in it:
TSGetDM(ts,&dm);
DMClone(dm,&dm_aux);
DMGetDS(dm,&prob_aux);
DMSetDS(dm_aux,prob_aux);
DMCreateGlobalVector(dm_aux,&old_solution);
VecCopy(u,oldsolution);
PetscObjectCompose((PetscObject) dm, “A”, (PetscObject) old_solution);
VecDestroy(&old_solution);
DMDestroy(&dm_aux);
hoping that it would create an auxiliary field that I could access in the evaluation of the residual. It did that but messed with the discretisation of the initial problem in some way. So I figure that adding auxiliary fields to a dm after having fed it to a TS context is not something you should be doing.
Is there a way to access the fields of the solution for the previous timestep during the evaluation of the current residual?
Thanks,
Max
More information about the petsc-users
mailing list