23 |
|
|
24 |
|
|
25 |
|
|
26 |
from esys.escript.util import Lsup,kronecker,interpolate |
from esys.escript.util import Lsup,kronecker,interpolate,whereZero |
27 |
from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar |
from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar |
28 |
from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson |
from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson |
29 |
import numarray |
import numarray |
49 |
def test_setCoefficient_q(self): |
def test_setCoefficient_q(self): |
50 |
mypde=Poisson(self.domain,debug=self.DEBUG) |
mypde=Poisson(self.domain,debug=self.DEBUG) |
51 |
x=self.domain.getX() |
x=self.domain.getX() |
52 |
q_ref=interpolate(x[0].whereZero(),Solution(self.domain)) |
q_ref=interpolate(whereZero(x[0]),Solution(self.domain)) |
53 |
A_ref=kronecker(self.domain) |
A_ref=kronecker(self.domain) |
54 |
mypde.setValue(q=x[0].whereZero()) |
mypde.setValue(q=whereZero(x[0])) |
55 |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker") |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker") |
56 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty") |
self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty") |
57 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty") |
self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty") |
93 |
#construct mask: |
#construct mask: |
94 |
msk=Scalar(0.,cf) |
msk=Scalar(0.,cf) |
95 |
for i in range(d): |
for i in range(d): |
96 |
msk+=x[i].whereZero() |
msk+=whereZero(x[i]) |
97 |
#construct right hand side |
#construct right hand side |
98 |
f=Scalar(0,cf) |
f=Scalar(0,cf) |
99 |
for i in range(d): |
for i in range(d): |
333 |
def test_resetCoefficient_HomogeneousConstraint(self): |
def test_resetCoefficient_HomogeneousConstraint(self): |
334 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
335 |
x=self.domain.getX() |
x=self.domain.getX() |
336 |
mypde.setValue(A=kronecker(self.domain),Y=1.,q=x[0].whereZero()) |
mypde.setValue(A=kronecker(self.domain),Y=1.,q=whereZero(x[0])) |
337 |
u1=mypde.getSolution() |
u1=mypde.getSolution() |
338 |
mypde.setValue(Y=2.) |
mypde.setValue(Y=2.) |
339 |
u2=mypde.getSolution() |
u2=mypde.getSolution() |
343 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
344 |
mypde.setSymmetryOn() |
mypde.setSymmetryOn() |
345 |
x=self.domain.getX() |
x=self.domain.getX() |
346 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=x[0].whereZero()) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.,r=1,q=whereZero(x[0])) |
347 |
u1=mypde.getSolution(verbose=self.VERBOSE) |
u1=mypde.getSolution(verbose=self.VERBOSE) |
348 |
mypde.setValue(Y=2.,D=2) |
mypde.setValue(Y=2.,D=2) |
349 |
u2=mypde.getSolution(verbose=self.VERBOSE) |
u2=mypde.getSolution(verbose=self.VERBOSE) |
565 |
x=self.domain.getX() |
x=self.domain.getX() |
566 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
567 |
mypde.setSolverMethod(mypde.LUMPING) |
mypde.setSolverMethod(mypde.LUMPING) |
568 |
mypde.setValue(D=1.,Y=1.,q=x[0].whereZero(),r=1.) |
mypde.setValue(D=1.,Y=1.,q=whereZero(x[0]),r=1.) |
569 |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
570 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
571 |
def test_Lumping_updateRHS(self): |
def test_Lumping_updateRHS(self): |
575 |
mypde.setValue(D=1.,Y=1.) |
mypde.setValue(D=1.,Y=1.) |
576 |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
577 |
self.failUnless(self.check(u,1.),'first solution is wrong.') |
self.failUnless(self.check(u,1.),'first solution is wrong.') |
578 |
mypde.setValue(Y=2.,q=x[0].whereZero(),r=2.) |
mypde.setValue(Y=2.,q=whereZero(x[0]),r=2.) |
579 |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
u=mypde.getSolution(verbose=self.VERBOSE,preconditioner=mypde.ILU0) |
580 |
self.failUnless(self.check(u,2.),'second solution is wrong.') |
self.failUnless(self.check(u,2.),'second solution is wrong.') |
581 |
def test_Lumping_updateOperator(self): |
def test_Lumping_updateOperator(self): |