1 |
# $Id$ |
|
2 |
|
######################################################## |
3 |
|
# |
4 |
|
# Copyright (c) 2003-2008 by University of Queensland |
5 |
|
# Earth Systems Science Computational Center (ESSCC) |
6 |
|
# http://www.uq.edu.au/esscc |
7 |
|
# |
8 |
|
# Primary Business: Queensland, Australia |
9 |
|
# Licensed under the Open Software License version 3.0 |
10 |
|
# http://www.opensource.org/licenses/osl-3.0.php |
11 |
|
# |
12 |
|
######################################################## |
13 |
|
|
14 |
|
__copyright__="""Copyright (c) 2003-2008 by University of Queensland |
15 |
|
Earth Systems Science Computational Center (ESSCC) |
16 |
|
http://www.uq.edu.au/esscc |
17 |
|
Primary Business: Queensland, Australia""" |
18 |
|
__license__="""Licensed under the Open Software License version 3.0 |
19 |
|
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
|
__url__="http://www.uq.edu.au/esscc/escript-finley" |
21 |
|
|
22 |
""" |
""" |
23 |
Test suite for linearPDEs class |
Test suite for linearPDEs class |
28 |
class Test_LinearPDEOnFinley(Test_LinearPDE): |
class Test_LinearPDEOnFinley(Test_LinearPDE): |
29 |
def setUp(self): |
def setUp(self): |
30 |
self.domain = Rectangle(10,10,2) |
self.domain = Rectangle(10,10,2) |
31 |
|
def tearDown(self): |
32 |
|
del self.domain |
33 |
suite = unittest.TestSuite() |
suite = unittest.TestSuite() |
34 |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley)) |
suite.addTest(unittest.makeSuite(Test_LinearPDEOnFinley)) |
35 |
unittest.TextTestRunner(verbosity=2).run(suite) |
unittest.TextTestRunner(verbosity=2).run(suite) |
36 |
|
|
37 |
|
@var __author__: name of author |
38 |
|
@var __copyright__: copyrights |
39 |
|
@var __license__: licence agreement |
40 |
|
@var __url__: url entry point on documentation |
41 |
|
@var __version__: version |
42 |
|
@var __date__: date of the version |
43 |
""" |
""" |
44 |
|
|
45 |
__author__="Lutz Gross, l.gross@uq.edu.au" |
__author__="Lutz Gross, l.gross@uq.edu.au" |
|
__licence__="contact: esys@access.uq.edu.au" |
|
|
__url__="http://www.iservo.edu.au/esys/escript" |
|
|
__version__="$Revision$" |
|
|
__date__="$Date$" |
|
|
|
|
|
|
|
46 |
|
|
47 |
from esys.escript.util import Lsup,kronecker,interpolate,whereZero |
from esys.escript.util import Lsup,kronecker,interpolate,whereZero |
48 |
from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar |
from esys.escript import Function,FunctionOnBoundary,FunctionOnContactZero,Solution,ReducedSolution,Vector,ContinuousFunction,Scalar, ReducedFunction,ReducedFunctionOnBoundary,ReducedFunctionOnContactZero,Data, Tensor4, Tensor |
49 |
from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson |
from esys.escript.linearPDEs import LinearPDE,IllegalCoefficientValue,Poisson, IllegalCoefficientFunctionSpace, TransportPDE, IllegalCoefficient |
50 |
import numarray |
import numarray |
51 |
import unittest |
import unittest |
52 |
|
|
73 |
q_ref=interpolate(whereZero(x[0]),Solution(self.domain)) |
q_ref=interpolate(whereZero(x[0]),Solution(self.domain)) |
74 |
A_ref=kronecker(self.domain) |
A_ref=kronecker(self.domain) |
75 |
mypde.setValue(q=whereZero(x[0])) |
mypde.setValue(q=whereZero(x[0])) |
76 |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker") |
self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker") |
77 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty") |
self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty") |
78 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty") |
self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty") |
79 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty") |
self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty") |
80 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty") |
self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty") |
81 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("Y").isEmpty(),"Y is not empty") |
self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty") |
82 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty") |
self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty") |
83 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty") |
self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty") |
84 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty") |
self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty") |
85 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty") |
self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty") |
86 |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("q"),q_ref),"q is not empty") |
self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty") |
87 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty") |
self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty") |
88 |
|
self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty") |
89 |
|
self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty") |
90 |
|
self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty") |
91 |
|
self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty") |
92 |
|
self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty") |
93 |
|
self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty") |
94 |
|
self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty") |
95 |
|
self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty") |
96 |
|
self.failUnless(self.check(mypde.getCoefficient("q"),q_ref),"q is not empty") |
97 |
|
self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty") |
98 |
def test_setCoefficient_f(self): |
def test_setCoefficient_f(self): |
99 |
mypde=Poisson(self.domain,debug=self.DEBUG) |
mypde=Poisson(self.domain,debug=self.DEBUG) |
100 |
x=self.domain.getX() |
x=self.domain.getX() |
101 |
Y_ref=interpolate(x[0],Function(self.domain)) |
Y_ref=interpolate(x[0],Function(self.domain)) |
102 |
A_ref=kronecker(self.domain) |
A_ref=kronecker(self.domain) |
103 |
mypde.setValue(f=x[0]) |
mypde.setValue(f=x[0]) |
104 |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("A"),A_ref),"A is not kronecker") |
self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker") |
105 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("B").isEmpty(),"B is not empty") |
self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty") |
106 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("C").isEmpty(),"C is not empty") |
self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty") |
107 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("D").isEmpty(),"D is not empty") |
self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty") |
108 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("X").isEmpty(),"X is not empty") |
self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty") |
109 |
self.failUnless(self.check(mypde.getCoefficientOfGeneralPDE("Y"),Y_ref),"Y is not x[0]") |
self.failUnless(self.check(mypde.getCoefficient("Y"),Y_ref),"Y is not x[0]") |
110 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("y").isEmpty(),"y is not empty") |
self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty") |
111 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("d").isEmpty(),"d is not empty") |
self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty") |
112 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("d_contact").isEmpty(),"d_contact is not empty") |
self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty") |
113 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("y_contact").isEmpty(),"y_contact is not empty") |
self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty") |
114 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("q").isEmpty(),"q is not empty") |
self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty") |
115 |
self.failUnless(mypde.getCoefficientOfGeneralPDE("r").isEmpty(),"r is not empty") |
self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty") |
116 |
|
self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty") |
117 |
|
self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty") |
118 |
|
self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty") |
119 |
|
self.failUnless(mypde.getCoefficient("Y_reduced").isEmpty(),"Y_reduced is not empty") |
120 |
|
self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty") |
121 |
|
self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty") |
122 |
|
self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty") |
123 |
|
self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty") |
124 |
|
self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty") |
125 |
|
self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty") |
126 |
|
def test_setCoefficient_f_reduced(self): |
127 |
|
mypde=Poisson(self.domain,debug=self.DEBUG) |
128 |
|
x=self.domain.getX() |
129 |
|
Y_ref=interpolate(x[0],ReducedFunction(self.domain)) |
130 |
|
A_ref=kronecker(self.domain) |
131 |
|
mypde.setValue(f_reduced=x[0]) |
132 |
|
self.failUnless(self.check(mypde.getCoefficient("A"),A_ref),"A is not kronecker") |
133 |
|
self.failUnless(mypde.getCoefficient("B").isEmpty(),"B is not empty") |
134 |
|
self.failUnless(mypde.getCoefficient("C").isEmpty(),"C is not empty") |
135 |
|
self.failUnless(mypde.getCoefficient("D").isEmpty(),"D is not empty") |
136 |
|
self.failUnless(mypde.getCoefficient("X").isEmpty(),"X is not empty") |
137 |
|
self.failUnless(mypde.getCoefficient("Y").isEmpty(),"Y is not empty") |
138 |
|
self.failUnless(mypde.getCoefficient("y").isEmpty(),"y is not empty") |
139 |
|
self.failUnless(mypde.getCoefficient("d").isEmpty(),"d is not empty") |
140 |
|
self.failUnless(mypde.getCoefficient("d_contact").isEmpty(),"d_contact is not empty") |
141 |
|
self.failUnless(mypde.getCoefficient("y_contact").isEmpty(),"y_contact is not empty") |
142 |
|
self.failUnless(mypde.getCoefficient("A_reduced").isEmpty(),"A_reduced is not empty") |
143 |
|
self.failUnless(mypde.getCoefficient("B_reduced").isEmpty(),"B_reduced is not empty") |
144 |
|
self.failUnless(mypde.getCoefficient("C_reduced").isEmpty(),"C_reduced is not empty") |
145 |
|
self.failUnless(mypde.getCoefficient("D_reduced").isEmpty(),"D_reduced is not empty") |
146 |
|
self.failUnless(mypde.getCoefficient("X_reduced").isEmpty(),"X_reduced is not empty") |
147 |
|
self.failUnless(self.check(mypde.getCoefficient("Y_reduced"),Y_ref),"Y_reduced is not x[0]") |
148 |
|
self.failUnless(mypde.getCoefficient("y_reduced").isEmpty(),"y_reduced is not empty") |
149 |
|
self.failUnless(mypde.getCoefficient("d_reduced").isEmpty(),"d_reduced is not empty") |
150 |
|
self.failUnless(mypde.getCoefficient("d_contact_reduced").isEmpty(),"d_contact_reduced is not empty") |
151 |
|
self.failUnless(mypde.getCoefficient("y_contact_reduced").isEmpty(),"y_contact_reduced is not empty") |
152 |
|
self.failUnless(mypde.getCoefficient("q").isEmpty(),"q is not empty") |
153 |
|
self.failUnless(mypde.getCoefficient("r").isEmpty(),"r is not empty") |
154 |
def test_solve(self): |
def test_solve(self): |
155 |
d=self.domain.getDim() |
d=self.domain.getDim() |
156 |
cf=ContinuousFunction(self.domain) |
cf=ContinuousFunction(self.domain) |
178 |
u=mypde.getSolution() |
u=mypde.getSolution() |
179 |
self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution") |
self.failUnless(self.check(u,u_ex,10*self.TOL),"incorrect solution") |
180 |
|
|
181 |
class Test_LinearPDE(Test_linearPDEs): |
class Test_LinearPDE_noLumping(Test_linearPDEs): |
182 |
N=4 |
N=4 |
183 |
def test_setCoefficient_WithIllegalFunctionSpace(self): |
def test_setCoefficient_WithIllegalFunctionSpace(self): |
184 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
185 |
try: |
self.failUnlessRaises(IllegalCoefficientFunctionSpace,mypde.setValue, C=Vector(0.,FunctionOnBoundary(self.domain))) |
186 |
success=True |
|
187 |
mypde.setValue(C=Vector(0.,FunctionOnBoundary(self.domain))) |
def test_setCoefficient_WithWrongName(self): |
188 |
except IllegalCoefficientValue: |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
189 |
success=False |
self.failUnlessRaises(IllegalCoefficient, mypde.setValue, ROMA=0.) |
190 |
self.failUnless(not success,'inapropraite function space accepted') |
|
|
|
|
191 |
def test_resetCoefficient_WithWrongShape(self): |
def test_resetCoefficient_WithWrongShape(self): |
192 |
mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=2,debug=self.DEBUG) |
193 |
try: |
self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.) |
194 |
success=True |
|
|
mypde.setValue(C=0.) |
|
|
except IllegalCoefficientValue: |
|
|
success=False |
|
|
self.failUnless(not success,'illegal shape accepted') |
|
195 |
def test_reducedOn(self): |
def test_reducedOn(self): |
196 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
197 |
x=self.domain.getX() |
x=self.domain.getX() |
203 |
def test_attemptToChangeOrderAfterDefinedCoefficient(self): |
def test_attemptToChangeOrderAfterDefinedCoefficient(self): |
204 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
205 |
mypde.setValue(D=1.) |
mypde.setValue(D=1.) |
206 |
try: |
self.failUnlessRaises(RuntimeError,mypde.setReducedOrderOn) |
|
success=True |
|
|
mypde.setReducedOrderOn() |
|
|
except RuntimeError: |
|
|
success=False |
|
|
self.failUnless(not success,'alterion of order after coefficient is changed not detected.') |
|
207 |
|
|
208 |
def test_reducedOnConfig(self): |
def test_reducedOnConfig(self): |
209 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
216 |
d=self.domain.getDim() |
d=self.domain.getDim() |
217 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
218 |
mypde.setValue(A=numarray.ones((d,d))) |
mypde.setValue(A=numarray.ones((d,d))) |
219 |
coeff=mypde.getCoefficientOfGeneralPDE("A") |
coeff=mypde.getCoefficient("A") |
220 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1)) |
221 |
def test_setCoefficient_B_Scalar(self): |
def test_setCoefficient_B_Scalar(self): |
222 |
d=self.domain.getDim() |
d=self.domain.getDim() |
223 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
224 |
mypde.setValue(B=numarray.ones((d,))) |
mypde.setValue(B=numarray.ones((d,))) |
225 |
coeff=mypde.getCoefficientOfGeneralPDE("B") |
coeff=mypde.getCoefficient("B") |
226 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
227 |
def test_setCoefficient_C_Scalar(self): |
def test_setCoefficient_C_Scalar(self): |
228 |
d=self.domain.getDim() |
d=self.domain.getDim() |
229 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
230 |
mypde.setValue(C=numarray.ones((d,))) |
mypde.setValue(C=numarray.ones((d,))) |
231 |
coeff=mypde.getCoefficientOfGeneralPDE("C") |
coeff=mypde.getCoefficient("C") |
232 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
233 |
def test_setCoefficient_D_Scalar(self): |
def test_setCoefficient_D_Scalar(self): |
234 |
d=self.domain.getDim() |
d=self.domain.getDim() |
235 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
236 |
mypde.setValue(D=1.) |
mypde.setValue(D=1.) |
237 |
coeff=mypde.getCoefficientOfGeneralPDE("D") |
coeff=mypde.getCoefficient("D") |
238 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1)) |
239 |
def test_setCoefficient_X_Scalar(self): |
def test_setCoefficient_X_Scalar(self): |
240 |
d=self.domain.getDim() |
d=self.domain.getDim() |
241 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
242 |
mypde.setValue(X=numarray.ones((d,))) |
mypde.setValue(X=numarray.ones((d,))) |
243 |
coeff=mypde.getCoefficientOfGeneralPDE("X") |
coeff=mypde.getCoefficient("X") |
244 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1)) |
245 |
def test_setCoefficient_Y_Scalar(self): |
def test_setCoefficient_Y_Scalar(self): |
246 |
d=self.domain.getDim() |
d=self.domain.getDim() |
247 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
248 |
mypde.setValue(Y=1.) |
mypde.setValue(Y=1.) |
249 |
coeff=mypde.getCoefficientOfGeneralPDE("Y") |
coeff=mypde.getCoefficient("Y") |
250 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1)) |
251 |
def test_setCoefficient_y_Scalar(self): |
def test_setCoefficient_y_Scalar(self): |
252 |
d=self.domain.getDim() |
d=self.domain.getDim() |
253 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
254 |
mypde.setValue(y=1.) |
mypde.setValue(y=1.) |
255 |
coeff=mypde.getCoefficientOfGeneralPDE("y") |
coeff=mypde.getCoefficient("y") |
256 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1)) |
257 |
def test_setCoefficient_d_Scalar(self): |
def test_setCoefficient_d_Scalar(self): |
258 |
d=self.domain.getDim() |
d=self.domain.getDim() |
259 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
260 |
mypde.setValue(d=1.) |
mypde.setValue(d=1.) |
261 |
coeff=mypde.getCoefficientOfGeneralPDE("d") |
coeff=mypde.getCoefficient("d") |
262 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1)) |
263 |
def test_setCoefficient_d_contact_Scalar(self): |
def test_setCoefficient_d_contact_Scalar(self): |
264 |
d=self.domain.getDim() |
d=self.domain.getDim() |
265 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
266 |
mypde.setValue(d_contact=1.) |
mypde.setValue(d_contact=1.) |
267 |
coeff=mypde.getCoefficientOfGeneralPDE("d_contact") |
coeff=mypde.getCoefficient("d_contact") |
268 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1)) |
269 |
def test_setCoefficient_y_contact_Scalar(self): |
def test_setCoefficient_y_contact_Scalar(self): |
270 |
d=self.domain.getDim() |
d=self.domain.getDim() |
271 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
272 |
mypde.setValue(y_contact=1.) |
mypde.setValue(y_contact=1.) |
273 |
coeff=mypde.getCoefficientOfGeneralPDE("y_contact") |
coeff=mypde.getCoefficient("y_contact") |
274 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1)) |
275 |
|
def test_setCoefficient_A_reduced_Scalar(self): |
276 |
|
d=self.domain.getDim() |
277 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
278 |
|
mypde.setValue(A_reduced=numarray.ones((d,d))) |
279 |
|
coeff=mypde.getCoefficient("A_reduced") |
280 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1)) |
281 |
|
def test_setCoefficient_B_reduced_Scalar(self): |
282 |
|
d=self.domain.getDim() |
283 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
284 |
|
mypde.setValue(B_reduced=numarray.ones((d,))) |
285 |
|
coeff=mypde.getCoefficient("B_reduced") |
286 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
287 |
|
def test_setCoefficient_C_reduced_Scalar(self): |
288 |
|
d=self.domain.getDim() |
289 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
290 |
|
mypde.setValue(C_reduced=numarray.ones((d,))) |
291 |
|
coeff=mypde.getCoefficient("C_reduced") |
292 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
293 |
|
def test_setCoefficient_D_reduced_Scalar(self): |
294 |
|
d=self.domain.getDim() |
295 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
296 |
|
mypde.setValue(D_reduced=1.) |
297 |
|
coeff=mypde.getCoefficient("D_reduced") |
298 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
299 |
|
def test_setCoefficient_X_reduced_Scalar(self): |
300 |
|
d=self.domain.getDim() |
301 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
302 |
|
mypde.setValue(X_reduced=numarray.ones((d,))) |
303 |
|
coeff=mypde.getCoefficient("X_reduced") |
304 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1)) |
305 |
|
def test_setCoefficient_Y_reduced_Scalar(self): |
306 |
|
d=self.domain.getDim() |
307 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
308 |
|
mypde.setValue(Y_reduced=1.) |
309 |
|
coeff=mypde.getCoefficient("Y_reduced") |
310 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1)) |
311 |
|
def test_setCoefficient_y_reduced_Scalar(self): |
312 |
|
d=self.domain.getDim() |
313 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
314 |
|
mypde.setValue(y_reduced=1.) |
315 |
|
coeff=mypde.getCoefficient("y_reduced") |
316 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1)) |
317 |
|
def test_setCoefficient_d_reduced_Scalar(self): |
318 |
|
d=self.domain.getDim() |
319 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
320 |
|
mypde.setValue(d_reduced=1.) |
321 |
|
coeff=mypde.getCoefficient("d_reduced") |
322 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
323 |
|
def test_setCoefficient_d_contact_reduced_Scalar(self): |
324 |
|
d=self.domain.getDim() |
325 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
326 |
|
mypde.setValue(d_contact_reduced=1.) |
327 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
328 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1)) |
329 |
|
def test_setCoefficient_y_contact_reduced_Scalar(self): |
330 |
|
d=self.domain.getDim() |
331 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
332 |
|
mypde.setValue(y_contact_reduced=1.) |
333 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
334 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1)) |
335 |
def test_setCoefficient_r_Scalar(self): |
def test_setCoefficient_r_Scalar(self): |
336 |
d=self.domain.getDim() |
d=self.domain.getDim() |
337 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
338 |
mypde.setValue(r=1.) |
mypde.setValue(r=1.) |
339 |
coeff=mypde.getCoefficientOfGeneralPDE("r") |
coeff=mypde.getCoefficient("r") |
340 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
341 |
def test_setCoefficient_q_Scalar(self): |
def test_setCoefficient_q_Scalar(self): |
342 |
d=self.domain.getDim() |
d=self.domain.getDim() |
343 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
344 |
mypde.setValue(q=1.) |
mypde.setValue(q=1.) |
345 |
coeff=mypde.getCoefficientOfGeneralPDE("q") |
coeff=mypde.getCoefficient("q") |
346 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
347 |
def test_setCoefficient_r_Scalar_reducedOn(self): |
def test_setCoefficient_r_Scalar_reducedOn(self): |
348 |
d=self.domain.getDim() |
d=self.domain.getDim() |
349 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
350 |
mypde.setReducedOrderOn() |
mypde.setReducedOrderOn() |
351 |
mypde.setValue(r=1.) |
mypde.setValue(r=1.) |
352 |
coeff=mypde.getCoefficientOfGeneralPDE("r") |
coeff=mypde.getCoefficient("r") |
353 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
354 |
def test_setCoefficient_q_Scalar_reducedOn(self): |
def test_setCoefficient_q_Scalar_reducedOn(self): |
355 |
d=self.domain.getDim() |
d=self.domain.getDim() |
356 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
357 |
mypde.setReducedOrderOn() |
mypde.setReducedOrderOn() |
358 |
mypde.setValue(q=1.) |
mypde.setValue(q=1.) |
359 |
coeff=mypde.getCoefficientOfGeneralPDE("q") |
coeff=mypde.getCoefficient("q") |
360 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
361 |
|
|
362 |
|
def test_setCoefficient_A_reduced_Scalar_usingA(self): |
363 |
|
d=self.domain.getDim() |
364 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
365 |
|
mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain))) |
366 |
|
coeff=mypde.getCoefficient("A_reduced") |
367 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1)) |
368 |
|
def test_setCoefficient_B_reduced_Scalar_usingB(self): |
369 |
|
d=self.domain.getDim() |
370 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
371 |
|
mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
372 |
|
coeff=mypde.getCoefficient("B_reduced") |
373 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
374 |
|
def test_setCoefficient_C_reduced_Scalar_usingC(self): |
375 |
|
d=self.domain.getDim() |
376 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
377 |
|
mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
378 |
|
coeff=mypde.getCoefficient("C_reduced") |
379 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
380 |
|
def test_setCoefficient_D_reduced_Scalar_usingD(self): |
381 |
|
d=self.domain.getDim() |
382 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
383 |
|
mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain))) |
384 |
|
coeff=mypde.getCoefficient("D_reduced") |
385 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
386 |
|
def test_setCoefficient_X_reduced_Scalar_usingX(self): |
387 |
|
d=self.domain.getDim() |
388 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
389 |
|
mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
390 |
|
coeff=mypde.getCoefficient("X_reduced") |
391 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1)) |
392 |
|
def test_setCoefficient_Y_reduced_Scalar_usingY(self): |
393 |
|
d=self.domain.getDim() |
394 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
395 |
|
mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain))) |
396 |
|
coeff=mypde.getCoefficient("Y_reduced") |
397 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1)) |
398 |
|
def test_setCoefficient_y_reduced_Scalar_using_y(self): |
399 |
|
d=self.domain.getDim() |
400 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
401 |
|
mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain))) |
402 |
|
coeff=mypde.getCoefficient("y_reduced") |
403 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1)) |
404 |
|
def test_setCoefficient_d_reduced_Scalar_using_d(self): |
405 |
|
d=self.domain.getDim() |
406 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
407 |
|
mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain))) |
408 |
|
coeff=mypde.getCoefficient("d_reduced") |
409 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
410 |
|
def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self): |
411 |
|
d=self.domain.getDim() |
412 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
413 |
|
mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain))) |
414 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
415 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1)) |
416 |
|
def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self): |
417 |
|
d=self.domain.getDim() |
418 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
419 |
|
mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain))) |
420 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
421 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1)) |
422 |
# |
# |
423 |
# set coefficients for systems: |
# set coefficients for systems: |
424 |
# |
# |
426 |
d=self.domain.getDim() |
d=self.domain.getDim() |
427 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
428 |
mypde.setValue(A=numarray.ones((self.N,d,self.N,d))) |
mypde.setValue(A=numarray.ones((self.N,d,self.N,d))) |
429 |
coeff=mypde.getCoefficientOfGeneralPDE("A") |
coeff=mypde.getCoefficient("A") |
430 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N)) |
431 |
def test_setCoefficient_B_System(self): |
def test_setCoefficient_B_System(self): |
432 |
d=self.domain.getDim() |
d=self.domain.getDim() |
433 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
434 |
mypde.setValue(B=numarray.ones((self.N,d,self.N))) |
mypde.setValue(B=numarray.ones((self.N,d,self.N))) |
435 |
coeff=mypde.getCoefficientOfGeneralPDE("B") |
coeff=mypde.getCoefficient("B") |
436 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N)) |
437 |
def test_setCoefficient_C_System(self): |
def test_setCoefficient_C_System(self): |
438 |
d=self.domain.getDim() |
d=self.domain.getDim() |
439 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
440 |
mypde.setValue(C=numarray.ones((self.N,self.N,d))) |
mypde.setValue(C=numarray.ones((self.N,self.N,d))) |
441 |
coeff=mypde.getCoefficientOfGeneralPDE("C") |
coeff=mypde.getCoefficient("C") |
442 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N)) |
443 |
def test_setCoefficient_D_System(self): |
def test_setCoefficient_D_System(self): |
444 |
d=self.domain.getDim() |
d=self.domain.getDim() |
445 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
446 |
mypde.setValue(D=numarray.ones((self.N,self.N))) |
mypde.setValue(D=numarray.ones((self.N,self.N))) |
447 |
coeff=mypde.getCoefficientOfGeneralPDE("D") |
coeff=mypde.getCoefficient("D") |
448 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N)) |
449 |
def test_setCoefficient_X_System(self): |
def test_setCoefficient_X_System(self): |
450 |
d=self.domain.getDim() |
d=self.domain.getDim() |
451 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
452 |
mypde.setValue(X=numarray.ones((self.N,d))) |
mypde.setValue(X=numarray.ones((self.N,d))) |
453 |
coeff=mypde.getCoefficientOfGeneralPDE("X") |
coeff=mypde.getCoefficient("X") |
454 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N)) |
455 |
def test_setCoefficient_Y_System(self): |
def test_setCoefficient_Y_System(self): |
456 |
d=self.domain.getDim() |
d=self.domain.getDim() |
457 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
458 |
mypde.setValue(Y=numarray.ones((self.N,))) |
mypde.setValue(Y=numarray.ones((self.N,))) |
459 |
coeff=mypde.getCoefficientOfGeneralPDE("Y") |
coeff=mypde.getCoefficient("Y") |
460 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N)) |
461 |
def test_setCoefficient_y_System(self): |
def test_setCoefficient_y_System(self): |
462 |
d=self.domain.getDim() |
d=self.domain.getDim() |
463 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
464 |
mypde.setValue(y=numarray.ones((self.N,))) |
mypde.setValue(y=numarray.ones((self.N,))) |
465 |
coeff=mypde.getCoefficientOfGeneralPDE("y") |
coeff=mypde.getCoefficient("y") |
466 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N)) |
467 |
def test_setCoefficient_d_System(self): |
def test_setCoefficient_d_System(self): |
468 |
d=self.domain.getDim() |
d=self.domain.getDim() |
469 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
470 |
mypde.setValue(d=numarray.ones((self.N,self.N))) |
mypde.setValue(d=numarray.ones((self.N,self.N))) |
471 |
coeff=mypde.getCoefficientOfGeneralPDE("d") |
coeff=mypde.getCoefficient("d") |
472 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N)) |
473 |
def test_setCoefficient_d_contact_System(self): |
def test_setCoefficient_d_contact_System(self): |
474 |
d=self.domain.getDim() |
d=self.domain.getDim() |
475 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
476 |
mypde.setValue(d_contact=numarray.ones((self.N,self.N))) |
mypde.setValue(d_contact=numarray.ones((self.N,self.N))) |
477 |
coeff=mypde.getCoefficientOfGeneralPDE("d_contact") |
coeff=mypde.getCoefficient("d_contact") |
478 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N)) |
479 |
def test_setCoefficient_y_contact_System(self): |
def test_setCoefficient_y_contact_System(self): |
480 |
d=self.domain.getDim() |
d=self.domain.getDim() |
481 |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
482 |
mypde.setValue(y_contact=numarray.ones((self.N,))) |
mypde.setValue(y_contact=numarray.ones((self.N,))) |
483 |
coeff=mypde.getCoefficientOfGeneralPDE("y_contact") |
coeff=mypde.getCoefficient("y_contact") |
484 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N)) |
485 |
|
def test_setCoefficient_A_reduced_System(self): |
486 |
|
d=self.domain.getDim() |
487 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
488 |
|
mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d))) |
489 |
|
coeff=mypde.getCoefficient("A_reduced") |
490 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
491 |
|
def test_setCoefficient_B_reduced_System(self): |
492 |
|
d=self.domain.getDim() |
493 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
494 |
|
mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N))) |
495 |
|
coeff=mypde.getCoefficient("B_reduced") |
496 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N)) |
497 |
|
def test_setCoefficient_C_reduced_System(self): |
498 |
|
d=self.domain.getDim() |
499 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
500 |
|
mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d))) |
501 |
|
coeff=mypde.getCoefficient("C_reduced") |
502 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
503 |
|
def test_setCoefficient_D_System_reduced(self): |
504 |
|
d=self.domain.getDim() |
505 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
506 |
|
mypde.setValue(D_reduced=numarray.ones((self.N,self.N))) |
507 |
|
coeff=mypde.getCoefficient("D_reduced") |
508 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
509 |
|
def test_setCoefficient_X_System_reduced(self): |
510 |
|
d=self.domain.getDim() |
511 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
512 |
|
mypde.setValue(X_reduced=numarray.ones((self.N,d))) |
513 |
|
coeff=mypde.getCoefficient("X_reduced") |
514 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N)) |
515 |
|
def test_setCoefficient_Y_System_reduced(self): |
516 |
|
d=self.domain.getDim() |
517 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
518 |
|
mypde.setValue(Y_reduced=numarray.ones((self.N,))) |
519 |
|
coeff=mypde.getCoefficient("Y_reduced") |
520 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N)) |
521 |
|
def test_setCoefficient_y_System_reduced(self): |
522 |
|
d=self.domain.getDim() |
523 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
524 |
|
mypde.setValue(y_reduced=numarray.ones((self.N,))) |
525 |
|
coeff=mypde.getCoefficient("y_reduced") |
526 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N)) |
527 |
|
def test_setCoefficient_d_reduced_System(self): |
528 |
|
d=self.domain.getDim() |
529 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
530 |
|
mypde.setValue(d_reduced=numarray.ones((self.N,self.N))) |
531 |
|
coeff=mypde.getCoefficient("d_reduced") |
532 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
533 |
|
def test_setCoefficient_d_contact_reduced_System(self): |
534 |
|
d=self.domain.getDim() |
535 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
536 |
|
mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N))) |
537 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
538 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N)) |
539 |
|
def test_setCoefficient_y_contact_reduced_System(self): |
540 |
|
d=self.domain.getDim() |
541 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
542 |
|
mypde.setValue(y_contact_reduced=numarray.ones((self.N,))) |
543 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
544 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N)) |
545 |
def test_setCoefficient_r_System(self): |
def test_setCoefficient_r_System(self): |
546 |
d=self.domain.getDim() |
d=self.domain.getDim() |
547 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
548 |
mypde.setValue(r=numarray.ones((self.N,))) |
mypde.setValue(r=numarray.ones((self.N,))) |
549 |
coeff=mypde.getCoefficientOfGeneralPDE("r") |
coeff=mypde.getCoefficient("r") |
550 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
551 |
def test_setCoefficient_q_System(self): |
def test_setCoefficient_q_System(self): |
552 |
d=self.domain.getDim() |
d=self.domain.getDim() |
553 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
554 |
mypde.setValue(q=numarray.ones((self.N,))) |
mypde.setValue(q=numarray.ones((self.N,))) |
555 |
coeff=mypde.getCoefficientOfGeneralPDE("q") |
coeff=mypde.getCoefficient("q") |
556 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
557 |
def test_setCoefficient_r_System_reducedOn(self): |
def test_setCoefficient_r_System_reducedOn(self): |
558 |
d=self.domain.getDim() |
d=self.domain.getDim() |
559 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
560 |
mypde.setReducedOrderOn() |
mypde.setReducedOrderOn() |
561 |
mypde.setValue(r=numarray.ones((self.N,))) |
mypde.setValue(r=numarray.ones((self.N,))) |
562 |
coeff=mypde.getCoefficientOfGeneralPDE("r") |
coeff=mypde.getCoefficient("r") |
563 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
564 |
def test_setCoefficient_q_System_reducedOn(self): |
def test_setCoefficient_q_System_reducedOn(self): |
565 |
d=self.domain.getDim() |
d=self.domain.getDim() |
566 |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,numEquations=3,debug=self.DEBUG) |
567 |
mypde.setReducedOrderOn() |
mypde.setReducedOrderOn() |
568 |
mypde.setValue(q=numarray.ones((self.N,))) |
mypde.setValue(q=numarray.ones((self.N,))) |
569 |
coeff=mypde.getCoefficientOfGeneralPDE("q") |
coeff=mypde.getCoefficient("q") |
570 |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
571 |
|
|
572 |
|
def test_setCoefficient_A_reduced_System_using_A(self): |
573 |
|
d=self.domain.getDim() |
574 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
575 |
|
mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain))) |
576 |
|
coeff=mypde.getCoefficient("A_reduced") |
577 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
578 |
|
def test_setCoefficient_B_reduced_System_using_B(self): |
579 |
|
d=self.domain.getDim() |
580 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
581 |
|
mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain))) |
582 |
|
coeff=mypde.getCoefficient("B_reduced") |
583 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N)) |
584 |
|
def test_setCoefficient_C_reduced_System_using_C(self): |
585 |
|
d=self.domain.getDim() |
586 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
587 |
|
mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain))) |
588 |
|
coeff=mypde.getCoefficient("C_reduced") |
589 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
590 |
|
def test_setCoefficient_D_System_reduced_using_D(self): |
591 |
|
d=self.domain.getDim() |
592 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
593 |
|
mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain))) |
594 |
|
coeff=mypde.getCoefficient("D_reduced") |
595 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
596 |
|
def test_setCoefficient_X_System_reduced_using_X(self): |
597 |
|
d=self.domain.getDim() |
598 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
599 |
|
mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain))) |
600 |
|
coeff=mypde.getCoefficient("X_reduced") |
601 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N)) |
602 |
|
def test_setCoefficient_Y_System_reduced_using_Y(self): |
603 |
|
d=self.domain.getDim() |
604 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
605 |
|
mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain))) |
606 |
|
coeff=mypde.getCoefficient("Y_reduced") |
607 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N)) |
608 |
|
def test_setCoefficient_y_reduced_System_using_y(self): |
609 |
|
d=self.domain.getDim() |
610 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
611 |
|
mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain))) |
612 |
|
coeff=mypde.getCoefficient("y_reduced") |
613 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N)) |
614 |
|
def test_setCoefficient_d_reduced_System_using_d(self): |
615 |
|
d=self.domain.getDim() |
616 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
617 |
|
mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain))) |
618 |
|
coeff=mypde.getCoefficient("d_reduced") |
619 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
620 |
|
def test_setCoefficient_d_contact_reduced_System_using_d_contact(self): |
621 |
|
d=self.domain.getDim() |
622 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
623 |
|
mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain))) |
624 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
625 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N)) |
626 |
|
def test_setCoefficient_y_contact_reduced_System_using_y_contact(self): |
627 |
|
d=self.domain.getDim() |
628 |
|
mypde=LinearPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
629 |
|
mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain))) |
630 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
631 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N)) |
632 |
def test_resetCoefficient_HomogeneousConstraint(self): |
def test_resetCoefficient_HomogeneousConstraint(self): |
633 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
634 |
x=self.domain.getX() |
x=self.domain.getX() |
662 |
D=3*numarray.ones((self.N,self.N)) |
D=3*numarray.ones((self.N,self.N)) |
663 |
d=4*numarray.ones((self.N,self.N)) |
d=4*numarray.ones((self.N,self.N)) |
664 |
d_contact=5*numarray.ones((self.N,self.N)) |
d_contact=5*numarray.ones((self.N,self.N)) |
665 |
mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact) |
mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact) |
666 |
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
667 |
|
|
668 |
def test_symmetryCheckFalse_A_System(self): |
def test_symmetryCheckFalse_A_System(self): |
702 |
mypde.setValue(d_contact=d_contact) |
mypde.setValue(d_contact=d_contact) |
703 |
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
704 |
|
|
705 |
|
def test_symmetryCheckFalse_A_reduced_System(self): |
706 |
|
d=self.domain.getDim() |
707 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
708 |
|
A=numarray.ones((self.N,d,self.N,d)) |
709 |
|
A[1,1,1,0]=0. |
710 |
|
mypde.setValue(A_reduced=A) |
711 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
712 |
|
def test_symmetryCheckFalse_BC_reduced_System(self): |
713 |
|
d=self.domain.getDim() |
714 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
715 |
|
C=2*numarray.ones((self.N,self.N,d)) |
716 |
|
B=2*numarray.ones((self.N,d,self.N)) |
717 |
|
B[0,0,1]=1. |
718 |
|
mypde.setValue(B_reduced=B,C_reduced=C) |
719 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
720 |
|
|
721 |
|
def test_symmetryCheckFalse_D_reduced_System(self): |
722 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
723 |
|
D=3*numarray.ones((self.N,self.N)) |
724 |
|
D[0,1]=0. |
725 |
|
mypde.setValue(D_reduced=D) |
726 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
727 |
|
|
728 |
|
def test_symmetryCheckFalse_d_reduced_System(self): |
729 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
730 |
|
d=4*numarray.ones((self.N,self.N)) |
731 |
|
d[0,1]=0. |
732 |
|
mypde.setValue(d_reduced=d) |
733 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
734 |
|
|
735 |
|
def test_symmetryCheckFalse_d_contact_reduced_System(self): |
736 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
737 |
|
d_contact=5*numarray.ones((self.N,self.N)) |
738 |
|
d_contact[0,1]=0. |
739 |
|
mypde.setValue(d_contact_reduced=d_contact) |
740 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
741 |
|
|
742 |
def test_symmetryCheckTrue_Scalar(self): |
def test_symmetryCheckTrue_Scalar(self): |
743 |
d=self.domain.getDim() |
d=self.domain.getDim() |
744 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
748 |
D=3 |
D=3 |
749 |
d=4 |
d=4 |
750 |
d_contact=5 |
d_contact=5 |
751 |
mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact) |
mypde.setValue(A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact) |
752 |
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
753 |
|
|
754 |
def test_symmetryCheckFalse_A_Scalar(self): |
def test_symmetryCheckFalse_A_Scalar(self): |
766 |
B[0]=1. |
B[0]=1. |
767 |
mypde.setValue(B=B,C=C) |
mypde.setValue(B=B,C=C) |
768 |
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
769 |
|
def test_symmetryCheckFalse_A_reduced_Scalar(self): |
770 |
|
d=self.domain.getDim() |
771 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
772 |
|
A=numarray.ones((d,d)) |
773 |
|
A[1,0]=0. |
774 |
|
mypde.setValue(A_reduced=A) |
775 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
776 |
|
def test_symmetryCheckFalse_BC_reduced_Scalar(self): |
777 |
|
d=self.domain.getDim() |
778 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
779 |
|
C=2*numarray.ones((d,)) |
780 |
|
B=2*numarray.ones((d,)) |
781 |
|
B[0]=1. |
782 |
|
mypde.setValue(B_reduced=B,C_reduced=C) |
783 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
784 |
# |
# |
785 |
# solver checks: |
# solver checks (single PDE) |
786 |
# |
# |
787 |
def test_symmetryOnIterative(self): |
def test_symmetryOnIterative(self): |
788 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
807 |
mypde.setSolverMethod(mypde.PCG,mypde.ILU0) |
mypde.setSolverMethod(mypde.PCG,mypde.ILU0) |
808 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
809 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
810 |
|
def test_PCG_RILU(self): |
811 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
812 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
813 |
|
mypde.setSolverMethod(mypde.PCG,mypde.RILU) |
814 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
815 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
816 |
def test_DIRECT(self): |
def test_DIRECT(self): |
817 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
818 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
831 |
mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0) |
mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0) |
832 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
833 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
834 |
|
def test_BICGSTAB_RILU(self): |
835 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
836 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
837 |
|
mypde.setSolverMethod(mypde.BICGSTAB,mypde.RILU) |
838 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
839 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
840 |
|
def test_MINRES_JACOBI(self): |
841 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
842 |
|
mypde.setSolverMethod(mypde.MINRES,mypde.JACOBI) |
843 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
844 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
845 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
846 |
|
def test_MINRES_ILU0(self): |
847 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
848 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
849 |
|
mypde.setSolverMethod(mypde.MINRES,mypde.ILU0) |
850 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
851 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
852 |
|
def test_MINRES_RILU(self): |
853 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
854 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
855 |
|
mypde.setSolverMethod(mypde.MINRES,mypde.RILU) |
856 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
857 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
858 |
|
def test_TFQMR_JACOBI(self): |
859 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
860 |
|
mypde.setSolverMethod(mypde.TFQMR,mypde.JACOBI) |
861 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
862 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
863 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
864 |
|
def test_TFQMR_ILU0(self): |
865 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
866 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
867 |
|
mypde.setSolverMethod(mypde.TFQMR,mypde.ILU0) |
868 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
869 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
870 |
|
def test_TFQMR_RILU(self): |
871 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
872 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
873 |
|
mypde.setSolverMethod(mypde.TFQMR,mypde.RILU) |
874 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
875 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
876 |
def test_PRES20_JACOBI(self): |
def test_PRES20_JACOBI(self): |
877 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
878 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
885 |
mypde.setSolverMethod(mypde.PRES20,mypde.ILU0) |
mypde.setSolverMethod(mypde.PRES20,mypde.ILU0) |
886 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
887 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
888 |
|
def test_PRES20_RILU(self): |
889 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
890 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
891 |
|
mypde.setSolverMethod(mypde.PRES20,mypde.RILU) |
892 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
893 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
894 |
def test_GMRESnoRestart_JACOBI(self): |
def test_GMRESnoRestart_JACOBI(self): |
895 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
896 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
897 |
mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI) |
mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI) |
898 |
# u=mypde.getSolution(verbose=self.VERBOSE,truncation=5) |
u=mypde.getSolution(verbose=self.VERBOSE,truncation=50) |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
|
899 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
900 |
def test_GMRESnoRestart_ILU0(self): |
def test_GMRESnoRestart_ILU0(self): |
901 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
902 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
903 |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
904 |
# u=mypde.getSolution(verbose=self.VERBOSE,truncation=5) |
u=mypde.getSolution(verbose=self.VERBOSE,truncation=50) |
905 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
906 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
907 |
|
def test_GMRESnoRestart_RILU(self): |
908 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
909 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
910 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.RILU) |
911 |
|
u=mypde.getSolution(verbose=self.VERBOSE,truncation=50) |
912 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
913 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
914 |
def test_GMRES_JACOBI(self): |
def test_GMRES_JACOBI(self): |
923 |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
924 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
925 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
926 |
|
def test_GMRES_RILU(self): |
927 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
928 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
929 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.RILU) |
930 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
931 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
932 |
def test_GMRES_truncation_restart_JACOBI(self): |
def test_GMRES_truncation_restart_JACOBI(self): |
933 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
934 |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
941 |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
942 |
u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20) |
u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20) |
943 |
self.failUnless(self.check(u,1.),'solution is wrong.') |
self.failUnless(self.check(u,1.),'solution is wrong.') |
944 |
|
def test_GMRES_truncation_restart_RILU(self): |
945 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
946 |
|
mypde.setValue(A=kronecker(self.domain),D=1.,Y=1.) |
947 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.RILU) |
948 |
|
u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20) |
949 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
950 |
|
# |
951 |
|
# solver checks (PDE system) |
952 |
|
# |
953 |
|
def test_symmetryOnIterative_System(self): |
954 |
|
A=Tensor4(0.,Function(self.domain)) |
955 |
|
D=Tensor(1.,Function(self.domain)) |
956 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
957 |
|
for i in range(self.domain.getDim()): |
958 |
|
A[i,:,i,:]=kronecker(self.domain) |
959 |
|
D[i,i]+=i |
960 |
|
Y[i]+=i |
961 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
962 |
|
mypde.setValue(A=A,D=D,Y=Y) |
963 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
964 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
965 |
|
def test_symmetryOnDirect_System(self): |
966 |
|
A=Tensor4(0.,Function(self.domain)) |
967 |
|
D=Tensor(1.,Function(self.domain)) |
968 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
969 |
|
for i in range(self.domain.getDim()): |
970 |
|
A[i,:,i,:]=kronecker(self.domain) |
971 |
|
D[i,i]+=i |
972 |
|
Y[i]+=i |
973 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
974 |
|
mypde.setValue(A=A,D=D,Y=Y) |
975 |
|
mypde.setSolverMethod(mypde.DIRECT) |
976 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
977 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
978 |
|
def test_PCG_JACOBI_System(self): |
979 |
|
A=Tensor4(0.,Function(self.domain)) |
980 |
|
D=Tensor(1.,Function(self.domain)) |
981 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
982 |
|
for i in range(self.domain.getDim()): |
983 |
|
A[i,:,i,:]=kronecker(self.domain) |
984 |
|
D[i,i]+=i |
985 |
|
Y[i]+=i |
986 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
987 |
|
mypde.setValue(A=A,D=D,Y=Y) |
988 |
|
mypde.setSolverMethod(mypde.PCG,mypde.JACOBI) |
989 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
990 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
991 |
|
def test_PCG_ILU0_System(self): |
992 |
|
A=Tensor4(0.,Function(self.domain)) |
993 |
|
D=Tensor(1.,Function(self.domain)) |
994 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
995 |
|
for i in range(self.domain.getDim()): |
996 |
|
A[i,:,i,:]=kronecker(self.domain) |
997 |
|
D[i,i]+=i |
998 |
|
Y[i]+=i |
999 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1000 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1001 |
|
mypde.setSolverMethod(mypde.PCG,mypde.ILU0) |
1002 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1003 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1004 |
|
def test_DIRECT_System(self): |
1005 |
|
A=Tensor4(0.,Function(self.domain)) |
1006 |
|
D=Tensor(1.,Function(self.domain)) |
1007 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1008 |
|
for i in range(self.domain.getDim()): |
1009 |
|
A[i,:,i,:]=kronecker(self.domain) |
1010 |
|
D[i,i]+=i |
1011 |
|
Y[i]+=i |
1012 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1013 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1014 |
|
mypde.setSolverMethod(mypde.DIRECT) |
1015 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1016 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1017 |
|
def test_BICGSTAB_JACOBI_System(self): |
1018 |
|
A=Tensor4(0.,Function(self.domain)) |
1019 |
|
D=Tensor(1.,Function(self.domain)) |
1020 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1021 |
|
for i in range(self.domain.getDim()): |
1022 |
|
A[i,:,i,:]=kronecker(self.domain) |
1023 |
|
D[i,i]+=i |
1024 |
|
Y[i]+=i |
1025 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1026 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1027 |
|
mypde.setSolverMethod(mypde.BICGSTAB,mypde.JACOBI) |
1028 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1029 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1030 |
|
def test_BICGSTAB_ILU0_System(self): |
1031 |
|
A=Tensor4(0.,Function(self.domain)) |
1032 |
|
D=Tensor(1.,Function(self.domain)) |
1033 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1034 |
|
for i in range(self.domain.getDim()): |
1035 |
|
A[i,:,i,:]=kronecker(self.domain) |
1036 |
|
D[i,i]+=i |
1037 |
|
Y[i]+=i |
1038 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1039 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1040 |
|
mypde.setSolverMethod(mypde.BICGSTAB,mypde.ILU0) |
1041 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1042 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1043 |
|
def test_PRES20_JACOBI_System(self): |
1044 |
|
A=Tensor4(0.,Function(self.domain)) |
1045 |
|
D=Tensor(1.,Function(self.domain)) |
1046 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1047 |
|
for i in range(self.domain.getDim()): |
1048 |
|
A[i,:,i,:]=kronecker(self.domain) |
1049 |
|
D[i,i]+=i |
1050 |
|
Y[i]+=i |
1051 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1052 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1053 |
|
mypde.setSolverMethod(mypde.PRES20,mypde.JACOBI) |
1054 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1055 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1056 |
|
def test_PRES20_ILU0_System(self): |
1057 |
|
A=Tensor4(0.,Function(self.domain)) |
1058 |
|
D=Tensor(1.,Function(self.domain)) |
1059 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1060 |
|
for i in range(self.domain.getDim()): |
1061 |
|
A[i,:,i,:]=kronecker(self.domain) |
1062 |
|
D[i,i]+=i |
1063 |
|
Y[i]+=i |
1064 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1065 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1066 |
|
mypde.setSolverMethod(mypde.PRES20,mypde.ILU0) |
1067 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1068 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1069 |
|
def test_GMRESnoRestart_JACOBI_System(self): |
1070 |
|
A=Tensor4(0.,Function(self.domain)) |
1071 |
|
D=Tensor(1.,Function(self.domain)) |
1072 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1073 |
|
for i in range(self.domain.getDim()): |
1074 |
|
A[i,:,i,:]=kronecker(self.domain) |
1075 |
|
D[i,i]+=i |
1076 |
|
Y[i]+=i |
1077 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1078 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1079 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI) |
1080 |
|
# u=mypde.getSolution(verbose=self.VERBOSE,truncation=5) |
1081 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1082 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1083 |
|
def test_GMRESnoRestart_ILU0_System(self): |
1084 |
|
A=Tensor4(0.,Function(self.domain)) |
1085 |
|
D=Tensor(1.,Function(self.domain)) |
1086 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1087 |
|
for i in range(self.domain.getDim()): |
1088 |
|
A[i,:,i,:]=kronecker(self.domain) |
1089 |
|
D[i,i]+=i |
1090 |
|
Y[i]+=i |
1091 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1092 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1093 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
1094 |
|
# u=mypde.getSolution(verbose=self.VERBOSE,truncation=5) |
1095 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1096 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1097 |
|
def test_GMRES_JACOBI_System(self): |
1098 |
|
A=Tensor4(0.,Function(self.domain)) |
1099 |
|
D=Tensor(1.,Function(self.domain)) |
1100 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1101 |
|
for i in range(self.domain.getDim()): |
1102 |
|
A[i,:,i,:]=kronecker(self.domain) |
1103 |
|
D[i,i]+=i |
1104 |
|
Y[i]+=i |
1105 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1106 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1107 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI) |
1108 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1109 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1110 |
|
def test_GMRES_ILU0_System(self): |
1111 |
|
A=Tensor4(0.,Function(self.domain)) |
1112 |
|
D=Tensor(1.,Function(self.domain)) |
1113 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1114 |
|
for i in range(self.domain.getDim()): |
1115 |
|
A[i,:,i,:]=kronecker(self.domain) |
1116 |
|
D[i,i]+=i |
1117 |
|
Y[i]+=i |
1118 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1119 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1120 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
1121 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1122 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1123 |
|
def test_GMRES_truncation_restart_JACOBI_System(self): |
1124 |
|
A=Tensor4(0.,Function(self.domain)) |
1125 |
|
D=Tensor(1.,Function(self.domain)) |
1126 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1127 |
|
for i in range(self.domain.getDim()): |
1128 |
|
A[i,:,i,:]=kronecker(self.domain) |
1129 |
|
D[i,i]+=i |
1130 |
|
Y[i]+=i |
1131 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1132 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1133 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.JACOBI) |
1134 |
|
u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20) |
1135 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1136 |
|
def test_GMRES_truncation_restart_ILU0_System(self): |
1137 |
|
A=Tensor4(0.,Function(self.domain)) |
1138 |
|
D=Tensor(1.,Function(self.domain)) |
1139 |
|
Y=Vector(self.domain.getDim(),Function(self.domain)) |
1140 |
|
for i in range(self.domain.getDim()): |
1141 |
|
A[i,:,i,:]=kronecker(self.domain) |
1142 |
|
D[i,i]+=i |
1143 |
|
Y[i]+=i |
1144 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1145 |
|
mypde.setValue(A=A,D=D,Y=Y) |
1146 |
|
mypde.setSolverMethod(mypde.GMRES,mypde.ILU0) |
1147 |
|
u=mypde.getSolution(verbose=self.VERBOSE,truncation=10,restart=20) |
1148 |
|
self.failUnless(self.check(u,1.),'solution is wrong.') |
1149 |
|
|
1150 |
|
class Test_LinearPDE(Test_LinearPDE_noLumping): |
1151 |
def test_Lumping_attemptToSetA(self): |
def test_Lumping_attemptToSetA(self): |
1152 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1153 |
try: |
try: |
1179 |
success=False |
success=False |
1180 |
self.failUnless(not success,'error should be issued') |
self.failUnless(not success,'error should be issued') |
1181 |
|
|
1182 |
|
def test_Lumping_attemptToSetA_reduced(self): |
1183 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1184 |
|
try: |
1185 |
|
success=True |
1186 |
|
mypde.setSolverMethod(mypde.LUMPING) |
1187 |
|
mypde.setValue(A_reduced=kronecker(self.domain)) |
1188 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1189 |
|
except ValueError: |
1190 |
|
success=False |
1191 |
|
self.failUnless(not success,'error should be issued') |
1192 |
|
def test_Lumping_attemptToSetB_reduced(self): |
1193 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1194 |
|
try: |
1195 |
|
success=True |
1196 |
|
mypde.setSolverMethod(mypde.LUMPING) |
1197 |
|
mypde.setValue(B_reduced=kronecker(self.domain)[0]) |
1198 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1199 |
|
except ValueError: |
1200 |
|
success=False |
1201 |
|
self.failUnless(not success,'error should be issued') |
1202 |
|
def test_Lumping_attemptToSetC_reduced(self): |
1203 |
|
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1204 |
|
try: |
1205 |
|
success=True |
1206 |
|
mypde.setSolverMethod(mypde.LUMPING) |
1207 |
|
mypde.setValue(C_reduced=kronecker(self.domain)[0]) |
1208 |
|
u=mypde.getSolution(verbose=self.VERBOSE) |
1209 |
|
except ValueError: |
1210 |
|
success=False |
1211 |
|
self.failUnless(not success,'error should be issued') |
1212 |
|
|
1213 |
def test_Lumping(self): |
def test_Lumping(self): |
1214 |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
mypde=LinearPDE(self.domain,debug=self.DEBUG) |
1215 |
mypde.setSolverMethod(mypde.LUMPING) |
mypde.setSolverMethod(mypde.LUMPING) |
1259 |
u=mypde.getSolution(verbose=self.VERBOSE) |
u=mypde.getSolution(verbose=self.VERBOSE) |
1260 |
self.failUnless(self.check(u,0.5),'second solution is wrong.') |
self.failUnless(self.check(u,0.5),'second solution is wrong.') |
1261 |
|
|
1262 |
|
|
1263 |
|
class Test_TransportPDE(Test_linearPDEs): |
1264 |
|
N=4 |
1265 |
|
def test_init_theta(self): |
1266 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG, theta=1.) |
1267 |
|
self.failUnless(mypde.getTheta()==1.,'wrong theta') |
1268 |
|
def test_init_invalid_theta(self): |
1269 |
|
self.failUnlessRaises(ValueError,TransportPDE,self.domain,debug=self.DEBUG, theta=-1.) |
1270 |
|
|
1271 |
|
def test_setCoefficient_WithWrongName(self): |
1272 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1273 |
|
self.failUnlessRaises(IllegalCoefficient,mypde.setValue, ROMA=Vector(0.,FunctionOnBoundary(self.domain))) |
1274 |
|
|
1275 |
|
def test_setCoefficient_WithIllegalFunctionSpace(self): |
1276 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1277 |
|
self.failUnlessRaises(IllegalCoefficientFunctionSpace,mypde.setValue,C=Vector(0.,FunctionOnBoundary(self.domain))) |
1278 |
|
|
1279 |
|
def test_resetCoefficient_WithWrongShape(self): |
1280 |
|
mypde=TransportPDE(self.domain,numEquations=2,debug=self.DEBUG) |
1281 |
|
self.failUnlessRaises(IllegalCoefficientValue, mypde.setValue, C=0.) |
1282 |
|
|
1283 |
|
def test_setInitialSolution_scalar(self): |
1284 |
|
mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG) |
1285 |
|
mypde.setInitialSolution(1.) |
1286 |
|
|
1287 |
|
def test_setInitialSolution_scalar_negative(self): |
1288 |
|
mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG) |
1289 |
|
self.failUnlessRaises(RuntimeError,mypde.setInitialSolution,-1.) |
1290 |
|
|
1291 |
|
def test_setInitialSolution_scalar_WithWrongShape(self): |
1292 |
|
mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG) |
1293 |
|
self.failUnlessRaises(ValueError,mypde.setInitialSolution,[1.,2.]) |
1294 |
|
|
1295 |
|
def test_setInitialSolution_system(self): |
1296 |
|
mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG) |
1297 |
|
mypde.setInitialSolution([1.,2.]) |
1298 |
|
|
1299 |
|
def test_setInitialSolution_system(self): |
1300 |
|
mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG) |
1301 |
|
self.failUnlessRaises(RuntimeError,mypde.setInitialSolution,[-1,2.]) |
1302 |
|
|
1303 |
|
def test_setInitialSolution_system_WithWrongShape(self): |
1304 |
|
mypde=TransportPDE(self.domain,numSolutions=2,debug=self.DEBUG) |
1305 |
|
self.failUnlessRaises(ValueError,mypde.setInitialSolution,1.) |
1306 |
|
|
1307 |
|
|
1308 |
|
def test_attemptToChangeOrderAfterDefinedCoefficient(self): |
1309 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1310 |
|
mypde.setValue(D=1.) |
1311 |
|
self.failUnlessRaises(RuntimeError, mypde.setReducedOrderOn) |
1312 |
|
|
1313 |
|
def test_reducedOnConfig(self): |
1314 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1315 |
|
mypde.setReducedOrderOn() |
1316 |
|
self.failUnlessEqual((mypde.getFunctionSpaceForSolution(),mypde.getFunctionSpaceForEquation()),(ReducedSolution(self.domain),ReducedSolution(self.domain)),"reduced function spaces expected.") |
1317 |
|
# |
1318 |
|
# set coefficients for scalars: |
1319 |
|
# |
1320 |
|
def test_setCoefficient_M_Scalar(self): |
1321 |
|
d=self.domain.getDim() |
1322 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1323 |
|
mypde.setValue(M=1.) |
1324 |
|
coeff=mypde.getCoefficient("M") |
1325 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1)) |
1326 |
|
def test_setCoefficient_A_Scalar(self): |
1327 |
|
d=self.domain.getDim() |
1328 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1329 |
|
mypde.setValue(A=numarray.ones((d,d))) |
1330 |
|
coeff=mypde.getCoefficient("A") |
1331 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),Function(self.domain),1,1)) |
1332 |
|
def test_setCoefficient_B_Scalar(self): |
1333 |
|
d=self.domain.getDim() |
1334 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1335 |
|
mypde.setValue(B=numarray.ones((d,))) |
1336 |
|
coeff=mypde.getCoefficient("B") |
1337 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
1338 |
|
def test_setCoefficient_C_Scalar(self): |
1339 |
|
d=self.domain.getDim() |
1340 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1341 |
|
mypde.setValue(C=numarray.ones((d,))) |
1342 |
|
coeff=mypde.getCoefficient("C") |
1343 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),Function(self.domain),1,1)) |
1344 |
|
def test_setCoefficient_D_Scalar(self): |
1345 |
|
d=self.domain.getDim() |
1346 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1347 |
|
mypde.setValue(D=1.) |
1348 |
|
coeff=mypde.getCoefficient("D") |
1349 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),Function(self.domain),1,1)) |
1350 |
|
def test_setCoefficient_X_Scalar(self): |
1351 |
|
d=self.domain.getDim() |
1352 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1353 |
|
mypde.setValue(X=numarray.ones((d,))) |
1354 |
|
coeff=mypde.getCoefficient("X") |
1355 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),Function(self.domain),1)) |
1356 |
|
def test_setCoefficient_Y_Scalar(self): |
1357 |
|
d=self.domain.getDim() |
1358 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1359 |
|
mypde.setValue(Y=1.) |
1360 |
|
coeff=mypde.getCoefficient("Y") |
1361 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),Function(self.domain),1)) |
1362 |
|
def test_setCoefficient_y_Scalar(self): |
1363 |
|
d=self.domain.getDim() |
1364 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1365 |
|
mypde.setValue(y=1.) |
1366 |
|
coeff=mypde.getCoefficient("y") |
1367 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1)) |
1368 |
|
def test_setCoefficient_d_Scalar(self): |
1369 |
|
d=self.domain.getDim() |
1370 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1371 |
|
mypde.setValue(d=1.) |
1372 |
|
coeff=mypde.getCoefficient("d") |
1373 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1)) |
1374 |
|
def test_setCoefficient_m_Scalar(self): |
1375 |
|
d=self.domain.getDim() |
1376 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1377 |
|
mypde.setValue(m=1.) |
1378 |
|
coeff=mypde.getCoefficient("m") |
1379 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnBoundary(self.domain),1,1)) |
1380 |
|
def test_setCoefficient_d_contact_Scalar(self): |
1381 |
|
d=self.domain.getDim() |
1382 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1383 |
|
mypde.setValue(d_contact=1.) |
1384 |
|
coeff=mypde.getCoefficient("d_contact") |
1385 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1,1)) |
1386 |
|
def test_setCoefficient_y_contact_Scalar(self): |
1387 |
|
d=self.domain.getDim() |
1388 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1389 |
|
mypde.setValue(y_contact=1.) |
1390 |
|
coeff=mypde.getCoefficient("y_contact") |
1391 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),FunctionOnContactZero(self.domain),1)) |
1392 |
|
|
1393 |
|
def test_setCoefficient_M_reduced_Scalar(self): |
1394 |
|
d=self.domain.getDim() |
1395 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1396 |
|
mypde.setValue(M_reduced=1.) |
1397 |
|
coeff=mypde.getCoefficient("M_reduced") |
1398 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
1399 |
|
def test_setCoefficient_A_reduced_Scalar(self): |
1400 |
|
d=self.domain.getDim() |
1401 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1402 |
|
mypde.setValue(A_reduced=numarray.ones((d,d))) |
1403 |
|
coeff=mypde.getCoefficient("A_reduced") |
1404 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1)) |
1405 |
|
def test_setCoefficient_B_reduced_Scalar(self): |
1406 |
|
d=self.domain.getDim() |
1407 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1408 |
|
mypde.setValue(B_reduced=numarray.ones((d,))) |
1409 |
|
coeff=mypde.getCoefficient("B_reduced") |
1410 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
1411 |
|
def test_setCoefficient_C_reduced_Scalar(self): |
1412 |
|
d=self.domain.getDim() |
1413 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1414 |
|
mypde.setValue(C_reduced=numarray.ones((d,))) |
1415 |
|
coeff=mypde.getCoefficient("C_reduced") |
1416 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
1417 |
|
def test_setCoefficient_D_reduced_Scalar(self): |
1418 |
|
d=self.domain.getDim() |
1419 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1420 |
|
mypde.setValue(D_reduced=1.) |
1421 |
|
coeff=mypde.getCoefficient("D_reduced") |
1422 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
1423 |
|
def test_setCoefficient_X_reduced_Scalar(self): |
1424 |
|
d=self.domain.getDim() |
1425 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1426 |
|
mypde.setValue(X_reduced=numarray.ones((d,))) |
1427 |
|
coeff=mypde.getCoefficient("X_reduced") |
1428 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1)) |
1429 |
|
def test_setCoefficient_Y_reduced_Scalar(self): |
1430 |
|
d=self.domain.getDim() |
1431 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1432 |
|
mypde.setValue(Y_reduced=1.) |
1433 |
|
coeff=mypde.getCoefficient("Y_reduced") |
1434 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1)) |
1435 |
|
def test_setCoefficient_y_reduced_Scalar(self): |
1436 |
|
d=self.domain.getDim() |
1437 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1438 |
|
mypde.setValue(y_reduced=1.) |
1439 |
|
coeff=mypde.getCoefficient("y_reduced") |
1440 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1)) |
1441 |
|
def test_setCoefficient_m_reduced_Scalar(self): |
1442 |
|
d=self.domain.getDim() |
1443 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1444 |
|
mypde.setValue(m_reduced=1.) |
1445 |
|
coeff=mypde.getCoefficient("m_reduced") |
1446 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
1447 |
|
def test_setCoefficient_d_reduced_Scalar(self): |
1448 |
|
d=self.domain.getDim() |
1449 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1450 |
|
mypde.setValue(d_reduced=1.) |
1451 |
|
coeff=mypde.getCoefficient("d_reduced") |
1452 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
1453 |
|
def test_setCoefficient_d_contact_reduced_Scalar(self): |
1454 |
|
d=self.domain.getDim() |
1455 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1456 |
|
mypde.setValue(d_contact_reduced=1.) |
1457 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
1458 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1)) |
1459 |
|
def test_setCoefficient_y_contact_reduced_Scalar(self): |
1460 |
|
d=self.domain.getDim() |
1461 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1462 |
|
mypde.setValue(y_contact_reduced=1.) |
1463 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
1464 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1)) |
1465 |
|
def test_setCoefficient_r_Scalar(self): |
1466 |
|
d=self.domain.getDim() |
1467 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1468 |
|
mypde.setValue(r=1.) |
1469 |
|
coeff=mypde.getCoefficient("r") |
1470 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
1471 |
|
def test_setCoefficient_q_Scalar(self): |
1472 |
|
d=self.domain.getDim() |
1473 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1474 |
|
mypde.setValue(q=1.) |
1475 |
|
coeff=mypde.getCoefficient("q") |
1476 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),Solution(self.domain),1)) |
1477 |
|
def test_setCoefficient_r_Scalar_reducedOn(self): |
1478 |
|
d=self.domain.getDim() |
1479 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1480 |
|
mypde.setReducedOrderOn() |
1481 |
|
mypde.setValue(r=1.) |
1482 |
|
coeff=mypde.getCoefficient("r") |
1483 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
1484 |
|
def test_setCoefficient_q_Scalar_reducedOn(self): |
1485 |
|
d=self.domain.getDim() |
1486 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1487 |
|
mypde.setReducedOrderOn() |
1488 |
|
mypde.setValue(q=1.) |
1489 |
|
coeff=mypde.getCoefficient("q") |
1490 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((),ReducedSolution(self.domain),1)) |
1491 |
|
|
1492 |
|
def test_setCoefficient_M_reduced_Scalar_usingM(self): |
1493 |
|
d=self.domain.getDim() |
1494 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1495 |
|
mypde.setValue(M=Scalar(1.,ReducedFunction(self.domain))) |
1496 |
|
coeff=mypde.getCoefficient("M_reduced") |
1497 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
1498 |
|
def test_setCoefficient_A_reduced_Scalar_usingA(self): |
1499 |
|
d=self.domain.getDim() |
1500 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1501 |
|
mypde.setValue(A=Data(numarray.ones((d,d)),ReducedFunction(self.domain))) |
1502 |
|
coeff=mypde.getCoefficient("A_reduced") |
1503 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,d),ReducedFunction(self.domain),1,1)) |
1504 |
|
def test_setCoefficient_B_reduced_Scalar_usingB(self): |
1505 |
|
d=self.domain.getDim() |
1506 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1507 |
|
mypde.setValue(B=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
1508 |
|
coeff=mypde.getCoefficient("B_reduced") |
1509 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
1510 |
|
def test_setCoefficient_C_reduced_Scalar_usingC(self): |
1511 |
|
d=self.domain.getDim() |
1512 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1513 |
|
mypde.setValue(C=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
1514 |
|
coeff=mypde.getCoefficient("C_reduced") |
1515 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1,1)) |
1516 |
|
def test_setCoefficient_D_reduced_Scalar_usingD(self): |
1517 |
|
d=self.domain.getDim() |
1518 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1519 |
|
mypde.setValue(D=Scalar(1.,ReducedFunction(self.domain))) |
1520 |
|
coeff=mypde.getCoefficient("D_reduced") |
1521 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1,1)) |
1522 |
|
def test_setCoefficient_X_reduced_Scalar_usingX(self): |
1523 |
|
d=self.domain.getDim() |
1524 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1525 |
|
mypde.setValue(X_reduced=Data(numarray.ones((d,)),ReducedFunction(self.domain))) |
1526 |
|
coeff=mypde.getCoefficient("X_reduced") |
1527 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((d,),ReducedFunction(self.domain),1)) |
1528 |
|
def test_setCoefficient_Y_reduced_Scalar_usingY(self): |
1529 |
|
d=self.domain.getDim() |
1530 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1531 |
|
mypde.setValue(Y=Scalar(1.,ReducedFunction(self.domain))) |
1532 |
|
coeff=mypde.getCoefficient("Y_reduced") |
1533 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunction(self.domain),1)) |
1534 |
|
def test_setCoefficient_y_reduced_Scalar_using_y(self): |
1535 |
|
d=self.domain.getDim() |
1536 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1537 |
|
mypde.setValue(y=Scalar(1.,ReducedFunctionOnBoundary(self.domain))) |
1538 |
|
coeff=mypde.getCoefficient("y_reduced") |
1539 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1)) |
1540 |
|
def test_setCoefficient_m_reduced_Scalar_using_m(self): |
1541 |
|
d=self.domain.getDim() |
1542 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1543 |
|
mypde.setValue(d=Scalar(1.,ReducedFunctionOnBoundary(self.domain))) |
1544 |
|
coeff=mypde.getCoefficient("d_reduced") |
1545 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
1546 |
|
def test_setCoefficient_d_reduced_Scalar_using_d(self): |
1547 |
|
d=self.domain.getDim() |
1548 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1549 |
|
mypde.setValue(m=Scalar(1.,ReducedFunctionOnBoundary(self.domain))) |
1550 |
|
coeff=mypde.getCoefficient("m_reduced") |
1551 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnBoundary(self.domain),1,1)) |
1552 |
|
def test_setCoefficient_d_contact_reduced_Scalar_using_d_contact(self): |
1553 |
|
d=self.domain.getDim() |
1554 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1555 |
|
mypde.setValue(d_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain))) |
1556 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
1557 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1,1)) |
1558 |
|
def test_setCoefficient_y_contact_reduced_Scalar_using_y_contact(self): |
1559 |
|
d=self.domain.getDim() |
1560 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1561 |
|
mypde.setValue(y_contact=Scalar(1.,ReducedFunctionOnContactZero(self.domain))) |
1562 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
1563 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((),ReducedFunctionOnContactZero(self.domain),1)) |
1564 |
|
# |
1565 |
|
# set coefficients for systems: |
1566 |
|
# |
1567 |
|
def test_setCoefficient_M_System(self): |
1568 |
|
d=self.domain.getDim() |
1569 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1570 |
|
mypde.setValue(M=numarray.ones((self.N,self.N))) |
1571 |
|
coeff=mypde.getCoefficient("M") |
1572 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N)) |
1573 |
|
def test_setCoefficient_A_System(self): |
1574 |
|
d=self.domain.getDim() |
1575 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1576 |
|
mypde.setValue(A=numarray.ones((self.N,d,self.N,d))) |
1577 |
|
coeff=mypde.getCoefficient("A") |
1578 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),Function(self.domain),self.N,self.N)) |
1579 |
|
def test_setCoefficient_B_System(self): |
1580 |
|
d=self.domain.getDim() |
1581 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1582 |
|
mypde.setValue(B=numarray.ones((self.N,d,self.N))) |
1583 |
|
coeff=mypde.getCoefficient("B") |
1584 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),Function(self.domain),self.N,self.N)) |
1585 |
|
def test_setCoefficient_C_System(self): |
1586 |
|
d=self.domain.getDim() |
1587 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1588 |
|
mypde.setValue(C=numarray.ones((self.N,self.N,d))) |
1589 |
|
coeff=mypde.getCoefficient("C") |
1590 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),Function(self.domain),self.N,self.N)) |
1591 |
|
def test_setCoefficient_D_System(self): |
1592 |
|
d=self.domain.getDim() |
1593 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1594 |
|
mypde.setValue(D=numarray.ones((self.N,self.N))) |
1595 |
|
coeff=mypde.getCoefficient("D") |
1596 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),Function(self.domain),self.N,self.N)) |
1597 |
|
def test_setCoefficient_X_System(self): |
1598 |
|
d=self.domain.getDim() |
1599 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1600 |
|
mypde.setValue(X=numarray.ones((self.N,d))) |
1601 |
|
coeff=mypde.getCoefficient("X") |
1602 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),Function(self.domain),self.N)) |
1603 |
|
def test_setCoefficient_Y_System(self): |
1604 |
|
d=self.domain.getDim() |
1605 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1606 |
|
mypde.setValue(Y=numarray.ones((self.N,))) |
1607 |
|
coeff=mypde.getCoefficient("Y") |
1608 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),Function(self.domain),self.N)) |
1609 |
|
def test_setCoefficient_y_System(self): |
1610 |
|
d=self.domain.getDim() |
1611 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1612 |
|
mypde.setValue(y=numarray.ones((self.N,))) |
1613 |
|
coeff=mypde.getCoefficient("y") |
1614 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnBoundary(self.domain),self.N)) |
1615 |
|
def test_setCoefficient_m_System(self): |
1616 |
|
d=self.domain.getDim() |
1617 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1618 |
|
mypde.setValue(m=numarray.ones((self.N,self.N))) |
1619 |
|
coeff=mypde.getCoefficient("m") |
1620 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N)) |
1621 |
|
def test_setCoefficient_d_System(self): |
1622 |
|
d=self.domain.getDim() |
1623 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1624 |
|
mypde.setValue(d=numarray.ones((self.N,self.N))) |
1625 |
|
coeff=mypde.getCoefficient("d") |
1626 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnBoundary(self.domain),self.N,self.N)) |
1627 |
|
def test_setCoefficient_d_contact_System(self): |
1628 |
|
d=self.domain.getDim() |
1629 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1630 |
|
mypde.setValue(d_contact=numarray.ones((self.N,self.N))) |
1631 |
|
coeff=mypde.getCoefficient("d_contact") |
1632 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),FunctionOnContactZero(self.domain),self.N,self.N)) |
1633 |
|
def test_setCoefficient_y_contact_System(self): |
1634 |
|
d=self.domain.getDim() |
1635 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1636 |
|
mypde.setValue(y_contact=numarray.ones((self.N,))) |
1637 |
|
coeff=mypde.getCoefficient("y_contact") |
1638 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),FunctionOnContactZero(self.domain),self.N)) |
1639 |
|
def test_setCoefficient_M_System_reduced(self): |
1640 |
|
d=self.domain.getDim() |
1641 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1642 |
|
mypde.setValue(M_reduced=numarray.ones((self.N,self.N))) |
1643 |
|
coeff=mypde.getCoefficient("M_reduced") |
1644 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1645 |
|
def test_setCoefficient_A_reduced_System(self): |
1646 |
|
d=self.domain.getDim() |
1647 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1648 |
|
mypde.setValue(A_reduced=numarray.ones((self.N,d,self.N,d))) |
1649 |
|
coeff=mypde.getCoefficient("A_reduced") |
1650 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
1651 |
|
def test_setCoefficient_B_reduced_System(self): |
1652 |
|
d=self.domain.getDim() |
1653 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1654 |
|
mypde.setValue(B_reduced=numarray.ones((self.N,d,self.N))) |
1655 |
|
coeff=mypde.getCoefficient("B_reduced") |
1656 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1657 |
|
def test_setCoefficient_C_reduced_System(self): |
1658 |
|
d=self.domain.getDim() |
1659 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1660 |
|
mypde.setValue(C_reduced=numarray.ones((self.N,self.N,d))) |
1661 |
|
coeff=mypde.getCoefficient("C_reduced") |
1662 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
1663 |
|
def test_setCoefficient_D_System_reduced(self): |
1664 |
|
d=self.domain.getDim() |
1665 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1666 |
|
mypde.setValue(D_reduced=numarray.ones((self.N,self.N))) |
1667 |
|
coeff=mypde.getCoefficient("D_reduced") |
1668 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1669 |
|
def test_setCoefficient_X_System_reduced(self): |
1670 |
|
d=self.domain.getDim() |
1671 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1672 |
|
mypde.setValue(X_reduced=numarray.ones((self.N,d))) |
1673 |
|
coeff=mypde.getCoefficient("X_reduced") |
1674 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N)) |
1675 |
|
def test_setCoefficient_Y_System_reduced(self): |
1676 |
|
d=self.domain.getDim() |
1677 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1678 |
|
mypde.setValue(Y_reduced=numarray.ones((self.N,))) |
1679 |
|
coeff=mypde.getCoefficient("Y_reduced") |
1680 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N)) |
1681 |
|
def test_setCoefficient_y_System_reduced(self): |
1682 |
|
d=self.domain.getDim() |
1683 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1684 |
|
mypde.setValue(y_reduced=numarray.ones((self.N,))) |
1685 |
|
coeff=mypde.getCoefficient("y_reduced") |
1686 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N)) |
1687 |
|
def test_setCoefficient_m_reduced_System(self): |
1688 |
|
d=self.domain.getDim() |
1689 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1690 |
|
mypde.setValue(m_reduced=numarray.ones((self.N,self.N))) |
1691 |
|
coeff=mypde.getCoefficient("m_reduced") |
1692 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
1693 |
|
def test_setCoefficient_d_reduced_System(self): |
1694 |
|
d=self.domain.getDim() |
1695 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1696 |
|
mypde.setValue(d_reduced=numarray.ones((self.N,self.N))) |
1697 |
|
coeff=mypde.getCoefficient("d_reduced") |
1698 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
1699 |
|
def test_setCoefficient_d_contact_reduced_System(self): |
1700 |
|
d=self.domain.getDim() |
1701 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1702 |
|
mypde.setValue(d_contact_reduced=numarray.ones((self.N,self.N))) |
1703 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
1704 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N)) |
1705 |
|
def test_setCoefficient_y_contact_reduced_System(self): |
1706 |
|
d=self.domain.getDim() |
1707 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1708 |
|
mypde.setValue(y_contact_reduced=numarray.ones((self.N,))) |
1709 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
1710 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N)) |
1711 |
|
def test_setCoefficient_r_System(self): |
1712 |
|
d=self.domain.getDim() |
1713 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1714 |
|
mypde.setValue(r=numarray.ones((self.N,))) |
1715 |
|
coeff=mypde.getCoefficient("r") |
1716 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
1717 |
|
def test_setCoefficient_q_System(self): |
1718 |
|
d=self.domain.getDim() |
1719 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1720 |
|
mypde.setValue(q=numarray.ones((self.N,))) |
1721 |
|
coeff=mypde.getCoefficient("q") |
1722 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),Solution(self.domain),self.N)) |
1723 |
|
def test_setCoefficient_r_System_reducedOn(self): |
1724 |
|
d=self.domain.getDim() |
1725 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1726 |
|
mypde.setReducedOrderOn() |
1727 |
|
mypde.setValue(r=numarray.ones((self.N,))) |
1728 |
|
coeff=mypde.getCoefficient("r") |
1729 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
1730 |
|
def test_setCoefficient_q_System_reducedOn(self): |
1731 |
|
d=self.domain.getDim() |
1732 |
|
mypde=TransportPDE(self.domain,numEquations=3,debug=self.DEBUG) |
1733 |
|
mypde.setReducedOrderOn() |
1734 |
|
mypde.setValue(q=numarray.ones((self.N,))) |
1735 |
|
coeff=mypde.getCoefficient("q") |
1736 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions()),((self.N,),ReducedSolution(self.domain),self.N)) |
1737 |
|
|
1738 |
|
def test_setCoefficient_M_System_reduced_using_D(self): |
1739 |
|
d=self.domain.getDim() |
1740 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1741 |
|
mypde.setValue(M=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain))) |
1742 |
|
coeff=mypde.getCoefficient("M_reduced") |
1743 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1744 |
|
def test_setCoefficient_A_reduced_System_using_A(self): |
1745 |
|
d=self.domain.getDim() |
1746 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1747 |
|
mypde.setValue(A=Data(numarray.ones((self.N,d,self.N,d)),ReducedFunction(self.domain))) |
1748 |
|
coeff=mypde.getCoefficient("A_reduced") |
1749 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
1750 |
|
def test_setCoefficient_B_reduced_System_using_B(self): |
1751 |
|
d=self.domain.getDim() |
1752 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1753 |
|
mypde.setValue(B=Data(numarray.ones((self.N,d,self.N)),ReducedFunction(self.domain))) |
1754 |
|
coeff=mypde.getCoefficient("B_reduced") |
1755 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,d,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1756 |
|
def test_setCoefficient_C_reduced_System_using_C(self): |
1757 |
|
d=self.domain.getDim() |
1758 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1759 |
|
mypde.setValue(C=Data(numarray.ones((self.N,self.N,d)),ReducedFunction(self.domain))) |
1760 |
|
coeff=mypde.getCoefficient("C_reduced") |
1761 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N,d),ReducedFunction(self.domain),self.N,self.N)) |
1762 |
|
def test_setCoefficient_D_System_reduced_using_D(self): |
1763 |
|
d=self.domain.getDim() |
1764 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1765 |
|
mypde.setValue(D=Data(numarray.ones((self.N,self.N)),ReducedFunction(self.domain))) |
1766 |
|
coeff=mypde.getCoefficient("D_reduced") |
1767 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunction(self.domain),self.N,self.N)) |
1768 |
|
def test_setCoefficient_X_System_reduced_using_X(self): |
1769 |
|
d=self.domain.getDim() |
1770 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1771 |
|
mypde.setValue(X=Data(numarray.ones((self.N,d)),ReducedFunction(self.domain))) |
1772 |
|
coeff=mypde.getCoefficient("X_reduced") |
1773 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,d),ReducedFunction(self.domain),self.N)) |
1774 |
|
def test_setCoefficient_Y_System_reduced_using_Y(self): |
1775 |
|
d=self.domain.getDim() |
1776 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1777 |
|
mypde.setValue(Y=Data(numarray.ones((self.N,)),ReducedFunction(self.domain))) |
1778 |
|
coeff=mypde.getCoefficient("Y_reduced") |
1779 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunction(self.domain),self.N)) |
1780 |
|
def test_setCoefficient_y_reduced_System_using_y(self): |
1781 |
|
d=self.domain.getDim() |
1782 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1783 |
|
mypde.setValue(y=Data(numarray.ones((self.N,)),ReducedFunctionOnBoundary(self.domain))) |
1784 |
|
coeff=mypde.getCoefficient("y_reduced") |
1785 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnBoundary(self.domain),self.N)) |
1786 |
|
def test_setCoefficient_m_reduced_System_using_m(self): |
1787 |
|
d=self.domain.getDim() |
1788 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1789 |
|
mypde.setValue(m=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain))) |
1790 |
|
coeff=mypde.getCoefficient("m_reduced") |
1791 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
1792 |
|
def test_setCoefficient_d_reduced_System_using_d(self): |
1793 |
|
d=self.domain.getDim() |
1794 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1795 |
|
mypde.setValue(d=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnBoundary(self.domain))) |
1796 |
|
coeff=mypde.getCoefficient("d_reduced") |
1797 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnBoundary(self.domain),self.N,self.N)) |
1798 |
|
def test_setCoefficient_d_contact_reduced_System_using_d_contact(self): |
1799 |
|
d=self.domain.getDim() |
1800 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1801 |
|
mypde.setValue(d_contact=Data(numarray.ones((self.N,self.N)),ReducedFunctionOnContactZero(self.domain))) |
1802 |
|
coeff=mypde.getCoefficient("d_contact_reduced") |
1803 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumSolutions(),mypde.getNumEquations()),((self.N,self.N),ReducedFunctionOnContactZero(self.domain),self.N,self.N)) |
1804 |
|
def test_setCoefficient_y_contact_reduced_System_using_y_contact(self): |
1805 |
|
d=self.domain.getDim() |
1806 |
|
mypde=TransportPDE(self.domain,numSolutions=3,debug=self.DEBUG) |
1807 |
|
mypde.setValue(y_contact=Data(numarray.ones((self.N,)),ReducedFunctionOnContactZero(self.domain))) |
1808 |
|
coeff=mypde.getCoefficient("y_contact_reduced") |
1809 |
|
self.failUnlessEqual((coeff.getShape(),coeff.getFunctionSpace(),mypde.getNumEquations()),((self.N,),ReducedFunctionOnContactZero(self.domain),self.N)) |
1810 |
|
|
1811 |
|
def test_symmetryCheckTrue_System(self): |
1812 |
|
d=self.domain.getDim() |
1813 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1814 |
|
M=100*numarray.ones((self.N,self.N)) |
1815 |
|
A=numarray.ones((self.N,d,self.N,d)) |
1816 |
|
C=2*numarray.ones((self.N,self.N,d)) |
1817 |
|
B=2*numarray.ones((self.N,d,self.N)) |
1818 |
|
D=3*numarray.ones((self.N,self.N)) |
1819 |
|
d=4*numarray.ones((self.N,self.N)) |
1820 |
|
m=64*numarray.ones((self.N,self.N)) |
1821 |
|
d_contact=5*numarray.ones((self.N,self.N)) |
1822 |
|
mypde.setValue(M=M,A=A,B=B,C=C,D=D,d=d,d_contact=d_contact,m=m,M_reduced=-M,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact, m_reduced=-m) |
1823 |
|
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
1824 |
|
|
1825 |
|
def test_symmetryCheckFalse_M_System(self): |
1826 |
|
d=self.domain.getDim() |
1827 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1828 |
|
M=numarray.ones((self.N,self.N)) |
1829 |
|
M[1,0]=0. |
1830 |
|
mypde.setValue(M=M) |
1831 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1832 |
|
|
1833 |
|
def test_symmetryCheckFalse_A_System(self): |
1834 |
|
d=self.domain.getDim() |
1835 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1836 |
|
A=numarray.ones((self.N,d,self.N,d)) |
1837 |
|
A[1,1,1,0]=0. |
1838 |
|
mypde.setValue(A=A) |
1839 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1840 |
|
|
1841 |
|
def test_symmetryCheckFalse_BC_System(self): |
1842 |
|
d=self.domain.getDim() |
1843 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1844 |
|
C=2*numarray.ones((self.N,self.N,d)) |
1845 |
|
B=2*numarray.ones((self.N,d,self.N)) |
1846 |
|
B[0,0,1]=1. |
1847 |
|
mypde.setValue(B=B,C=C) |
1848 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1849 |
|
|
1850 |
|
def test_symmetryCheckFalse_D_System(self): |
1851 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1852 |
|
D=3*numarray.ones((self.N,self.N)) |
1853 |
|
D[0,1]=0. |
1854 |
|
mypde.setValue(D=D) |
1855 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1856 |
|
|
1857 |
|
def test_symmetryCheckFalse_m_System(self): |
1858 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1859 |
|
m=4*numarray.ones((self.N,self.N)) |
1860 |
|
m[0,1]=0. |
1861 |
|
mypde.setValue(m=m) |
1862 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1863 |
|
|
1864 |
|
def test_symmetryCheckFalse_d_System(self): |
1865 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1866 |
|
d=4*numarray.ones((self.N,self.N)) |
1867 |
|
d[0,1]=0. |
1868 |
|
mypde.setValue(d=d) |
1869 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1870 |
|
|
1871 |
|
def test_symmetryCheckFalse_d_contact_System(self): |
1872 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1873 |
|
d_contact=5*numarray.ones((self.N,self.N)) |
1874 |
|
d_contact[0,1]=0. |
1875 |
|
mypde.setValue(d_contact=d_contact) |
1876 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1877 |
|
|
1878 |
|
def test_symmetryCheckFalse_M_reduced_System(self): |
1879 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1880 |
|
M=3*numarray.ones((self.N,self.N)) |
1881 |
|
M[0,1]=0. |
1882 |
|
mypde.setValue(M_reduced=M) |
1883 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1884 |
|
|
1885 |
|
def test_symmetryCheckFalse_A_reduced_System(self): |
1886 |
|
d=self.domain.getDim() |
1887 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1888 |
|
A=numarray.ones((self.N,d,self.N,d)) |
1889 |
|
A[1,1,1,0]=0. |
1890 |
|
mypde.setValue(A_reduced=A) |
1891 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1892 |
|
|
1893 |
|
def test_symmetryCheckFalse_BC_reduced_System(self): |
1894 |
|
d=self.domain.getDim() |
1895 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1896 |
|
C=2*numarray.ones((self.N,self.N,d)) |
1897 |
|
B=2*numarray.ones((self.N,d,self.N)) |
1898 |
|
B[0,0,1]=1. |
1899 |
|
mypde.setValue(B_reduced=B,C_reduced=C) |
1900 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1901 |
|
|
1902 |
|
def test_symmetryCheckFalse_D_reduced_System(self): |
1903 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1904 |
|
D=3*numarray.ones((self.N,self.N)) |
1905 |
|
D[0,1]=0. |
1906 |
|
mypde.setValue(D_reduced=D) |
1907 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1908 |
|
|
1909 |
|
def test_symmetryCheckFalse_m_reduced_System(self): |
1910 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1911 |
|
m=4*numarray.ones((self.N,self.N)) |
1912 |
|
m[0,1]=0. |
1913 |
|
mypde.setValue(m_reduced=m) |
1914 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1915 |
|
|
1916 |
|
def test_symmetryCheckFalse_d_reduced_System(self): |
1917 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1918 |
|
d=4*numarray.ones((self.N,self.N)) |
1919 |
|
d[0,1]=0. |
1920 |
|
mypde.setValue(d_reduced=d) |
1921 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1922 |
|
|
1923 |
|
def test_symmetryCheckFalse_d_contact_reduced_System(self): |
1924 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1925 |
|
d_contact=5*numarray.ones((self.N,self.N)) |
1926 |
|
d_contact[0,1]=0. |
1927 |
|
mypde.setValue(d_contact_reduced=d_contact) |
1928 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1929 |
|
|
1930 |
|
#============================================================== |
1931 |
|
def test_symmetryCheckTrue_Scalar(self): |
1932 |
|
d=self.domain.getDim() |
1933 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1934 |
|
M=100 |
1935 |
|
A=numarray.ones((d,d)) |
1936 |
|
C=2*numarray.ones((d,)) |
1937 |
|
B=2*numarray.ones((d,)) |
1938 |
|
D=3 |
1939 |
|
m=10 |
1940 |
|
d=4 |
1941 |
|
d_contact=5 |
1942 |
|
mypde.setValue(M=M,A=A,B=B,C=C,D=D,d=d,m=m,d_contact=d_contact,M_reduced=-M,A_reduced=-A,B_reduced=-B,C_reduced=-C,D_reduced=-D,d_reduced=-d,d_contact_reduced=-d_contact,m_reduced=-m) |
1943 |
|
self.failUnless(mypde.checkSymmetry(verbose=False),"symmetry detected") |
1944 |
|
|
1945 |
|
def test_symmetryCheckFalse_A_Scalar(self): |
1946 |
|
d=self.domain.getDim() |
1947 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1948 |
|
A=numarray.ones((d,d)) |
1949 |
|
A[1,0]=0. |
1950 |
|
mypde.setValue(A=A) |
1951 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1952 |
|
def test_symmetryCheckFalse_BC_Scalar(self): |
1953 |
|
d=self.domain.getDim() |
1954 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1955 |
|
C=2*numarray.ones((d,)) |
1956 |
|
B=2*numarray.ones((d,)) |
1957 |
|
B[0]=1. |
1958 |
|
mypde.setValue(B=B,C=C) |
1959 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1960 |
|
def test_symmetryCheckFalse_A_reduced_Scalar(self): |
1961 |
|
d=self.domain.getDim() |
1962 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1963 |
|
A=numarray.ones((d,d)) |
1964 |
|
A[1,0]=0. |
1965 |
|
mypde.setValue(A_reduced=A) |
1966 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1967 |
|
def test_symmetryCheckFalse_BC_reduced_Scalar(self): |
1968 |
|
d=self.domain.getDim() |
1969 |
|
mypde=TransportPDE(self.domain,debug=self.DEBUG) |
1970 |
|
C=2*numarray.ones((d,)) |
1971 |
|
B=2*numarray.ones((d,)) |
1972 |
|
B[0]=1. |
1973 |
|
mypde.setValue(B_reduced=B,C_reduced=C) |
1974 |
|
self.failUnless(not mypde.checkSymmetry(verbose=False),"symmetry detected") |
1975 |
|
|
1976 |
|
def test_reducedOn(self): |
1977 |
|
dt=0.1 |
1978 |
|
mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG) |
1979 |
|
mypde.setReducedOrderOn() |
1980 |
|
mypde.setInitialSolution(10.) |
1981 |
|
mypde.setValue(M=1.,Y=1) |
1982 |
|
u=mypde.getSolution(dt) |
1983 |
|
self.failUnless(u.getFunctionSpace() == ReducedSolution(self.domain), "wrong function space") |
1984 |
|
self.failUnless(self.check(u,10.+dt),'solution is wrong.') |
1985 |
|
|
1986 |
|
def Off_test_reducedOff(self): |
1987 |
|
dt=0.1 |
1988 |
|
mypde=TransportPDE(self.domain,numSolutions=1,debug=self.DEBUG) |
1989 |
|
mypde.setInitialSolution(10.) |
1990 |
|
mypde.setValue(M=1.,Y=1.) |
1991 |
|
u=mypde.getSolution(0.1) |
1992 |
|
self.failUnless(u.getFunctionSpace() == Solution(self.domain), "wrong function space") |
1993 |
|
self.failUnless(self.check(u,10.+dt),'solution is wrong.') |