@@ -520,7 +520,7 @@ def c_map_init(self, is_top=False, layers=1, is_facet=False):
520
520
'off' : ' + ' + str (m .offset [idx ])})
521
521
return '\n ' .join (val )+ '\n '
522
522
523
- def c_map_bcs (self , sign ):
523
+ def c_map_bcs (self , sign , is_facet ):
524
524
maps = as_tuple (self .map , Map )
525
525
val = []
526
526
# To throw away boundary condition values, we subtract a large
@@ -534,16 +534,22 @@ def c_map_bcs(self, sign):
534
534
if not map .iterset ._extruded :
535
535
continue
536
536
for j , m in enumerate (map ):
537
- if 'bottom' not in m .implicit_bcs :
538
- continue
539
- need_bottom = True
540
- for idx in range (m .arity ):
541
- if m .bottom_mask [idx ] < 0 :
542
- val .append ("xtr_%(name)s[%(ind)s] %(sign)s= %(val)s;" %
543
- {'name' : self .c_map_name (i , j ),
544
- 'val' : max_int ,
545
- 'ind' : idx ,
546
- 'sign' : sign })
537
+ bottom_masks = None
538
+ for location , name in m .implicit_bcs :
539
+ if location == "bottom" :
540
+ if bottom_masks is None :
541
+ bottom_masks = m .bottom_mask [name ].copy ()
542
+ else :
543
+ bottom_masks += m .bottom_mask [name ]
544
+ need_bottom = True
545
+ if bottom_masks is not None :
546
+ for idx in range (m .arity ):
547
+ if bottom_masks [idx ] < 0 :
548
+ val .append ("xtr_%(name)s[%(ind)s] %(sign)s= %(val)s;" %
549
+ {'name' : self .c_map_name (i , j ),
550
+ 'val' : max_int ,
551
+ 'ind' : idx ,
552
+ 'sign' : sign })
547
553
if need_bottom :
548
554
val .insert (0 , "if (j_0 == 0) {" )
549
555
val .append ("}" )
@@ -555,18 +561,25 @@ def c_map_bcs(self, sign):
555
561
if not map .iterset ._extruded :
556
562
continue
557
563
for j , m in enumerate (map ):
558
- if 'top' not in m .implicit_bcs :
559
- continue
560
- need_top = True
561
- for idx in range (m .arity ):
562
- if m .top_mask [idx ] < 0 :
563
- val .append ("xtr_%(name)s[%(ind)s] %(sign)s= %(val)s;" %
564
- {'name' : self .c_map_name (i , j ),
565
- 'val' : max_int ,
566
- 'ind' : idx ,
567
- 'sign' : sign })
564
+ top_masks = None
565
+ for location , name in m .implicit_bcs :
566
+ if location == "top" :
567
+ if top_masks is None :
568
+ top_masks = m .top_mask [name ].copy ()
569
+ else :
570
+ top_masks += m .top_mask [name ]
571
+ need_top = True
572
+ if top_masks is not None :
573
+ facet_offset = m .arity if is_facet else 0
574
+ for idx in range (m .arity ):
575
+ if top_masks [idx ] < 0 :
576
+ val .append ("xtr_%(name)s[%(ind)s] %(sign)s= %(val)s;" %
577
+ {'name' : self .c_map_name (i , j ),
578
+ 'val' : max_int ,
579
+ 'ind' : idx + facet_offset ,
580
+ 'sign' : sign })
568
581
if need_top :
569
- val .insert (pos , "if (j_0 == end_layer - 1) {" )
582
+ val .insert (pos , "if (j_0 == top_layer - 1) {" )
570
583
val .append ("}" )
571
584
return '\n ' .join (val )+ '\n '
572
585
@@ -865,13 +878,13 @@ def extrusion_loop():
865
878
_map_bcs_p = ""
866
879
_layer_arg = ""
867
880
if self ._itspace ._extruded :
868
- _layer_arg = ", int start_layer, int end_layer"
881
+ _layer_arg = ", int start_layer, int end_layer, int top_layer "
869
882
_map_decl += ';\n ' .join ([arg .c_map_decl (is_facet = is_facet )
870
883
for arg in self ._args if arg ._uses_itspace ])
871
884
_map_init += ';\n ' .join ([arg .c_map_init (is_top = is_top , layers = self ._itspace .layers , is_facet = is_facet )
872
885
for arg in self ._args if arg ._uses_itspace ])
873
- _map_bcs_m += ';\n ' .join ([arg .c_map_bcs ("-" ) for arg in self ._args if arg ._is_mat ])
874
- _map_bcs_p += ';\n ' .join ([arg .c_map_bcs ("+" ) for arg in self ._args if arg ._is_mat ])
886
+ _map_bcs_m += ';\n ' .join ([arg .c_map_bcs ("-" , is_facet ) for arg in self ._args if arg ._is_mat ])
887
+ _map_bcs_p += ';\n ' .join ([arg .c_map_bcs ("+" , is_facet ) for arg in self ._args if arg ._is_mat ])
875
888
_apply_offset += ';\n ' .join ([arg .c_add_offset_map (is_facet = is_facet )
876
889
for arg in self ._args if arg ._uses_itspace ])
877
890
_apply_offset += ';\n ' .join ([arg .c_add_offset (is_facet = is_facet )
0 commit comments