Dear Community,
I am trying to collapse my results of Stokes flow to get the velocity and the pressure. However, collapsing the subspaces of the mpc.function_space
gives an error - only in parallel.
Is it possible that the error occurs if one rank has no DOFs of a certain subspace? Or are there other reasons? And how can this be fixed?
Here is the MWE: [vel = func_sol.sub(0).collapse()
does work, but sub(1).collapse
is not possible]
import dolfinx
import dolfinx_mpc
import basix.ufl
import numpy as np
from mpi4py import MPI
# mesh
n_ele = 200
domain = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, n_ele, n_ele, dolfinx.mesh.CellType.quadrilateral)
# Taylor-Hood elements and Mixed Functionspace
P2 = basix.ufl.element("Lagrange", domain.topology.cell_name(), 2, gdim=domain.geometry.dim, shape=(domain.geometry.dim, ))
P1 = basix.ufl.element("Lagrange", domain.topology.cell_name(), 1, gdim=domain.geometry.dim)
TH = basix.ufl.mixed_element([P2, P1])
V = dolfinx.fem.functionspace(domain, TH)
# periodic bcs
mpc = dolfinx_mpc.MultiPointConstraint(V)
def PeriodicBoundary(x):
return np.isclose(x[1], 1., atol=1e-5)
facets = dolfinx.mesh.locate_entities_boundary(domain, domain.topology.dim - 1, PeriodicBoundary)
arg_sort = np.argsort(facets)
mt = dolfinx.mesh.meshtags(domain, domain.topology.dim - 1, facets[arg_sort], np.full(len(facets), 2, dtype=np.int32))
def periodic_relation(x):
out_x = np.zeros(x.shape)
out_x[0] = x[0]
out_x[1] = 1 - x[1]
out_x[2] = x[2]
return out_x
bcs = []
mpc.create_periodic_constraint_topological(V.sub(0).sub(0), mt, 2, periodic_relation, bcs)
mpc.create_periodic_constraint_topological(V.sub(0).sub(1), mt, 2, periodic_relation, bcs)
mpc.create_periodic_constraint_topological(V.sub(1), mt, 2, periodic_relation, bcs)
mpc.finalize()
# solution functionspace
func_sol = dolfinx.fem.Function(mpc.function_space)
# collapse functionspace
vel = func_sol.sub(0).collapse()
pre = func_sol.sub(1).collapse()
The error message is:
python3: /src/dolfinx/cpp/dolfinx/fem/DofMap.cpp:103: dolfinx::fem::DofMap {anonymous}::build_collapsed_dofmap(const dolfinx::fem::DofMap&, const dolfinx::mesh::Topology&): Assertion `idx + k < (int)old_to_new.size()' failed.