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


Out[1]:
HPFEM

In [2]:
nel = 5
nnodes = nel + 1
idir = Int[]#1,nnodes]
M = 5
Q = M+2
bas = HPFEM.Basis1d(M,Q)
lmap = HPFEM.locmap(bas)
dof = HPFEM.DofMap1d(lmap, nnodes, idir, true);

In [3]:
uexact(x) = sin(x)
rhsfun(x) = 2*sin(x)


Out[3]:
rhsfun (generic function with 1 method)

In [4]:
a = 1.0π
b = 3.0π
nodes = collect(linspace(a, b, nnodes));

In [5]:
elems = [HPFEM.Element1d(e, nodes[e], nodes[e+1], bas) for e = 1:nel];

In [6]:
solver = HPFEM.CholeskySC(dof, HPFEM.BBMatrix);

In [7]:
for e = 1:nel
    Ae = zeros(M, M)
    HPFEM.add_stiff_matrix!(bas, elems[e], Ae)
    HPFEM.add_mass_matrix!(bas, elems[e], Ae)
    HPFEM.add_local_matrix(solver, e, Ae)
end

In [8]:
solver.Abb


Out[8]:
HPFEM.BBMatrix{Float64}(5,5,5x5 Array{Float64,2}:
  2.35257   -0.619392   0.0        0.0       -0.619392
 -0.619392   2.35257   -0.619392   0.0        0.0     
  0.0       -0.619392   2.35257   -0.619392   0.0     
  0.0        0.0       -0.619392   2.35257   -0.619392
 -0.619392   0.0        0.0       -0.619392   2.35257 ,#undef)

In [9]:
Fe = zeros(HPFEM.nmodes(lmap), nel)

for e = 1:nel
    fe = rhsfun(elems[e].x)
    HPFEM.add_rhs!(bas, elems[e], fe, sub(Fe, :, e))
end

# Apply Dirichilet BCs:
#Fe[1,1] = uexact(a);
#Fe[2,nel] = uexact(b);

In [10]:
HPFEM.solve!(solver, Fe);

In [11]:
 = 101
ξ = collect(linspace(-1,1,));
ϕ = zeros(, M)
for i = 1:M
    ϕ[:,i] = bas(ξ, i)
end

Ue = ϕ * Fe;

In [12]:
using PyPlot
maxerr = 0.0
for e = 1:nel
    el = elems[e]
    x = (1-ξ)*el.a/2 + (1+ξ)*el.b/2 
    uu = uexact(x)
    err = maxabs(uu-Ue[:,e])
    if err > maxerr maxerr = err end
        
    plot(x, Ue[:,e], "r", x, uu, "b")
end
maxerr


Out[12]:
7.476079668847224e-5

In [ ]:


In [ ]:


In [ ]: