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

Julien BRUCHON bruchon at emse.fr
Fri Jun 28 10:30:53 CDT 2024


Thank you for your answers, it woks well. 

Julien 

De: "Barry Smith" <bsmith at petsc.dev> 
À: "Matthew Knepley" <knepley at gmail.com> 
Cc: "Julien BRUCHON" <bruchon at emse.fr>, "petsc-users" <petsc-users at mcs.anl.gov> 
Envoyé: Mardi 25 Juin 2024 19:14:52 
Objet: Re: [petsc-users] Trying to develop my own Krylov solver 


Make sure that you are using the latest PETSc if at all possible 

Also copy over a makefile from the cg directory (you do not need to edit any makefiles) 
You also need to add it to KSPRegisterAll() 

You will need to do make clean before running make all to compiler your new code. 

Barry 









On Jun 25, 2024, at 1:11 PM, Matthew Knepley <knepley at gmail.com> wrote: 

This Message Is From an External Sender 
This message came from outside your organization. 
On Tue, Jun 25, 2024 at 12:05 PM Julien BRUCHON via petsc-users < [ mailto:petsc-users at mcs.anl.gov | petsc-users at mcs.anl.gov ] > wrote: 

BQ_BEGIN

This Message Is From an External Sender 
This message came from outside your organization. 
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/? 



Yes. 

Thanks, 

Matt 

BQ_BEGIN

- 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 [ https://urldefense.us/v3/__http://libcoeur.so/__;!!G_uCfscf7eWS!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b4f3-nU3A$  | 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 : [ https://urldefense.us/v3/__http://libcoeur.so/__;!!G_uCfscf7eWS!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b4f3-nU3A$  | 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!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b7q0tC0Xw$  ] 
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 

BQ_END



-- 
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://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZSMOgmxB-aRx34PmTC3s7ZkDC-zT09xxpmLjhj_vx8oVkTvDSORUOeoTe8ZdEFCHVCUxSrs3eOz346S6E1L_$ | https://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b50sR16ZQ$  ] 

BQ_END



-- 
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!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b7q0tC0Xw$  | https://urldefense.us/v3/__https://www.mines-stetienne.fr/lgf/__;!!G_uCfscf7eWS!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b7q0tC0Xw$  ] 
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!eJ5wDIF503lmkSoc9ckRL6Hf7-ac1BL99ksSTDaYQ0VLXGrgZJzkMOQhSpDEOSQpkux5LxL9PqMV1b4DLBtKFA$  | Librairie Éléments Finis Coeur ] 
0477420072 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240628/20a0af4c/attachment-0001.html>


More information about the petsc-users mailing list