[petsc-users] Question About Assembly matrix and declaration of KSP & pc

김성익 ksi2443 at gmail.com
Wed Nov 30 04:07:56 CST 2022


Hello,



I’m working on FEM using PETSc.

As everyone knows, it is necessary to repeatedly solve Ax=B.

Regarding this, I have 4 questions.



1.     There are many steps for preparing KSPSolve. For example KSPcreate,
KSPSetOperators, KSPGetPC, PCSetType, PCFactorSetMatSolverType,
KSPSetFromOptions…
In Nonlinear FEM, there are repeatedly kspsolve for getting answer vector.
Is it correct to do all of the aforementioned processes (KSPcreate,
KSPSetOperators ~~~) for each KSPSolve? Or should I declare it only once at
the beginning and not call it again?



2.     If the answer to question 1 is that it must be repeated every time,
should this work be done right before kspsolve, that is, when the global
matrix assembly is finished, or is it irrelevant to performance at any time?



3.     When performing FEM, local matrices are often scattered in global
matrices depending on connectivity. In this case, which is better in terms
of performance: adding the values one by one with MatSetValue or adding
them all at once with MatSetValues even if they are scattered?





4.     I would like to measure the time of each section of the process.
Which method is recommended?



Thank you for your help.



Hyung Kim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221130/4d012698/attachment.html>


More information about the petsc-users mailing list