Integrate solution over internal (unmarked) line
I was just wondering whether there’s a simple way to integrate a 2D solution, p(x,y), over an arbitrary line segment, e.g., p(0 <= x <= 1, y = 1)? I imagine p will have to be interpolated along relevant points, but not sure how best to do this. Many thanks.
Hi Jessica, What Firedrake can easily do is evaluate p at an arbitrary set of points that you provide. The instructions for how to do this are at: https://www.firedrakeproject.org/point-evaluation.html You can then use this with a quadrature rule for a line to perform the integration. You can get a quadrature rule from FIAT: import FIAT npoints=10 # Number of quadrature points q = FIAT.make_quadrature(FIAT.reference_element.UFCInterval(), npoints) q is now a quadrature rule on the interval [0, 1]. You can get the points with q.get_points() and the weights with q.get_weights(). You need to work out your own change of coordinates to the line you want. For example in the case you give that would be: G = lambda x: [x[0], 1.0] Then you could do the integral with: Integral = numpy.dot(q.get_weights(), p.at([G(x) for x in q.get_points()])) (code untested but essentially right). Regards, David On 23/08/2019, 11:03, "firedrake-bounces@imperial.ac.uk on behalf of Jessica Williams" <firedrake-bounces@imperial.ac.uk on behalf of williamsj@maths.ox.ac.uk> wrote: I was just wondering whether there’s a simple way to integrate a 2D solution, p(x,y), over an arbitrary line segment, e.g., p(0 <= x <= 1, y = 1)? I imagine p will have to be interpolated along relevant points, but not sure how best to do this. Many thanks. _______________________________________________ firedrake mailing list firedrake@imperial.ac.uk https://mailman.ic.ac.uk/mailman/listinfo/firedrake
Dear Jessica,
On 23 Aug 2019, at 11:03, Jessica Williams <williamsj@maths.ox.ac.uk> wrote:
I was just wondering whether there’s a simple way to integrate a 2D solution, p(x,y), over an arbitrary line segment, e.g., p(0 <= x <= 1, y = 1)?
I imagine p will have to be interpolated along relevant points, but not sure how best to do this.
As David say, the current best option we have would be for you to evaluate your function at some sample points along the line and then compute the integral by hand with your favourite numerical integration scheme. Note that this is mathematically a little dubious, because even H^1 functions don't have enough regularity for point evaluation. The nice way to do this would be to mesh the line segment, then compute a super mesh projection, take the trace of your field and integrate along the line: effectively using the approach espoused here https://www.sciencedirect.com/science/article/pii/S0021999112000885. But we don't have facility for doing this right now. Being able to do such kinds of geometrically specified integrals is on the roadmap however, and I believe we might have someone starting in October on this stuff. Thanks, Lawrence
participants (3)
- 
                
                Ham, David A
- 
                
                Jessica Williams
- 
                
                Lawrence Mitchell