17 |
The general interface is provided through the L{LinearPDE} class. The |
The general interface is provided through the L{LinearPDE} class. The |
18 |
L{AdvectivePDE} which is derived from the L{LinearPDE} class |
L{AdvectivePDE} which is derived from the L{LinearPDE} class |
19 |
provides an interface to PDE dominated by its advective terms. The L{Poisson}, |
provides an interface to PDE dominated by its advective terms. The L{Poisson}, |
20 |
L{Helmholtz}, L{LameEquation} |
L{Helmholtz}, L{LameEquation}, L{AdvectionDiffusion} |
21 |
classs which are also derived form the L{LinearPDE} class should be used |
classs which are also derived form the L{LinearPDE} class should be used |
22 |
to define of solve these sepecial PDEs. |
to define of solve these sepecial PDEs. |
23 |
|
|
2242 |
elif name == "r" : |
elif name == "r" : |
2243 |
return self.getCoefficient("r") |
return self.getCoefficient("r") |
2244 |
elif name == "q" : |
elif name == "q" : |
2245 |
|
return self.getCoefficient("q") |
2246 |
|
else: |
2247 |
|
raise IllegalCoefficient,"illegal coefficient %s requested for general PDE."%name |
2248 |
|
|
2249 |
|
class AdvectionDiffusion(LinearPDE): |
2250 |
|
""" |
2251 |
|
Class to define PDE equation of the unisotropic advection-diffusion problem, which is genear L{LinearPDE} of the form |
2252 |
|
|
2253 |
|
M{S{omega}*u + inner(v,grad(u))- grad(matrixmult(k,grad(u))[j])[j] = f} |
2254 |
|
|
2255 |
|
with natural boundary conditons |
2256 |
|
|
2257 |
|
M{n[j]*matrixmult(k,grad(u))[j] = g- S{alpha}u } |
2258 |
|
|
2259 |
|
and constraints: |
2260 |
|
|
2261 |
|
M{u=r} where M{q>0} |
2262 |
|
|
2263 |
|
@remark: no upwinding is applied yet. |
2264 |
|
|
2265 |
|
""" |
2266 |
|
|
2267 |
|
def __init__(self,domain,debug=False): |
2268 |
|
""" |
2269 |
|
initializes a new Poisson equation |
2270 |
|
|
2271 |
|
@param domain: domain of the PDE |
2272 |
|
@type domain: L{Domain<escript.Domain>} |
2273 |
|
@param debug: if True debug informations are printed. |
2274 |
|
|
2275 |
|
""" |
2276 |
|
super(Helmholtz, self).__init__(domain,1,1,debug) |
2277 |
|
self.COEFFICIENTS={"omega": PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.BY_EQUATION,),PDECoefficient.OPERATOR), |
2278 |
|
"k": PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.BY_DIM,PDECoefficient.BY_DIM),PDECoefficient.OPERATOR), |
2279 |
|
"f": PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.BY_EQUATION,),PDECoefficient.RIGHTHANDSIDE), |
2280 |
|
"v": PDECoefficient(PDECoefficient.INTERIOR,(PDECoefficient.BY_DIM,),PDECoefficient.OPERATOR), |
2281 |
|
"alpha": PDECoefficient(PDECoefficient.BOUNDARY,(PDECoefficient.BY_EQUATION,),PDECoefficient.OPERATOR), |
2282 |
|
"g": PDECoefficient(PDECoefficient.BOUNDARY,(PDECoefficient.BY_EQUATION,),PDECoefficient.RIGHTHANDSIDE), |
2283 |
|
"r": PDECoefficient(PDECoefficient.SOLUTION,(PDECoefficient.BY_EQUATION,),PDECoefficient.BOTH), |
2284 |
|
"q": PDECoefficient(PDECoefficient.SOLUTION,(PDECoefficient.BY_EQUATION,),PDECoefficient.BOTH)} |
2285 |
|
|
2286 |
|
def setValue(self,**coefficients): |
2287 |
|
""" |
2288 |
|
sets new values to coefficients |
2289 |
|
|
2290 |
|
@param coefficients: new values assigned to coefficients |
2291 |
|
@keyword omega: value for coefficient M{S{omega}} |
2292 |
|
@type omega: any type that can be casted to L{Scalar<escript.Scalar>} object on L{Function<escript.Function>}. |
2293 |
|
@keyword k: value for coefficient M{k} |
2294 |
|
@type k: any type that can be casted to L{Tensor<escript.Tensor>} object on L{Function<escript.Function>}. |
2295 |
|
@keyword v: value for coefficient M{v} |
2296 |
|
@type v: any type that can be casted to L{Vector<escript.Vector>} object on L{Function<escript.Function>}. |
2297 |
|
@keyword f: value for right hand side M{f} |
2298 |
|
@type f: any type that can be casted to L{Scalar<escript.Scalar>} object on L{Function<escript.Function>}. |
2299 |
|
@keyword alpha: value for right hand side M{S{alpha}} |
2300 |
|
@type alpha: any type that can be casted to L{Scalar<escript.Scalar>} object on L{FunctionOnBoundary<escript.FunctionOnBoundary>}. |
2301 |
|
@keyword g: value for right hand side M{g} |
2302 |
|
@type g: any type that can be casted to L{Scalar<escript.Scalar>} object on L{FunctionOnBoundary<escript.FunctionOnBoundary>}. |
2303 |
|
@keyword r: prescribed values M{r} for the solution in constraints. |
2304 |
|
@type r: any type that can be casted to L{Scalar<escript.Scalar>} object on L{Solution<escript.Solution>} or L{ReducedSolution<escript.ReducedSolution>} |
2305 |
|
depending of reduced order is used for the representation of the equation. |
2306 |
|
@keyword q: mask for location of constraints |
2307 |
|
@type q: any type that can be casted to L{Scalar<escript.Scalar>} object on L{Solution<escript.Solution>} or L{ReducedSolution<escript.ReducedSolution>} |
2308 |
|
depending of reduced order is used for the representation of the equation. |
2309 |
|
@raise IllegalCoefficient: if an unknown coefficient keyword is used. |
2310 |
|
""" |
2311 |
|
super(Helmholtz, self).setValue(**coefficients) |
2312 |
|
|
2313 |
|
def getCoefficientOfGeneralPDE(self,name): |
2314 |
|
""" |
2315 |
|
return the value of the coefficient name of the general PDE |
2316 |
|
|
2317 |
|
@param name: name of the coefficient requested. |
2318 |
|
@type name: C{string} |
2319 |
|
@return: the value of the coefficient name |
2320 |
|
@rtype: L{Data<escript.Data>} |
2321 |
|
@raise IllegalCoefficient: if name is not one of coefficients |
2322 |
|
"A", M{B}, M{C}, M{D}, M{X}, M{Y}, M{d}, M{y}, M{d_contact}, M{y_contact}, M{r} or M{q}. |
2323 |
|
@note: This method is called by the assembling routine to map the Possion equation onto the general PDE. |
2324 |
|
""" |
2325 |
|
if name == "A" : |
2326 |
|
return escript.Data(numarray.identity(self.getDim()),escript.Function(self.getDomain()))*self.getCoefficient("k") |
2327 |
|
elif name == "B" : |
2328 |
|
return escript.Data() |
2329 |
|
elif name == "C" : |
2330 |
|
return escript.getCoefficient("v") |
2331 |
|
elif name == "D" : |
2332 |
|
return self.getCoefficient("omega") |
2333 |
|
elif name == "X" : |
2334 |
|
return escript.Data() |
2335 |
|
elif name == "Y" : |
2336 |
|
return self.getCoefficient("f") |
2337 |
|
elif name == "d" : |
2338 |
|
return self.getCoefficient("alpha") |
2339 |
|
elif name == "y" : |
2340 |
|
return self.getCoefficient("g") |
2341 |
|
elif name == "d_contact" : |
2342 |
|
return escript.Data() |
2343 |
|
elif name == "y_contact" : |
2344 |
|
return escript.Data() |
2345 |
|
elif name == "r" : |
2346 |
|
return self.getCoefficient("r") |
2347 |
|
elif name == "q" : |
2348 |
return self.getCoefficient("q") |
return self.getCoefficient("q") |
2349 |
else: |
else: |
2350 |
raise IllegalCoefficient,"illegal coefficient %s requested for general PDE."%name |
raise IllegalCoefficient,"illegal coefficient %s requested for general PDE."%name |