Thank you, Lawrence. Cool! That's perfect!
Bests, Marco Cisternino ________________________________________ Da: Lawrence Mitchell <wen...@gmail.com> Inviato: martedì 24 settembre 2019 13:59 A: Marco Cisternino Cc: petsc-users Oggetto: Re: [petsc-users] Multiple linear solver defined at command line Dear Marco, > On 24 Sep 2019, at 12:06, Marco Cisternino via petsc-users > <petsc-users@mcs.anl.gov> wrote: > > Good morning, > in my code I need to solve 2 linear systems. I would like to use different > solvers for the 2 systems and most of all I would like to choose the single > solver by flags from command line, is it possible? > I can call PetscInitialize/PetscFinalize multiple times passing > PetscInitialize different argc and argv. What happens if I call the second > PetscInitiliaze before the first PetscFinalize with different argc and argv? The way you should do this is by giving your two different solvers two different options prefixes: Assuming they are KSP objects call: KSPSetOptionsPrefix(ksp1, "solver1_"); KSPSetOptionsPrefix(ksp2, "solver2_"); Now you can configure ksp1 with: -solver1_ksp_type ... -solver1_pc_type ... And ksp2 with: -solver2_ksp_type ... -solver2_pc_type ... In general, all PETSc objects can be given such an options prefix so that they may be controlled separately. Thanks, Lawrence