In [48]:
include("../src/HPFEM.jl");


WARNING: replacing module HPFEM

In [49]:
M=5
Q=M+2
#
b1 = HPFEM.Basis1d(M,Q);
#
lagr = HPFEM.Lagrange1d(M);
quad = HPFEM.QuadType(Q);
b2 = HPFEM.Basis1d(lagr, quad);
#;
b3 = HPFEM.SEM1d(M);
#
leg = HPFEM.Legendre1d(M);
b4 = HPFEM.Basis1d(leg, quad);

In [63]:
el1 = HPFEM.Element1d(1, -1.0, 1.0, b1);
el2 = HPFEM.Element1d(1, -1.0, 1.0, b2);
el3 = HPFEM.Element1d(1, -1.0, 1.0, b3);
el4 = HPFEM.Element1d(1, -1.0, 1.0, b4);

In [64]:
M1 = HPFEM.mass_matrix(b1, el1);
M2 = HPFEM.mass_matrix(b2, el2);
M3 = zeros(M,M);
HPFEM.add_mass_matrix!(b3, el3, M3);
M4 = HPFEM.mass_matrix(b4, el4);

In [52]:
round(M1,5);


Out[52]:
5x5 Array{Float64,2}:
  0.66667  0.33333   0.16667  -0.06667   0.0    
  0.33333  0.66667   0.16667   0.06667   0.0    
  0.16667  0.16667   0.06667   0.0      -0.01429
 -0.06667  0.06667   0.0       0.0381    0.0    
  0.0      0.0      -0.01429   0.0       0.02857

In [53]:
M2


Out[53]:
5x5 Array{Float64,2}:
  0.0888889   0.0259259  -0.0296296   0.0259259  -0.0111111
  0.0259259   0.483951    0.0691358  -0.0604938   0.0259259
 -0.0296296   0.0691358   0.632099    0.0691358  -0.0296296
  0.0259259  -0.0604938   0.0691358   0.483951    0.0259259
 -0.0111111   0.0259259  -0.0296296   0.0259259   0.0888889

In [86]:
fun(x) = sin(2*pi*x)
f = fun(zglj(5))
u = M2\f
plot(zglj(5),u)
plot(zglj(5),f)


LoadError: PyError (:PyObject_Call) <type 'exceptions.ValueError'>
ValueError(u'x and y must have same first dimension',)
  File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 3099, in plot
    ret = ax.plot(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_axes.py", line 1374, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 303, in _grab_next_args
    for seg in self._plot_args(remaining, kwargs):
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 281, in _plot_args
    x, y = self._xy_from_xy(x, y)
  File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 223, in _xy_from_xy
    raise ValueError("x and y must have same first dimension")

while loading In[86], in expression starting on line 4

 in getindex at /home/augusto/.julia/v0.4/PyCall/src/PyCall.jl:228
 in pysequence_query at /home/augusto/.julia/v0.4/PyCall/src/conversions.jl:717
 [inlined code] from /home/augusto/.julia/v0.4/PyCall/src/conversions.jl:733
 in pytype_query at /home/augusto/.julia/v0.4/PyCall/src/conversions.jl:762
 in convert at /home/augusto/.julia/v0.4/PyCall/src/conversions.jl:782
 in pycall at /home/augusto/.julia/v0.4/PyCall/src/PyCall.jl:363
 in call at /home/augusto/.julia/v0.4/PyCall/src/PyCall.jl:372
 in close_queued_figs at /home/augusto/.julia/v0.4/PyPlot/src/PyPlot.jl:401

In [55]:
sum(M2,2)


Out[55]:
5x1 Array{Float64,2}:
 0.1     
 0.544444
 0.711111
 0.544444
 0.1     

In [56]:
round(M4,5)


Out[56]:
6x6 Array{Float64,2}:
  2.0  -0.0       0.0   0.0      -0.0       0.0    
 -0.0   0.66667  -0.0   0.0       0.0      -0.0    
  0.0  -0.0       0.4   0.0      -0.0       0.0    
  0.0   0.0       0.0   0.28571   0.0      -0.0    
 -0.0   0.0      -0.0   0.0       0.22222   0.0    
  0.0  -0.0       0.0  -0.0       0.0       0.18182

In [57]:
sum(M1,2)


Out[57]:
5x1 Array{Float64,2}:
 1.1      
 1.23333  
 0.385714 
 0.0380952
 0.0142857

In [58]:
using Jacobi
using PyPlot

In [59]:
z = zglj(5)
x = linspace(-1,1,101)
for i in 1:3
    plot(x,lagrange(i,x,z),label="\$ l_$i \$")
    legend()
end



In [60]:
quad = HPFEM.QuadType(5)
quad.w


Out[60]:
5-element Array{Float64,1}:
 0.1     
 0.544444
 0.711111
 0.544444
 0.1     

In [61]:
z = zglj(5)
w = wglj(z)
quad.Q


Out[61]:
5

In [62]:
methods(HPFEM.lagrange1d)


LoadError: UndefVarError: lagrange1d not defined
while loading In[62], in expression starting on line 1