I am brand new to fenics and I am trying to implement the following strong form:
zsh_\ell
, sigma
, and i_\ell
are all known.
I have this as a weak from:
In particular, there are two extra (not in the mesh) degrees of freedom here, v_1
and v_2
. I discretized it as follows:
Where the bottom block row has the two extra equations for the two extra dofs.
This is based on the complete electrode model (see for example https://doi.org/10.1137/015206 or https://doi.org/10.3934/math.2021431)
Note that for my application, sigma is a 3x3 tensor, but I think i figured out how to that in dolfinx by just declaring, for example,
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 20, 20)
basis = dolfinx.fem.FunctionSpace(mesh, ("Lagrange", 2))
u = ufl.TrialFunction(basis)
v = ufl.TestFunction(basis)
sigma = dolfinx.fem.Constant(
mesh,
dolfinx.default_scalar_type([
[1,0,0],
[0,1,0],
[0,0,1],
]))
A = ufl.inner(sigma * ufl.grad(u), ufl.grad(v)) * ufl.dx
# Don't know how to get B,C,D above
M = # Don't know how to get full system matrix (block matrix?)
a = # or maybe I'm trying to get just a lhs representation?
f = dolfinx.fem.Constant(mesh, PETSc.ScalarType(1))
L = ufl.inner(f, v) * ufl.dx
...
bc = # don't know what to put here
problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()
Following the tutorials, it was pretty straight forward to get the above code. But I cannot figure out how to assemble the other terms over only the respective e_\ell
domains or how to combine all the terms into one LinearProblem to solve. I’ve written it as a block matrix, but I’m not familiar enough with doxfinx terms or running on a cluster (which I am) to know if this is best approached as a block matrix type of problem. Can you point me to some examples of this kind of assembly?
I am targeting an HPE Cray machine where I have dolfinx installed (dolfinx.__version__=='.0.7.2'
) and working via micromamba
and conda-forge
. My problem scope is 100+ time-harmonic frequencies, each an independent problem with 10+ million dofs. I mention this in case there are pitfalls waiting for me when I try to scale up from toy problems.