Skip to content

Commit

Permalink
lgmap now returns lgmap / dof_dset lgmap, +naming
Browse files Browse the repository at this point in the history
  • Loading branch information
emmarothwell1 committed Feb 15, 2024
1 parent 71ef88f commit 75d2c91
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ def __init__(self, function_space, name=None, boundary_set=frozenset()):
function_space.ufl_element(),
label=self._label)
self.function_space = function_space
self.name = name or (function_space.name + "_"
self.name = name or (function_space.name or "Restricted" + "_"
+ "_".join(sorted(
[str(i) for i in self.boundary_set])))

Expand Down Expand Up @@ -1225,51 +1225,7 @@ def dof_count(self):
return node_count*self.value_size

def local_to_global_map(self, bcs, lgmap=None):
if bcs is None or len(bcs) == 0:
return lgmap or self.dof_dset.lgmap
for bc in bcs:
fs = bc.function_space()
while fs.component is not None and fs.parent is not None:
fs = fs.parent
if fs.topological != self.topological:
raise RuntimeError("DirichletBC defined on a different FunctionSpace!")
unblocked = any(bc.function_space().component is not None
for bc in bcs)
if lgmap is None:
lgmap = self.dof_dset.lgmap
if unblocked:
indices = lgmap.indices.copy()
bsize = 1
else:
indices = lgmap.block_indices.copy()
bsize = lgmap.getBlockSize()
assert bsize == self.value_size
else:
# MatBlock case, LGMap is already unrolled.
indices = lgmap.block_indices.copy()
bsize = lgmap.getBlockSize()
unblocked = True
nodes = []
for bc in bcs:
if bc.function_space().component is not None:
nodes.append(bc.nodes * self.value_size
+ bc.function_space().component)
elif unblocked:
tmp = bc.nodes * self.value_size
for i in range(self.value_size):
nodes.append(tmp + i)
else:
nodes.append(bc.nodes)
nodes = numpy.unique(numpy.concatenate(nodes))
indices[nodes] = -1
bc_node_count = 0
for node in range(len(indices)):
if indices[node] == -1:
bc_node_count += 1
else:
indices[node] -= bc_node_count
indices = indices[indices >= 0]
return PETSc.LGMap().create(indices, bsize=bsize, comm=lgmap.comm)
return lgmap or self.dof_dset.lgmap


@dataclass
Expand Down

0 comments on commit 75d2c91

Please sign in to comment.