7 |
- Projector - to project a discontinuous |
- Projector - to project a discontinuous |
8 |
- Locator - to trace values in data objects at a certain location |
- Locator - to trace values in data objects at a certain location |
9 |
- TimeIntegrationManager - to handel extraplotion in time |
- TimeIntegrationManager - to handel extraplotion in time |
10 |
|
- SaddlePointProblem - solver for Saddle point problems using the inexact uszawa scheme |
11 |
|
|
12 |
@var __author__: name of author |
@var __author__: name of author |
13 |
@var __copyright__: copyrights |
@var __copyright__: copyrights |
354 |
else: |
else: |
355 |
return data |
return data |
356 |
|
|
357 |
|
class SaddlePointProblem(object): |
358 |
|
""" |
359 |
|
This implements a solver for a saddlepoint problem |
360 |
|
|
361 |
|
f(u,p)=0 |
362 |
|
g(u)=0 |
363 |
|
|
364 |
|
for u and p. The problem is solved with an inexact Uszawa scheme for p: |
365 |
|
|
366 |
|
Q_f (u^{k+1}-u^{k}) = - f(u^{k},p^{k}) |
367 |
|
Q_g (p^{k+1}-p^{k}) = g(u^{k+1}) |
368 |
|
|
369 |
|
where Q_f is an approximation of the Jacobiean A_f of f with respect to u and Q_f is an approximation of |
370 |
|
A_g A_f^{-1} A_g with A_g is the jacobiean of g with respect to p. As a the construction of a 'proper' |
371 |
|
Q_g can be difficult, non-linear conjugate gradient method is applied to solve for p, so Q_g plays |
372 |
|
in fact the role of a preconditioner. |
373 |
|
""" |
374 |
|
def __init__(self,verbose=False,*args): |
375 |
|
""" |
376 |
|
initializes the problem |
377 |
|
|
378 |
|
@parm verbose: switches on the printing out some information |
379 |
|
@type verbose: C{bool} |
380 |
|
@note: this method may be overwritten by a particular saddle point problem |
381 |
|
""" |
382 |
|
self.__verbose=verbose |
383 |
|
|
384 |
|
def trace(self,text): |
385 |
|
""" |
386 |
|
prints text if verbose has been set |
387 |
|
|
388 |
|
@parm text: a text message |
389 |
|
@type text: C{str} |
390 |
|
""" |
391 |
|
if self.__verbose: print "%s: %s"%(str(self),text) |
392 |
|
|
393 |
|
def solve_f(self,u,p,tol=1.e-7,*args): |
394 |
|
""" |
395 |
|
solves |
396 |
|
|
397 |
|
A_f du = f(u,p) |
398 |
|
|
399 |
|
with tolerance C{tol} and return du. A_f is Jacobiean of f with respect to u. |
400 |
|
|
401 |
|
@param u: current approximation of u |
402 |
|
@type u: L{escript.Data} |
403 |
|
@param p: current approximation of p |
404 |
|
@type p: L{escript.Data} |
405 |
|
@param tol: tolerance for du |
406 |
|
@type tol: C{float} |
407 |
|
@return: increment du |
408 |
|
@rtype: L{escript.Data} |
409 |
|
@note: this method has to be overwritten by a particular saddle point problem |
410 |
|
""" |
411 |
|
pass |
412 |
|
|
413 |
|
def solve_g(self,u,*args): |
414 |
|
""" |
415 |
|
solves |
416 |
|
|
417 |
|
Q_g dp = g(u) |
418 |
|
|
419 |
|
with Q_g is a preconditioner for A_g A_f^{-1} A_g with A_g is the jacobiean of g with respect to p. |
420 |
|
|
421 |
|
@param u: current approximation of u |
422 |
|
@type u: L{escript.Data} |
423 |
|
@return: increment dp |
424 |
|
@rtype: L{escript.Data} |
425 |
|
@note: this method has to be overwritten by a particular saddle point problem |
426 |
|
""" |
427 |
|
pass |
428 |
|
|
429 |
|
def inner(self,p0,p1): |
430 |
|
""" |
431 |
|
inner product of p0 and p1 approximating p. Typically this returns integrate(p0*p1) |
432 |
|
@return: inner product of p0 and p1 |
433 |
|
@rtype: C{float} |
434 |
|
""" |
435 |
|
pass |
436 |
|
|
437 |
|
def solve(self,u0,p0,tolerance=1.e-6,*args): |
438 |
|
pass |
439 |
# vim: expandtab shiftwidth=4: |
# vim: expandtab shiftwidth=4: |