project-asgard / DG-SparseGrid

Matlab implementation of ASGarD
1 stars 2 forks source link

why is nodes not uniformly spaced (apart from the end points)? #35

Closed dlg0 closed 4 years ago

dlg0 commented 4 years ago

@MollyRaver

The nodes variable, say for running the following (with a stop at line 101 of asgard.m) ...

asgard(projecti_diff1,'lev',3,'deg',3,'timestep_method','FE', 'dt',0.01,'num_steps',16)
diff(nodes{1})
ans =

   2.8175e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   5.6351e-02
   9.6825e-02
   9.6825e-02
   2.8175e-02

you will see non-uniform grid spacing (beyond just the end points). So this has be somewhat confused. Any thoughts on this?

MollyRaver commented 4 years ago

The "nodes" is generated from file "matrix_plot_D.m". On line 26, we are using Gaussian quadrature (non-uniform points) and on the first and last cells we include left and right boundary points. If we want to use uniform points we can do:

[quad_x_interior_element,quad_w] = linspace(-1,1,Num_Pts_Plot); or [quad_x_interior_element,quad_w] = linspace(-1+delta,1-delta,Num_Pts_Plot);

The first one will generate the same points but with different function values for DG and will show wiggling. The second one will move the cell boundary a little bit (depending on the value of delta), and thus deal with the wiggling plot.

efdazedo commented 4 years ago

If we have the function values at quadrature points, perhaps we can use interpolation to evaluate the function on another set of uniform points. The whole process may be viewed as a matrix-vector multiply. Maybe something like f_uniform = T f_gaussian, if T is square and well conditioned, perhaps inv(T) f_uniform = f_gaussian. Would this help? Just a thought.

dlg0 commented 4 years ago

@MollyRaver There seems to be a challenge here that if we want a uniform sampling AND to include the boundary points, then we MUST sample at the interior element boundaries - which means dual values at the interior element boundaries?

Is there a "correct" way to average together the dual values at the element boundaries?

dlg0 commented 4 years ago

I have pushed an update to reference which provided for an 'uniform_output',true option which gives the realspace output on a uniform grid. However, it "solves" the dual value at interior element boundary problem by simply picking the left element. For values of deg >=3 this has no practical issues, but below that things look strange as expected.

MollyRaver commented 4 years ago

Could you please comment on the code and let me reproduce the plotting? I tried with advection equation, and deg = 1 or 2 look ok to me. @dlg0

dlg0 commented 4 years ago

OK, this is all good. Closing.