[petsc-dev] How to use fieldsplit for a block system with sizes change dynamically in TS
Matthew Knepley
knepley at gmail.com
Tue Sep 22 11:52:54 CDT 2020
On Tue, Sep 22, 2020 at 12:20 PM Mebratu Wakeni <
Mebratu.Wakeni at glasgow.ac.uk> wrote:
> Hello,
>
>
> I have the following issue regarding TS and field split.
>
>
> In a TS setting, I have a linear problem with the IJacobian of the
> IFunction with a block form
>
>
>
> | K 0 |
>
> | 0 D |
>
>
>
> Where K is sparse, while D is a diagonal. The sizes of the square matrices
> K and D are dynamic (varying between time steps).
>
How are you doing this in TS? Are you using just TSStep and calling
TSReset() after each step?
> The fact that, K and D are completely decoupled, and D is just a diagonal
> motivated us to use fieldsplit techniques rather than a monolithic one.
> However, this needs to recreate a fieldsplit preconditioner at each time
> step using the indices of K. To achieve this, I use the TSSetPreStep(ts,
> fun) function to perform the fun(TS ts) routine which does following
>
>
>
> 1. Get indices of K,
>
>
>
> PetscInt *idx_k; // size_of_k
>
>
>
> 2. Create an IS corresponding to K (IS is_k) using
>
>
>
> ISCreatGeneral(mpiComm, size_of_k, idx_k, PETSC_COPY_VALUES, &is_k);
>
>
>
> 3. Then set a fieldsplit preconditioner PC pc using is_k through
>
>
>
> PCFieldSplitSetIS(pc, NULL, is_k);
>
>
>
> 4. Finally the is_k is properly destroyed through
>
>
>
> ISDestroy(&is_lo);
>
That all looks fine.
> With the above setup, I have also used the following runtime options
>
>
>
> -ts_monitor
>
> -ts_exact_final_time stepover
>
> -ts_dt 0.1
>
> -ts_max_time 1
>
> -ts_adapt_type none
>
>
>
> -ksp_type gmres
>
> -pc_type fieldsplit
>
> -pc_fieldsplit_diag_use_amat
>
You do not need this unless you have a separate preconditioner matrix.
> -pc_fieldsplit_type additive
>
> -fieldsplit_0_ksp_type preonly
>
> -fieldsplit_0_pc_type lu
>
> -fieldsplit_0_pc_factor_mat_solver_type mumps
>
> -fieldsplit_1_ksp_type preonly
>
> -fieldsplit_1_pc_type jacobi
>
>
>
> -snes_atol 1e-8
>
> -snes_rtol 1e-12
>
> -ksp_monitor
>
> -snes_monitor
>
> -snes_lag_jacobian 1
>
You should not need this since your SNES should converge in 1 iterate with
an exact linear solver and a linear problem.
> Result: with the setup described above and the options, I expect to get
> ksp convergence in a single step (at every time step), however, what I am
> getting in actuality is that the fieldsplit works as expected only for the
> first timestep, after that it either take too many ksp steps to converge or
> diverge completely. I have a suspicion that, the way the fieldsplit set up
> at each time using the TSSetPreStep() somehow adds new split over previous
> splits. For this, I have also tried using TSSetPostStep() function to reset
> both the ksp and pc as follows
>
First check -snes_view to see if you have the solver you think you do, and
also
-snes_monitor -ksp_monitor_true_residual -ksp_converged_reason
-snes_converged_reason
It sounds to me like something is not being recreated correctly.
Thanks,
Matt
> KSPRest(ksp);
>
> PCReset(pc);
>
>
> But these don’t help either.
>
--
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
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20200922/5b15d8f7/attachment-0001.html>
More information about the petsc-dev
mailing list