[petsc-users] Trying to develop my own Krylov solver
Barry Smith
bsmith at petsc.dev
Tue Jun 25 12:14:52 CDT 2024
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 <petsc-users at mcs.anl.gov <mailto:petsc-users at mcs.anl.gov>> wrote:
>> 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
>
>> - 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 <https://urldefense.us/v3/__http://libcoeur.so/__;!!G_uCfscf7eWS!YdfbFMzwUYFerTqmfdwOGaPcudU8m_JVVuuMI9-wko7kKcOqgNi_xiJZC-uQ6hpwAtBdhocY_wzknRHkH4wv_nQ$ >
>> /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 <https://urldefense.us/v3/__http://libcoeur.so/__;!!G_uCfscf7eWS!YdfbFMzwUYFerTqmfdwOGaPcudU8m_JVVuuMI9-wko7kKcOqgNi_xiJZC-uQ6hpwAtBdhocY_wzknRHkH4wv_nQ$ >] 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!YdfbFMzwUYFerTqmfdwOGaPcudU8m_JVVuuMI9-wko7kKcOqgNi_xiJZC-uQ6hpwAtBdhocY_wzknRHk84A4kYM$ <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
>> Librairie Éléments Finis Coeur <https://urldefense.us/v3/__https://gitlab.emse.fr/bruchon/Coeur/-/wikis/home__;!!G_uCfscf7eWS!dQgv-IRWC7OgdDf1X9Oew4nHSgleq2ty0AszuRPj70bBiFeCcT4RibQVAvv6FFeD081W1yY8IczRHAG6pz3FrQ$>
>> 0477420072
>
>
> --
> 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/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!YdfbFMzwUYFerTqmfdwOGaPcudU8m_JVVuuMI9-wko7kKcOqgNi_xiJZC-uQ6hpwAtBdhocY_wzknRHk8zs6keo$ <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!ZSMOgmxB-aRx34PmTC3s7ZkDC-zT09xxpmLjhj_vx8oVkTvDSORUOeoTe8ZdEFCHVCUxSrs3eOz346S6E1L_$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20240625/32e4fcb4/attachment-0001.html>
More information about the petsc-users
mailing list