I’m trying to solve Poisson equations on the layered cylindrical mesh with Fenics 2019.1.0.
For each subdomain there is a conductivity tensor
basis_conds
defined. For some values of basis_conds
, however, the assembled matrix contains only zeros (A.nnz() = 0
). Here is the code that I’m using:
mesh = femg.fwd_fem.read_mesh_xdmf(os.path.join(data_dir, '4shell_cylinder_mesh.xdmf'))
subdomains = femg.fwd_fem.read_mesh_function_xdmf(mesh, os.path.join(data_dir, '4shell_cylinder_subdomains.xdmf'), 3)
basis_conds = {8: 1. * np.eye(3),
9: 2. * np.eye(3),
10: 3. * np.eye(3),
11: 4. * np.eye(3)}
V = df.FunctionSpace(mesh, 'CG', 1)
u = df.TrialFunction(V)
v = df.TestFunction(V)
# Describe bilinear form as a som of integrals over subdomains
dx = df.Measure("dx")(domain=mesh, subdomain_data=subdomains)
form_list = []
for label in basis_conds.keys():
cond_tensor = df.as_matrix(basis_conds[label])
form_list.append(df.inner(df.dot(cond_tensor, df.grad(u)),
df.grad(v)) * dx(label))
a = sum(form_list)
A = df.assemble(a)
If I use multipliers 1, 2, 3, 4 for basis_conds
, A is well assembled. However, if for example I use multipliers 8, 9, 10, 11, matrix A contains only zeros. If I define these multipliers as random positive floats between 0 and 1, some times A is well assembled, some times not.
Where lies the problem and what should I change to make the algorithm robust to variation in conductivity tensors?
Thank you in advance.