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


Out[2]:
HPFEM

In [3]:
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 [4]:
uexact(x) = sin(x)
rhsfun(x) = 2*sin(x)


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

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

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

In [7]:
solver = HPFEM.CholeskySC(dof, HPFEM.BBSymTriP);

In [8]:
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 [9]:
solver.Abb


Out[9]:
HPFEM.BBSymTriP{Float64}(5,5,false,[2.3525697629814664,2.3525697629814664,2.352569762981467,2.352569762981467,2.3525697629814664],[-0.6193915741514133,-0.6193915741514133,-0.619391574151414,-0.6193915741514124],#undef,6.94062041001823e-310,6.94062405634285e-310,0.0)

In [10]:
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 [11]:
HPFEM.solve!(solver, Fe);

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

Ue = ϕ * Fe;

In [13]:
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[13]:
0.2706788993979622

In [ ]:


In [ ]:


In [ ]: