4
path.append("../poisson")
7
from BlockLinearAlgebra import *
9
# Create mesh and finite element
11
mesh = UnitSquare(N,N)
13
CG = FiniteElement("Lagrange", "triangle", 1)
14
DG = FiniteElement("DG", "triangle", 0)
17
class Source1(Function):
18
def __init__(self, element, mesh):
19
Function.__init__(self, element, mesh)
20
def eval(self, values, x):
21
values[0] = exp(x[0]*x[1])
24
class Source2(Function):
25
def __init__(self, element, mesh):
26
Function.__init__(self, element, mesh)
27
def eval(self, values, x):
28
values[0] = cos(x[0]*x[1])
34
f1 = Source1(CG, mesh)
35
f2 = Source2(DG, mesh)
36
f3 = Source2(CG, mesh)
38
a = u*v*dx + dot(grad(v), grad(u))*dx
45
b1 = assemble(L1, mesh)
46
b2 = assemble(L2, mesh)
47
b3 = assemble(L3, mesh)
49
file = File("A.m"); file << A;
50
file = File("b1.m"); file << b1;
51
file = File("b2.m"); file << b2;
52
file = File("b3.m"); file << b3;
55
print "testing Matrix Vector Product"
56
print " testing Vector (transposed)",
63
print " testing BlockVector (transposed)",
64
AA = BlockMatrix(1,1); AA[0,0] = A;
65
bb1 = BlockVector(1) ; bb1[0] = b1;
66
xx = BlockVector(1); xx[0] = x;
68
AA.prod(bb1, xx, True);
73
print "testing Matrix Vector Product"
74
print " testing Matrix::mult ",
79
print " testing Matrix::__mul__ ",
84
print " testing BlockVector",
87
bb2 = BlockVector(1) ; bb2[0] = b2;
88
xx = BlockVector(1); xx[0] = x;
90
AA.prod(bb2, xx, False);
95
print "testing Vector Addition "
97
print " testing Vector",
102
bb1 = BlockVector(1) ; bb1[0] = tmp;
103
bb3 = BlockVector(1) ; bb3[0] = b3;
105
print " testing BlockVector", bb1.inner(bb1)
108
print "testing Vector Subtraction "
110
print " testing Vector",
115
bb1 = BlockVector(1) ; bb1[0] = tmp;
116
bb3 = BlockVector(1) ; bb3[0] = b3;
118
print " testing BlockVector", bb1.inner(bb1)
122
print "testing Vector Multiplication "
124
print " testing Vector",
129
bb1 = BlockVector(1) ; bb1[0] = tmp;
130
bb3 = BlockVector(1) ; bb3[0] = b3;
132
print " testing BlockVector", bb1.inner(bb1)