Пример #1
0
fform = mfem.LinearForm()
fform.Update(R_space, rhs.GetBlock(0), 0)
fform.AddDomainIntegrator(mfem.VectorFEDomainLFIntegrator(fcoeff))
fform.AddBoundaryIntegrator(mfem.VectorFEBoundaryFluxLFIntegrator(fnatcoeff))
fform.Assemble()

gform = mfem.LinearForm()
gform.Update(W_space, rhs.GetBlock(1), 0)
gform.AddDomainIntegrator(mfem.DomainLFIntegrator(gcoeff))
gform.Assemble()

mVarf = mfem.BilinearForm(R_space)
bVarf = mfem.MixedBilinearForm(R_space, W_space)

mVarf.AddDomainIntegrator(mfem.VectorFEMassIntegrator(k))
mVarf.Assemble()
mVarf.Finalize()
M = mVarf.SpMat()

bVarf.AddDomainIntegrator(mfem.VectorFEDivergenceIntegrator())
bVarf.Assemble()
bVarf.Finalize()
B = bVarf.SpMat()
B *= -1
BT = mfem.Transpose(B)

darcyOp = mfem.BlockOperator(block_offsets)
darcyOp.SetBlock(0, 0, M)
darcyOp.SetBlock(0, 1, BT)
darcyOp.SetBlock(1, 0, B)
Пример #2
0
#    r.h.s. vector b.

#from mfem.examples.ex3 import E_exact_cb
x = mfem.GridFunction(fespace)
E = E_exact()
x.ProjectCoefficient(E);

# 8. Set up the bilinear form corresponding to the EM diffusion operator
#       curl muinv curl + sigma I, by adding the curl-curl and the mass domain
#       integrators.

muinv = mfem.ConstantCoefficient(1.0);
sigma = mfem.ConstantCoefficient(1.0);
a = mfem.BilinearForm(fespace);
a.AddDomainIntegrator(mfem.CurlCurlIntegrator(muinv));
a.AddDomainIntegrator(mfem.VectorFEMassIntegrator(sigma));

# 9. Assemble the bilinear form and the corresponding linear system,
#       applying any necessary transformations such as: eliminating boundary
#       conditions, applying conforming constraints for non-conforming AMR,
#       static condensation, etc.


if (static_cond):  a.EnableStaticCondensation()
a.Assemble();

A = mfem.SparseMatrix()
B = mfem.Vector()
X = mfem.Vector()
a.FormLinearSystem(ess_tdof_list, x, b, A, X, B);
## Here, original version calls hegith, which is not
Пример #3
0
b = mfem.LinearForm(fespace)
f = f_exact()
dd = mfem.VectorFEDomainLFIntegrator(f)
b.AddDomainIntegrator(dd)
b.Assemble()

x = mfem.GridFunction(fespace)
F = E_exact()
x.ProjectCoefficient(F)

alpha = mfem.ConstantCoefficient(1.0)
beta = mfem.ConstantCoefficient(1.0)
a = mfem.BilinearForm(fespace)
a.AddDomainIntegrator(mfem.DivDivIntegrator(alpha))
a.AddDomainIntegrator(mfem.VectorFEMassIntegrator(beta))

if (static_cond): a.EnableStaticCondensation()
elif (hybridization):
    hfec = mfem.DG_Interface_FECollection(order - 1, dim)
    hfes = mfem.FiniteElementSpace(mesh, hfec)
    a.EnableHybridization(hfes, mfem.NormalTraceJumpIntegrator(),
                          ess_tdof_list)
a.Assemble()

A = mfem.SparseMatrix()
B = mfem.Vector()
X = mfem.Vector()
a.FormLinearSystem(ess_tdof_list, x, b, A, X, B)
## Here, original version calls hegith, which is not
## defined in the header...!?