21 #ifndef THUNDEREGG_SCHUR_PATCHSOLVERWRAPPER_H
22 #define THUNDEREGG_SCHUR_PATCHSOLVERWRAPPER_H
46 std::shared_ptr<const InterfaceDomain<D>> iface_domain;
50 std::shared_ptr<const PatchSolver<D>> solver;
58 std::deque<std::shared_ptr<const PatchIfaceInfo<D>>> patches_with_only_local_ifaces;
62 std::deque<std::shared_ptr<const PatchIfaceInfo<D>>> patches_with_ifaces_on_neighbor_rank;
73 , solver(solver.
clone())
74 , scatter(iface_domain)
77 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
80 if (piinfo->pinfo.hasNbr(s) && piinfo->getIfaceInfo(s)->rank != rank) {
81 patches_with_ifaces_on_neighbor_rank.push_back(piinfo);
85 if (patches_with_ifaces_on_neighbor_rank.empty() ||
86 patches_with_ifaces_on_neighbor_rank.back() != piinfo) {
87 patches_with_only_local_ifaces.push_back(piinfo);
106 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
117 for (
auto piinfo : iface_domain->getPatchIfaceInfos()) {
120 if (piinfo->pinfo.hasNbr(s) && piinfo->getIfaceInfo(s)->rank == rank) {
121 auto ghosts = local_data.
getSliceOn(s, { -1 });
122 auto interface = local_x->getComponentView(0, piinfo->getIfaceInfo(s)->patch_local_index);
124 ghosts[coord] = 2 * interface[coord];
130 for (
auto piinfo : patches_with_only_local_ifaces) {
133 solver->solveSinglePatch(piinfo->pinfo, f_view, u_view);
139 for (
auto piinfo : patches_with_ifaces_on_neighbor_rank) {
142 if (piinfo->pinfo.hasNbr(s) && piinfo->getIfaceInfo(s)->rank != rank) {
143 auto ghosts = local_data.
getSliceOn(s, { -1 });
144 auto interface = local_x->getComponentView(0, piinfo->getIfaceInfo(s)->patch_local_index);
146 ghosts[coord] = 2 * interface[coord];
152 for (
auto piinfo : patches_with_ifaces_on_neighbor_rank) {
155 solver->solveSinglePatch(piinfo->pinfo, f_view, u_view);
158 solver->getGhostFiller().fillGhost(u);
160 for (
auto iface : iface_domain->getInterfaces()) {
161 for (
auto patch : iface->patches) {
162 if (patch.piinfo->pinfo.rank == rank &&
163 (patch.type.isNormal() || patch.type.isCoarseToCoarse() || patch.type.isFineToFine())) {
165 auto ghosts = local_data.
getSliceOn(patch.side, { -1 });
166 auto inner = local_data.getSliceOn(patch.side, { 0 });
168 b.getComponentView(0, patch.piinfo->getIfaceInfo(patch.side)->patch_local_index);
170 interface.getStart(), interface.getEnd(), [&](
const std::array<int, D - 1>& coord) {
171 interface[coord] = (ghosts[coord] + inner[coord]) / 2;
177 b.scaleThenAdd(-1, x);
188 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
192 for (
auto piinfo : iface_domain->getPatchIfaceInfos()) {
195 if (piinfo->pinfo.hasNbr(s)) {
196 auto ghosts = local_data.
getSliceOn(s, { -1 });
197 auto inner = local_data.getSliceOn(s, { 0 });
199 ghosts.getStart(), ghosts.getEnd(), [&](
const std::array<int, D - 1>& coord) {
200 ghosts[coord] = -inner[coord];
205 for (
auto piinfo : iface_domain->getPatchIfaceInfos()) {
208 solver->solveSinglePatch(piinfo->pinfo, f_view, u_view);
211 solver->getGhostFiller().fillGhost(u);
213 for (
auto iface : iface_domain->getInterfaces()) {
214 for (
auto patch : iface->patches) {
215 if (patch.piinfo->pinfo.rank == rank &&
216 (patch.type.isNormal() || patch.type.isCoarseToCoarse() || patch.type.isFineToFine())) {
218 auto ghosts = local_data.
getSliceOn(patch.side, { -1 });
219 auto inner = local_data.getSliceOn(patch.side, { 0 });
221 schur_b.getComponentView(0, patch.piinfo->getIfaceInfo(patch.side)->patch_local_index);
223 interface.getStart(), interface.getEnd(), [&](
const std::array<int, D - 1>& coord) {
224 interface[coord] = (ghosts[coord] + inner[coord]) / 2;
232 extern template class PatchSolverWrapper<2>;
233 extern template class PatchSolverWrapper<3>;