Skip to content

Commit

Permalink
EquationBC: do not reconstruct empty Forms
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Jan 5, 2025
1 parent d99ba50 commit d6bb7dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions firedrake/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ def __init__(self,
zero_bc_nodes=False,
diagonal=False,
weight=1.0,
allocation_integral_types=None,
needs_zeroing=False):
allocation_integral_types=None):
super().__init__(form, bcs=bcs, form_compiler_parameters=form_compiler_parameters)
self._mat_type = mat_type
self._sub_mat_type = sub_mat_type
Expand All @@ -322,7 +321,6 @@ def __init__(self,
self._diagonal = diagonal
self._weight = weight
self._allocation_integral_types = allocation_integral_types
assert not needs_zeroing

def allocate(self):
rank = len(self._form.arguments())
Expand Down Expand Up @@ -1129,8 +1127,7 @@ def _apply_bc(self, tensor, bc):
pass

def _check_tensor(self, tensor):
if not isinstance(tensor, op2.Global):
raise TypeError(f"Expecting a op2.Global, got {tensor!r}.")
pass

@staticmethod
def _as_pyop2_type(tensor, indices=None):
Expand Down Expand Up @@ -1192,8 +1189,8 @@ def _apply_bc(self, tensor, bc):
self._apply_dirichlet_bc(tensor, bc)
elif isinstance(bc, EquationBCSplit):
bc.zero(tensor)
get_assembler(bc.f, bcs=bc.bcs, form_compiler_parameters=self._form_compiler_params, needs_zeroing=False,
zero_bc_nodes=self._zero_bc_nodes, diagonal=self._diagonal).assemble(tensor=tensor)
type(self)(bc.f, bcs=bc.bcs, form_compiler_parameters=self._form_compiler_params, needs_zeroing=False,
zero_bc_nodes=self._zero_bc_nodes, diagonal=self._diagonal).assemble(tensor=tensor)
else:
raise AssertionError

Expand Down
8 changes: 4 additions & 4 deletions firedrake/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,10 @@ def reconstruct(self, field=None, V=None, subu=None, u=None, row_field=None, col
return
rank = len(self.f.arguments())
splitter = ExtractSubBlock()
if rank == 1:
form = splitter.split(self.f, argument_indices=(row_field, ))
elif rank == 2:
form = splitter.split(self.f, argument_indices=(row_field, col_field))
form = splitter.split(self.f, argument_indices=(row_field, col_field)[:rank])
if form == 0:
# form is empty, do nothing
return
if u is not None:
form = firedrake.replace(form, {self.u: u})
if action_x is not None:
Expand Down

0 comments on commit d6bb7dd

Please sign in to comment.