Analyzing MethodOfLines

In this example the wave equation

U = NDSolveValue[{D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}],
u[0, t] == 0, u[1, t] == 0, (* RBn *)
u[x, 0] == 1 - Abs[2 x - 1], (D[u[x, t], t] /. t -> 0) == 0 (*
ABn *)
}, u, {x, 0, 1}, {t, 0, 2 },
Method -> {"MethodOfLines", "TemporalVariable" -> t,
"SpatialDiscretization" -> {"FiniteElement","MeshOptions" ->
{"MaxCellMeasure" -> 0.3}}}]
Plot3D[ U[x, t] , {x, 0, 1}, {t, 0, 2}, Mesh -> All,AxesLabel -> {x, t}]


is solved with the "MethodOfLines" and "FiniteElement".

My questions

#1 How can I get the complete mesh(two dimensional), which NDSolve uses? U["ElementMesh"["Wireframe" ] seems to be onedimensional?

#2 How can I get the time grid of "MethodOfLines"?

#3 Is it possible to expand the pde with an additional variable to a DAE system and calculate for example NIntegrate[u[x,t],{x,0,1}]in every time step t?

Thanks!

answers #1: xi = Union@Flatten[Map[Union@#[[All, 1]] &, U["Grid"]] , 1] ;

answers #2: ti=U["Coordinates"] [[-1]];

• by "complete mesh(two dimensional)" do you mean a List of TriangleElements ? Jul 27 '18 at 9:43
• Yes, elements or node coordinates! Jul 27 '18 at 9:44
• The problem is that in your example the finite element method is used only for the temporal variable x. The resolution over the time t is done with the "method of line" (which considers the equations as a set of ODEs). Hence from the Finite Element Method point of view, the problem is a 1D problem. That's the reason why the Finite Element Method returns some 'LineElement' and not 'TriangleElement'. By the way, the mesh we see in your question has nothing to do with the real mesh internaly used by the FEM (it's a mesh created by Plot3D) Jul 27 '18 at 9:54
• @andre: Thank you for your helpful answer, which solves my first question. Jul 27 '18 at 10:02
• I think that U["ValuesOnGrid"]  is what you are looking for in the first 2 questions (?) Jul 27 '18 at 10:08

answers #1: xi = Union@Flatten[Map[Union@#[[All, 1]] &, U["Grid"]] , 1] ;

answers #2: ti=U["Coordinates"] [[-1]];

I don't think computing the integrals after NDSolve[] would be any less efficient than computing them during. It's probably possible to do it during the NDSolve integration (I've done it before here on the site with the method of lines and a tensor grid, (192707), (192736)), but it's much simpler after NSolve has finished.
{xmesh, tgrid} = U["Coordinates"];