[petsc-users] PETSc with mesh refinement
Zou, Ling
ling.zou at inl.gov
Sun Sep 3 12:02:44 CDT 2017
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?
Best,
Ling
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170903/c2877260/attachment.html>
More information about the petsc-users
mailing list