[petsc-dev] Problem with assembly of Jacobian in ex12 & ex77

Sander Arens Sander.Arens at ugent.be
Tue Jun 28 11:47:40 CDT 2016


Please reply to all, so that other people can also read this discussion on
the mailing list.

I do currently have problems understanding the inner workings of PetscFE.
> For example how the element matrix is assembled. As far as I could deduce
> from your example, g3_uu_3d is the fourth-order elasticity tensor which
> means that we should form the double-dot product of it with the strain for
> it to be the integrand of the gradient of the basis functions ( int_omega
> [g3:epsilon]•grad(v) d omega). So for a linear elastic problem, according
> to my understanding, g3 *should* be the elasticity tensor and g0,g1,g2 =
> NULL if there is no volumetric force. And the residual should be f0 = 0 ;
> f1= the cauchy stress tensor.
>
> Yes, that seems correct.

I also have troubles understanding how to apply boundary conditions. There
> seems to be the concept of DMAddBoundary() and the PetscDSSetBdJacobian()
> and PetscDSSetBdResidual(). I struggle to understand what sets them apart
> from each other. My impression is that DMAddBoundary() is for Dirichlet and
> Neumann conditions and that PetscDSSetBdJacobian() and
> PetscDSSetBdResidual() are for BC types that do not fall in those
> categories?

Note that you can also use PetscDSAddBoundary now (if you use the master
branch). DMAddBoundary is basically used to tell which boundary region to
apply which bc. If it's a Dirichlet bc you have to provide a function to
prescribe the values on the boundary, if it's a Neumann bc you just give it
NULL. PetscDSSetBdJacobian() and PetscDSSetBdResidual() are for Neumann
bcs.
The reason why there's this difference for Dirichlet and Neumann bcs is
because for finite elements you need to assemble stuff for non-zero Neumann
bcs while for Dirichlet you set some dofs to some prescribed value.

ex77 works with the options you provided me with. However the solver does
> not seem to converge.
>
What do you mean that it works but it doesn't converge? Did you use all the
options I provided you? In case not, you should send the output of
-snes_view.

The problem I have with the documentation online so far is that I fail to
> fully understand how to apply petscFE. I did for example not know that you
> had to set the order of the finite element space and I have the feeling
> that there is much more I am missing.
>

I don't really understand what you mean with "applying PetscFE".
I think the simplest way to learn how to use it is to start from one of the
examples and if you don't understand what a function does you look it up in
the documentation. If you want to see what kind of options there are for
some object, for example petscspace, you add "-help|grep petscspace" to the
command line.

Thanks,
Sander

On 28 June 2016 at 17:47, <rickcha at googlemail.com> wrote:

> Yes, that was vague, I should have formulated that better.
> What I’m trying to accomplish is writing a FEM code to calculate
> deformation and stress of structure. As a first step analysing a linear
> elastic and static problem in 2D, which I plan to extend to a
> elastic-plastic transient analysis for a 3D case.
>
> I do currently have problems understanding the inner workings of PetscFE.
> For example how the element matrix is assembled. As far as I could deduce
> from your example, g3_uu_3d is the fourth-order elasticity tensor which
> means that we should form the double-dot product of it with the strain for
> it to be the integrand of the gradient of the basis functions ( int_omega
> [g3:epsilon]•grad(v) d omega). So for a linear elastic problem, according
> to my understanding, g3 *should* be the elasticity tensor and g0,g1,g2 =
> NULL if there is no volumetric force. And the residual should be f0 = 0 ;
> f1= the cauchy stress tensor.
>
> I also have troubles understanding how to apply boundary conditions. There
> seems to be the concept of DMAddBoundary() and the PetscDSSetBdJacobian()
> and PetscDSSetBdResidual(). I struggle to understand what sets them apart
> from each other. My impression is that DMAddBoundary() is for Dirichlet and
> Neumann conditions and that PetscDSSetBdJacobian() and
> PetscDSSetBdResidual() are for BC types that do not fall in those
> categories?
>
> ex77 works with the options you provided me with. However the solver does
> not seem to converge.
>
> The problem I have with the documentation online so far is that I fail to
> fully understand how to apply petscFE. I did for example not know that you
> had to set the order of the finite element space and I have the feeling
> that there is much more I am missing.
>
> Thank you for your precious time,
>
> M. Hartig
>
>
> On 28 Jun 2016, at 14:30, Sander Arens <Sander.Arens at ugent.be> wrote:
>
> What are you trying to do with it? I don't think there's more
> documentation on how to use PetscFE than what's already in the online
> documentation and in the examples.
> What do you mean with "grasp the concept"?
>
> Thanks,
> Sander
>
> On 27 June 2016 at 17:41, <rickcha at googlemail.com> wrote:
>
>> That did do the trick with the examples, thank you. I am still struggling
>> with my own simple example however. Is there any documentation available on
>> how to use petscFE? I could not find anything besides the three examples.
>> And I yet have to grasp the concept.
>>
>>
>> Thanks in advance,
>> M. Hartig
>>
>> On 27 Jun 2016, at 15:49, Sander Arens <Sander.Arens at ugent.be> wrote:
>>
>> I think you forgot to set the order of the finite element spaces, which
>> default to 0. Does it work if you try for example ex77 with the following
>> options found here?
>> <https://bitbucket.org/petsc/petsc/src/8bc5349a152c81f25b59a9592e1e5936c01866af/config/builder.py?at=master&fileviewer=file-view-default#builder.py-562>
>>
>> Thanks,
>> Sander
>>
>> On 27 June 2016 at 15:28, <rickcha at googlemail.com> wrote:
>>
>>> Dear Petsc developer team,
>>>
>>> while learning the ways of the petscFE I came across a curiosity I’d
>>> like to point out to you. The Jacobians that are created from the petscFE
>>> object seem to have only 0-entries (apart from the obviously empty regions)
>>> in examples 12 and 77. That might be due to a limited understanding from my
>>> side on how exactly petscFE and the mentioned examples work, but it struck
>>> me as unusual.
>>>
>>> Thanks in advance,
>>>
>>> M. Hartig
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160628/3331a505/attachment.html>


More information about the petsc-dev mailing list