8#include <kernel/adjacency/dynamic_graph.hpp>
9#include <kernel/global/alg_dof_parti.hpp>
10#include <kernel/global/filter.hpp>
11#include <kernel/global/matrix.hpp>
12#include <kernel/lafem/null_matrix.hpp>
13#include <kernel/lafem/sparse_matrix_csr.hpp>
14#include <kernel/lafem/sparse_matrix_bcsr.hpp>
15#include <kernel/lafem/saddle_point_matrix.hpp>
16#include <kernel/lafem/tuple_matrix.hpp>
17#include <kernel/lafem/unit_filter.hpp>
18#include <kernel/lafem/unit_filter_blocked.hpp>
19#include <kernel/lafem/mean_filter.hpp>
20#include <kernel/lafem/mean_filter_blocked.hpp>
21#include <kernel/lafem/none_filter.hpp>
22#include <kernel/lafem/slip_filter.hpp>
23#include <kernel/lafem/filter_chain.hpp>
24#include <kernel/lafem/filter_sequence.hpp>
25#include <kernel/lafem/sparse_vector_factory.hpp>
26#include <kernel/lafem/tuple_filter.hpp>
27#include <kernel/global/mean_filter.hpp>
28#include <kernel/lafem/matrix_mirror.hpp>
40 template<
typename Matrix_>
44 template<
typename Matrix_>
48 template<
typename Filter_>
134 template<
typename LocalMatrix_,
typename LocalFilter_,
typename Mirror_>
178 typedef Intern::ADPMatAux<LocalMatrixType> ADPMatAuxType;
179 typedef Intern::ADPFilAux<LocalFilterType> ADPFilAuxType;
201 std::vector<BufferMatrixType> _owner_bufs;
205 std::vector<OwnerMirrorType> _owner_data_mirs;
246 std::shared_ptr<AlgDofPartiType> adp) :
265 if(this->_alg_dof_parti)
266 r += this->_alg_dof_parti->bytes();
267 if(this->_owned_graph)
268 r += this->_owned_graph->bytes();
269 for(
const auto& x : this->_donee_bufs)
271 for(
const auto& x : this->_owner_bufs)
273 for(
const auto& x : this->_donee_data_mirs)
275 for(
const auto& x : this->_owner_data_mirs)
297 return this->_alg_dof_parti->get_num_owned_dofs();
303 return this->_alg_dof_parti->get_num_global_dofs();
309 return this->_alg_dof_parti->get_global_dof_offset();
315 return this->_alg_dof_parti->get_num_owned_dofs();
321 return this->_alg_dof_parti->get_num_owned_dofs();
327 return this->_alg_dof_parti->get_num_global_dofs();
345 XASSERT(this->_alg_dof_parti !=
nullptr);
346 return this->_alg_dof_parti->get_comm();
359 template<
typename DTV_>
362 XASSERT(this->_alg_dof_parti !=
nullptr);
363 this->_alg_dof_parti->upload_vector(val, vector);
377 template<
typename DTV_>
380 XASSERT(this->_alg_dof_parti !=
nullptr);
381 this->_alg_dof_parti->download_vector(val, vector);
404 template<
typename DTX_,
typename RPT_,
typename CIT_>
405 void apply(DTX_* vec_r,
const DTX_* vec_x,
const DTX_* val_a,
const RPT_* row_ptr,
const CIT_* col_idx)
const
407 XASSERTM(!this->_alg_dof_parti->get_all_global_dof_counts().empty(),
408 "You did not ask to assemble the required AlgDofParti allgather data");
411 std::vector<DTX_> vec_full(this->_alg_dof_parti->get_num_global_dofs());
413 this->_alg_dof_parti->get_num_owned_dofs(),
415 this->_alg_dof_parti->get_all_global_dof_counts().data(),
416 this->_alg_dof_parti->get_all_global_dof_offsets().data());
419 LAFEM::Arch::MatVecMultCSRDense::exec_generic_impl(vec_r, DTX_(1), vec_full.data(), (DTX_*)
nullptr, val_a, col_idx, row_ptr,
420 this->get_adp_matrix_rows(), this->get_adp_matrix_cols(), this->get_adp_matrix_nzes(),
false);
432 if(this->_alg_dof_parti ==
nullptr)
434 this->_alg_dof_parti = std::make_shared<AlgDofPartiType>();
435 this->_alg_dof_parti->assemble_by_gate(*this->_global_matrix.
get_row_gate());
467 template<
typename RPT_,
typename CIT_>
472 XASSERT(this->_owned_graph !=
nullptr);
475 static constexpr std::uint64_t max_rpt = 1ull << (8*
sizeof(RPT_) - 1);
476 static constexpr std::uint64_t max_cit = 1ull << (8*
sizeof(CIT_) - 1);
482 const Index* dom_ptr = this->_owned_graph->get_domain_ptr();
483 const Index* img_idx = this->_owned_graph->get_image_idx();
485 const Index n = this->_owned_graph->get_num_nodes_domain();
486 FEAT_PRAGMA_OMP(parallel
for)
487 for(
Index i = 0u; i <= n; ++i)
489 ASSERTM(std::uint64_t(dom_ptr[i]) < max_rpt,
"row-pointer exceeds RPT_ type range!");
490 row_ptr[i] = RPT_(dom_ptr[i]);
493 const Index m = this->_owned_graph->get_num_indices();
494 FEAT_PRAGMA_OMP(parallel
for)
495 for(
Index j = 0; j < m; ++j)
497 ASSERTM(std::uint64_t(img_idx[j]) < max_cit,
"column-index exceeds CIT_ type range!");
498 col_idx[j] = CIT_(img_idx[j]);
503 this->_owned_graph.reset();
523 template<
typename DTA_,
typename RPT_,
typename CIT_>
552 template<
typename DTA_,
typename RPT_,
typename CIT_>
555 XASSERT(this->_alg_dof_parti !=
nullptr);
572 std::vector<BufferVectorType> donee_vbufs(num_neigh_donee);
573 std::vector<BufferVectorType> owner_vbufs(num_neigh_owner);
575 std::vector<Memory::TypedView<DataType>> donee_views(num_neigh_donee);
576 std::vector<Memory::TypedView<DataType>> owner_views(num_neigh_owner);
579 for(
Index i(0); i < num_neigh_donee; ++i)
584 donee_views.at(i) = buf.elements_view_w();
591 for(
Index i(0); i < num_neigh_owner; ++i)
598 this->_owner_data_mirs.at(i).gather_owner_data(buf, matrix);
599 owner_views.at(i) = buf.elements_view_r();
606 this->_owned_data_mir.upload_owned_data(val, matrix);
609 for(std::size_t idx(0u); recv_reqs.
wait_any(idx); )
612 donee_views.at(idx).release();
635 ADPFilAuxType::upload_filter(factory, filter,
_alg_dof_parti->get_owned_mirror() ,0u);
645 template<
typename DTV_>
653 LAFEM::Arch::UnitFilterDenseVec::exec_generic_impl(vec_def, (DTV_*)
nullptr,
664 template<
typename DTV_>
672 LAFEM::Arch::UnitFilterDenseVec::exec_generic_impl(vec_cor, (DTV_*)
nullptr,
691 template<
typename DTA_,
typename RPT_,
typename CIT_>
706 for(
Index i = 0; i < n; ++i)
708 const Index row = row_off + row_idx[i];
709 RPT_ j = row_ptr[row_idx[i]];
710 const RPT_ j_end = row_ptr[row_idx[i]+1];
711 for(; j < j_end; ++j)
713 val[j] = DTA_(row ==
Index(col_idx[j]) ? 1 : 0);
730 const Index num_global_dofs)
733 Index num_buf_rows = ADPMatAuxType::calc_mat_buf_num_rows(local_matrix, row_mirror);
736 std::vector<IndexType> aux_row(std::size_t(num_buf_rows+1u),
IndexType(0));
739 ADPMatAuxType::calc_mat_buf_row_nze(aux_row.data(), local_matrix, row_mirror);
742 feat_omp_ex_scan(std::size_t(num_buf_rows+1u), aux_row.data(), aux_row.data());
751 for(
Index i = 0u; i <= num_buf_rows; ++i)
752 buf_row_ptr[i] = aux_row[i];
756 ADPMatAuxType::gather_mat_buf_col_idx(aux_row.data(), buf_col_idx.
get_w(), local_matrix, row_mirror, global_dof_idx);
759 for(
Index i = 0u; i < num_buf_rows; ++i)
761 std::sort(&buf_col_idx[buf_row_ptr[i]], &buf_col_idx[buf_row_ptr[i+1]]);
784 _owner_bufs.resize(num_neigh_owner);
788 std::vector<Memory::TypedView<IndexType>> owner_row_ptr_views(num_neigh_owner);
789 std::vector<Memory::TypedView<IndexType>> owner_col_idx_views(num_neigh_owner);
792 for(
Index i(0); i < num_neigh_owner; ++i)
799 owner_row_ptr_views.at(i) = this->_owner_bufs.at(i).row_ptr_view_r();
800 owner_col_idx_views.at(i) = this->_owner_bufs.at(i).col_idx_view_r();
818 std::vector<std::array<Index,4>> send_dims(num_neigh_owner);
819 std::vector<std::array<Index,4>> recv_dims(num_neigh_donee);
822 for(
Index i(0); i < num_neigh_donee; ++i)
828 for(
Index i(0); i < num_neigh_owner; ++i)
842 std::vector<Memory::TypedView<IndexType>> donee_row_ptr_views(num_neigh_donee);
843 std::vector<Memory::TypedView<IndexType>> donee_col_idx_views(num_neigh_donee);
846 for(
Index i(0); i < num_neigh_donee; ++i)
849 Index nrows = recv_dims.at(i)[0];
850 Index ncols = recv_dims.at(i)[1];
851 Index nepnz = recv_dims.at(i)[2];
852 Index nnze = recv_dims.at(i)[3];
858 donee_row_ptr_views.at(i) = this->_donee_bufs.at(i).row_ptr_view_w();
859 donee_col_idx_views.at(i) = this->_donee_bufs.at(i).col_idx_view_w();
863 for(
Index i(0); i < num_neigh_donee; ++i)
865 recv_reqs[i] = comm.
irecv(donee_row_ptr_views.at(i).get_w(),
866 this->_donee_bufs.at(i).num_rows()+std::size_t(1), adp.
get_donee_rank(i));
873 for(
Index i(0); i < num_neigh_owner; ++i)
875 send_reqs[i] = comm.
isend(owner_row_ptr_views.at(i).get_r(),
876 this->_owner_bufs.at(i).num_rows()+std::size_t(1), adp.
get_owner_rank(i));
883 for(
Index i(0); i < num_neigh_donee; ++i)
885 recv_reqs[i] = comm.
irecv(donee_col_idx_views.at(i).get_w(),
893 for(
Index i(0); i < num_neigh_owner; ++i)
895 send_reqs[i] = comm.
isend(owner_col_idx_views.at(i).get_r(),
928 ADPMatAuxType::gather_owned_struct(dynamic_graph, this->_global_matrix.
local(),
933 for(
Index ineigh(0); ineigh < num_neigh_donee; ++ineigh)
940 const Index num_idx = mir.num_indices();
946 for(
Index i(0); i < num_idx; ++i)
952 for(
IndexType j(buf_ptr[i]); j < buf_ptr[i + 1]; ++j)
955 dynamic_graph.
insert(row, buf_idx[j]);
966 dynamic_graph.
clear();
991 for(
Index i(0); i < buf_rows; ++i)
995 Index k = row_ptr[row_idx[i]];
996 const Index k_end = row_ptr[row_idx[i] + 1];
999 while((j < j_end) && (k < k_end))
1001 if(buf_idx[j] < col_idx[k])
1003 else if(buf_idx[j] > col_idx[k])
1029 this->_donee_data_mirs.resize(this->_donee_bufs.size());
1030 for(
Index i(0); i < this->_donee_bufs.size(); ++i)
1035 this->_owner_data_mirs.resize(this->_owner_bufs.size());
1036 for(
Index i(0); i < this->_owner_bufs.size(); ++i)
1037 this->_owner_data_mirs.at(i).asm_neighbor_owner_data_mir(this->_global_matrix.
local(),
1042 this->_owned_data_mir.asm_owned_data_mir(this->_global_matrix.
local(), *this->_owned_graph,
1049 template<
typename DTA_>
1058 for(
Index i(0); i < n; ++i)
1060 adp_val[mir_idx[i]] += DTA_(buf_val[i]);
1074 template<
typename DT_,
typename IT_>
1075 class ADPDOMM<LAFEM::SparseMatrixCSR<DT_, IT_>>
1080 Index num_indices()
const
1085 Index buf_size()
const
1087 return _buf_mir.
size();
1090 Index loc_size()
const
1092 return _loc_mir.
size();
1099 const Memory::TypedView<IT_> buf_idx = _buf_mir.indices_view_r();
1100 const Memory::TypedView<IT_> loc_idx = _loc_mir.indices_view_r();
1122 Index asm_neighbor_owner_data_mir(
1123 const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix,
1124 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1125 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
1126 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
1130 const Memory::TypedView<IT_> row_idx = row_mirror.indices_view_r();
1131 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
1132 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
1133 const Memory::TypedView<IT_> buf_ptr = buffer.row_ptr_view_r();
1134 const Memory::TypedView<IT_> buf_idx = buffer.col_idx_view_r();
1135 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
1136 const Index row_mir_num_idx = row_mirror.num_indices();
1139 Index data_mir_num_idx = 0u;
1140 for(Index i = 0; i < row_mir_num_idx; ++i)
1141 data_mir_num_idx += row_ptr[row_idx[i]+1u] - row_ptr[row_idx[i]];
1143 XASSERT(data_mir_num_idx <= buffer.num_nzes());
1146 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1147 aux_data_mir.reserve(data_mir_num_idx);
1150 std::vector<IT_> loc_it;
1151 loc_it.reserve(local_matrix.num_cols());
1154 auto sort_rel_loc = [&glob_dof_idx, &col_idx] (IT_ a, IT_ b)
1156 return glob_dof_idx[col_idx[a]] < glob_dof_idx[col_idx[b]];
1160 for(Index i(0); i < row_mir_num_idx; ++i)
1163 IT_ j = buf_ptr[row_offset + i];
1164 const IT_ j_end = buf_ptr[row_offset + i + 1];
1165 const IT_ k_beg = row_ptr[row_idx[i]];
1166 const IT_ k_end = row_ptr[row_idx[i] + 1];
1168 for(IT_ k = k_beg; k < k_end; ++k)
1169 loc_it.push_back(k);
1170 std::sort(loc_it.begin(), loc_it.end(), sort_rel_loc);
1172 auto kit = loc_it.begin();
1175 while((j < j_end) && (kit != loc_it.end()))
1177 if(buf_idx[j] < glob_dof_idx[col_idx[*kit]])
1179 else if(buf_idx[j] > glob_dof_idx[col_idx[*kit]])
1183 aux_data_mir.push_back(std::make_pair(j, *kit));
1192 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(buffer.num_nzes(), num_idx);
1193 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(
1194 local_matrix.num_nzes_raw(), num_idx);
1196 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1197 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1198 for(Index i = 0; i < num_idx; ++i)
1200 bm_idx[i] = aux_data_mir[i].first;
1201 lm_idx[i] = aux_data_mir[i].second;
1204 return row_mir_num_idx;
1220 Index asm_owned_data_mir(
1221 const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix,
1222 const Adjacency::Graph& owned_graph,
1223 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1224 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
1228 const Index* own_row_ptr = owned_graph.get_domain_ptr();
1229 const Index* own_col_idx = owned_graph.get_image_idx();
1230 const Memory::TypedView<IT_> loc_row_ptr = local_matrix.row_ptr_view_r();
1231 const Memory::TypedView<IT_> loc_col_idx = local_matrix.col_idx_view_r();
1234 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1235 aux_data_mir.reserve(owned_graph.get_num_indices());
1237 const Index num_owned_dofs = row_mirror.num_indices();
1238 const Memory::TypedView<IT_> loc_dof_idx = row_mirror.indices_view_r();
1239 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
1244 std::deque<IT_> row_it;
1247 auto sort_rel = [&glob_dof_idx, &loc_col_idx] (IT_ a, IT_ b)
1249 return glob_dof_idx[loc_col_idx[a]] < glob_dof_idx[loc_col_idx[b]];
1253 for(Index own_dof(0); own_dof < num_owned_dofs; ++own_dof)
1255 const IT_ k_beg = loc_row_ptr[loc_dof_idx[own_dof]];
1256 const IT_ k_end = loc_row_ptr[loc_dof_idx[own_dof] + 1];
1258 for(IT_ k = k_beg; k < k_end; ++k)
1259 row_it.push_back(k);
1260 std::sort(row_it.begin(), row_it.end(), sort_rel);
1263 IT_ j = IT_(own_row_ptr[row_offset + own_dof]);
1264 const IT_ j_end = IT_(own_row_ptr[row_offset + own_dof + 1]);
1265 auto kit = row_it.begin();
1268 while((j < j_end) && (kit != row_it.end()))
1270 if(own_col_idx[j] < glob_dof_idx[loc_col_idx[*kit]])
1272 else if(own_col_idx[j] > glob_dof_idx[loc_col_idx[*kit]])
1276 aux_data_mir.push_back(std::make_pair(j, *kit));
1285 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(local_matrix.num_nzes(), num_idx);
1286 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(local_matrix.num_nzes(), num_idx);
1288 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1289 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1290 for(Index i = 0; i < num_idx; ++i)
1292 bm_idx[i] = aux_data_mir[i].first;
1293 lm_idx[i] = aux_data_mir[i].second;
1296 return num_owned_dofs;
1299 template<
typename DTA_>
1300 void upload_owned_data(DTA_* adp_val,
const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix)
const
1302 const Memory::TypedView<DT_> loc_val = local_matrix.val_view_r();
1303 const Memory::TypedView<IT_> adp_idx = _buf_mir.indices_view_r();
1304 const Memory::TypedView<IT_> loc_idx = _loc_mir.indices_view_r();
1307 for(Index i = 0; i < n; ++i)
1309 ASSERT(loc_idx[i] < local_matrix.num_nzes());
1310 adp_val[adp_idx[i]] = DTA_(loc_val[loc_idx[i]]);
1326 void gather_owner_data(LAFEM::DenseVector<DT_, IT_>& buffer,
const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix)
const
1328 Memory::TypedView<DT_> buf_val = buffer.elements_view_rw();
1329 const Memory::TypedView<DT_> loc_val = local_matrix.val_view_r();
1330 const Memory::TypedView<IT_> buf_idx = this->_buf_mir.indices_view_r();
1331 const Memory::TypedView<IT_> loc_idx = this->_loc_mir.indices_view_r();
1334 for(Index i = 0; i < n; ++i)
1336 ASSERT(buf_idx[i] < buffer.size());
1337 ASSERT(loc_idx[i] < local_matrix.num_nzes());
1338 buf_val[buf_idx[i]] = loc_val[loc_idx[i]];
1346 template<
typename DT_,
typename IT_,
int bh_,
int bw_>
1347 class ADPDOMM<LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>>
1350 LAFEM::VectorMirror<DT_, IT_> _buf_mir, _loc_mir;
1352 Index num_indices()
const
1354 return _buf_mir.num_indices();
1357 Index buf_size()
const
1359 return _buf_mir.size();
1362 Index loc_size()
const
1364 return _loc_mir.size();
1370 XASSERT(_buf_mir.num_indices() == _loc_mir.num_indices());
1371 const Memory::TypedView<IT_> buf_idx = _buf_mir.indices_view_r();
1372 const Memory::TypedView<IT_> loc_idx = _loc_mir.indices_view_r();
1373 for(Index i = 0; i < _buf_mir.num_indices(); ++i)
1375 return "[" + s +
"]*" +
stringify(_buf_mir.num_indices());
1378 Index asm_neighbor_owner_data_mir(
1379 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix,
1380 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1381 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
1382 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>& global_dof_idx,
1386 const Memory::TypedView<IT_> row_idx = row_mirror.indices_view_r();
1387 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
1388 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
1389 const Memory::TypedView<IT_> buf_ptr = buffer.row_ptr_view_r();
1390 const Memory::TypedView<IT_> buf_idx = buffer.col_idx_view_r();
1391 const Memory::TypedView<Tiny::Vector<IT_,bw_>> glob_dof_idx = global_dof_idx.elements_view_r();
1392 const Index row_mir_num_idx = row_mirror.num_indices();
1395 Index data_mir_num_idx = 0u;
1396 for(Index i = 0; i < row_mir_num_idx; ++i)
1397 data_mir_num_idx += row_ptr[row_idx[i]+1u] - row_ptr[row_idx[i]];
1398 data_mir_num_idx *=
Index(bh_*bw_);
1400 XASSERT(data_mir_num_idx <= buffer.num_nzes());
1403 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1404 aux_data_mir.reserve(data_mir_num_idx);
1407 std::vector<IT_> loc_it;
1408 loc_it.reserve(local_matrix.num_cols() * std::size_t(bh_*bw_));
1411 auto sort_rel_loc = [&glob_dof_idx, &col_idx] (IT_ a, IT_ b)
1413 return glob_dof_idx[col_idx[a]][0] < glob_dof_idx[col_idx[b]][0];
1417 for(Index i(0); i < row_mir_num_idx; ++i)
1419 const IT_ k_beg = row_ptr[row_idx[i]];
1420 const IT_ k_end = row_ptr[row_idx[i] + 1];
1422 for(IT_ k = k_beg; k < k_end; ++k)
1423 loc_it.push_back(k);
1424 std::sort(loc_it.begin(), loc_it.end(), sort_rel_loc);
1427 for(
int bi = 0; bi < bh_; ++bi)
1430 IT_ j = buf_ptr[row_offset + i*IT_(bh_) + IT_(bi)];
1431 const IT_ j_end = buf_ptr[row_offset + i*IT_(bh_) + IT_(bi) + 1];
1433 auto kit = loc_it.begin();
1436 while((j < j_end) && (kit != loc_it.end()))
1438 if(buf_idx[j] < glob_dof_idx[col_idx[*kit]][0])
1440 else if(buf_idx[j] > glob_dof_idx[col_idx[*kit]][0])
1445 for(
int bj = 0; bj < bw_; ++bj)
1447 aux_data_mir.push_back(std::make_pair(j, (*kit)*IT_(bh_*bw_) + IT_(bi*bw_) + IT_(bj)));
1458 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(buffer.num_nzes(), num_idx);
1459 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(
1460 local_matrix.num_nzes_raw(), num_idx);
1462 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1463 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1464 for(Index i = 0; i < num_idx; ++i)
1466 bm_idx[i] = aux_data_mir[i].first;
1467 lm_idx[i] = aux_data_mir[i].second;
1470 return row_mir_num_idx *
Index(bh_);
1473 Index asm_neighbor_owner_data_mir(
1474 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, 1>& local_matrix,
1475 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1476 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
1477 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
1481 const Memory::TypedView<IT_> row_idx = row_mirror.indices_view_r();
1482 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
1483 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
1484 const Memory::TypedView<IT_> buf_ptr = buffer.row_ptr_view_r();
1485 const Memory::TypedView<IT_> buf_idx = buffer.col_idx_view_r();
1486 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
1487 const Index row_mir_num_idx = row_mirror.num_indices();
1490 Index data_mir_num_idx = 0u;
1491 for(Index i = 0; i < row_mir_num_idx; ++i)
1492 data_mir_num_idx += row_ptr[row_idx[i]+1u] - row_ptr[row_idx[i]];
1493 data_mir_num_idx *=
Index(bh_);
1495 XASSERT(data_mir_num_idx <= buffer.num_nzes());
1498 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1499 aux_data_mir.reserve(data_mir_num_idx);
1502 std::vector<IT_> loc_it;
1503 loc_it.reserve(local_matrix.num_cols() * std::size_t(bh_));
1506 auto sort_rel_loc = [&glob_dof_idx, &col_idx] (IT_ a, IT_ b)
1508 return glob_dof_idx[col_idx[a]] < glob_dof_idx[col_idx[b]];
1512 for(Index i(0); i < row_mir_num_idx; ++i)
1514 const IT_ k_beg = row_ptr[row_idx[i]];
1515 const IT_ k_end = row_ptr[row_idx[i] + 1];
1517 for(IT_ k = k_beg; k < k_end; ++k)
1518 loc_it.push_back(k);
1519 std::sort(loc_it.begin(), loc_it.end(), sort_rel_loc);
1522 for(
int bi = 0; bi < bh_; ++bi)
1525 IT_ j = buf_ptr[row_offset + i*IT_(bh_) + IT_(bi)];
1526 const IT_ j_end = buf_ptr[row_offset + i*IT_(bh_) + IT_(bi) + 1];
1527 auto kit = loc_it.begin();
1530 while((j < j_end) && (kit != loc_it.end()))
1532 if(buf_idx[j] < glob_dof_idx[col_idx[*kit]])
1534 else if(buf_idx[j] > glob_dof_idx[col_idx[*kit]])
1539 aux_data_mir.push_back(std::make_pair(j, (*kit)*IT_(bh_) + IT_(bi)));
1549 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(buffer.num_nzes(), num_idx);
1550 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(local_matrix.num_nzes_raw(), num_idx);
1552 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1553 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1554 for(Index i = 0; i < num_idx; ++i)
1556 bm_idx[i] = aux_data_mir[i].first;
1557 lm_idx[i] = aux_data_mir[i].second;
1560 return row_mir_num_idx *
Index(bh_);
1563 Index asm_owned_data_mir(
1564 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix,
1565 const Adjacency::Graph& owned_graph,
1566 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1567 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>& global_dof_idx,
1571 const Index* own_row_ptr = owned_graph.get_domain_ptr();
1572 const Index* own_col_idx = owned_graph.get_image_idx();
1573 const Memory::TypedView<IT_> loc_row_ptr = local_matrix.row_ptr_view_r();
1574 const Memory::TypedView<IT_> loc_col_idx = local_matrix.col_idx_view_r();
1577 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1578 aux_data_mir.reserve(owned_graph.get_num_indices() * std::size_t(bh_*bw_));
1580 const Index num_owned_dofs = row_mirror.num_indices();
1581 const Memory::TypedView<IT_> loc_dof_idx = row_mirror.indices_view_r();
1582 const Memory::TypedView<Tiny::Vector<IT_,bw_>> glob_dof_idx = global_dof_idx.elements_view_r();
1587 std::deque<IT_> row_it;
1590 auto sort_rel = [&glob_dof_idx, &loc_col_idx] (IT_ a, IT_ b)
1592 return glob_dof_idx[loc_col_idx[a]][0] < glob_dof_idx[loc_col_idx[b]][0];
1596 for(Index own_dof(0); own_dof < num_owned_dofs; ++own_dof)
1598 const IT_ k_beg = loc_row_ptr[loc_dof_idx[own_dof]];
1599 const IT_ k_end = loc_row_ptr[loc_dof_idx[own_dof] + 1];
1601 for(IT_ k = k_beg; k < k_end; ++k)
1602 row_it.push_back(k);
1603 std::sort(row_it.begin(), row_it.end(), sort_rel);
1606 for(
int bi = 0; bi < bh_; ++bi)
1608 IT_ j = IT_(own_row_ptr[row_offset + own_dof*IT_(bh_) + IT_(bi)]);
1609 const IT_ j_end = IT_(own_row_ptr[row_offset + own_dof*IT_(bh_) + IT_(bi) + 1]);
1610 auto kit = row_it.begin();
1613 while((j < j_end) && (kit != row_it.end()))
1615 if(own_col_idx[j] < glob_dof_idx[loc_col_idx[*kit]][0])
1617 else if(own_col_idx[j] > glob_dof_idx[loc_col_idx[*kit]][0])
1622 for(
int bj = 0; bj < bw_; ++bj)
1624 aux_data_mir.push_back(std::make_pair(j, (*kit)*IT_(bh_*bw_) + IT_(bi*bw_) + IT_(bj)));
1635 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(owned_graph.get_num_indices(), num_idx);
1636 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(
1637 local_matrix.num_nzes_raw(), num_idx);
1639 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1640 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1641 for(Index i = 0; i < num_idx; ++i)
1643 bm_idx[i] = aux_data_mir[i].first;
1644 lm_idx[i] = aux_data_mir[i].second;
1647 return num_owned_dofs *
Index(bh_);
1650 Index asm_owned_data_mir(
1651 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, 1>& local_matrix,
1652 const Adjacency::Graph& owned_graph,
1653 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1654 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
1658 const Index* own_row_ptr = owned_graph.get_domain_ptr();
1659 const Index* own_col_idx = owned_graph.get_image_idx();
1660 const Memory::TypedView<IT_> loc_row_ptr = local_matrix.row_ptr_view_r();
1661 const Memory::TypedView<IT_> loc_col_idx = local_matrix.col_idx_view_r();
1664 std::vector<std::pair<IT_, IT_>> aux_data_mir;
1665 aux_data_mir.reserve(owned_graph.get_num_indices() * std::size_t(bh_));
1667 const Index num_owned_dofs = row_mirror.num_indices();
1668 const Memory::TypedView<IT_> loc_dof_idx = row_mirror.indices_view_r();
1669 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
1674 std::deque<IT_> row_it;
1677 auto sort_rel = [&glob_dof_idx, &loc_col_idx] (IT_ a, IT_ b)
1679 return glob_dof_idx[loc_col_idx[a]] < glob_dof_idx[loc_col_idx[b]];
1683 for(Index own_dof(0); own_dof < num_owned_dofs; ++own_dof)
1685 const IT_ k_beg = loc_row_ptr[loc_dof_idx[own_dof]];
1686 const IT_ k_end = loc_row_ptr[loc_dof_idx[own_dof] + 1];
1688 for(IT_ k = k_beg; k < k_end; ++k)
1689 row_it.push_back(k);
1690 std::sort(row_it.begin(), row_it.end(), sort_rel);
1693 for(
int bi = 0; bi < bh_; ++bi)
1695 IT_ j = IT_(own_row_ptr[row_offset + own_dof*IT_(bh_) + IT_(bi)]);
1696 const IT_ j_end = IT_(own_row_ptr[row_offset + own_dof*IT_(bh_) + IT_(bi) + 1]);
1697 auto kit = row_it.begin();
1700 while((j < j_end) && (kit != row_it.end()))
1702 if(own_col_idx[j] < glob_dof_idx[loc_col_idx[*kit]])
1704 else if(own_col_idx[j] > glob_dof_idx[loc_col_idx[*kit]])
1709 aux_data_mir.push_back(std::make_pair(j, (*kit)*IT_(bh_) + IT_(bi)));
1719 this->_buf_mir = LAFEM::VectorMirror<DT_, IT_>(owned_graph.get_num_indices(), num_idx);
1720 this->_loc_mir = LAFEM::VectorMirror<DT_, IT_>(local_matrix.num_nzes_raw(), num_idx);
1722 Memory::TypedView<IT_> bm_idx = this->_buf_mir.indices_view_w();
1723 Memory::TypedView<IT_> lm_idx = this->_loc_mir.indices_view_w();
1724 for(Index i = 0; i < num_idx; ++i)
1726 bm_idx[i] = aux_data_mir[i].first;
1727 lm_idx[i] = aux_data_mir[i].second;
1730 return num_owned_dofs *
Index(bh_);
1733 template<
typename DTA_>
1734 void upload_owned_data(DTA_* adp_val,
const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix)
const
1736 const Memory::TypedView<DT_> loc_val = local_matrix.val_view_raw_r();
1737 const Memory::TypedView<IT_> adp_idx = _buf_mir.indices_view_r();
1738 const Memory::TypedView<IT_> loc_idx = _loc_mir.indices_view_r();
1739 XASSERT(_buf_mir.num_indices() == _loc_mir.num_indices());
1740 Index n = _buf_mir.num_indices();
1741 for(Index i = 0; i < n; ++i)
1743 ASSERT(loc_idx[i] < local_matrix.num_nzes_raw());
1744 adp_val[adp_idx[i]] = DTA_(loc_val[loc_idx[i]]);
1748 void gather_owner_data(
1749 LAFEM::DenseVector<DT_, IT_>& buffer,
1750 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix)
const
1752 Memory::TypedView<DT_> buf_val = buffer.elements_view_w();
1753 const Memory::TypedView<DT_> loc_val = local_matrix.val_view_raw_r();
1754 const Memory::TypedView<IT_> buf_idx = this->_buf_mir.indices_view_r();
1755 const Memory::TypedView<IT_> loc_idx = this->_loc_mir.indices_view_r();
1756 XASSERT(this->_buf_mir.num_indices() == this->_loc_mir.num_indices());
1757 Index n = this->_buf_mir.num_indices();
1758 for(Index i = 0; i < n; ++i)
1760 ASSERT(buf_idx[i] < buffer.size());
1761 ASSERT(loc_idx[i] < local_matrix.num_nzes_raw());
1762 buf_val[buf_idx[i]] = loc_val[loc_idx[i]];
1770 template<
typename DT_,
typename IT_,
int bh_,
int bw_>
1771 class ADPDOMM<LAFEM::NullMatrix<DT_, IT_, bh_, bw_>>
1774 Index num_indices()
const
1779 Index buf_size()
const
1784 Index loc_size()
const
1794 Index asm_neighbor_owner_data_mir(
1795 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
1796 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1797 const LAFEM::MatrixMirrorBuffer<DT_, IT_>&,
1798 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>&,
1801 return row_mirror.num_indices() *
Index(bh_);
1804 Index asm_neighbor_owner_data_mir(
1805 const LAFEM::NullMatrix<DT_, IT_, bh_, 1>&,
1806 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1807 const LAFEM::MatrixMirrorBuffer<DT_, IT_>&,
1808 const LAFEM::DenseVector<IT_, IT_>&,
1811 return row_mirror.num_indices() *
Index(bh_);
1814 Index asm_owned_data_mir(
1815 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
1816 const Adjacency::Graph&,
1817 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1818 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>&,
1821 return row_mirror.num_indices() *
Index(bh_);
1824 Index asm_owned_data_mir(
1825 const LAFEM::NullMatrix<DT_, IT_, bh_, 1>&,
1826 const Adjacency::Graph&,
1827 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
1828 const LAFEM::DenseVector<IT_, IT_>&,
1831 return row_mirror.num_indices() *
Index(bh_);
1834 template<
typename DTA_>
1835 void upload_owned_data(DTA_*,
const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&)
const
1839 void gather_owner_data(
1840 LAFEM::DenseVector<DT_, IT_>&,
1841 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&)
const
1848 template<
typename FirstMatrix_,
typename... RestMatrix_>
1849 class ADPDOMM<LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>>
1852 typedef typename FirstMatrix_::DataType DT_;
1853 typedef typename FirstMatrix_::IndexType IT_;
1855 ADPDOMM<FirstMatrix_> first;
1856 ADPDOMM<LAFEM::TupleMatrixRow<RestMatrix_...>>
rest;
1858 Index num_indices()
const
1860 return first.num_indices() +
rest.num_indices();
1863 Index buf_size()
const
1865 return first.buf_size() +
rest.buf_size();
1868 Index loc_size()
const
1870 return first.loc_size() +
rest.loc_size();
1873 String dump_raw()
const
1875 return first.dump() +
"," +
rest.dump_raw();
1880 return "[" + dump_raw() +
"]";
1884 typename RowMirror_,
1885 typename FirstIdxVec_,
typename... RestIdxVec_>
1886 Index asm_neighbor_owner_data_mir(
1887 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
1888 const RowMirror_& row_mirror,
1889 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
1890 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
1893 Index n1 = first.asm_neighbor_owner_data_mir(local_matrix.first(), row_mirror, buffer, global_dof_idx.first(), row_offset);
1894 Index n2 =
rest.asm_neighbor_owner_data_mir(local_matrix.rest(), row_mirror, buffer, global_dof_idx.rest(), row_offset);
1900 typename RowMirror_,
1901 typename FirstIdxVec_,
typename... RestIdxVec_>
1902 Index asm_owned_data_mir(
1903 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
1904 const Adjacency::Graph& owned_graph,
1905 const RowMirror_& row_mirror,
1906 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
1909 Index n1 = first.asm_owned_data_mir(local_matrix.first(), owned_graph, row_mirror, global_dof_idx.first(), row_offset);
1910 Index n2 =
rest.asm_owned_data_mir(local_matrix.rest(), owned_graph, row_mirror, global_dof_idx.rest(), row_offset);
1915 template<
typename DTA_>
1916 void upload_owned_data(DTA_* adp_val,
const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix)
const
1918 first.upload_owned_data(adp_val, local_matrix.first());
1919 rest.upload_owned_data(adp_val, local_matrix.rest());
1922 void gather_owner_data(
1923 LAFEM::DenseVector<DT_, IT_>& buffer,
1924 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix)
const
1926 first.gather_owner_data(buffer, local_matrix.first());
1927 rest.gather_owner_data(buffer, local_matrix.rest());
1933 template<
typename FirstMatrix_>
1934 class ADPDOMM<LAFEM::TupleMatrixRow<FirstMatrix_>>
1937 typedef typename FirstMatrix_::DataType DT_;
1938 typedef typename FirstMatrix_::IndexType IT_;
1940 ADPDOMM<FirstMatrix_> first;
1942 Index num_indices()
const
1944 return first.num_indices();
1947 Index buf_size()
const
1949 return first.buf_size();
1952 Index loc_size()
const
1954 return first.loc_size();
1957 String dump_raw()
const
1959 return first.dump();
1964 return "[" + dump_raw() +
"]";
1968 typename RowMirror_,
1969 typename FirstIdxVec_>
1970 Index asm_neighbor_owner_data_mir(
1971 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
1972 const RowMirror_& row_mirror,
1973 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
1974 const LAFEM::TupleVector<FirstIdxVec_>& global_dof_idx,
1977 return first.asm_neighbor_owner_data_mir(local_matrix.first(), row_mirror, buffer, global_dof_idx.first(), row_offset);
1981 typename RowMirror_,
1982 typename FirstIdxVec_>
1983 Index asm_owned_data_mir(
1984 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
1985 const Adjacency::Graph& owned_graph,
1986 const RowMirror_& row_mirror,
1987 const LAFEM::TupleVector<FirstIdxVec_>& global_dof_idx,
1990 return first.asm_owned_data_mir(local_matrix.first(), owned_graph, row_mirror, global_dof_idx.first(), row_offset);
1993 template<
typename DTA_>
1994 void upload_owned_data(DTA_* adp_val,
const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix)
const
1996 first.upload_owned_data(adp_val, local_matrix.first());
1999 void gather_owner_data(
2000 LAFEM::DenseVector<DT_, IT_>& buffer,
2001 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix)
const
2003 first.gather_owner_data(buffer, local_matrix.first());
2009 template<
typename FirstMatRow_,
typename... RestMatRow_>
2010 class ADPDOMM<LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>>
2013 typedef typename FirstMatRow_::DataType DT_;
2014 typedef typename FirstMatRow_::IndexType IT_;
2016 ADPDOMM<FirstMatRow_> first;
2017 ADPDOMM<LAFEM::TupleMatrix<RestMatRow_...>>
rest;
2019 Index num_indices()
const
2021 return first.num_indices() +
rest.num_indices();
2024 Index buf_size()
const
2026 return first.buf_size() +
rest.buf_size();
2029 Index loc_size()
const
2031 return first.loc_size() +
rest.loc_size();
2034 String dump_raw()
const
2036 return first.dump() +
"," +
rest.dump_raw();
2041 return "[" + dump_raw() +
"]";
2045 typename FirstRowMir_,
typename... RestRowMir_,
2046 typename FirstIdxVec_,
typename... RestIdxVec_>
2047 Index asm_neighbor_owner_data_mir(
2048 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2049 const LAFEM::TupleMirror<FirstRowMir_, RestRowMir_...>& row_mirror,
2050 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
2051 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
2054 Index n1 = first.asm_neighbor_owner_data_mir(local_matrix.first(), row_mirror.first(), buffer, global_dof_idx, row_offset);
2055 Index n2 =
rest.asm_neighbor_owner_data_mir(local_matrix.rest(), row_mirror.rest(), buffer, global_dof_idx, row_offset + n1);
2060 typename FirstRowMir_,
typename... RestRowMir_,
2061 typename FirstIdxVec_,
typename... RestIdxVec_>
2062 Index asm_owned_data_mir(
2063 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2064 const Adjacency::Graph& owned_graph,
2065 const LAFEM::TupleMirror<FirstRowMir_, RestRowMir_...>& row_mirror,
2066 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
2069 Index n1 = first.asm_owned_data_mir(local_matrix.first(), owned_graph, row_mirror.first(), global_dof_idx, row_offset);
2070 Index n2 =
rest.asm_owned_data_mir(local_matrix.rest(), owned_graph, row_mirror.rest(), global_dof_idx, row_offset + n1);
2074 template<
typename DTA_>
2075 void upload_owned_data(DTA_* adp_val,
const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix)
const
2077 first.upload_owned_data(adp_val, local_matrix.first());
2078 rest.upload_owned_data(adp_val, local_matrix.rest());
2081 void gather_owner_data(
2082 LAFEM::DenseVector<DT_, IT_>& buffer,
2083 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix)
const
2085 first.gather_owner_data(buffer, local_matrix.first());
2086 rest.gather_owner_data(buffer, local_matrix.rest());
2092 template<
typename FirstMatRow_>
2093 class ADPDOMM<LAFEM::TupleMatrix<FirstMatRow_>>
2096 typedef typename FirstMatRow_::DataType DT_;
2097 typedef typename FirstMatRow_::IndexType IT_;
2099 ADPDOMM<FirstMatRow_> first;
2101 Index num_indices()
const
2103 return first.num_indices();
2106 Index buf_size()
const
2108 return first.buf_size();
2111 Index loc_size()
const
2113 return first.loc_size();
2116 String dump_raw()
const
2118 return first.dump();
2123 return "[" + dump_raw() +
"]";
2127 typename FirstRowMir_,
2128 typename FirstIdxVec_,
typename... RestIdxVec_>
2129 Index asm_neighbor_owner_data_mir(
2130 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2131 const LAFEM::TupleMirror<FirstRowMir_>& row_mirror,
2132 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
2133 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
2136 return first.asm_neighbor_owner_data_mir(local_matrix.first(), row_mirror.first(), buffer, global_dof_idx, row_offset);
2140 typename FirstRowMir_,
2141 typename FirstIdxVec_,
typename... RestIdxVec_>
2142 Index asm_owned_data_mir(
2143 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2144 const Adjacency::Graph& owned_graph,
2145 const LAFEM::TupleMirror<FirstRowMir_>& row_mirror,
2146 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
2149 return first.asm_owned_data_mir(local_matrix.first(), owned_graph, row_mirror.first(), global_dof_idx, row_offset);
2152 template<
typename DTA_>
2153 void upload_owned_data(DTA_* adp_val,
const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix)
const
2155 first.upload_owned_data(adp_val, local_matrix.first());
2158 void gather_owner_data(
2159 LAFEM::DenseVector<DT_, IT_>& buffer,
2160 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix)
const
2162 first.gather_owner_data(buffer, local_matrix.first());
2168 template<
typename MatrixA_,
typename MatrixB_,
typename MatrixD_>
2169 class ADPDOMM<LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>>
2172 typedef typename MatrixA_::DataType DT_;
2173 typedef typename MatrixA_::IndexType IT_;
2175 ADPDOMM<MatrixA_> block_a;
2176 ADPDOMM<MatrixB_> block_b;
2177 ADPDOMM<MatrixD_> block_d;
2179 Index num_indices()
const
2181 return block_a.num_indices() + block_b.num_indices() + block_d.num_indices();
2184 Index buf_size()
const
2186 return block_a.buf_size() + block_b.buf_size() + block_d.buf_size();
2189 Index loc_size()
const
2191 return block_a.loc_size() + block_b.loc_size() + block_d.loc_size();
2196 return "[[" + block_a.dump() +
"," + block_b.dump() +
"],[" + block_d.dump() +
",0]";
2200 typename MirrorV_,
typename MirrorP_,
2201 typename IdxVecV_,
typename IdxVecP_>
2202 Index asm_neighbor_owner_data_mir(
2203 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2204 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror,
2205 const LAFEM::MatrixMirrorBuffer<DT_, IT_>& buffer,
2206 const LAFEM::TupleVector<IdxVecV_, IdxVecP_>& global_dof_idx,
2209 Index na = block_a.asm_neighbor_owner_data_mir(local_matrix.block_a(), row_mirror.template at<0>(), buffer, global_dof_idx.template at<0>(), row_offset);
2210 Index nb = block_b.asm_neighbor_owner_data_mir(local_matrix.block_b(), row_mirror.template at<0>(), buffer, global_dof_idx.template at<1>(), row_offset);
2212 Index nd = block_d.asm_neighbor_owner_data_mir(local_matrix.block_d(), row_mirror.template at<1>(), buffer, global_dof_idx.template at<0>(), row_offset + na);
2217 typename MirrorV_,
typename MirrorP_,
2218 typename IdxVecV_,
typename IdxVecP_>
2219 Index asm_owned_data_mir(
2220 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2221 const Adjacency::Graph& owned_graph,
2222 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror,
2223 const LAFEM::TupleVector<IdxVecV_, IdxVecP_>& global_dof_idx,
2226 Index na = block_a.asm_owned_data_mir(local_matrix.block_a(), owned_graph, row_mirror.template at<0>(), global_dof_idx.template at<0>(), row_offset);
2227 Index nb = block_b.asm_owned_data_mir(local_matrix.block_b(), owned_graph, row_mirror.template at<0>(), global_dof_idx.template at<1>(), row_offset);
2229 Index nd = block_d.asm_owned_data_mir(local_matrix.block_d(), owned_graph, row_mirror.template at<1>(), global_dof_idx.template at<0>(), row_offset + na);
2233 template<
typename DTA_>
2234 void upload_owned_data(DTA_* adp_val,
const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix)
const
2236 block_a.upload_owned_data(adp_val, local_matrix.block_a());
2237 block_b.upload_owned_data(adp_val, local_matrix.block_b());
2238 block_d.upload_owned_data(adp_val, local_matrix.block_d());
2241 void gather_owner_data(
2242 LAFEM::DenseVector<DT_, IT_>& buffer,
2243 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix)
const
2245 block_a.gather_owner_data(buffer, local_matrix.block_a());
2246 block_b.gather_owner_data(buffer, local_matrix.block_b());
2247 block_d.gather_owner_data(buffer, local_matrix.block_d());
2253 template<
typename DT_,
typename IT_>
2254 class ADPMatAux<LAFEM::SparseMatrixCSR<DT_, IT_>>
2257 static Index calc_mat_buf_num_rows(
2258 const LAFEM::SparseMatrixCSR<DT_, IT_>& DOXY(local_matrix),
2259 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2261 return row_mirror.num_indices();
2264 static Index calc_mat_buf_row_nze(
2266 const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix,
2267 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2269 const Index num_idx = row_mirror.num_indices();
2270 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2271 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2273 for(Index i(0); i < num_idx; ++i)
2275 buf_row_nze[i] += (row_ptr[mir_idx[i]+1] - row_ptr[mir_idx[i]]);
2281 static Index gather_mat_buf_col_idx(
2284 const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix,
2285 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2286 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx)
2288 const Index num_idx = row_mirror.num_indices();
2289 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2290 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2291 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
2292 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
2294 for(Index i(0); i < num_idx; ++i)
2297 IT_& k = aux_row_ptr[i];
2298 const IT_ row = mir_idx[i];
2301 for(IT_ j(row_ptr[row]); j < row_ptr[row+1]; ++j, ++k)
2302 buf_col_idx[k] = glob_dof_idx[col_idx[j]];
2308 static Index gather_owned_struct(
2309 Adjacency::DynamicGraph& graph,
2310 const LAFEM::SparseMatrixCSR<DT_, IT_>& local_matrix,
2311 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2312 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
2313 const Index row_offset)
2315 const Index num_rows = row_mirror.num_indices();
2316 const Memory::TypedView<IT_> loc_row_ptr = local_matrix.row_ptr_view_r();
2317 const Memory::TypedView<IT_> loc_col_idx = local_matrix.col_idx_view_r();
2318 const Memory::TypedView<IT_> row_mir_idx = row_mirror.indices_view_r();
2319 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
2321 for(Index i(0); i < num_rows; ++i)
2323 const IT_ lrow = row_mir_idx[i];
2324 for(IT_ j(loc_row_ptr[lrow]); j < loc_row_ptr[lrow + 1]; ++j)
2326 graph.insert(row_offset + i,
Index(glob_dof_idx[loc_col_idx[j]]));
2335 template<
typename DT_,
typename IT_,
int bh_,
int bw_>
2336 class ADPMatAux<LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>>
2339 static Index calc_mat_buf_num_rows(
2340 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& DOXY(local_matrix),
2341 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2343 return row_mirror.num_indices() *
Index(bh_);
2346 static Index calc_mat_buf_row_nze(
2348 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix,
2349 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2351 const Index num_idx = row_mirror.num_indices();
2352 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2353 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2355 for(Index i(0), j(0); i < num_idx; ++i)
2357 IT_ nn = IT_(bw_) * (row_ptr[mir_idx[i]+1] - row_ptr[mir_idx[i]]);
2358 for(
int k(0); k < bh_; ++k, ++j)
2359 buf_row_nze[j] += nn;
2362 return num_idx *
Index(bh_);
2365 static Index gather_mat_buf_col_idx(
2368 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix,
2369 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2370 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>& global_dof_idx)
2372 const Index num_idx = row_mirror.num_indices();
2373 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2374 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2375 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
2376 const Memory::TypedView<Tiny::Vector<IT_,bw_>> glob_dof_idx = global_dof_idx.elements_view_r();
2378 for(Index i(0); i < num_idx; ++i)
2380 const IT_ row = mir_idx[i];
2383 for(
int bi(0); bi < bh_; ++bi)
2386 IT_& k = aux_row_ptr[i*IT_(bh_) + IT_(bi)];
2389 for(IT_ j(row_ptr[row]); j < row_ptr[row+1]; ++j)
2392 for(
int bj(0); bj < bw_; ++bj, ++k)
2394 buf_col_idx[k] = glob_dof_idx[col_idx[j]][bj];
2400 return num_idx *
Index(bh_);
2403 static Index gather_mat_buf_col_idx(
2406 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, 1>& local_matrix,
2407 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2408 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx)
2410 const Index num_idx = row_mirror.num_indices();
2411 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2412 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2413 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
2414 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
2416 for(Index i(0); i < num_idx; ++i)
2418 const IT_ row = mir_idx[i];
2421 for(
int bi(0); bi < bh_; ++bi)
2424 IT_& k = aux_row_ptr[i*IT_(bh_) + IT_(bi)];
2427 for(IT_ j(row_ptr[row]); j < row_ptr[row+1]; ++j, ++k)
2429 buf_col_idx[k] = glob_dof_idx[col_idx[j]];
2434 return num_idx *
Index(bh_);
2437 static Index gather_owned_struct(
2438 Adjacency::DynamicGraph& graph,
2439 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, bw_>& local_matrix,
2440 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2441 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>& global_dof_idx,
2442 const Index row_offset)
2444 const Index num_rows = row_mirror.num_indices();
2445 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2446 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2447 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
2448 const Memory::TypedView<Tiny::Vector<IT_, bw_>> glob_dof_idx = global_dof_idx.elements_view_r();
2450 for(Index i(0); i < num_rows; ++i)
2452 const Index lrow = mir_idx[i];
2453 for(IT_ j(row_ptr[lrow]); j < row_ptr[lrow + 1]; ++j)
2455 const auto& gci = glob_dof_idx[col_idx[j]];
2456 for(
int bi = 0; bi < bh_; ++bi)
2458 for(
int bj = 0; bj < bw_; ++bj)
2465 return num_rows *
Index(bh_);
2468 static Index gather_owned_struct(
2469 Adjacency::DynamicGraph& graph,
2470 const LAFEM::SparseMatrixBCSR<DT_, IT_, bh_, 1>& local_matrix,
2471 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2472 const LAFEM::DenseVector<IT_, IT_>& global_dof_idx,
2473 const Index row_offset)
2475 const Index num_rows = row_mirror.num_indices();
2476 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2477 const Memory::TypedView<IT_> row_ptr = local_matrix.row_ptr_view_r();
2478 const Memory::TypedView<IT_> col_idx = local_matrix.col_idx_view_r();
2479 const Memory::TypedView<IT_> glob_dof_idx = global_dof_idx.elements_view_r();
2481 for(Index i(0); i < num_rows; ++i)
2483 const Index lrow = mir_idx[i];
2484 for(IT_ j(row_ptr[lrow]); j < row_ptr[lrow + 1]; ++j)
2486 const IT_ gci = glob_dof_idx[col_idx[j]];
2487 for(
int bi = 0; bi < bh_; ++bi)
2493 return num_rows *
Index(bh_);
2499 template<
typename DT_,
typename IT_,
int bh_,
int bw_>
2500 class ADPMatAux<LAFEM::NullMatrix<DT_, IT_, bh_, bw_>>
2503 static Index calc_mat_buf_num_rows(
2504 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
2505 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2507 return row_mirror.num_indices() *
Index(bh_);
2510 static Index calc_mat_buf_row_nze(
2512 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
2513 const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2515 return row_mirror.num_indices() *
Index(bh_);
2518 static Index gather_mat_buf_col_idx(
2521 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
2522 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2523 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>&)
2525 return row_mirror.num_indices() *
Index(bh_);
2528 static Index gather_mat_buf_col_idx(
2531 const LAFEM::NullMatrix<DT_, IT_, bh_, 1>&,
2532 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2533 const LAFEM::DenseVector<IT_, IT_>&)
2535 return row_mirror.num_indices() *
Index(bh_);
2538 static Index gather_owned_struct(
2539 Adjacency::DynamicGraph&,
2540 const LAFEM::NullMatrix<DT_, IT_, bh_, bw_>&,
2541 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2542 const LAFEM::DenseVectorBlocked<IT_, IT_, bw_>&,
2545 return row_mirror.num_indices() *
Index(bh_);
2548 static Index gather_owned_struct(
2549 Adjacency::DynamicGraph&,
2550 const LAFEM::NullMatrix<DT_, IT_, bh_, 1>&,
2551 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2552 const LAFEM::DenseVector<IT_, IT_>&,
2555 return row_mirror.num_indices() *
Index(bh_);
2561 template<
typename FirstMatrix_,
typename... RestMatrix_>
2562 class ADPMatAux<LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>>
2565 typedef typename FirstMatrix_::IndexType IT_;
2566 typedef ADPMatAux<FirstMatrix_> ADPMatAuxFirst;
2567 typedef ADPMatAux<LAFEM::TupleMatrixRow<RestMatrix_...>> ADPMatAuxRest;
2569 template<
typename RowMirror_>
2570 static Index calc_mat_buf_num_rows(
2571 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
2572 const RowMirror_& row_mirror)
2574 Index n1 = ADPMatAuxFirst::calc_mat_buf_num_rows(local_matrix.first(), row_mirror);
2575 Index n2 = ADPMatAuxRest::calc_mat_buf_num_rows(local_matrix.rest(), row_mirror);
2580 template<
typename RowMirror_>
2581 static Index calc_mat_buf_row_nze(
2583 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
2584 const RowMirror_& row_mirror)
2586 Index n1 = ADPMatAuxFirst::calc_mat_buf_row_nze(buf_row_nze, local_matrix.first(), row_mirror);
2587 Index n2 = ADPMatAuxRest::calc_mat_buf_row_nze(buf_row_nze, local_matrix.rest(), row_mirror);
2593 typename RowMirror_,
2594 typename FirstIdxVec_,
typename... RestIdxVec_>
2595 static Index gather_mat_buf_col_idx(
2598 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
2599 const RowMirror_& row_mirror,
2600 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx)
2602 Index n1 = ADPMatAuxFirst::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.first(), row_mirror, global_dof_idx.first());
2603 Index n2 = ADPMatAuxRest::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.rest(), row_mirror, global_dof_idx.rest());
2609 typename RowMirror_,
2610 typename FirstIdxVec_,
typename... RestIdxVec_>
2611 static Index gather_owned_struct(
2612 Adjacency::DynamicGraph& graph,
2613 const LAFEM::TupleMatrixRow<FirstMatrix_, RestMatrix_...>& local_matrix,
2614 const RowMirror_& row_mirror,
2615 const LAFEM::TupleVector<FirstIdxVec_, RestIdxVec_...>& global_dof_idx,
2616 const Index row_offset)
2618 Index n1 = ADPMatAuxFirst::gather_owned_struct(graph, local_matrix.first(), row_mirror, global_dof_idx.first(), row_offset);
2619 Index n2 = ADPMatAuxRest::gather_owned_struct(graph, local_matrix.rest(), row_mirror, global_dof_idx.rest(), row_offset);
2627 template<
typename FirstMatrix_>
2628 class ADPMatAux<LAFEM::TupleMatrixRow<FirstMatrix_>>
2631 typedef typename FirstMatrix_::IndexType IT_;
2632 typedef ADPMatAux<FirstMatrix_> ADPMatAuxFirst;
2634 template<
typename RowMirror_>
2635 static Index calc_mat_buf_num_rows(
2636 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
2637 const RowMirror_& row_mirror)
2639 return ADPMatAuxFirst::calc_mat_buf_num_rows(local_matrix.first(), row_mirror);
2642 template<
typename RowMirror_>
2643 static Index calc_mat_buf_row_nze(
2645 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
2646 const RowMirror_& row_mirror)
2648 return ADPMatAuxFirst::calc_mat_buf_row_nze(buf_row_nze, local_matrix.first(), row_mirror);
2652 typename RowMirror_,
2653 typename FirstIdxVec_>
2654 static Index gather_mat_buf_col_idx(
2657 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
2658 const RowMirror_& row_mirror,
2659 const LAFEM::TupleVector<FirstIdxVec_>& global_dof_idx)
2661 return ADPMatAuxFirst::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.first(), row_mirror, global_dof_idx.first());
2665 typename RowMirror_,
2666 typename FirstIdxVec_>
2667 static Index gather_owned_struct(
2668 Adjacency::DynamicGraph& graph,
2669 const LAFEM::TupleMatrixRow<FirstMatrix_>& local_matrix,
2670 const RowMirror_& row_mirror,
2671 const LAFEM::TupleVector<FirstIdxVec_>& global_dof_idx,
2672 const Index row_offset)
2674 return ADPMatAuxFirst::gather_owned_struct(graph, local_matrix.first(), row_mirror, global_dof_idx.first(), row_offset);
2680 template<
typename FirstMatRow_,
typename... RestMatRow_>
2681 class ADPMatAux<LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>>
2684 typedef typename FirstMatRow_::IndexType IT_;
2685 typedef ADPMatAux<FirstMatRow_> ADPMatAuxFirst;
2686 typedef ADPMatAux<LAFEM::TupleMatrix<RestMatRow_...>> ADPMatAuxRest;
2688 template<
typename FirstMirror_,
typename... RestMirror_>
2689 static Index calc_mat_buf_num_rows(
2690 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2691 const LAFEM::TupleMirror<FirstMirror_, RestMirror_...>& row_mirror)
2693 Index n1 = ADPMatAuxFirst::calc_mat_buf_num_rows(local_matrix.first(), row_mirror.first());
2694 Index n2 = ADPMatAuxRest::calc_mat_buf_num_rows(local_matrix.rest(), row_mirror.rest());
2698 template<
typename FirstMirror_,
typename... RestMirror_>
2699 static Index calc_mat_buf_row_nze(
2701 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2702 const LAFEM::TupleMirror<FirstMirror_, RestMirror_...>& row_mirror)
2704 Index n1 = ADPMatAuxFirst::calc_mat_buf_row_nze(buf_row_nze, local_matrix.first(), row_mirror.first());
2705 Index n2 = ADPMatAuxRest::calc_mat_buf_row_nze(&buf_row_nze[n1], local_matrix.rest(), row_mirror.rest());
2710 typename FirstMirror_,
typename... RestMirror_,
2711 typename IndexVector_>
2712 static Index gather_mat_buf_col_idx(
2715 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2716 const LAFEM::TupleMirror<FirstMirror_, RestMirror_...>& row_mirror,
2717 const IndexVector_& global_dof_idx)
2719 Index n1 = ADPMatAuxFirst::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.first(), row_mirror.first(), global_dof_idx);
2720 Index n2 = ADPMatAuxRest::gather_mat_buf_col_idx(&aux_row_ptr[n1], buf_col_idx, local_matrix.rest(), row_mirror.rest(), global_dof_idx);
2725 typename FirstMirror_,
typename... RestMirror_,
2726 typename IndexVector_>
2727 static Index gather_owned_struct(
2728 Adjacency::DynamicGraph& graph,
2729 const LAFEM::TupleMatrix<FirstMatRow_, RestMatRow_...>& local_matrix,
2730 const LAFEM::TupleMirror<FirstMirror_, RestMirror_...>& row_mirror,
2731 const IndexVector_& global_dof_idx,
2732 const Index row_offset)
2734 Index n1 = ADPMatAuxFirst::gather_owned_struct(graph, local_matrix.first(), row_mirror.first(), global_dof_idx, row_offset);
2735 Index n2 = ADPMatAuxRest::gather_owned_struct(graph, local_matrix.rest(), row_mirror.rest(), global_dof_idx, row_offset + n1);
2742 template<
typename FirstMatRow_>
2743 class ADPMatAux<LAFEM::TupleMatrix<FirstMatRow_>>
2746 typedef typename FirstMatRow_::IndexType IT_;
2747 typedef ADPMatAux<FirstMatRow_> ADPMatAuxFirst;
2749 template<
typename FirstMirror_>
2750 static Index calc_mat_buf_num_rows(
2751 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2752 const LAFEM::TupleMirror<FirstMirror_>& row_mirror)
2754 return ADPMatAuxFirst::calc_mat_buf_num_rows(local_matrix.first(), row_mirror.first());
2757 template<
typename FirstMirror_>
2758 static Index calc_mat_buf_row_nze(
2760 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2761 const LAFEM::TupleMirror<FirstMirror_>& row_mirror)
2763 return ADPMatAuxFirst::calc_mat_buf_row_nze(buf_row_nze, local_matrix.first(), row_mirror.first());
2767 typename FirstMirror_,
2768 typename IndexVector_>
2769 static Index gather_mat_buf_col_idx(
2772 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2773 const LAFEM::TupleMirror<FirstMirror_>& row_mirror,
2774 const IndexVector_& global_dof_idx)
2776 return ADPMatAuxFirst::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.first(), row_mirror.first(), global_dof_idx);
2780 typename FirstMirror_,
2781 typename IndexVector_>
2782 static Index gather_owned_struct(
2783 Adjacency::DynamicGraph& graph,
2784 const LAFEM::TupleMatrix<FirstMatRow_>& local_matrix,
2785 const LAFEM::TupleMirror<FirstMirror_>& row_mirror,
2786 const IndexVector_& global_dof_idx,
2787 const Index row_offset)
2789 return ADPMatAuxFirst::gather_owned_struct(graph, local_matrix.first(), row_mirror.first(), global_dof_idx, row_offset);
2795 template<
typename MatrixA_,
typename MatrixB_,
typename MatrixD_>
2796 class ADPMatAux<LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>>
2799 typedef typename MatrixA_::IndexType IT_;
2800 typedef ADPMatAux<MatrixA_> ADPMatAuxA;
2801 typedef ADPMatAux<MatrixB_> ADPMatAuxB;
2802 typedef ADPMatAux<MatrixD_> ADPMatAuxD;
2804 template<
typename MirrorV_,
typename MirrorP_>
2805 static Index calc_mat_buf_num_rows(
2806 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2807 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror)
2809 Index n1 = ADPMatAuxB::calc_mat_buf_num_rows(local_matrix.block_b(), row_mirror.template at<0>());
2810 Index n2 = ADPMatAuxD::calc_mat_buf_num_rows(local_matrix.block_d(), row_mirror.template at<1>());
2814 template<
typename MirrorV_,
typename MirrorP_>
2815 static Index calc_mat_buf_row_nze(
2817 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2818 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror)
2820 Index na = ADPMatAuxA::calc_mat_buf_row_nze(buf_row_nze, local_matrix.block_a(), row_mirror.template at<0>());
2821 Index nb = ADPMatAuxB::calc_mat_buf_row_nze(buf_row_nze, local_matrix.block_b(), row_mirror.template at<0>());
2823 Index nd = ADPMatAuxD::calc_mat_buf_row_nze(&buf_row_nze[na], local_matrix.block_d(), row_mirror.template at<1>());
2833 typename MirrorV_,
typename MirrorP_,
2834 typename IdxVecV_,
typename IdxVecP_>
2835 static Index gather_mat_buf_col_idx(
2838 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2839 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror,
2840 const LAFEM::TupleVector<IdxVecV_, IdxVecP_>& global_dof_idx)
2842 Index na = ADPMatAuxA::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.block_a(), row_mirror.template at<0>(), global_dof_idx.template at<0>());
2843 Index nb = ADPMatAuxB::gather_mat_buf_col_idx(aux_row_ptr, buf_col_idx, local_matrix.block_b(), row_mirror.template at<0>(), global_dof_idx.template at<1>());
2845 Index nd = ADPMatAuxD::gather_mat_buf_col_idx(&aux_row_ptr[na], buf_col_idx, local_matrix.block_d(), row_mirror.template at<1>(), global_dof_idx.template at<0>());
2856 typename MirrorV_,
typename MirrorP_,
2857 typename IdxVecV_,
typename IdxVecP_>
2858 static Index gather_owned_struct(
2859 Adjacency::DynamicGraph& graph,
2860 const LAFEM::SaddlePointMatrix<MatrixA_, MatrixB_, MatrixD_>& local_matrix,
2861 const LAFEM::TupleMirror<MirrorV_, MirrorP_>& row_mirror,
2862 const LAFEM::TupleVector<IdxVecV_, IdxVecP_>& global_dof_idx,
2863 const Index row_offset)
2865 Index na = ADPMatAuxA::gather_owned_struct(graph, local_matrix.block_a(), row_mirror.template at<0>(), global_dof_idx.template at<0>(), row_offset);
2866 Index nb = ADPMatAuxB::gather_owned_struct(graph, local_matrix.block_b(), row_mirror.template at<0>(), global_dof_idx.template at<1>(), row_offset);
2868 Index nd = ADPMatAuxD::gather_owned_struct(graph, local_matrix.block_d(), row_mirror.template at<1>(), global_dof_idx.template at<0>(), row_offset + na);
2872 const auto p_dof_idx = global_dof_idx.template at<1>().elements_view_r();
2873 for(Index i = 0u; i < nd; ++i)
2874 graph.insert(na + i, p_dof_idx[i]);
2885 template<
typename DT_,
typename IT_>
2886 class ADPFilAux<LAFEM::NoneFilter<DT_, IT_>>
2889 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2891 return row_mirror.num_indices();
2894 static Index upload_filter(
2895 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
2896 const LAFEM::NoneFilter<DT_, IT_>& DOXY(filter),
2897 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2898 Index DOXY(row_offset))
2901 return row_count(row_mirror);
2907 template<
typename DT_,
typename IT_,
int bs_>
2908 class ADPFilAux<LAFEM::NoneFilterBlocked<DT_, IT_, bs_>>
2911 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2913 return row_mirror.num_indices() *
Index(bs_);
2916 static Index upload_filter(
2917 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
2918 const LAFEM::NoneFilterBlocked<DT_, IT_, bs_>& DOXY(filter),
2919 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2920 Index DOXY(row_offset))
2923 return row_count(row_mirror);
2929 template<
typename DT_,
typename IT_>
2930 class ADPFilAux<LAFEM::UnitFilter<DT_, IT_>>
2933 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2935 return row_mirror.num_indices();
2938 static Index upload_filter(
2939 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
2940 const LAFEM::UnitFilter<DT_, IT_>& filter,
2941 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2944 if(filter.num_nzes() <=
Index(0))
2945 return row_count(row_mirror);
2947 const Memory::TypedView<IT_> fil_idx = filter.get_filter_vector().indices_view_r();
2948 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2949 const Index num_fil = filter.num_nzes();
2950 const Index num_mir = row_mirror.num_indices();
2952 Index i = 0u, j = 0u;
2953 while((i < num_fil) && (j < num_mir))
2955 if(fil_idx[i] <
Index(mir_idx[j]))
2957 else if(fil_idx[i] >
Index(mir_idx[j]))
2961 factory.add(IT_(row_offset + j), DT_(0));
2967 return row_count(row_mirror);
2973 template<
typename DT_,
typename IT_,
int bs_>
2974 class ADPFilAux<LAFEM::UnitFilterBlocked<DT_, IT_, bs_>>
2977 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
2979 return row_mirror.num_indices() *
Index(bs_);
2982 static Index upload_filter(
2983 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
2984 const LAFEM::UnitFilterBlocked<DT_, IT_, bs_>& filter,
2985 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
2988 if(filter.num_nzes() <=
Index(0))
2989 return row_count(row_mirror);
2991 const bool ignore_nans = filter.get_ignore_nans();
2992 const auto fil_val = filter.get_filter_vector().elements_view_r();
2993 const Memory::TypedView<IT_> fil_idx = filter.get_filter_vector().indices_view_r();
2994 const Memory::TypedView<IT_> mir_idx = row_mirror.indices_view_r();
2995 const Index num_fil = filter.num_nzes();
2996 const Index num_mir = row_mirror.num_indices();
2998 Index i = 0u, j = 0u;
2999 while((i < num_fil) && (j < num_mir))
3001 if(fil_idx[i] <
Index(mir_idx[j]))
3003 else if(fil_idx[i] >
Index(mir_idx[j]))
3008 for(
int k = 0; k < bs_; ++k)
3010 if(!ignore_nans || !Math::isnan(fil_val[i][k]))
3011 factory.add(IT_(row_offset + j*
Index(bs_) +
Index(k)), DT_(0));
3017 return row_count(row_mirror);
3023 template<
typename DT_,
typename IT_>
3024 class ADPFilAux<LAFEM::MeanFilter<DT_, IT_>>
3027 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3029 return row_mirror.num_indices();
3032 static Index upload_filter(
3033 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
3034 const LAFEM::MeanFilter<DT_, IT_>& filter,
3035 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
3036 Index DOXY(row_offset))
3038 XASSERTM(filter.empty(),
"AlgDofParti does not support LAFEM::MeanFilter yet!");
3039 return row_count(row_mirror);
3045 template<
typename DT_,
typename IT_,
int bs_>
3046 class ADPFilAux<LAFEM::MeanFilterBlocked<DT_, IT_, bs_>>
3049 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3051 return row_mirror.num_indices() *
Index(bs_);
3054 static Index upload_filter(
3055 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
3056 const LAFEM::MeanFilterBlocked<DT_, IT_, bs_>& filter,
3057 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
3058 Index DOXY(row_offset))
3060 XASSERTM(filter.empty(),
"AlgDofParti does not support LAFEM::MeanFilterBlocked yet!");
3061 return row_count(row_mirror);
3067 template<
typename DT_,
typename IT_>
3068 class ADPFilAux<Global::MeanFilter<DT_, IT_>>
3071 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3073 return row_mirror.num_indices();
3076 static Index upload_filter(
3077 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
3078 const Global::MeanFilter<DT_, IT_>& filter,
3079 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
3080 Index DOXY(row_offset))
3082 XASSERTM(filter.empty(),
"AlgDofParti does not support Global::MeanFilter yet!");
3083 return row_count(row_mirror);
3089 template<
typename DT_,
typename IT_,
int bs_>
3090 class ADPFilAux<LAFEM::SlipFilter<DT_, IT_, bs_>>
3093 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3095 return row_mirror.num_indices() *
Index(bs_);
3098 static Index upload_filter(
3099 LAFEM::SparseVectorFactory<DT_, IT_>& DOXY(factory),
3100 const LAFEM::SlipFilter<DT_, IT_, bs_>& filter,
3101 const LAFEM::VectorMirror<DT_, IT_>& row_mirror,
3102 Index DOXY(row_offset))
3104 XASSERTM(filter.empty(),
"AlgDofParti does not support LAFEM::SlipFilter yet!");
3105 return row_count(row_mirror);
3111 template<
typename FirstFilter_,
typename... RestFilter_>
3112 class ADPFilAux<LAFEM::FilterChain<FirstFilter_, RestFilter_...>>
3115 typedef typename FirstFilter_::DataType DT_;
3116 typedef typename FirstFilter_::IndexType IT_;
3117 typedef ADPFilAux<FirstFilter_> ADPFilAuxFirst;
3118 typedef ADPFilAux<LAFEM::FilterChain<RestFilter_...>> ADPFilAuxRest;
3120 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3122 Index n1 = ADPFilAuxFirst::row_count(row_mirror);
3123 Index n2 = ADPFilAuxRest::row_count(row_mirror);
3128 template<
typename RowMirror_>
3129 static Index upload_filter(
3130 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
3131 const LAFEM::FilterChain<FirstFilter_, RestFilter_...>& filter,
3132 const RowMirror_& row_mirror,
3135 Index n1 = ADPFilAuxFirst::upload_filter(factory, filter.first(), row_mirror, row_offset);
3136 Index n2 = ADPFilAuxRest::upload_filter(factory, filter.rest(), row_mirror, row_offset);
3144 template<
typename FirstFilter_>
3145 class ADPFilAux<LAFEM::FilterChain<FirstFilter_>>
3148 typedef typename FirstFilter_::DataType DT_;
3149 typedef typename FirstFilter_::IndexType IT_;
3150 typedef ADPFilAux<FirstFilter_> ADPFilAuxFirst;
3152 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3154 return ADPFilAuxFirst::row_count(row_mirror);
3157 template<
typename RowMirror_>
3158 static Index upload_filter(
3159 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
3160 const LAFEM::FilterChain<FirstFilter_>& filter,
3161 const RowMirror_& row_mirror,
3164 return ADPFilAuxFirst::upload_filter(factory, filter.first(), row_mirror, row_offset);
3170 template<
typename SubFilter_>
3171 class ADPFilAux<LAFEM::FilterSequence<SubFilter_>>
3174 typedef typename SubFilter_::DataType DT_;
3175 typedef typename SubFilter_::IndexType IT_;
3176 typedef ADPFilAux<SubFilter_> ADPFilAuxSub;
3178 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3180 return ADPFilAuxSub::row_count(row_mirror);
3183 template<
typename RowMirror_>
3184 static Index upload_filter(
3185 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
3186 const LAFEM::FilterSequence<SubFilter_>& filter,
3187 const RowMirror_& row_mirror,
3190 for(
const auto& x : filter)
3192 ADPFilAuxSub::upload_filter(factory, x.second, row_mirror, row_offset);
3194 return row_count(row_mirror);
3200 template<
typename FirstFilter_,
typename... RestFilter_>
3201 class ADPFilAux<LAFEM::TupleFilter<FirstFilter_, RestFilter_...>>
3204 typedef typename FirstFilter_::DataType DT_;
3205 typedef typename FirstFilter_::IndexType IT_;
3206 typedef ADPFilAux<FirstFilter_> ADPFilAuxFirst;
3207 typedef ADPFilAux<LAFEM::TupleFilter<RestFilter_...>> ADPFilAuxRest;
3209 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3211 Index n1 = ADPFilAuxFirst::row_count(row_mirror);
3212 Index n2 = ADPFilAuxRest::row_count(row_mirror);
3216 template<
typename FirstMirror_,
typename... RestMirror_>
3217 static Index upload_filter(
3218 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
3219 const LAFEM::TupleFilter<FirstFilter_, RestFilter_...>& filter,
3220 const LAFEM::TupleMirror<FirstMirror_, RestMirror_...>& row_mirror,
3223 Index n1 = ADPFilAuxFirst::upload_filter(factory, filter.first(), row_mirror.first(), row_offset);
3224 Index n2 = ADPFilAuxRest::upload_filter(factory, filter.rest(), row_mirror.rest(), row_offset + n1);
3231 template<
typename FirstFilter_>
3232 class ADPFilAux<LAFEM::TupleFilter<FirstFilter_>>
3235 typedef typename FirstFilter_::DataType DT_;
3236 typedef typename FirstFilter_::IndexType IT_;
3237 typedef ADPFilAux<FirstFilter_> ADPFilAuxFirst;
3239 static Index row_count(
const LAFEM::VectorMirror<DT_, IT_>& row_mirror)
3241 return ADPFilAuxFirst::row_count(row_mirror);
3244 template<
typename FirstMirror_>
3245 static Index upload_filter(
3246 LAFEM::SparseVectorFactory<DT_, IT_>& factory,
3247 const LAFEM::TupleFilter<FirstFilter_>& filter,
3248 const LAFEM::TupleMirror<FirstMirror_>& row_mirror,
3251 return ADPFilAuxFirst::upload_filter(factory, filter.first(), row_mirror.first(), row_offset);
#define ASSERT(expr)
Debug-Assertion macro definition.
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Dynamic Adjacency Graph implementation.
void clear()
Clears the graph.
bool insert(Index domain_node, Index image_node)
Inserts a new adjacency entry to the graph.
Index get_num_indices() const
Returns the total number of indices.
Adjacency Graph implementation.
Index * get_domain_ptr()
Returns the domain pointer array.
Index * get_image_idx()
Returns the image node index array.
Index get_num_indices() const
Returns the total number indices.
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
Request irecv(void *buffer, std::size_t count, const Datatype &datatype, int source, int tag=0) const
Nonblocking Receive.
Request isend(const void *buffer, std::size_t count, const Datatype &datatype, int dest, int tag=0) const
Nonblocking Send.
void allgatherv(const void *sendbuf, std::size_t sendcount, const Datatype &sendtype, void *recvbuf, const int *recvcounts, const int *displs, const Datatype &recvtype) const
Blocking gather-to-all.
Communication Request vector class.
bool wait_any(std::size_t &idx, Status &status)
Blocks until one of the active requests has been fulfilled.
void wait_all()
Blocks until all active requests are fulfilled.
Algebraic DOF Partitioning implementation.
int get_donee_rank(Index i) const
Returns an donee neighbor rank.
const OwnedMirrorType & get_owned_mirror() const
Returns the Mirror of the owned DOFs.
const OwnerMirrorType & get_owner_mirror(Index i) const
Returns an owner neighbor mirror.
LocalVectorType::template ContainerTypeByDI< IndexType, IndexType > IndexVectorType
the index vector type, this one is required for internal computations
const IndexVectorType & get_global_dof_indices() const
Returns the global-dof-indices array.
int get_owner_rank(Index i) const
Returns an owner neighbor rank.
Index get_num_owner_neighbors() const
Index get_num_donee_neighbors() const
const DoneeMirrorType & get_donee_mirror(Index i) const
Returns a donee neighbor mirror.
Index get_num_global_dofs() const
Index get_num_owned_dofs() const
Algebraic DOF partitioning linear system conversion class.
Index get_adp_vector_size() const
Index _num_owned_non_zeros
number of non-zero entries owned by this process
void filter_vec_cor(DTV_ *vec_cor)
Applies the ADP filter onto an ADP correction vector.
void filter_vec_def(DTV_ *vec_def)
Applies the ADP filter onto an ADP defect vector.
std::shared_ptr< Adjacency::Graph > _owned_graph
adjacency graph containing the owned matrix structure
std::size_t bytes() const
Index get_num_global_nonzeros() const
void upload_matrix_numeric(DTA_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Uploads the data value array of the ADP CSR system matrix.
AlgDofPartiSystem(const GlobalMatrixType &matrix, const GlobalFilterType &filter)
Constructor.
LocalMatrix_ LocalMatrixType
the local matrix type
Index get_adp_matrix_nzes() const
LAFEM::MatrixMirrorBuffer< DataType, IndexType > BufferMatrixType
the buffer matrix type used for communication
const GlobalFilterType & _global_filter
the global filter that we want to convert
LAFEM::VectorMirror< DataType, IndexType > DoneeMirrorType
donee neighbor mirror type
LAFEM::DenseVector< DataType, IndexType > BufferVectorType
the buffer vector type used for communication
LAFEM::SparseMatrixCSR< DataType, IndexType > OwnedMatrixType
the matrix type used for the internal storage of our owned matrix rows
void upload_filter(const LocalFilterType &filter)
Uploads the values of the given filter to the ADP system.
std::shared_ptr< AlgDofPartiType > _alg_dof_parti
the algebraic dof-partitioning
Global::AlgDofParti< LocalVectorType, MirrorType > AlgDofPartiType
the algebraic DOF partitioning
Index get_adp_matrix_rows() const
Index get_adp_matrix_cols() const
void upload_vector(DTV_ *val, const LocalVectorType &vector)
Uploads the ADP vector values to the given array.
Mirror_ MirrorType
the vector mirror type
Index get_global_dof_offset() const
AlgDofPartiSystem & operator=(const AlgDofPartiSystem &)=delete
no copy, no problems
void init_symbolic()
Performs the symbolic initialization.
void apply(DTX_ *vec_r, const DTX_ *vec_x, const DTX_ *val_a, const RPT_ *row_ptr, const CIT_ *col_idx) const
Performs a global matrix-vector product with this matrix.
static void _asm_neighbor_donee_data_mir(DoneeMirrorType &data_mirror, const Adjacency::Graph &owned_graph, const DoneeMirrorType &mirror, const BufferMatrixType &buffer)
Auxiliary function: assembles a data-mirror for a donee-neighbor.
const GlobalMatrixType & _global_matrix
the global matrix that we want to convert
void _assemble_data_mirrors()
Assembles the data-mirrors for all owner- and donee-neighbors.
const Dist::Comm * get_comm() const
void download_vector(LocalVectorType &vector, const DTV_ *val)
Downloads the ADP vector values from the given array.
Index get_num_global_dofs() const
LocalMatrixType::VectorTypeR LocalVectorType
the local vector type
static BufferMatrixType _asm_mat_buf(const LocalMatrixType &local_matrix, const MirrorType &row_mirror, const IndexVectorType &global_dof_idx, const Index num_global_dofs)
Assembles a matrix buffer for a given row mirror.
Global::Filter< LocalFilterType, MirrorType > GlobalFilterType
the global filter type
std::shared_ptr< AlgDofPartiType > get_alg_dof_parti()
Returns the algebraic dof partitioning that is used internally.
std::vector< DoneeMirrorType > _donee_data_mirs
the data array mirrors for our donee and owner neighbors
LocalMatrix_::DataType DataType
our data type
void _assemble_buffers()
Assembles the owner and donee matrix buffers.
void _assemble_structure()
Assembles the matrix structure of the algebraic-DOF-partitioned matrix.
Index get_num_owned_dofs() const
LAFEM::UnitFilter< DataType, IndexType > _unit_filter_rows
indices of all unit-filtered matrix rows; we store this as a mirror
LocalMatrix_::IndexType IndexType
our index type
void filter_matrix(DTA_ *val, const RPT_ *row_ptr, const CIT_ *col_idx)
Applies the ADP filter onto an ADP matrix.
OwnerMirrorType _owned_data_mir
the data array mirror for this process
LocalFilter_ LocalFilterType
the local filter type
Index _num_global_non_zeros
number of non-zero entries in total
AlgDofPartiType::IndexVectorType IndexVectorType
auxiliary index vector type
static void _scatter_donee_data(DTA_ *adp_val, const BufferVectorType &buffer, const DoneeMirrorType &data_mirror)
Scatters the values of a donee-neighbor buffer-vector into a local matrix.
AlgDofPartiSystem(const AlgDofPartiSystem &)=delete
no copy, no problems
std::vector< BufferMatrixType > _donee_bufs
the matrix buffers for our donee and owner neighbors; both buffers use global DOF indices
void upload_matrix_numeric(DTA_ *val, const RPT_ *row_ptr, const CIT_ *col_idx, const LocalMatrixType &matrix)
Copies the matrix entry values from the input matrix into this algebraic-dof-partitioned matrix.
void upload_matrix_symbolic(RPT_ *row_ptr, CIT_ *col_idx, bool keep_graph=false)
Uploads the row-pointer and column-index arrays of the ADP CSR system matrix.
void upload_filter()
Uploads the values of the system filter to the ADP system.
Intern::ADPDOMM< LocalMatrixType > OwnerMirrorType
owner neighbor mirror type
AlgDofPartiSystem(const GlobalMatrixType &matrix, const GlobalFilterType &filter, std::shared_ptr< AlgDofPartiType > adp)
Constructor.
Global::Matrix< LocalMatrixType, MirrorType, MirrorType > GlobalMatrixType
the global matrix type
Global Filter wrapper class template.
Global Matrix wrapper class template.
const GateRowType * get_row_gate() const
Returns a const pointer to the internal row gate of the matrix.
LocalMatrix_ & local()
Returns a reference to the internal local LAFEM matrix object.
Dense data vector class template.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Matrix Mirror Buffer class template.
Index num_rows() const
Retrieve matrix row count.
Index num_cols() const
Retrieve matrix column count.
Index num_nzes() const
Retrieve non zero element count.
Index entries_per_nonzero() const
Retrieve entries per non zero element count.
Factory for SparseVector and SparseVectorBlocked construction.
Unit Filter class template.
Index num_nzes() const
Returns the number of non-zero entries in the filter.
std::size_t bytes() const
Returns the total amount of bytes allocated.
Memory::TypedView< IT_ > indices_view_r(Memory::Location loc=Memory::Location::main) const
Creates a read-only memory view for the indices array for a given memory location.
Handles vector prolongation, restriction and serialization.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Index num_indices() const
Returns the number of indices in the mirror.
T_ * get_w()
Returns a typed pointer to the array that grants write (and read) access.
@ as_is
Render-As-Is mode.
const Operation op_sum(MPI_SUM)
Operation wrapper for MPI_SUM.
void memset_main(void *ptr, int value, std::size_t bytes)
Formats all bytes of a memory block in main memory to a given value.
@ rest
restriction (multigrid)
void feat_omp_ex_scan(std::size_t n, const T_ x[], T_ y[])
Computes an OpenMP-parallel exclusive scan a.k.a. a prefix sum of an array, i.e.
String stringify(const T_ &item)
Converts an item into a String.
std::uint64_t Index
Index data type.