MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / BVP

Function BVP

python/bvp.py:2–77  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1
2def 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
10Parameters
11----------
12
13bf : BilinearForm
14 provides the matrix.
15
16lf : LinearForm
17 provides the right hand side.
18
19gf : GridFunction
20 provides the solution vector
21
22pre : 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
29pre_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)

Callers 4

scattering.pyFile · 0.85
d1_square.pyFile · 0.85
d5_beam.pyFile · 0.85
d2_chip.pyFile · 0.85

Calls 7

CGFunction · 0.90
PreconditionerClass · 0.85
ProjectMethod · 0.80
InverseMethod · 0.80
UpdateMethod · 0.45
AssembleMethod · 0.45
CreateVectorMethod · 0.45

Tested by

no test coverage detected