dokken
June 12, 2023, 9:25am
6
keep_diagonal
should not fix this issue by it-self, as it only keeps zero-entries in the sparsity pattern (ref: Bitbucket )
You would have to call ident_zeros
in legacy DOLFIN to resolve that issue (which would add identity rows in these places).
For this to be done with dolfinx, see for instance:
I guess you are referring to A.ident_zeros() in legacy dolfin?
As this simply calls petsc, you can still do this in DOLFINx, as illustrated in the following code:
(The following code is a refined snippet of @CastriMik code at thomas-fermi-demo/demo_tf_mwe.py at mpi-issue · mikics/thomas-fermi-demo · GitHub which avoid global communciation)
problem._A.zeroEntries()
fem.petsc.assemble_matrix(problem._A, problem._a, bcs=problem.bcs)
problem._A.assemble()
# Get diagonal of assembled A matrix
di…
or
I would suggest the following:
import time
import dolfinx
import numpy as np
import ufl
from dolfinx import cpp, fem
from mpi4py import MPI
from petsc4py import PETSc
N = 75
degree = 1
mesh = dolfinx.mesh.create_unit_cube(MPI.COMM_WORLD, N, N, N)
V = dolfinx.fem.FunctionSpace(mesh, ("CG", degree))
u = ufl.TrialFunction(V)
v = ufl.TestFunction(V)
print(
f"N={N}, Num dofs global {V.dofmap.index_map.size_global*V.dofmap.index_map_bs}")
# form is defined on the boundary => matrix wil have man…