[petsc-users] better way of setting dirichlet boundary conditions

Jed Brown jedbrown at mcs.anl.gov
Wed Aug 21 10:23:33 CDT 2013


Matthew Knepley <knepley at gmail.com> writes:
> If you want symmetry, you can do MatZeroRowColumns(). I said is generally
> not a good idea because it is more complicated to eliminate
> them in the FD case.

I don't agree.

> You can definitely do what you propose. With FEM, it makes more sense. You
> eliminate constrained variables from the system, but
> keep the values in the local vector. Then when you do an element integral,
> you get the correct answer including the boundary
> conditions, and everything is natural.

Assuming you are working with a nonlinear problem in defect correction
form (e.g., Newton).  This simple procedure works fine for FD and FE, to
evaluate the residual F(U) and the "Jacobian" or Picard matrix J(U):

  Scatter UGlobal to ULocal
  Write correct Dirichlet values into ULocal

  Evaluate local residual FLocal(ULocal) and scatter to global if applicable
  Set Dirichlet nodes of FGlobal to UGlobal - UDesired

  Assemble J at ULocal, ignoring Dirichlet rows and columns
  Insert 1 on diagonal of Dirichlet rows and columns
-------------- 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/20130821/9825c921/attachment.pgp>


More information about the petsc-users mailing list