Solve a linear boundary value problem A(u,v) = f(v) Parameters ---------- bf : BilinearForm provides the matrix. lf : LinearForm provides the right hand side. gf : GridFunction provides the solution vector pre : Basematrix or class or string = None used if an iterative solver is u
(bf, lf, gf, \
pre=None, pre_flags={}, \
solver=None, solver_flags={},
maxsteps=200, tol=1e-8, print=True, inverse="umfpack",
needsassembling=True)
| 1 | |
| 2 | def BVP(bf, lf, gf, \ |
| 3 | pre=None, pre_flags={}, \ |
| 4 | solver=None, solver_flags={}, |
| 5 | maxsteps=200, tol=1e-8, print=True, inverse="umfpack", |
| 6 | needsassembling=True): |
| 7 | """ |
| 8 | Solve a linear boundary value problem A(u,v) = f(v) |
| 9 | |
| 10 | Parameters |
| 11 | ---------- |
| 12 | |
| 13 | bf : BilinearForm |
| 14 | provides the matrix. |
| 15 | |
| 16 | lf : LinearForm |
| 17 | provides the right hand side. |
| 18 | |
| 19 | gf : GridFunction |
| 20 | provides the solution vector |
| 21 | |
| 22 | pre : Basematrix or class or string = None |
| 23 | used if an iterative solver is used |
| 24 | can be one of |
| 25 | * a preconditioner object |
| 26 | * a preconditioner class |
| 27 | * a preconditioner class name |
| 28 | |
| 29 | pre_flags : dictionary = { } |
| 30 | flags used to create preconditioner |
| 31 | |
| 32 | |
| 33 | """ |
| 34 | from ngsolve import Projector, Preconditioner |
| 35 | from ngsolve.krylovspace import CG |
| 36 | |
| 37 | |
| 38 | if isinstance(pre,type): |
| 39 | pre = pre(bf, **pre_flags) |
| 40 | if not needsassembling: |
| 41 | pre.Update() |
| 42 | |
| 43 | if isinstance(pre,str): |
| 44 | pre = Preconditioner(bf, pre, **pre_flags) |
| 45 | if not needsassembling: |
| 46 | pre.Update() |
| 47 | |
| 48 | |
| 49 | if needsassembling: |
| 50 | bf.Assemble() |
| 51 | lf.Assemble() |
| 52 | |
| 53 | r = lf.vec.CreateVector() |
| 54 | r.data = lf.vec |
| 55 | |
| 56 | if bf.condense: |
| 57 | r.data += bf.harmonic_extension_trans * r |
| 58 | |
| 59 | # zero local dofs |
| 60 | innerbits = gf.space.FreeDofs(False) & ~gf.space.FreeDofs(True) |
no test coverage detected