8#include <kernel/adjacency/dynamic_graph.hpp> 
    9#include <kernel/global/gate.hpp> 
   10#include <kernel/global/vector.hpp> 
   11#include <kernel/global/filter.hpp> 
   12#include <kernel/global/matrix.hpp> 
   13#include <kernel/lafem/dense_vector.hpp> 
   14#include <kernel/lafem/sparse_matrix_csr.hpp> 
   15#include <kernel/lafem/unit_filter.hpp> 
   16#include <kernel/lafem/vector_mirror.hpp> 
   17#include <kernel/lafem/matrix_mirror.hpp> 
   31    template<
typename LocalVector_, 
typename Mirror_>
 
   83    template<
typename DT_, 
typename IT_>
 
  136        _glob_dof_idx.clear();
 
  137        _owned_mirror.
clear();
 
  138        _neighbors_owner.clear();
 
  139        _neighbors_donee.clear();
 
  140        _all_glob_dof_offset.clear();
 
  141        _all_glob_dof_counts.clear();
 
  165        return this->_glob_dof_count;
 
  171        return this->_glob_dof_offset;
 
  179        return this->_glob_dof_idx;
 
  193        ASSERT(local_dof_idx < this->_owned_mirror.
size());
 
  194        return this->_glob_dof_idx.at(local_dof_idx);
 
  209        return this->_owned_mirror.
indices()[owned_dof_idx];
 
  217        return this->_owned_mirror;
 
  223        return IndexType(this->_neighbors_owner.size());
 
  229        return IndexType(this->_neighbors_donee.size());
 
  243        return this->_neighbors_owner.at(i).first;
 
  257        return this->_neighbors_donee.at(i).first;
 
  274        return this->_neighbors_owner.at(i).second;
 
  291        return this->_neighbors_donee.at(i).second;
 
  305        XASSERTM(!this->_all_glob_dof_offset.empty(), 
"You did not ask to assemble the global dof offsets");
 
  306        return this->_all_glob_dof_offset;
 
  320        XASSERTM(!this->_all_glob_dof_counts.empty(), 
"You did not ask to assemble the global dof counts");
 
  321        return this->_all_glob_dof_counts;
 
  340        XASSERTM(yes_i_really_want_this, 
"You probably don't want to do this!");
 
  342        std::size_t num_ranks = std::size_t(this->_comm->
size());
 
  344        int my_nod = int(this->get_num_owned_dofs());
 
  345        int my_off = int(this->get_global_dof_offset());
 
  348        this->_all_glob_dof_offset.resize(num_ranks, 0);
 
  349        this->_all_glob_dof_counts.resize(num_ranks, 0);
 
  352        this->_comm->
allgather(&my_off, 1, this->_all_glob_dof_offset.data(), 1);
 
  353        this->_comm->
allgather(&my_nod, 1, this->_all_glob_dof_counts.data(), 1);
 
  365        XASSERTM(this->_comm != 
nullptr, 
"need a communicator here!");
 
  371        const int my_rank = comm.
rank();
 
  372        const std::vector<int>& neighbor_ranks = gate.
_ranks;
 
  384        std::vector<int> dof_owners(num_local_dofs, my_rank);
 
  387        for(std::size_t i(0); i < neighbor_ranks.size(); ++i)
 
  391          const int neighbor_rank = neighbor_ranks.at(i);
 
  392          if(neighbor_rank < my_rank)
 
  398            for(
Index j(0); j < num_indices; ++j)
 
  403              int& dof_owner = dof_owners.at(idx[j]);
 
  404              if(neighbor_rank < dof_owner)
 
  405                dof_owner = neighbor_rank;
 
  413        std::vector<IndexType> owned_dofs;
 
  414        owned_dofs.reserve(num_local_dofs);
 
  420        std::vector<IndexType> own_dof_idx(num_local_dofs, ~
IndexType(0));
 
  423        for(
IndexType i(0); i < num_local_dofs; ++i)
 
  426          if(dof_owners[i] == my_rank)
 
  429            own_dof_idx.at(i) = 
IndexType(owned_dofs.size());
 
  431            owned_dofs.push_back(i);
 
  436        XASSERTM(!owned_dofs.empty(), 
"this process has no DOFs!");
 
  451        this->_owned_mirror = _vidx2mirror(num_local_dofs, owned_dofs);
 
  454        for(std::size_t i(0); i < neighbor_ranks.size(); ++i)
 
  457          const int neighbor_rank = neighbor_ranks.at(i);
 
  465          if(neighbor_rank < my_rank)
 
  474            std::vector<IndexType> v = _owner_vidx(mirror, dof_owners, neighbor_rank);
 
  480              _neighbors_owner.emplace_back(std::make_pair(neighbor_rank, _vidx2mirror(num_local_dofs, v)));
 
  493            std::vector<IndexType> v = _donee_vidx(mirror, own_dof_idx);
 
  499              _neighbors_donee.emplace_back(std::make_pair(neighbor_rank, _vidx2mirror(num_owned_dofs, v)));
 
  512        this->_glob_dof_idx.resize(num_local_dofs, ~
IndexType(0));
 
  517        for(std::size_t i(0); i < owned_dofs.size(); ++i)
 
  518          this->_glob_dof_idx[owned_dofs[i]] = this->_glob_dof_offset + 
IndexType(i);
 
  528        std::vector<std::vector<IndexType>> recv_bufs(num_neigh_owner);
 
  529        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
  531          const std::size_t num_idx = _neighbors_owner.at(i).second.num_indices();
 
  532          recv_bufs.at(i).resize(num_idx);
 
  533          recv_reqs[i] = comm.
irecv(recv_bufs.at(i).data(), num_idx, _neighbors_owner.at(i).first);
 
  540        std::vector<std::vector<IndexType>> send_bufs(num_neigh_donee);
 
  541        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
  544          const MirrorType& mirror = _neighbors_donee.at(i).second;
 
  550          send_bufs.at(i).resize(num_idx);
 
  553            jdx[j] = this->_glob_dof_offset + mir_idx[j];
 
  554          send_reqs[i] = comm.
isend(send_bufs.at(i).data(), num_idx, _neighbors_donee.at(i).first);
 
  558        for(std::size_t i(0u); recv_reqs.
wait_any(i); )
 
  560          const MirrorType& mirror = _neighbors_owner.at(i).second;
 
  563          const IndexType* jdx = recv_bufs.at(i).data();
 
  567            this->_glob_dof_idx[mir_idx[j]] = jdx[j];
 
  585      static MirrorType _vidx2mirror(
const IndexType size, 
const std::vector<IndexType>& vidx)
 
  587        const IndexType nidx = IndexType(vidx.size());
 
  588        MirrorType mirror(size, nidx);
 
  589        IndexType* idx = mirror.indices();
 
  590        for(IndexType i(0); i < nidx; ++i)
 
  597      static std::vector<IndexType> _owner_vidx(
const MirrorType& old_mir,
 
  598        const std::vector<int>& dof_owners, 
const int neighbor_rank)
 
  600        std::vector<IndexType> v;
 
  601        v.reserve(old_mir.num_indices());
 
  603        const IndexType* old_idx = old_mir.indices();
 
  604        for(IndexType i(0); i < old_mir.num_indices(); ++i)
 
  607          if(neighbor_rank == dof_owners[old_idx[i]])
 
  608            v.push_back(old_idx[i]);
 
  615      static std::vector<IndexType> _donee_vidx(
const MirrorType& old_mir,
 
  616        const std::vector<IndexType>& own_dof_idx)
 
  618        std::vector<IndexType> v;
 
  619        v.reserve(old_mir.num_indices());
 
  621        const IndexType* old_idx = old_mir.indices();
 
  622        for(IndexType i(0); i < old_mir.num_indices(); ++i)
 
  625          if(own_dof_idx[old_idx[i]] != ~IndexType(0))
 
  626            v.push_back(own_dof_idx[old_idx[i]]);
 
  655    template<
typename LocalVector_, 
typename Mirror_>
 
  705        _vector(adp_in->get_num_owned_dofs())
 
  712        this->_alg_dof_parti = 
nullptr;
 
  713        this->_vector.
clear();
 
  723      const OwnedVectorType& 
owned()
 const 
  737        XASSERT(this->_alg_dof_parti != 
nullptr);
 
  738        return this->_alg_dof_parti->get_comm();
 
  759        XASSERTM(!this->_alg_dof_parti->get_all_global_dof_counts().empty(),
 
  760          "You did not ask to assemble the required allgather data");
 
  762        XASSERT(vec_full.
size() == this->_alg_dof_parti->get_num_global_dofs());
 
  763        this->_alg_dof_parti->get_comm()->allgatherv(this->_vector.
elements(),
 
  764          this->_alg_dof_parti->get_num_owned_dofs(),
 
  766          this->_alg_dof_parti->get_all_global_dof_counts().data(),
 
  767          this->_alg_dof_parti->get_all_global_dof_offsets().data());
 
  789        XASSERT(this->_alg_dof_parti != 
nullptr);
 
  790        XASSERT(this->_vector.
size() == this->_alg_dof_parti->get_num_owned_dofs());
 
  791        XASSERT(local_vector.size() == this->_alg_dof_parti->get_num_local_dofs());
 
  795        this->_alg_dof_parti->get_owned_mirror().gather(this->_vector, local_vector);
 
  819        XASSERT(this->_alg_dof_parti != 
nullptr);
 
  820        XASSERT(this->_vector.
size() == this->_alg_dof_parti->get_num_owned_dofs());
 
  821        XASSERT(local_vector.size() == this->_alg_dof_parti->get_num_local_dofs());
 
  830        const IndexType num_neigh_owner = adp.get_num_owner_neighbors();
 
  831        const IndexType num_neigh_donee = adp.get_num_donee_neighbors();
 
  840        std::vector<BufferVectorType> recv_bufs(num_neigh_owner);
 
  841        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
  845          recv_bufs.at(i) = adp.get_owner_mirror(i).create_buffer(local_vector);
 
  847          recv_reqs[i] = comm.
irecv(recv_bufs.at(i).elements(), recv_bufs.at(i).size(), adp.get_owner_rank(i));
 
  853        std::vector<BufferVectorType> send_bufs(num_neigh_donee);
 
  854        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
  858          const MirrorType& mir = adp.get_donee_mirror(i);
 
  859          send_bufs.at(i) = mir.create_buffer(this->_vector);
 
  860          mir.gather(send_bufs.at(i), this->_vector);
 
  862          send_reqs[i] = comm.
isend(send_bufs.at(i).elements(), send_bufs.at(i).size(), adp.get_donee_rank(i));
 
  866        local_vector.format();
 
  869        adp.get_owned_mirror().scatter_axpy(local_vector, this->_vector);
 
  872        for(std::size_t idx(0u); recv_reqs.
wait_any(idx); )
 
  875          adp.get_owner_mirror(
IndexType(idx)).scatter_axpy(local_vector, recv_bufs.at(idx));
 
  912    template<
typename LocalMatrix_, 
typename Mirror_>
 
  991        _data_owner_mirs.clear();
 
 1016        XASSERT(this->_alg_dof_parti != 
nullptr);
 
 1017        return this->_alg_dof_parti->get_comm();
 
 1042        XASSERTM(!this->_alg_dof_parti->get_all_global_dof_counts().empty(),
 
 1043          "You did not ask to assemble the required allgather data");
 
 1046        LocalVectorType vec_full(this->_alg_dof_parti->get_num_global_dofs());
 
 1052        this->_matrix.
apply(vec_r.
owned(), vec_full);
 
 1109        XASSERT(this->_alg_dof_parti != 
nullptr);
 
 1141        XASSERT(this->_alg_dof_parti != 
nullptr);
 
 1152        const IndexType num_neigh_owner = adp.get_num_owner_neighbors();
 
 1153        const IndexType num_neigh_donee = adp.get_num_donee_neighbors();
 
 1158        std::vector<BufferVectorType> donee_vbufs(num_neigh_donee);
 
 1159        std::vector<BufferVectorType> owner_vbufs(num_neigh_owner);
 
 1162        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
 1173        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
 1180          this->
_gather_data(buf, mat_a, this->_data_owner_mirs.at(i));
 
 1190        for(std::size_t idx(0u); recv_reqs.
wait_any(idx); )
 
 1193          this->
_scatter_data(this->_matrix, donee_vbufs.at(idx), this->_data_donee_mirs.at(idx));
 
 1212      template<
typename LocalFilter_>
 
 1233        if(filter.used_elements() <= 
IndexType(0))
 
 1240        const IndexType off_glob = adp.get_global_dof_offset();
 
 1241        const IndexType num_glob = adp.get_num_global_dofs();
 
 1244        const Index num_idx = filter.used_elements();
 
 1245        const IndexType* fil_idx = filter.get_indices();
 
 1256          const IndexType gidx = adp.map_local_to_global_index(fil_idx[i]);
 
 1259          if((gidx < off_glob) || (off_glob + num_glob <= gidx))
 
 1264          for(
IndexType j(row_ptr[row]); j < row_ptr[row+1]; ++j)
 
 1266            val[j] = 
DataType(col_idx[j] == gidx ? 1 : 0);
 
 1295        const std::vector<IndexType>& gdi, 
const IndexType num_glob_dofs)
 
 1297        const Index num_idx = mirror.num_indices();
 
 1298        const IndexType* mir_idx = mirror.indices();
 
 1301        const IndexType* col_idx = local_matrix.col_ind();
 
 1307          nnze += (row_ptr[mir_idx[i]+1] - row_ptr[mir_idx[i]]);
 
 1322          for(
IndexType j(row_ptr[row]); j < row_ptr[row+1]; ++j, ++k)
 
 1323            buf_idx[k] = gdi[col_idx[j]];
 
 1349        const IndexType num_neigh_owner = adp.get_num_owner_neighbors();
 
 1350        const IndexType num_neigh_donee = adp.get_num_donee_neighbors();
 
 1351        _owner_bufs.resize(num_neigh_owner);
 
 1355        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
 1357          this->_owner_bufs.at(i) = 
_asm_mat_buf(local_matrix, adp.get_owner_mirror(i),
 
 1358            adp.get_global_dof_indices(), adp.get_num_global_dofs());
 
 1376        std::vector<std::array<IndexType,4>> send_dims(num_neigh_owner);
 
 1377        std::vector<std::array<IndexType,4>> recv_dims(num_neigh_donee);
 
 1380        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
 1382          recv_reqs[i] = comm.
irecv(recv_dims.at(i).data(), std::size_t(4), adp.get_donee_rank(i));
 
 1386        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
 1393          send_reqs[i] = comm.
isend(send_dims.at(i).data(), std::size_t(4), adp.get_owner_rank(i));
 
 1400        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
 1413        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
 1415          recv_reqs[i] = comm.
irecv(this->_donee_bufs.at(i).row_ptr(),
 
 1416            this->_donee_bufs.at(i).rows()+std::size_t(1), adp.get_donee_rank(i));
 
 1423        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
 1425          send_reqs[i] = comm.
isend(this->_owner_bufs.at(i).row_ptr(),
 
 1426            this->_owner_bufs.at(i).rows()+std::size_t(1), adp.get_owner_rank(i));
 
 1433        for(
IndexType i(0); i < num_neigh_donee; ++i)
 
 1435          recv_reqs[i] = comm.
irecv(this->_donee_bufs.at(i).col_ind(),
 
 1436            this->_donee_bufs.at(i).used_elements(), adp.get_donee_rank(i));
 
 1443        for(
IndexType i(0); i < num_neigh_owner; ++i)
 
 1445          send_reqs[i] = comm.
isend(this->_owner_bufs.at(i).col_ind(),
 
 1446            this->_owner_bufs.at(i).used_elements(), adp.get_owner_rank(i));
 
 1469        const IndexType num_rows = adp.get_num_owned_dofs();
 
 1470        const IndexType num_cols = adp.get_num_global_dofs();
 
 1483        const IndexType* loc_row_ptr = local_matrix.row_ptr();
 
 1484        const IndexType* loc_col_idx = local_matrix.col_ind();
 
 1485        const IndexType* own_mir_idx = adp.get_owned_mirror().indices();
 
 1490          for(
IndexType j(loc_row_ptr[lrow]); j < loc_row_ptr[lrow + 1]; ++j)
 
 1493            dynamic_graph.
insert(i, adp.map_local_to_global_index(loc_col_idx[j]));
 
 1498        const IndexType num_neigh_donee = adp.get_num_donee_neighbors();
 
 1499        for(
IndexType ineigh(0); ineigh < num_neigh_donee; ++ineigh)
 
 1503          const MirrorType& mir = adp.get_donee_mirror(ineigh);
 
 1506          const Index num_idx = mir.num_indices();
 
 1507          const IndexType* mir_idx = mir.indices();
 
 1518            for(
IndexType j(buf_ptr[i]); j < buf_ptr[i + 1]; ++j)
 
 1521              dynamic_graph.
insert(row, buf_idx[j]);
 
 1552        MirrorType dat_mir(local_matrix.used_elements(), num_idx);
 
 1554        const IndexType* row_idx = mirror.indices();
 
 1555        const IndexType* row_ptr = local_matrix.row_ptr();
 
 1556        const IndexType* col_idx = local_matrix.col_ind();
 
 1566          for(
IndexType j(buf_ptr[i]); j < buf_ptr[i + 1]; ++j)
 
 1572            for(
IndexType k(row_ptr[row]); k < row_ptr[row + 1]; ++k)
 
 1575              if(col_idx[k] == col)
 
 1606        const std::vector<IndexType>& glob_dof_idx)
 
 1611        MirrorType dat_mir(local_matrix.used_elements(), num_idx);
 
 1613        const IndexType* row_idx = mirror.indices();
 
 1614        const IndexType* row_ptr = local_matrix.row_ptr();
 
 1615        const IndexType* col_idx = local_matrix.col_ind();
 
 1625          for(
IndexType j(buf_ptr[i]); j < buf_ptr[i + 1]; ++j)
 
 1631            for(
IndexType k(row_ptr[row]); k < row_ptr[row + 1]; ++k)
 
 1634              if(glob_dof_idx[col_idx[k]] == col)
 
 1665        this->_data_donee_mirs.resize(this->_donee_bufs.size());
 
 1666        for(
IndexType i(0); i < this->_donee_bufs.size(); ++i)
 
 1668            adp.get_donee_mirror(i), this->_donee_bufs.at(i));
 
 1671        this->_data_owner_mirs.resize(this->_owner_bufs.size());
 
 1672        for(
IndexType i(0); i < this->_owner_bufs.size(); ++i)
 
 1674            adp.get_owner_mirror(i), this->_owner_bufs.at(i),
 
 1675            adp.get_global_dof_indices());
 
 1680        const IndexType* row_ptr_a = local_matrix.row_ptr();
 
 1681        const IndexType* col_idx_a = local_matrix.col_ind();
 
 1687        const IndexType num_owned_dofs = adp.get_num_owned_dofs();
 
 1688        const IndexType* loc_dof_idx = adp.get_owned_mirror().indices();
 
 1689        const std::vector<IndexType>& glob_dof_idx = adp.get_global_dof_indices();
 
 1694        for(
IndexType own_dof(0); own_dof < num_owned_dofs; ++own_dof)
 
 1697          const IndexType loc_dof = loc_dof_idx[own_dof];
 
 1700          for(
IndexType j(row_ptr_x[own_dof]); j < row_ptr_x[own_dof + 1]; ++j)
 
 1706            for(
IndexType k(row_ptr_a[loc_dof]); k < row_ptr_a[loc_dof + 1]; ++k)
 
 1709              const IndexType col_a = glob_dof_idx[col_idx_a[k]];
 
 1732        const DataType* val_a = local_matrix.val();
 
 1736        for(
auto ij : this->_my_data_mir)
 
 1737          val_x[ij.first] = val_a[ij.second];
 
 1755        XASSERT(buffer.
size() == data_mirror.num_indices());
 
 1756        XASSERT(data_mirror.size() == local_matrix.used_elements());
 
 1759        const DataType* mat_val = local_matrix.val();
 
 1760        const IndexType* mir_idx = data_mirror.indices();
 
 1763          buf_val[i] = mat_val[mir_idx[i]];
 
 1781        XASSERT(buffer.
size() == data_mirror.num_indices());
 
 1782        XASSERT(data_mirror.size() == local_matrix.used_elements());
 
 1784        DataType* mat_val = local_matrix.val();
 
 1786        const IndexType* mir_idx = data_mirror.indices();
 
 1789          mat_val[mir_idx[i]] += buf_val[i];
 
#define ASSERT(expr)
Debug-Assertion macro definition.
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Dynamic Adjacency Graph implementation.
bool insert(Index domain_node, Index image_node)
Inserts a new adjacency entry to the graph.
Adjacency Graph implementation.
void allreduce(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking All-Reduce.
int size() const
Returns the size of this communicator.
void exscan(const void *sendbuf, void *recvbuf, std::size_t count, const Datatype &datatype, const Operation &op) const
Blocking Exclusive Scan.
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.
int rank() const
Returns the rank of this process in this communicator.
void allgather(const void *sendbuf, std::size_t sendcount, const Datatype &sendtype, void *recvbuf, std::size_t recvcount, const Datatype &recvtype) const
Blocking gather-to-all.
Communication Request vector class.
bool is_null() const
Checks whether all requests are null requests.
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.
const MirrorType & get_donee_mirror(IndexType i) const
Returns a donee neighbor mirror.
const MirrorType & get_owner_mirror(IndexType i) const
Returns an owner neighbor mirror.
void assemble_allgather(bool yes_i_really_want_this=false)
Assembles the required data for the AlgDofPartiVector::allgather() and AlgDofPartiMatrix::apply() fun...
Global::Gate< LocalVectorType, MirrorType > GateType
the global gate type
int get_donee_rank(IndexType i) const
Returns an donee neighbor rank.
IndexType map_owned_to_local_index(const IndexType owned_dof_idx) const
Maps an owned DOF index to the corresponding local DOF index.
MirrorType _owned_mirror
mirror for this process's owned DOFs
LAFEM::VectorMirror< DataType, IndexType > MirrorType
the vector mirror type
IndexType get_num_donee_neighbors() const
IndexType get_num_local_dofs() const
IndexType _glob_dof_offset
global dof offset of this process
void assemble_by_gate(const GateType &gate)
Assembles the AlgDofParti object from a given Global::Gate.
IndexType get_global_dof_offset() const
IndexType get_num_global_dofs() const
std::vector< IndexType > _glob_dof_idx
global dof indices, size = number of local DOFs
std::vector< std::pair< int, MirrorType > > _neighbors_owner
rank/mirror-pair of DOF-owner processes
LAFEM::DenseVector< DataType, IndexType > LocalVectorType
the local vector type
Global::Vector< LocalVectorType, MirrorType > GlobalVectorType
the global vector type
IndexType map_local_to_global_index(const IndexType local_dof_idx) const
Maps a local DOF index to the corresponding global DOF index.
IT_ IndexType
our index type
int get_owner_rank(IndexType i) const
Returns an owner neighbor rank.
const std::vector< IndexType > get_global_dof_indices() const
Returns the global-dof-indices array.
const MirrorType & get_owned_mirror() const
Returns the Mirror of the owned DOFs.
const Dist::Comm * _comm
our communicator
IndexType _glob_dof_count
global dof count over all processes
const std::vector< int > & get_all_global_dof_counts() const
Returns the all-global-dof-counts vector.
std::vector< int > _all_glob_dof_counts
global DOF counts of all processes,
const std::vector< int > & get_all_global_dof_offsets() const
Returns the all-global-dof-offsets vector.
IndexType get_num_owned_dofs() const
DT_ DataType
our data type
IndexType get_num_owner_neighbors() const
void clear()
Resets the whole object.
std::vector< std::pair< int, MirrorType > > _neighbors_donee
rank/mirror-pair of DOF-donee processes
const Dist::Comm * get_comm() const
std::vector< int > _all_glob_dof_offset
global DOF offsets of all processes,
Algebraic DOF Partitioning implementation class template.
Algebraic DOF Partitioned CSR matrix class template.
void upload_symbolic(const GlobalMatrixType &mat_a)
Initializes this algebraic dof-partitioned matrix from a global matrix.
void filter_matrix(const LAFEM::UnitFilter< DataType, IndexType > &filter)
Applies a unit-filter into this matrix.
static BufferMatrixType _asm_mat_buf(const LocalMatrixType &local_matrix, const MirrorType &mirror, const std::vector< IndexType > &gdi, const IndexType num_glob_dofs)
Auxiliary function: creates a matrix buffer for a given owner mirror.
AlgDofPartiMatrix(const AlgDofPartiType *adp_in)
Creates a ADP matrix based on an algebraic dof partitioning.
std::vector< std::pair< IndexType, IndexType > > _my_data_mir
the data array "mirror" for this process
AlgDofPartiMatrix()
default constructor
static MirrorType _asm_donee_data_mir(const LocalMatrixType &local_matrix, const MirrorType &mirror, const BufferMatrixType &buffer)
Auxiliary function: assembles a data-mirror for a donee-neighbor.
LocalMatrix_::DataType DataType
our data type
LocalMatrix_ LocalMatrixType
the local matrix type
void _assemble_buffers(const LocalMatrixType &local_matrix)
Assembles the owner and donee matrix buffers.
const AlgDofPartiType * _alg_dof_parti
the algebraic dof-partitioning
void _upload_own(const LocalMatrixType &local_matrix)
Uploads the values of the local matrix into our matrix partition.
static void _gather_data(BufferVectorType &buffer, const LocalMatrixType &local_matrix, const MirrorType &data_mirror)
Gathers the values of a local matrix into an owner-neighbor buffer-vector.
LAFEM::MatrixMirrorBuffer< DataType, IndexType > BufferMatrixType
the buffer matrix type used for communication
void _assemble_structure(const LocalMatrixType &local_matrix)
Assembles the matrix structure of the algebraic-DOF-partitioned matrix.
Global::AlgDofPartiVector< LocalVectorType, MirrorType > AlgDofPartiVectorType
the compatible alg-dof-parti vector type
Mirror_ MirrorType
the vector mirror type
std::vector< MirrorType > _data_donee_mirs
the data array mirrors for our donee and owner neighbors
void upload(const LocalMatrixType &mat_a)
Initializes this algebraic dof-partitioned matrix from a global matrix.
OwnedMatrixType _matrix
the internal matrix storing our owned matrix rows
void upload_numeric(const GlobalMatrixType &mat_a)
Copies the matrix entry values from the input matrix into this algebraic-dof-partitioned matrix.
void upload_numeric(const LocalMatrixType &mat_a)
Copies the matrix entry values from the input matrix into this algebraic-dof-partitioned matrix.
const Dist::Comm * get_comm() const
std::vector< BufferMatrixType > _donee_bufs
the matrix buffers for our donee and owner neighbors
LAFEM::DenseVector< DataType, IndexType > BufferVectorType
the buffer vector type used for communication
LocalMatrix_::IndexType IndexType
our index type
void _assemble_data_mirrors(const LocalMatrixType &local_matrix)
Assembles the data-mirrors for all owner- and donee-neighbors.
LocalMatrixType::VectorTypeR LocalVectorType
the local vector type
void filter_matrix(const Global::Filter< LocalFilter_, MirrorType > &filter)
Applies a global unit-filter into this matrix.
const OwnedMatrixType & owned() const
static void _scatter_data(LocalMatrixType &local_matrix, const BufferVectorType &buffer, const MirrorType &data_mirror)
Scatters the values of a donee-neighbor buffer-vector into a local matrix.
OwnedMatrixType & owned()
void upload_symbolic(const LocalMatrixType &mat_a)
Initializes this algebraic-dof-partitioned matrix from a local matrix.
static MirrorType _asm_owner_data_mir(const LocalMatrixType &local_matrix, const MirrorType &mirror, const BufferMatrixType &buffer, const std::vector< IndexType > &glob_dof_idx)
Auxiliary function: assembles a data-mirror for an owner-neighbor.
Global::Matrix< LocalMatrixType, MirrorType, MirrorType > GlobalMatrixType
the global matrix type
const AlgDofPartiType * get_alg_dof_parti() const
void upload(const GlobalMatrixType &mat_a)
Initializes this algebraic dof-partitioned matrix from a global matrix.
Global::AlgDofParti< LocalVectorType, MirrorType > AlgDofPartiType
the algebraic DOF partitioning
void apply(AlgDofPartiVectorType &vec_r, const AlgDofPartiVectorType &vec_x) const
Performs a global matrix-vector product with this matrix.
void clear()
Resets the whole object.
LAFEM::SparseMatrixCSR< DataType, IndexType > OwnedMatrixType
the matrix type used for the internal storage of our owned matrix rows
Algebraic DOF Partitioned Vector class template.
LocalVector_::IndexType IndexType
our index type
const AlgDofPartiType * _alg_dof_parti
the algebraic dof-partitioning
OwnedVectorType & owned()
const Dist::Comm * get_comm() const
Global::AlgDofParti< LocalVector_, Mirror_ > AlgDofPartiType
the algebraic DOF partitioning type
AlgDofPartiVector(const AlgDofPartiType *adp_in)
Creates a ADP vector based on an algebraic dof partitioning.
LAFEM::DenseVector< DataType, IndexType > BufferVectorType
the buffer vector type used for communication
void upload(const GlobalVectorType &global_vector)
Copies the DOF values from a global vector to this algebraic-dof-partitioned vector.
void download(LocalVectorType &local_vector) const
Copies the DOF values from this algebraic-dof-partitioned vector into a local vector.
void download(GlobalVectorType &global_vector) const
Copies the DOF values from this algebraic-dof-partitioned vector into a global vector.
LocalVector_::DataType DataType
our data type
void clear()
Resets the whole object.
void upload(const LocalVectorType &local_vector)
Copies the DOF values from a local vector to this algebraic-dof-partitioned vector.
AlgDofPartiVector()
default constructor
OwnedVectorType _vector
the internal vector object storing our owned dofs
LAFEM::DenseVector< DataType, IndexType > OwnedVectorType
the vector type used for the internal storage of our owned DOFs
LocalVector_ LocalVectorType
the local vector type
Mirror_ MirrorType
the vector mirror type
const OwnedVectorType & owned() const
void allgather(BufferVectorType &vec_full) const
Gathers the full global vector on all processes.
Global::Vector< LocalVector_, Mirror_ > GlobalVectorType
the global vector type
const AlgDofPartiType * get_alg_dof_parti() const
Global Filter wrapper class template.
Global gate implementation.
const Dist::Comm * get_comm() const
Returns a const pointer to the underlying communicator.
std::vector< Mirror_ > _mirrors
vector mirrors
LocalVector_ _freqs
frequency vector
std::vector< int > _ranks
communication ranks
Global Matrix wrapper class template.
LocalMatrix_ & local()
Returns a reference to the internal local LAFEM matrix object.
Global vector wrapper class template.
LocalVector_ & local()
Returns a reference to the internal local LAFEM vector object.
Index size() const
Returns the containers size.
virtual void clear()
Free all allocated arrays.
void format(DT_ value=DT_(0))
Reset all elements of the container to a given value or zero if missing.
Dense data vector class template.
DT_ * elements()
Get a pointer to the data array.
Matrix Mirror Buffer class template.
Index columns() const
Retrieve matrix column count.
IT_ * row_ptr()
Retrieve row start index array.
IT_ * col_ind()
Retrieve column indices array.
Index entries_per_nonzero() const
Retrieve entries per non zero element count.
Index used_elements() const
Retrieve non zero element count.
Index rows() const
Retrieve matrix row count.
IT_ * col_ind()
Retrieve column indices array.
DT_ * val()
Retrieve non zero element array.
Index rows() const
Retrieve matrix row count.
void apply(DenseVector< DT_, IT_ > &r, const DenseVector< DT_, IT_ > &x) const
Calculate .
Index used_elements() const
Retrieve non zero element count.
IT_ * row_ptr()
Retrieve row start index array.
Unit Filter class template.
Handles vector prolongation, restriction and serialization.
IT_ * indices()
Get a pointer to the non zero indices array.
Index num_indices() const
Returns the number of indices in the mirror.
@ as_is
Render-As-Is mode.
const Operation op_sum(MPI_SUM)
Operation wrapper for MPI_SUM.
std::uint64_t Index
Index data type.