@@ -816,8 +816,11 @@ namespace samurai
816
816
// BC Types //
817
817
// ////////////
818
818
template <class Field , class Subset , std::size_t stencil_size, class Vector >
819
- void
820
- __apply_bc_on_subset (Bc<Field>& bc, Field& field, Subset& subset, const Stencil<stencil_size, Field::dim>& stencil, const Vector& direction)
819
+ void __apply_bc_on_subset (Bc<Field>& bc,
820
+ Field& field,
821
+ Subset& subset,
822
+ const StencilAnalyzer<stencil_size, Field::dim>& stencil,
823
+ const Vector& direction)
821
824
{
822
825
auto apply_bc = bc.get_apply_function (std::integral_constant<std::size_t , stencil_size>(), direction);
823
826
if (bc.get_value_type () == BCVType::constant)
@@ -833,14 +836,13 @@ namespace samurai
833
836
}
834
837
else if (bc.get_value_type () == BCVType::function)
835
838
{
836
- int origin_index = find_stencil_origin (stencil);
837
- assert (origin_index >= 0 );
839
+ assert (stencil.has_origin );
838
840
for_each_stencil (field.mesh (),
839
841
subset,
840
842
stencil,
841
- [&, origin_index ](auto & cells)
843
+ [&](auto & cells)
842
844
{
843
- auto & cell_in = cells[static_cast <std:: size_t >( origin_index) ];
845
+ auto & cell_in = cells[stencil. origin_index ];
844
846
auto face_coords = cell_in.face_center (direction);
845
847
auto value = bc.value (direction, cell_in, face_coords);
846
848
apply_bc (field, cells, value);
@@ -884,13 +886,14 @@ namespace samurai
884
886
885
887
if (is_cartesian_direction)
886
888
{
887
- auto stencil = convert_for_direction (stencil_0, direction[d]);
889
+ auto stencil = convert_for_direction (stencil_0, direction[d]);
890
+ auto stencil_analyzer = make_stencil_analyzer (stencil);
888
891
889
892
// 1. Inner cells in the boundary region
890
893
auto bdry_cells = intersection (mesh[mesh_id_t ::cells][level], lca[d]).on (level);
891
894
if (level >= mesh.min_level ()) // otherwise there is no cells
892
895
{
893
- __apply_bc_on_subset (bc, field, bdry_cells, stencil , direction[d]);
896
+ __apply_bc_on_subset (bc, field, bdry_cells, stencil_analyzer , direction[d]);
894
897
}
895
898
896
899
// 2. Inner ghosts in the boundary region that have a neighbouring ghost outside the domain
@@ -901,7 +904,7 @@ namespace samurai
901
904
auto inner_cells_and_ghosts = intersection (potential_inner_cells_and_ghosts, mesh[mesh_id_t ::reference][level]).on (level);
902
905
auto inner_ghosts_with_outer_nghbr = difference (inner_cells_and_ghosts, bdry_cells).on (level);
903
906
904
- __apply_bc_on_subset (bc, field, inner_ghosts_with_outer_nghbr, stencil , direction[d]);
907
+ __apply_bc_on_subset (bc, field, inner_ghosts_with_outer_nghbr, stencil_analyzer , direction[d]);
905
908
}
906
909
}
907
910
}
@@ -920,8 +923,9 @@ namespace samurai
920
923
921
924
auto & mesh = field.mesh ();
922
925
923
- auto stencil_0 = bc.get_stencil (std::integral_constant<std::size_t , stencil_size>());
924
- auto stencil = convert_for_direction (stencil_0, direction);
926
+ auto stencil_0 = bc.get_stencil (std::integral_constant<std::size_t , stencil_size>());
927
+ auto stencil = convert_for_direction (stencil_0, direction);
928
+ auto stencil_analyzer = make_stencil_analyzer (stencil);
925
929
926
930
// 1. Inner cells in the boundary region
927
931
if (!only_fill_ghost_neighbours && level >= mesh.min_level ())
@@ -931,7 +935,7 @@ namespace samurai
931
935
auto translated_outer_nghbr = translate (mesh[mesh_id_t ::reference][level], -(stencil_size / 2 ) * direction);
932
936
auto cells = intersection (translated_outer_nghbr, bdry_cells).on (level);
933
937
934
- __apply_bc_on_subset (bc, field, cells, stencil , direction);
938
+ __apply_bc_on_subset (bc, field, cells, stencil_analyzer , direction);
935
939
}
936
940
937
941
// 2. Inner ghosts in the boundary region that have a neighbouring ghost outside the domain
@@ -942,7 +946,7 @@ namespace samurai
942
946
auto inner_cells_and_ghosts = intersection (potential_inner_cells_and_ghosts, mesh[mesh_id_t ::reference][level]).on (level);
943
947
auto inner_ghosts_with_outer_nghbr = difference (inner_cells_and_ghosts, bdry_cells).on (level);
944
948
945
- __apply_bc_on_subset (bc, field, inner_ghosts_with_outer_nghbr, stencil , direction);
949
+ __apply_bc_on_subset (bc, field, inner_ghosts_with_outer_nghbr, stencil_analyzer , direction);
946
950
}
947
951
}
948
952
0 commit comments