@@ -22,25 +22,34 @@ def constrain_essential_bcs(expressions, **kwargs):
2222
2323 # build mapper
2424 for e in expressions :
25- # from IPython import embed; embed()
2625 if not isinstance (e , ConstrainBC ):
26+ new_exprs .append (e )
2727 continue
2828
2929 indexeds = retrieve_indexed (e )
3030 dims = retrieve_dimensions ([i for j in indexeds for i in j .indices ], mode = 'unique' )
31-
31+ # implicit_dims = set(e.implicit_dims)
32+ dims .update (e .implicit_dims )
33+ # from IPython import embed; embed()
3234 dims = [d for d in dims if d .is_Sub and not d .local ]
3335
36+ if not dims :
37+ new_exprs .append (e )
38+ continue
39+
3440 for d in dims :
3541 # replace the dim with a new one that has a different symbolic_min and symbolic_max
3642
3743 # obvs shouldn't be obtained from indexeds[0], but how should it be obtained?
3844 # USE e.lhs function -> the one that the BC is being applied to
3945 # from IPython import embed; embed()
4046 # f._size_nodomain.left
41- halo_size_left = indexeds [0 ].function ._size_halo [d ].left
42- halo_size_right = indexeds [0 ].function ._size_halo [d ].right
47+ # from IPython import embed; embed()
48+ # halo_size_left = indexeds[0].function._size_halo[d].left
49+ # halo_size_right = indexeds[0].function._size_halo[d].right
4350
51+ halo_size_left = 2
52+ halo_size_right = 2
4453
4554 from devito .petsc .types .dimension import SubDimMax , SubDimMin
4655
@@ -52,7 +61,7 @@ def constrain_essential_bcs(expressions, **kwargs):
5261 subdim_max = SubDimMax (sregistry .make_name (prefix = d .name + '_max' ), subdim = d , thickness = d .thickness )
5362 subdim_min = SubDimMin (sregistry .make_name (prefix = d .name + '_min' ), subdim = d , thickness = d .thickness )
5463
55- # from IPython import embed; embed()
64+ # unique_name
5665 new_dim = CustomBoundSubDimension (
5766 name = d .name ,
5867 parent = d .parent ,
@@ -63,13 +72,12 @@ def constrain_essential_bcs(expressions, **kwargs):
6372 )
6473 mapper [d ] = new_dim
6574
66- # build new expressions
67- for e in expressions :
68- if isinstance (e , ConstrainBC ):
69- new_e = e .subs (mapper )
70- new_exprs .append (new_e )
71-
72- else :
73- new_exprs .append (e )
74-
75+ new_e = e .subs (mapper )
76+ if e .implicit_dims :
77+ # from devito.symbolics import uxreplace
78+ implicit_dims_new = tuple (mapper .get (d , d ) for d in e .implicit_dims )
79+ # from IPython import embed; embed()
80+ new_e = new_e ._rebuild (implicit_dims = implicit_dims_new )
81+ new_exprs .append (new_e )
82+
7583 return new_exprs
0 commit comments