9#include <kernel/lafem/dense_vector.hpp>
10#include <kernel/lafem/dense_vector_blocked.hpp>
11#include <kernel/lafem/vector_mirror.hpp>
12#include <kernel/global/gate.hpp>
13#include <kernel/assembly/mirror_assembler.hpp>
15#include <control/domain/domain_control.hpp>
43 template<
typename DomainLevel_,
typename Space_,
typename Gate_>
45 const Space_& space, Gate_& gate,
bool skip_empty_halos)
47 typedef typename Gate_::LocalVectorType VectorType;
48 typedef typename Gate_::MirrorType MirrorType;
50 const auto& dom_level = virt_lvl.level();
51 const auto& dom_layer = virt_lvl.layer();
54 gate.set_comm(dom_layer.comm_ptr());
57 for(
Index i(0); i < dom_layer.neighbor_count(); ++i)
59 int rank = dom_layer.neighbor_rank(i);
62 auto* halo = dom_level.find_halo_part(rank);
76 gate.push(rank, std::move(mirror));
80 VectorType tmpl_s(space.get_num_dofs());
83 gate.compile(std::move(tmpl_s));
102 template<
typename SysGate_,
typename Gate0_,
typename Gate1_>
103 void build_gate_tuple(SysGate_& gate_sys,
const Gate0_& gate_0,
const Gate1_& gate_1)
105 typedef typename SysGate_::LocalVectorType LocalSystemVectorType;
106 typedef typename SysGate_::MirrorType SystemMirrorType;
109 XASSERTM(gate_0.get_comm() == gate_1.get_comm(),
"gates have incompatible communicators");
110 gate_sys.set_comm(gate_0.get_comm());
113 std::set<int> neighbors;
114 const std::vector<int>& ranks_0 = gate_0.get_ranks();
115 const std::vector<int>& ranks_1 = gate_1.get_ranks();
116 for(
auto r : ranks_0)
118 for(
auto r : ranks_1)
122 const auto& mirrors_0 = gate_0.get_mirrors();
123 const auto& mirrors_1 = gate_1.get_mirrors();
126 LocalSystemVectorType sys_loc;
131 for(
auto rank : neighbors)
134 SystemMirrorType sys_mir = SystemMirrorType::make_empty(sys_loc);
135 for(std::size_t i(0); i < ranks_0.size(); ++i)
137 if(ranks_0[i] == rank)
143 for(std::size_t i(0); i < ranks_1.size(); ++i)
145 if(ranks_1[i] == rank)
152 XASSERTM(!sys_mir.empty(),
"invalid empty mirror");
153 gate_sys.push(rank, std::move(sys_mir));
157 gate_sys.compile(std::move(sys_loc));
179 template<
typename SysGate_,
typename Gate0_,
typename Gate1_,
typename Gate2_>
180 void build_gate_tuple(SysGate_& gate_sys,
const Gate0_& gate_0,
const Gate1_& gate_1,
const Gate2_& gate_2)
182 typedef typename SysGate_::LocalVectorType LocalSystemVectorType;
183 typedef typename SysGate_::MirrorType SystemMirrorType;
186 XASSERTM(gate_0.get_comm() == gate_1.get_comm(),
"gates have incompatible communicators");
187 XASSERTM(gate_0.get_comm() == gate_2.get_comm(),
"gates have incompatible communicators");
188 gate_sys.set_comm(gate_0.get_comm());
191 std::set<int> neighbors;
192 const std::vector<int>& ranks_0 = gate_0.get_ranks();
193 const std::vector<int>& ranks_1 = gate_1.get_ranks();
194 const std::vector<int>& ranks_2 = gate_2.get_ranks();
195 for(
auto r : ranks_0)
197 for(
auto r : ranks_1)
199 for(
auto r : ranks_2)
203 const auto& mirrors_0 = gate_0.get_mirrors();
204 const auto& mirrors_1 = gate_1.get_mirrors();
205 const auto& mirrors_2 = gate_2.get_mirrors();
208 LocalSystemVectorType sys_loc;
214 for(
auto rank : neighbors)
217 SystemMirrorType sys_mir = SystemMirrorType::make_empty(sys_loc);
218 for(std::size_t i(0); i < ranks_0.size(); ++i)
220 if(ranks_0[i] == rank)
226 for(std::size_t i(0); i < ranks_1.size(); ++i)
228 if(ranks_1[i] == rank)
234 for(std::size_t i(0); i < ranks_2.size(); ++i)
236 if(ranks_2[i] == rank)
243 XASSERTM(!sys_mir.empty(),
"invalid empty mirror");
244 gate_sys.push(rank, std::move(sys_mir));
248 gate_sys.compile(std::move(sys_loc));
#define XABORTM(msg)
Abortion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
static void assemble_mirror(LAFEM::VectorMirror< DataType_, IndexType_ > &vec_mirror, const Space_ &space, const MeshPart_ &mesh_part)
Assembles a VectorMirror from a space and a mesh-part.
Virtual Domain Level class template.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.