@@ -357,7 +357,7 @@ def collapse(self):
357
357
return type (self ).create (self .topological .collapse (), self .mesh ())
358
358
359
359
@classmethod
360
- def make_function_space (cls , mesh , element , name = None , boundary_set = None ):
360
+ def make_function_space (cls , mesh , element , name = None ):
361
361
r"""Factory method for :class:`.WithGeometryBase`."""
362
362
mesh .init ()
363
363
topology = mesh .topology
@@ -376,25 +376,25 @@ def make_function_space(cls, mesh, element, name=None, boundary_set=None):
376
376
if mesh is not topology :
377
377
# Create a concrete WithGeometry or FiredrakeDualSpace on this mesh
378
378
new = cls .create (new , mesh )
379
-
380
- if boundary_set :
381
- new = RestrictedFunctionSpace (new , boundary_set = boundary_set )
382
- if mesh is not topology :
383
- new = cls .create (new , mesh )
384
379
return new
385
380
386
- def reconstruct (self , mesh = None , element = None , name = None , ** kwargs ):
381
+ def reconstruct (self , mesh = None , element = None , boundary_set = None , name = None , ** kwargs ):
387
382
r"""Reconstruct this :class:`.WithGeometryBase` .
388
383
389
384
:kwarg mesh: the new :func:`~.Mesh` (defaults to same mesh)
390
385
:kwarg element: the new :class:`finat.ufl.FiniteElement` (defaults to same element)
386
+ :kwarg boundary_set: boundary subdomain labels defining a new
387
+ :func:`~.RestrictedFunctionSpace` (defaults to same boundary_set)
391
388
:kwarg name: the new name (defaults to None)
392
389
:returns: the new function space of the same class as ``self``.
393
390
394
391
Any extra kwargs are used to reconstruct the finite element.
395
392
For details see :meth:`finat.ufl.finiteelement.FiniteElement.reconstruct`.
396
393
"""
397
394
V_parent = self
395
+ if boundary_set is None :
396
+ boundary_set = V_parent .boundary_set
397
+
398
398
# Deal with ProxyFunctionSpace
399
399
indices = []
400
400
while True :
@@ -409,17 +409,19 @@ def reconstruct(self, mesh=None, element=None, name=None, **kwargs):
409
409
410
410
if mesh is None :
411
411
mesh = V_parent .mesh ()
412
-
413
412
if element is None :
414
413
element = V_parent .ufl_element ()
414
+
415
415
cell = mesh .topology .ufl_cell ()
416
416
if len (kwargs ) > 0 or element .cell != cell :
417
417
element = element .reconstruct (cell = cell , ** kwargs )
418
418
419
- V = type (self ).make_function_space (mesh , element , name = name ,
420
- boundary_set = V_parent .boundary_set )
419
+ V = type (self ).make_function_space (mesh , element , name = name )
421
420
for i in reversed (indices ):
422
421
V = V .sub (i )
422
+
423
+ if boundary_set :
424
+ V = RestrictedFunctionSpace (V , boundary_set = boundary_set , name = V .name )
423
425
return V
424
426
425
427
@@ -884,6 +886,15 @@ class RestrictedFunctionSpace(FunctionSpace):
884
886
If using this class to solve or similar, a list of DirichletBCs will still
885
887
need to be specified on this space and passed into the function.
886
888
"""
889
+ def __new__ (cls , function_space , boundary_set = frozenset (), name = None ):
890
+ mesh = function_space .mesh ()
891
+ if mesh is not mesh .topology :
892
+ # Restrict WithGeometry and return a WithGeometry
893
+ V = RestrictedFunctionSpace (function_space .topological ,
894
+ boundary_set = boundary_set , name = name )
895
+ return type (function_space ).create (V , mesh )
896
+ return FunctionSpace .__new__ (cls )
897
+
887
898
def __init__ (self , function_space , boundary_set = frozenset (), name = None ):
888
899
label = ""
889
900
boundary_set_ = []
@@ -1207,7 +1218,7 @@ class ProxyFunctionSpace(FunctionSpace):
1207
1218
"""
1208
1219
def __new__ (cls , mesh , element , name = None ):
1209
1220
topology = mesh .topology
1210
- self = super ( ProxyFunctionSpace , cls ) .__new__ (cls )
1221
+ self = FunctionSpace .__new__ (cls )
1211
1222
if mesh is not topology :
1212
1223
return WithGeometry .create (self , mesh )
1213
1224
else :
@@ -1262,7 +1273,7 @@ class ProxyRestrictedFunctionSpace(RestrictedFunctionSpace):
1262
1273
"""
1263
1274
def __new__ (cls , function_space , boundary_set = frozenset (), name = None ):
1264
1275
topology = function_space ._mesh .topology
1265
- self = super ( ProxyRestrictedFunctionSpace , cls ) .__new__ (cls )
1276
+ self = FunctionSpace .__new__ (cls )
1266
1277
if function_space ._mesh is not topology :
1267
1278
return WithGeometry .create (self , function_space ._mesh )
1268
1279
else :
0 commit comments