[petsc-users] PETSc with mesh refinement
Matthew Knepley
knepley at gmail.com
Sun Sep 3 13:44:51 CDT 2017
On Sun, Sep 3, 2017 at 1:02 PM, Zou, Ling <ling.zou at inl.gov> wrote:
> Hi All,
>
> I wonder if there is a good example on how PETSc should work with mesh
> refinement. I have done some online search/PETSc-user email search, but did
> not find a good one.
>
> Here is my case. Currently, assuming NO mesh refinement (so I know exactly
> the problem size, mesh connectivity, non-zero pattern of matrices, etc.)
> In a transient simulation, my PETSc code looks like:
>
> ========================================================================
> SetupVectors(); // unknown vec, old unknown, etc.
> SetupResFunc(); // residual function, basically pointing to the
> discretized PDE
> SetupMatrices(); // allocate memory for preconditioning matrix based on
> non-zero pattern (so it is mesh dependent)
> // I also use finite differencing to get
> preconditioning matrix, so there is another MatFDColoring object associated
> with the matrix
> for (int step = 0; step < max_step; step++)
> {
> SNESSolve();
> }
> ========================================================================
>
> This setup works perfectly for my problems.
> (I understand it is low efficient to use FD to get the preconditioning
> matrix, but it is not a priority to me at this moment).
>
> However, now I would like to do some mesh refinement, so the previous
> setup would not work, because the problem size, non-zero pattern of the
> matrix and MatFDColoring change with mesh size (and connectivity).
> I suppose my code should be changed like this:
>
> ========================================================================
> SetupVectors();
> SetupResFunc();
> SetupMatrices();
>
> for (int step = 0; step < max_step; step++)
> {
> MeshRefinement(); // I will manage my mesh
>
> AdjustVectors(); // resize vector
> AdjustMatrices(); // resize matrix, re-allocate memory, adjust non-zero
> pattern, etc.
>
> SNESSolve();
> }
> ========================================================================
>
> The issue is that I understand one should not re-allocate memory to both
> PETSc vector and matrix dynamically during simulation, which has been
> discussed here:
> https://scicomp.stackexchange.com/questions/373/is-it-
> possible-to-dynamically-resize-a-sparse-matrix-in-the-petsc-library
>
> So, the final questions are:
> 1) Any good example on PETSc working with mesh refinement?
> 2) Any suggestion on my proposed code structure?
>
1) No
2) Yes. We advocate using the DM to describe your data layout. This allows
all Vec and Mats to be created automatically, and
also tells the solver (SNESSetDM, etc.) the sizes and potential
decomposition.
We are working on a mesh adaptivity interface which will allow adaptivity
to be used with all DM problems without any extra
code. We should have some examples with this soon.
Thanks,
Matt
> Best,
>
> Ling
>
>
>
--
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
http://www.caam.rice.edu/~mk51/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170903/fb4de729/attachment.html>
More information about the petsc-users
mailing list