rk4_ls;

NODETOL = 1e-12;

N_v = size(P,2);
K = size(E,2);

r = GaussLobattoNodes(N_p);

V = VandermondeMatrix1D(N,r); invV = inv(V);
M = invV' * invV; invM = V * V';
D_r = DiffMatrix1D(N,r,V);

v_1 = E(1,:); v_2 = E(2,:);
x = ones(N_p,1) * P(v_1) + 0.5 * (r + 1)' * (P(v_2) - P(v_1));

[r_x,J] = GeometricFactors1D(x,D_r);

fmask1 = find(abs(r + 1) < NODETOL); 
fmask2 = find(abs(r - 1) < NODETOL);
Fmask = [fmask1; fmask2;]';
Fx = x(Fmask(:),:);

n_x = Normals1D();
Fscale = r_x(Fmask,:);

[EtoE,EtoF] = Connectivity1D(E);

[vmapM,vmapP,mapB,vmapB] = BuildMaps1D();