[petsc-users] DMSNESSet<Function,Jacobian>
Matthew Knepley
knepley at gmail.com
Mon Apr 1 20:24:23 CDT 2013
On Tue, Apr 2, 2013 at 10:16 AM, Dharmendar Reddy
<dharmareddy84 at gmail.com>wrote:
> Hello,
> I am confused about the usage of SNESSetFunction,
> DMSNESSetFunction, DMSNESSetFunctionLocal and the corresponding Jacobin
> routines.
>
> At present my code is set up as follows.
>
> I initiate SNES with getFunction and getJacobain routines required as per
> SNESSet<Function,Jacobian>. I pass a user context which has the mesh and
> field layout information. I assemble the residual function and Jacobin
> element wise using the information from user context. My code at this point
> is serial, so i run the element loop from 1 to numberofTotalElements.
>
> Now i want to switch to using DMPlex. How should i change the interface to
> my code.
>
You can always look at SNES ex62
http://www.mcs.anl.gov/petsc/petsc-dev/src/snes/examples/tutorials/ex62.c.html
> If i set the dm for snes using SNESSetDM, i can see that the DM can be
> accessed via SNESGetDM inside getFunction and getJacobian, then i get the
> elementStartID and elementEndID to run the loop for assmbler. But now i
> will have to assemble to local vector into global vector right ?
>
No, here is the sequence:
1) SNESSetDM(snes, dm)
2) DMSNESSetFunctionLocal(dm, userResidual, userCtx)
where we have
userResidual(DM dm, Vec X, Vec F, void *userCtx)
Both X and F are local vectors which I normally interact with using
DMPlexVecGet/SetClosure(). If you
are using FEM, you can DMPlexComputeResidualFEM() here and
use DMPlexSetFEMIntegration() to
input point-wise physics functions as is done in ex62.
> Looks like the DMSNESSetFunctionLocal will assemble the local
> vector into global vector. The function provided to this should just
> evaluate the local vector. Did i understand this right ?
>
> I am confused about passing the DM in DMSNESSet<Function,Jacobian>. When
> the DM can be accessed via SNESGetDM, why do we pass it again explicitly ?
>
You are not passing the SNES, so where would it come from in this call?
Matt
>
> --
> -----------------------------------------------------
> Dharmendar Reddy Palle
> Graduate Student
> Microelectronics Research center,
> University of Texas at Austin,
> 10100 Burnet Road, Bldg. 160
> MER 2.608F, TX 78758-4445
> e-mail: dharmareddy84 at gmail.com
> Phone: +1-512-350-9082
> United States of America.
> Homepage: https://webspace.utexas.edu/~dpr342
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130402/dcd32596/attachment.html>
More information about the petsc-users
mailing list