[petsc-users] Question about DMPLEX/P4EST with different Sections
Berend van Wachem
berend.vanwachem at ovgu.de
Thu Mar 12 06:39:55 CDT 2020
Dear All,
I have started to use DMPLEX with P4EST for a computational fluid
dynamics application. I am solving a coupled system of 4 discretised
equations (for 3 velocity components and one pressure) on a mesh.
However, next to these 4 variables, I also have a few single field
variables (such as density and viscosity) defined over the mesh, which I
don't solve for (they should not be part of the matrix with unknowns).
Most of these variables are at the cell centers, but in a few cases, it
want to define them at cell faces.
With just DMPLEX, I solve this by:
DMPlexCreateMesh, so I get an initial DM
DMPlexCreateSection, indicating the need for 4 variables
DMSetLocalSection
DMCreateGlobalVector (and Matrix), so I get an Unknown vector, a RHS
vector, and a matrix for the 4 variables.
To get a vector for a single variable at the cell center or the cell
face, I clone the original DM, I define a new Section on it, and then
create the vector from that which I need (e.g. for density, viscosity or
a velocity at the cell face).
Then I loop over the mesh, and with MatSetValuesLocal, I set the
coefficients. After that, I solve the system for multiple timesteps
(sequential solves) and get the solution vector with the 4 variables
after each solve.
So-far, this works fine with DMPLEX. However, now I want to use P4EST,
and I have difficulty defining a variable vector other than the original 4.
I have changed the code structure:
DMPlexCreateMesh, so I get an initial DM
DMPlexCreateSection, indicating the need for 4 variables
DMSetLocalSection
DMForestSetBaseDM(DM, DMForest) to create a DMForest
DMCreateGlobalVector (and Matrix), so I get a Unknown vector, a RHS
vector, and a matrix for the 4 variables
then I perform multiple time-steps,
DMForestTemplate(DMForest -> DMForestPost)
Adapt DMForestPost
DMCreateGlovalVector(DMForestPost, RefinedUnknownVector)
DMForestTransferVec(UnknownVector , RefinedUnknownVector)
DMForestPost -> DMForest
and then DMConvert(DMForest,DMPLEX,DM)
and I can solve the system as usual. That also seems to work.
But my conceptual question: how can I convert the other variable vectors
(obtained with a different section on the same DM) such as density and
viscosity and faceVelocity within this framework?
The DMForest has the same Section as the original DM and will thus have
the space for exactly 4 variables per cell. I tried pushing another
section on the DMForest and DMForestPost, but that does not seem to
work. Please find attached a working example with code to do this, but I
get the error:
PETSC ERROR: PetscSectionGetChart() line 513 in
/usr/local/petsc-3.12.4/src/vec/is/section/interface/section.c Wrong
type of object: Parameter # 1
So, I is there a way to DMForestTransferVec my other vectors from one
DMForest to DMForestPost. How can I do this?
Many thanks for your help!
Best wishes, Berend.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example-dmplexp4est.c
Type: text/x-csrc
Size: 8137 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200312/9a175b23/attachment.bin>
More information about the petsc-users
mailing list