[petsc-users] [petsc-maint] Question about DMDA BOUNDARY_CONDITION set
Barry Smith
bsmith at mcs.anl.gov
Wed Mar 22 18:15:12 CDT 2017
> On Mar 21, 2017, at 8:46 AM, Wenbo Zhao <zhaowenbo.npic at gmail.com> wrote:
>
> Matt,
>
> Thanks.
>
> I want to solve neutron diffusion equations using finite difference method and PETSc.
> This rotation boundary condition is very common in my cases.
> Though the mesh consists of ~ 10 Miliion structured hexahedron cells, the mesh is simple and could be discribed by three vectors about x, y and z axis.
> It is appropriate for DMDA except boundary condition.
>
> I wanted to make mesh partition like DMDA by hand. Then I need to create matrix and vector and assemble matrix, and et al. I thought it was an easy work.
> As you say, it's not.
>
> As a newer, I can use DACreate2d to begin. It's OK.
> But finally, it does need this optimization.
>
> Though I read the manual about the vector and matrix, I am not clear about the basic idea behind the code.
> How can I create a matrix and vector as my mesh partition and create the map between the nature ordering and the PETSc ordering in global vector?
When using DMDA you generally don't need to worry about the mapping between natural numbering and PETSc ordering. All the indexing you write can take place in the natural ordering.
Look at src/snes/examples/tutorials/ex18.c a diffusion-like problem and look at FormFunction(). This example is much like what you need except you need the little extra code I sent you to update the "rotated boundary conditions" locations.
> How does vector communicate in the operation of matrix multi vector? Does it achieved automatically?
Yes all this is done automatically.
>
> BETS,
>
> Wenbo
>
>
>
>
>
More information about the petsc-users
mailing list