55X
sarkisPartitionOfUnity(
const GFS& gfs, LFS& lfs,
const CC& cc,
int cells_x,
int cells_y,
int overlap,
int partition_x,
int partition_y) {
58 int my_rank = gfs.gridView().comm().rank();
63 for (
auto it = gfs.gridView().template begin<0>(); it != gfs.gridView().template end<0>(); ++it) {
67 auto geo = it->geometry();
68 const auto gt = geo.type();
69 const auto& ref_el = Dune::ReferenceElements<double, dim>::general(gt);
71 auto& coeffs = lfs.finiteElement().localCoefficients();
73 for (std::size_t i = 0; i < coeffs.size(); ++i) {
75 auto local_pos = ref_el.position (coeffs.localKey(i).subEntity(), coeffs.localKey(i).codim());
77 auto global_pos = geo.global(local_pos);
79 auto subindex = gfs.entitySet().indexSet().subIndex(*it, coeffs.localKey(i).subEntity(), coeffs.localKey(i).codim());
81 double Hx = 1.0 / (double)partition_x;
82 double Hy = 1.0 / (double)partition_y;
83 double hx = (double)overlap / cells_x;
84 double hy = (double)overlap / cells_y;
86 int row = std::floor(my_rank / partition_x);
87 int col = my_rank - partition_x * row;
89 double dx1 = (col + 1) * Hx + hx - global_pos[0];
90 double dx2 = global_pos[0] - (col * Hx - hx);
92 double dy1 = (row + 1) * Hy + hy - global_pos[1];
93 double dy2 = global_pos[1] - (row * Hy - hy);
95 if (row == 0) dy2 = 2*Hy;
96 if (row == partition_y - 1) dy1 = 2*Hy;
97 if (col == 0) dx2 = 2*Hx;
98 if (col == partition_x - 1) dx1 = 2*Hx;
100 native(part_unity)[subindex] = std::min(std::min(std::min(dx1, dx2), dy1), dy2);
104 X sum_dists(part_unity);
106 gfs.gridView().communicate(addh_dists,Dune::All_All_Interface,Dune::ForwardCommunication);
108 auto iter_sum = sum_dists.begin();
109 for (
auto iter = part_unity.begin(); iter != part_unity.end(); iter++) {
111 *iter *= 1.0 / *iter_sum;
X standardPartitionOfUnity(const GFS &gfs, const CC &cc)
Compute a simple partition of unity.
Definition partitionofunity.hh:17
X sarkisPartitionOfUnity(const GFS &gfs, LFS &lfs, const CC &cc, int cells_x, int cells_y, int overlap, int partition_x, int partition_y)
Compute a partition of unity according to Sarkis.
Definition partitionofunity.hh:55
void set_constrained_dofs(const CG &cg, typename XG::ElementType x, XG &xg)
construct constraints from given boundary condition function
Definition constraints.hh:796
std::enable_if< std::is_base_of< impl::WrapperBase, T >::value, Native< T > & >::type native(T &t)
Definition backend/interface.hh:192