[petsc-users] Mass matrix with PetscFE

Matthew Knepley knepley at gmail.com
Wed Feb 24 06:58:38 CST 2016


On Wed, Feb 24, 2016 at 6:47 AM, Julian Andrej <juan at tf.uni-kiel.de> wrote:

> Hi,
>
> i'm trying to assemble a mass matrix with the PetscFE/DMPlex interface. I
> found something in the examples of TAO
>
>
> https://bitbucket.org/petsc/petsc/src/da8116b0e8d067e39fd79740a8a864b0fe207998/src/tao/examples/tutorials/ex3.c?at=master&fileviewer=file-view-default
>
> but using the lines
>
> DMClone(dm, &dm_mass);
> DMSetNumFields(dm_mass, 1);
> DMPlexCopyCoordinates(dm, dm_mass);
> DMGetDS(dm_mass, &prob_mass);
> PetscDSSetJacobian(prob_mass, 0, 0, mass_kernel, NULL, NULL, NULL);
> PetscDSSetDiscretization(prob_mass, 0, (PetscObject) fe);
> DMPlexSNESComputeJacobianFEM(dm_mass, u, M, M, NULL);
> DMCreateMatrix(dm_mass, &M);
>
> leads to errors in DMPlexSNESComputeJacobianFEM (u is a global vector).
>
> I don't can understand the necessary commands until
> DMPlexSNESComputeJacobianFEM. What does it do and why is it necessary?
> (especially why does the naming involve SNES?)
>
> Is there another/easier/better way to create a mass matrix (the inner
> product of the function space and the test space)?
>

1) That example needs updating. First, look at SNES ex12 which is up to
date.

2) I assume you are using 3.6. If you use the development version, you can
remove DMPlexCopyCoordinates().

3) You need to create the matrix BEFORE calling the assembly

4) Always always always send the entire error messge

  Matt


> Regards
> Julian Andrej
>



-- 
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/20160224/144359c6/attachment.html>


More information about the petsc-users mailing list