Skip to content

Commit 2d8da62

Browse files
committed
initial implementation
1 parent 80b6edd commit 2d8da62

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

firedrake/bcs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ class EquationBC(object):
488488
def __init__(self, *args, bcs=None, J=None, Jp=None, V=None, is_linear=False, Jp_eq_J=False):
489489
from firedrake.variational_solver import check_pde_args, is_form_consistent
490490
if isinstance(args[0], ufl.classes.Equation):
491+
self.function_arg = firedrake.Constant(0) # so line 286 of mg/ufl_utils.py runs
491492
# initial construction from equation
492493
eq = args[0]
493494
u = args[1]

firedrake/mg/ufl_utils.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ def coarsen_bc(bc, self, coefficient_mapping=None):
126126
return type(bc)(V, val, subdomain)
127127

128128

129+
@coarsen.register(firedrake.EquationBC)
130+
def coarsen_equation_bc(ebc, self, coefficient_mapping=None):
131+
eq = self(ebc._F.f, self, coefficient_mapping=coefficient_mapping)
132+
u = self(ebc._F.u, self, coefficient_mapping=coefficient_mapping)
133+
sub_domain = ebc._F.sub_domain
134+
V = self(ebc._F.function_space(), self, coefficient_mapping=coefficient_mapping)
135+
136+
return type(ebc)(eq == 0, u, sub_domain, V=V)
137+
138+
129139
@coarsen.register(firedrake.functionspaceimpl.WithGeometryBase)
130140
def coarsen_function_space(V, self, coefficient_mapping=None):
131141
if hasattr(V, "_coarse"):
@@ -311,7 +321,8 @@ def mult(self, mat, x, y, inc=False):
311321
x.copy(v)
312322
self.manager.prolong(self.cprimal, self.fprimal)
313323
for bc in self.fbcs:
314-
bc.zero(self.fprimal)
324+
if isinstance(bc, firedrake.DirichletBC):
325+
bc.zero(self.fprimal)
315326
with self.fprimal.dat.vec_ro as v:
316327
if inc:
317328
y.axpy(1.0, v)
@@ -330,7 +341,8 @@ def multTranspose(self, mat, x, y, inc=False):
330341
x.copy(v)
331342
self.manager.restrict(self.fdual, self.cdual)
332343
for bc in self.cbcs:
333-
bc.zero(self.cdual)
344+
if isinstance(bc, firedrake.DirichletBC):
345+
bc.zero(self.cdual)
334346
with self.cdual.dat.vec_ro as v:
335347
if inc:
336348
y.axpy(1.0, v)

0 commit comments

Comments
 (0)