<div dir="ltr"><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="im"></span>Ok,
 that makes sense. I did not find documentation on PetscDSAddBoundary 
but I managed to use the old functions to impose the correct BC.<span class="im"><br></span></blockquote><div>See: <a href="http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/DM/PetscDSAddBoundary.html">http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/DM/PetscDSAddBoundary.html</a>, but it does the same as DMAddBoundary.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">I must have made some changes without noticing when i tried to follow 
the workings of the ex77 sourcecode, my apologies. I copied the example 
again and it runs and converges fine now with the options you provided. 
If I change -dim to 2 however it does not converge and / or produce the 
correct Jacobian. But as far as I understand, ex77 is not intended to 
run in 2D.</blockquote><div>Indeed, jacobians and residuals are only implemented for 3d.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">I have troubles to understand what you mean with “tabulate the 
basis” and I am not too familiar with the concept of dual spaces. My 
intention is to use the  PetscFE  infrastructure to construct the global
 Jacobian to give to the nonlinear solver. As a simple example, I tried 
using snes for solving a linear elastic problem in 2D and PetscFE to 
create the Jacobian and to impose the BC.<div>I do now have a 
program that runs and gives the correct solution if I use the 
matrix-free SNES solver. -snes_type test gives a ratio of 0.45 however 
and I am almost certain that the stiffness tensor I create is correct (I
 checked the assembly algorithm in numpy and it gives the expected 
cauchy stress tensor). The only explanation I have left is some 
misunderstanding on my side about how the double contraction works in 
Petsc.</div></blockquote>Ah yes, if you have a tensor like A^i_I^j_J you should switch the I and j (first index is the component of the test function, second index is the component of the trial function, third index is the derivative index of the test function and fourth index is the derivative index of the trial function).<br><br></div><div>Thanks,<br></div><div>Sander<br></div><div><div> </div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 July 2016 at 15:24,  <span dir="ltr"><<a href="mailto:rickcha@googlemail.com" target="_blank">rickcha@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On 28 Jun 2016, at 23:45, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 28, 2016 at 6:47 PM, Sander Arens<span> </span><span dir="ltr"><<a href="mailto:Sander.Arens@ugent.be" target="_blank">Sander.Arens@ugent.be</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Please reply to all, so that other people can also read this discussion on the mailing list.<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div>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<span> </span><u>should</u><span> </span>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.</div><div><br></div></blockquote><div>Yes, that seems correct. </div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">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?</blockquote><div>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.<span> </span><br>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.<br></div></div></div></blockquote></div></div></div></div></blockquote></span>Ok, that makes sense. I did not find documentation on PetscDSAddBoundary but I managed to use the old functions to impose the correct BC.<span class=""><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div>ex77 works with the options you provided me with. However the solver does not seem to converge.</div></blockquote><div>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.<br></div></div></div></div></blockquote><div><br></div><div>The output of -ksp_view -ksp_monitor_true_residual -ksp_converged_reason</div></div></div></div></div></blockquote></span><div>I must have made some changes without noticing when i tried to follow the workings of the ex77 sourcecode, my apologies. I copied the example again and it runs and converges fine now with the options you provided. If I change -dim to 2 however it does not converge and / or produce the correct Jacobian. But as far as I understand, ex77 is not intended to run in 2D.</div><span class=""><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">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.<span> </span><br></blockquote></div><br></div><div>I don't really understand what you mean with "applying PetscFE".<br></div><div>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.<br></div></div></div></blockquote><div><br></div><div>PetscFE is a Ciarlet triple (P, P', K) meaning a PetscSpace for the primal space P, PetscDualSpace for the dual space P', and reference</div><div>cell K which is a DM. The main function of PetscFE is to tabulate the basis at quadrature points, and to act with dual space basis vectors</div><div>on functions.</div><div><br></div></div></div></div></div></blockquote></span>I have troubles to understand what you mean with “tabulate the basis” and I am not too familiar with the concept of dual spaces. My intention is to use the  PetscFE  infrastructure to construct the global Jacobian to give to the nonlinear solver. As a simple example, I tried using snes for solving a linear elastic problem in 2D and PetscFE to create the Jacobian and to impose the BC.</div><div>I do now have a program that runs and gives the correct solution if I use the matrix-free SNES solver. -snes_type test gives a ratio of 0.45 however and I am almost certain that the stiffness tensor I create is correct (I checked the assembly algorithm in numpy and it gives the expected cauchy stress tensor). The only explanation I have left is some misunderstanding on my side about how the double contraction works in Petsc.</div><div><br></div><div>Thank you,</div><div><br></div><div>M. Hartig<div><div class="h5"><br><blockquote type="cite"><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_extra"><div class="gmail_quote"><div> <span> </span>Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div></div><div>Thanks,<br></div><div>Sander<span> </span><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 28 June 2016 at 17:47,<span> </span><span> </span><span dir="ltr"><<a href="mailto:rickcha@googlemail.com" target="_blank">rickcha@googlemail.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Yes, that was vague, I should have formulated that better. <div>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. <div><br></div><div>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<span> </span><u>should</u><span> </span>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.</div><div><br></div><div>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?</div><div><br></div><div>ex77 works with the options you provided me with. However the solver does not seem to converge.</div><div><br></div><div>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. </div><div><br></div><div>Thank you for your precious time,</div><div><br></div><div>M. Hartig</div><div><div><div><div><div><br></div><div><br><div><blockquote type="cite"><div>On 28 Jun 2016, at 14:30, Sander Arens <<a href="mailto:Sander.Arens@ugent.be" target="_blank">Sander.Arens@ugent.be</a>> wrote:</div><br><div><div dir="ltr"><div><div><div>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.<br></div>What do you mean with "grasp the concept"?<br><br></div>Thanks,<br></div>Sander<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 June 2016 at 17:41,<span> </span><span> </span><span dir="ltr"><<a href="mailto:rickcha@googlemail.com" target="_blank">rickcha@googlemail.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">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.<div><br></div><div><br></div><div>Thanks in advance,</div><div>M. Hartig<div><div><br><div><blockquote type="cite"><div>On 27 Jun 2016, at 15:49, Sander Arens <<a href="mailto:Sander.Arens@ugent.be" target="_blank">Sander.Arens@ugent.be</a>> wrote:</div><br><div><div dir="ltr"><div><div>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<span> </span><a href="https://bitbucket.org/petsc/petsc/src/8bc5349a152c81f25b59a9592e1e5936c01866af/config/builder.py?at=master&fileviewer=file-view-default#builder.py-562" target="_blank">here?</a><br><br></div>Thanks,<br></div>Sander<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 June 2016 at 15:28,<span> </span><span> </span><span dir="ltr"><<a href="mailto:rickcha@googlemail.com" target="_blank">rickcha@googlemail.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Dear Petsc developer team,<br><br>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.<br><br>Thanks in advance,<br><br>M. Hartig</blockquote></div><br></div></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></div></div></div></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>--<span> </span><br><div data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div></div></div></div></blockquote></div></div></div><br></div></blockquote></div><br></div>