[petsc-users] linking and compiling cg.c with examples from tutorials

Elena Smith suguleasa at gmail.com
Mon Aug 23 11:48:39 CDT 2010


I went with option 1. It turned out that my problems were given by the
machine and its default settings.

Thank you very much!
Elena


On Fri, Aug 20, 2010 at 3:08 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>   If you are just "experimenting" with changes to cg.c there are two easy ways to do this
>
> 1) change cg.c directly in the PETSc directory tree and then run make in that directory, this updates the PETSc library, then relink your program and it will get your changes or
>
> 2) copy cg.c into your directory put it in your makefile as one of your source files and change it and compile there
>
>   If you actually want to make a whole new PETSc Krylov method, distinct from the current CG then read the comments in cg.c on how to do it.
>
>   Barry
>
> On Aug 20, 2010, at 2:57 PM, Elena Smith wrote:
>
>> Hello All,
>>
>> I am a new PETSc user and I need some help.
>> This is what I am trying to do:
>> - use one of the examples provided under "tutorials"
>> (src/ksp/ksp/examples/tutorials) and make it used one of the iterative
>> methods already in src/ksp/ksp/impls.
>> For example, instead of using KSPSetType(ksp,KSPCG) and then KSPSolve,
>> I want to just do: KSPSolve_CG, where KSPSolve_CG comes from cg.c
>> which would have some changes I would make.
>>
>>> From a previous post
>> (https://lists.mcs.anl.gov/mailman/htdig/petsc-dev/2008-November/001049.html
>> ) I understood that KSPSolve (with the KSPCG type set as above) calls
>> actually KSPSolve_CG that is implemented in cg.c from
>> src/ksp/ksp/impls/cg/cg.c.
>> Does this mean I can change cg.c and somehow (magically) when I
>> compile the example, it will know to compile the modified cg.c as
>> well, perhaps through something like PETSC_KSP_LIB?  I have tried this
>> and it doesn't work, but it could be because not knowing how to set up
>> the makefile... or my simplistic approach.
>>
>> Or would I have to recompile the entire source code to reflect the
>> changes? I believe the answer is much simpler than this question
>> suggests.
>>
>> Your help would be greatly appreciated.
>> Thank you in advance,
>>    Elena
>
>


More information about the petsc-users mailing list