<div dir="ltr"><div dir="ltr">On Fri, Sep 8, 2023 at 6:26 PM David Andrs <<a href="mailto:andrsd@gmail.com">andrsd@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all!<br>
<br>
I am trying to use DMPlexComputeIntegralFEM to compute an integral $\int_\Omega u d\Omega$. My domain is a square (-1, 1)^2 (2x2 QUAD4 elements), I add first order Lagrange FE field on it, set the solution vector (computed by a previous simulation).<br>
<br>
The value I am seeing computed by PETSc is -4, but the hand-calculated value of this integral is -4.6. I also checked this in paraview using the ‘Integrate Variables’ filter and it also returns -4.6 (this was to double check that my hand-calculated value is correct).<br></blockquote><div><br></div><div>Sorry it took so long. You caught me at a bad time.</div><div><br></div><div>Something must be wrong with your analytic integrals. Here is me doing them by hand. You have a 3x3 vertex arrangement with coefficients</div><div><br></div><div> 1 0 -3</div><div> -2 -1 -2</div><div> -3 0 1</div><div><br></div><div>From the symmetry, the integrals of the cells along each diagonal must be equal. Now, the shape functions for Q_1 are</div><div><br></div><div> (1 - x) y x y</div><div><br></div><div> (1 - x)(1 - y) x (1 - y)</div><div><br></div><div>Thus the integral for the lower left cell is</div><div><br></div><div> \int^1_0 dx \int^1_0 dy -3 + 3 x + y - 2 xy = -3 + 3/2 + 1/2 - 2/4 = -1.5</div><div><br></div><div>which is also the upper right cell. The integral for the lower right cell is</div><div><br></div><div> \int^1_0 dx \int^1_0 dy x - y - 2 xy = 1/2 - 1/2 - 2/4 = -1/2</div><div><br></div><div>which is also the upper left cell. Thus we get -1.5 - 1.5 - 0.5 - 0.5 = -4, which is what Plex gets.</div><div><br></div><div> THanks,</div><div><br></div><div> Matt</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
So, I must be missing something obvious in my code. Attached is the minimal PETSc code to show what I am doing. This is against PETSc 3.19.4.<br>
<br>
Thanks in advance for your help,<br>
<br>
David<br>
<br>
--<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>