66 |
FAC_DIAG=1. |
FAC_DIAG=1. |
67 |
FAC_OFFDIAG=-0.4 |
FAC_OFFDIAG=-0.4 |
68 |
|
|
69 |
|
class SimpleSolve_Rectangle_Order1_SinglePDE_Paso_BICGSTAB_Jacobi(unittest.TestCase): |
70 |
|
def test_solve(self): |
71 |
|
domain=Rectangle(NE0,NE1,1, optimize=OPTIMIZE) |
72 |
|
x=Solution(domain).getX() |
73 |
|
# --- set exact solution ---- |
74 |
|
u_ex=Scalar(0,Solution(domain)) |
75 |
|
u_ex=1.+2.*x[0]+3.*x[1] |
76 |
|
# --- set exact gradient ----------- |
77 |
|
g_ex=Data(0.,(2,),Solution(domain)) |
78 |
|
g_ex[0]=2. |
79 |
|
g_ex[1]=3. |
80 |
|
# -------- test gradient -------------------------------- |
81 |
|
g=grad(u_ex) |
82 |
|
self.failUnless(Lsup(g_ex-g)<REL_TOL*Lsup(g_ex)) |
83 |
|
# -------- set-up PDE ----------------------------------- |
84 |
|
pde=LinearPDE(domain,numEquations=1) |
85 |
|
mask=whereZero(x[0]) |
86 |
|
pde.setValue(r=u_ex,q=mask) |
87 |
|
pde.setValue(A=kronecker(2),y=inner(g_ex,domain.getNormal())) |
88 |
|
# -------- get the solution --------------------------- |
89 |
|
pde.setTolerance(SOLVER_TOL) |
90 |
|
pde.setSolverMethod(pde.BICGSTAB,pde.JACOBI) |
91 |
|
pde.setSolverPackage(pde.PASO) |
92 |
|
u=pde.getSolution(verbose=SOLVER_VERBOSE) |
93 |
|
# -------- test the solution --------------------------- |
94 |
|
error=Lsup(u-u_ex)/Lsup(u_ex) |
95 |
|
self.failUnless(error<REL_TOL*Lsup(u_ex), "solution error %s is too big."%error) |
96 |
class SimpleSolve_Rectangle_Order1_SinglePDE_Paso_PCG_Jacobi(unittest.TestCase): |
class SimpleSolve_Rectangle_Order1_SinglePDE_Paso_PCG_Jacobi(unittest.TestCase): |
97 |
def test_solve(self): |
def test_solve(self): |
98 |
domain=Rectangle(NE0,NE1,1, optimize=OPTIMIZE) |
domain=Rectangle(NE0,NE1,1, optimize=OPTIMIZE) |
367 |
|
|
368 |
if __name__ == '__main__': |
if __name__ == '__main__': |
369 |
suite = unittest.TestSuite() |
suite = unittest.TestSuite() |
370 |
|
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order1_SinglePDE_Paso_BICGSTAB_Jacobi)) |
371 |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order1_SinglePDE_Paso_PCG_Jacobi)) |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order1_SinglePDE_Paso_PCG_Jacobi)) |
372 |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order1_SystemPDE_Paso_PCG_Jacobi)) |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order1_SystemPDE_Paso_PCG_Jacobi)) |
373 |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order2_SinglePDE_Paso_PCG_Jacobi)) |
suite.addTest(unittest.makeSuite(SimpleSolve_Rectangle_Order2_SinglePDE_Paso_PCG_Jacobi)) |