You are mixing up KSPSetType() and KSPCGSetType(). KSPTCQMR can be passed as an argument of KSPSetType(), not KSPCGSetType(). The former has an argument of type KSPType, which is a string, while the latter has an argument of type KSPCGType, which is an enumerate.
Jose > El 20 jul 2023, a las 4:04, Alberto Cattaneo <[email protected]> > escribió: > > Greetings > I hope this email reaches you well. I'm new to using PETSc and so I thought a > good way to familiarize myself with the tools would be to noodle around with > a simple problem and see how different setups of the same problem play out. I > thought it would be prudent to try ex50.c with different linear solvers to > see how they compare on a simple problem that was easy enough to tweak. > However I'm having some trouble, when I try to set the KSP type the only one > that seems to work is KSP_CG_SYMMETRIC, all others throw up an error like this > > /home/cattaneo/petsc-3.19.1/include/petscksp.h:59:23: error: incompatible > type for argument 2 of ‘KSPCGSetType’ > 59 | #define KSPTCQMR "tcqmr" > | ^~~~~~~ > | | > | const char * > /home/cattaneo/petsc-3.19.1/include/petscerror.h:473:28: note: in definition > of macro ‘PetscCall’ > 473 | ierr_petsc_call_q_ = __VA_ARGS__; \ > | ^~~~~~~~~~~ > ex50B.c:56:29: note: in expansion of macro ‘KSPTCQMR’ > 56 | PetscCall(KSPCGSetType(ksp,KSPTCQMR)); > | ^~~~~~~~ > In file included from ex50B.c:25: > /home/cattaneo/petsc-3.19.1/include/petscksp.h:884:47: note: expected > ‘KSPCGType’ but argument is of type ‘const char *’ > 884 | PETSC_EXTERN PetscErrorCode KSPCGSetType(KSP, KSPCGType); > > When trying to make the file. I suspect I'm missing something fundamental, > but I can't seem to chase whatever it is down. I am using PETSc on WSL2 on > Windows 10 which I know is not the standard, but so far it hasn't seemed to > cause trouble. I'm confused because I'm using the same make that is used for > all the examples, and it doesn't seem to have an issue using KSPGMRES for > ex62 as an example. Sorry if this is a basic question, I'm just a little > unsure where to turn as I don't really know anyone that uses PETSc. Thank you > for your time. > Respectfully: > Alberto >
