<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 5, 2018 at 6:39 AM, Robert Speck <span dir="ltr"><<a href="mailto:r.speck@fz-juelich.de" target="_blank">r.speck@fz-juelich.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<br>
<br>
I would like to use petsc4py for my own Python library. Installation<br>
went well, first tests (serial and parallel) look good.<br>
<br>
Here is what I want to do: I have my own time-stepping playground and I<br>
want petsc4py to be one of my backbones for the data types and (linear<br>
or non-linear, serial or parallel) solvers. I don't want to use PETSc's<br>
time-steppers, at least not for now. So, I saw in some examples, in<br>
particular the ones shipped with petsc4py, that the standard way of<br>
running one of PETSc's solvers is a bunch of setup routines, then<br>
setting the right-hand side and solve.<br>
<br>
Now, I don't want to rerun the whole setup part each time I call the<br>
solver. I know that I can change the right-hand side without having to<br>
do so, but what if I change a parameter of my operator like, say, the<br>
time-step size or some material parameter?<br>
<br>
Take the simplest case: Say I have my own implicit Euler written in<br>
Python. I know the right-hand side F of my ODE, so in each step I want<br>
to solve "I - dt*F". But the time-step changes every now and then, so I<br>
cannot pre-assemble everything once and for all (or I don't want to).<br>
What do I need to rerun before I can use the solver again, what can I<br>
reuse? Could I just assemble F and combine it with the identity and the<br>
parameter dt right before I call the solver? How would that look like?<br>
<br>
I'm pretty new to PETSc and to petsc4py, so please forgive any stupidity<br>
or ignorance in these questions. I'm happy to take any advice, links to<br>
examples or previous questions. Thanks!<br></blockquote><div><br></div><div>For linear solves which stay the same size, you just have to call SetOperators</div><div>again with the new operator.</div><div><br></div><div>For nonlinear solves which stay the same size, you do nothing.</div><div><br></div><div>If the system size changes, it generally better to create the object. If that is hard,</div><div>then you can use KSPReset().</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Kind regards<br>
-Robert-<br>
<br>
--<br>
Dr. Robert Speck<br>
Juelich Supercomputing Centre<br>
Institute for Advanced Simulation<br>
Forschungszentrum Juelich GmbH<br>
52425 Juelich, Germany<br>
<br>
Tel: +49 2461 61 1644<br>
Fax: +49 2461 61 6656<br>
<br>
Email: <a href="mailto:r.speck@fz-juelich.de">r.speck@fz-juelich.de</a><br>
Website: <a href="http://www.fz-juelich.de/ias/jsc/speck_r" rel="noreferrer" target="_blank">http://www.fz-juelich.de/ias/<wbr>jsc/speck_r</a><br>
PinT: <a href="http://www.fz-juelich.de/ias/jsc/pint" rel="noreferrer" target="_blank">http://www.fz-juelich.de/ias/<wbr>jsc/pint</a><br>
<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------<br>
------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------<br>
Forschungszentrum Juelich GmbH<br>
52425 Juelich<br>
Sitz der Gesellschaft: Juelich<br>
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498<br>
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher<br>
Geschaeftsfuehrung: Prof. Dr.-Ing. Wolfgang Marquardt (Vorsitzender),<br>
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,<br>
Prof. Dr. Sebastian M. Schmidt<br>
------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------<br>
------------------------------<wbr>------------------------------<wbr>------------------------------<wbr>------<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.caam.rice.edu/~mk51/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div>
</div></div>