[petsc-users] Trying to develop my own Krylov solver

Julien BRUCHON bruchon at emse.fr
Tue Jun 25 11:04:25 CDT 2024


Hi, 

Based on 'cg.c', I'm trying to develop my own Krylov solver (a projected conjugate gradient). I want to integrate this into my C++ code, where I already have an interface for PETSC which works well. However, I have the following questions : 

- Where am I sensed to put my 'cg_projected.c' and 'pcgimpl.h' files? Should they go in a directory petsc/src/ksp/ksp/impls/pcg/? If so, how do I compile that? Is it simply by adding this directory to the Makefile in petsc/src/ksp/ksp/impls/? 

- I have also tried the basic approach of putting these two files in directories of my own C++ code and compiling. However, I have this error at the link edition: 
[100%] Linking CXX shared library libcoeur.so 
/usr/bin/ld: src/solvers/libsolvers.a(cg_projected.c.o): warning: relocation against `petscstack' in read-only section `.text' 
/usr/bin/ld: src/solvers/libsolvers.a(cg_projected.c.o): relocation R_X86_64_PC32 against symbol `petscstack' can not be used when making a shared object; recompilé avec -fPIC 
/usr/bin/ld : échec de l'édition de liens finale : bad value 
collect2: error: ld returned 1 exit status 
make[2]: *** [CMakeFiles/coeur.dir/build.make:121 : libcoeur.so] Erreur 1 
make[1]: *** [CMakeFiles/Makefile2:286 : CMakeFiles/coeur.dir/all] Erreur 2 
make: *** [Makefile:91 : all] Erreur 2 

Could you please tell me what is the right way to proceed? 

Thank you, 

Julien 
-- 
Julien Bruchon 
Professeur IMT - Responsable du département MPE 
LGF - UMR CNRS 5307 - [ https://urldefense.us/v3/__https://www.mines-stetienne.fr/lgf/__;!!G_uCfscf7eWS!dQgv-IRWC7OgdDf1X9Oew4nHSgleq2ty0AszuRPj70bBiFeCcT4RibQVAvv6FFeD081W1yY8IczRHAHopA0crg$  | https://urldefense.us/v3/__https://www.mines-stetienne.fr/lgf/__;!!G_uCfscf7eWS!dQgv-IRWC7OgdDf1X9Oew4nHSgleq2ty0AszuRPj70bBiFeCcT4RibQVAvv6FFeD081W1yY8IczRHAHopA0crg$  ] 
Mines Saint-Étienne, une école de l'Institut Mines-Télécom 
[ https://urldefense.us/v3/__https://gitlab.emse.fr/bruchon/Coeur/-/wikis/home__;!!G_uCfscf7eWS!dQgv-IRWC7OgdDf1X9Oew4nHSgleq2ty0AszuRPj70bBiFeCcT4RibQVAvv6FFeD081W1yY8IczRHAG6pz3FrQ$  | Librairie Éléments Finis Coeur ] 
0477420072 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240625/fe76deb6/attachment-0001.html>


More information about the petsc-users mailing list