[petsc-users] Suggestions for code with dof >> 1 ?

Jed Brown jedbrown at mcs.anl.gov
Tue Oct 15 07:53:32 CDT 2013


Christophe Ortiz <christophe.ortiz at ciemat.es> writes:

> I have a doubt...
> Let's imagine I have a system of 2 diffusion equations (dof=2) with one
> coupling, both with Dirichlet boundary conditions:
>
> u_t - D u_xx = -k*u*v        u(x=0,t)=u(x=L,t)=0
> v_t - D v_xx = -k*u*v         v(x=0,t)=v(x=L,t)=0
>
> If I write everything under IFunction, then the IJacobian is:
>
>        1        0          |
>        0        1          |
>
> -D/dx^2   0           | a+2D/dx^2+kv       +ku  | -D/dx^2     0
>     0        -D/dx^2  |         +kv                  +ku  |      0
> -D/dx^2
>
>
> The first block on top represents Dirichlet boundary conditions. The three
> other blocks are for interior nodes.
>
> My question is on how to set dfill matrix. For boundary conditions, the
> diagonal block does not have the same pattern as the one for interior node.
> We see that for node i=0, components are just coupled with themselves while
> for the interior diagonal block, they are coupled one with each other.
> Then, how to set dfill ? Should it be
>
> {1,   0,
>  0,    1 }
>
> or
>
> { 1,   1,
>   1,    1}   ?

You have to preallocate for the max number of entries in each kind of
block.  The slight bit of extra memory for the boundary conditions will
be squeezed out and not affect performance.

> BTW, does DMDASetBlockFills help during solving or is it just for managing
> memory ?

Allocated nonzeros that have never been "set" are squeezed out in
assembly, so they only affect memory.  Allocated entries that are
explicitly set to 0.0 are not squeezed out, though there is a Mat option
to do that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131015/d584568d/attachment.pgp>


More information about the petsc-users mailing list