Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
dof_handler.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22// Author: Pedro Peixoto <ppeixoto@usp.br>
23
24#ifndef VULPES_DOFS_DOF_HANDLER_HPP_
25#define VULPES_DOFS_DOF_HANDLER_HPP_
26
27#include <algorithm>
28#include <iostream>
29#include <limits>
30#include <memory>
31#include <random>
32#include <string>
33#include <type_traits>
34#include <utility>
35#include <vector>
36
37#include <boost/unordered/unordered_flat_map.hpp>
38#include <boost/unordered/unordered_flat_set.hpp>
39
48
49namespace vulpes {
50namespace dofs {
51
71template <typename MeshType>
73 public:
74 using Mesh = MeshType;
75 using index_t = typename MeshType::index_t;
76 inline static constexpr bool parallel = MeshType::parallel();
77
78 explicit DofHandler(const MeshType& mesh) : m_mesh(mesh) {}
79
86 template <
87 std::size_t Dim,
88 typename FloatType,
89 typename DofPolicy,
90 typename FeSpace>
91 void distributeDofs(
93
103 void applyRenumbering(
104 const RenumberingFunctor<index_t>& renumbering_func, bool reversed);
108 std::size_t ndofs() const { return m_dof_to_cell.size(); }
112 std::size_t ndofsGlobal() const { return m_glob_cum_ndof_per_entity.back(); }
116 const auto& dofOffset() const { return m_all_dof_offset; }
120 const auto& getSparsityPattern() const { return m_sparsity_pattern; }
127 const auto& getCellToDof() const { return m_cell_to_dof; }
128
129 const auto& getCellToCellDof() const { return m_cell_to_cell_dof; }
130 const auto& getCurrToRefNumbering() const { return m_new_to_old_numbering; }
131 const auto& getRefToCurrNumbering() const { return m_old_to_new_numbering; }
132 const auto& getGlobToLocNumbering() const { return m_global_to_local_dof; }
133 const auto& getLocToGlobNumbering() const { return m_local_to_global_dof; }
134 bool hasRenumbering() const { return m_has_renumbering; }
135
146 const std::vector<index_t>& getGhostDofs() const { return m_ghost_dofs; }
147
160 return m_ghost_dof_to_local.at(dof_id);
161 }
162
168 if constexpr (parallel) {
169 return static_cast<index_t>(
171 } else {
172 return static_cast<index_t>(ndofsGlobal());
173 }
174 }
175
189 if constexpr (parallel) {
190 const auto lo = static_cast<index_t>(m_all_dof_offset[mpi::rank()]);
191 const auto hi = static_cast<index_t>(m_all_dof_offset[mpi::rank() + 1]);
192 if (dof_id >= lo && dof_id < hi) {
193 return dof_id - lo;
194 }
195 return nOwnedDofs() + ghostDofLocalIndex(dof_id);
196 } else {
197 return dof_id;
198 }
199 }
200
201 void finalize();
202
210
216 auto gatherSparsityPatternRank0() const;
217
218 protected:
219 bool m_has_renumbering = false;
226 template <typename FeSpace>
228
242 template <bool DofInteractionDistance>
243 std::pair<index_t, index_t> computeSparsityForDof(
244 index_t dof_id, index_t* buffer1, index_t* buffer2);
245
270 template <
271 std::size_t SubentityDim,
272 std::size_t Dim,
273 typename FloatType,
274 typename DofPolicy,
275 typename FeSpace>
278 auto& dof_to_cell);
279
297 template <
298 std::size_t Dim,
299 typename FloatType,
300 typename DofPolicy,
301 typename FeSpace>
304 auto& dof_to_cell);
305
316 void invertDofToCellMappingAndCompress(auto& dof_to_cell);
317
324 void buildGhostDofs();
325
329 template <
330 std::size_t Dim,
331 typename FloatType,
332 typename DofPolicy,
333 typename FeSpace>
334 void computeNumDofs(
336
343 void sortSharedDofs();
344
357
364
368 template <
369 std::size_t Dim,
370 typename FloatType,
371 typename DofPolicy,
372 typename FeSpace>
375
377
381 const MeshType& m_mesh;
382
398
407 std::array<index_t, MeshType::self_dim + 2> m_glob_cum_ndof_per_entity = {0};
413 using MappingType = std::conditional_t<
414 MeshType::parallel(),
415 boost::unordered_flat_map<index_t, index_t>,
416 std::vector<index_t>>;
421 std::vector<index_t> m_old_to_new_numbering;
427
429 // parallel data
431
436 std::array<index_t, MeshType::self_dim + 2> m_loc_cum_ndof_per_entity = {0};
437
441 std::vector<index_t> m_local_to_global_dof;
445 boost::unordered_flat_map<index_t, index_t> m_global_to_local_dof;
446
453 std::vector<index_t> m_owned_dofs;
459 std::vector<index_t> m_shared_dofs;
463 std::vector<index_t> m_local_owned_dofs;
467 std::vector<index_t> m_local_shared_dofs;
468
473 std::size_t m_dof_offset = 0;
478 std::vector<std::size_t> m_all_dof_offset;
482 std::vector<index_t> m_owned_cells_dofs;
483
487 std::size_t m_owning_matrix_rows = 0;
488
493 std::vector<index_t> m_partition_bnd_dofs;
494
500 std::vector<index_t> m_ghost_dofs;
505 boost::unordered_flat_map<index_t, index_t> m_ghost_dof_to_local;
506
508 // parallel data, rank 0 only
510
513 std::vector<index_t> m_all_old_to_new_numbering;
517 std::vector<std::vector<index_t>> m_all_shared_dof;
521 std::vector<std::vector<index_t>> m_all_partition_bnd_dofs;
522};
523
524template <typename MeshType>
525template <
526 std::size_t Dim,
527 typename FloatType,
528 typename DofPolicy,
529 typename FeSpace>
532 // copy the sparsity pattern from the one of `m_cell_to_dof`
534 // cell_id is the local id in MPI numeration
535 for (index_t cell_id = 0; cell_id < m_cell_to_cell_dof.size(); ++cell_id) {
536 for (auto& dof_id : m_cell_to_cell_dof[cell_id]) {
537 // expand information of dof_id by exploiting global (geometric)
538 // enumeration
539 index_t global_dof_id = dof_id;
540 if constexpr (MeshType::parallel()) {
541 global_dof_id = m_local_to_global_dof[dof_id];
542 }
543 index_t enty_dim = 0;
544 while (!(global_dof_id < m_glob_cum_ndof_per_entity[enty_dim + 1])) {
545 enty_dim++;
546 }
547 const index_t entity_dof_id =
548 global_dof_id - m_glob_cum_ndof_per_entity[enty_dim];
549 const index_t n_dofs_per_entity =
550 fe_space.getNumDofsForSubdimEntity(enty_dim);
551 const index_t owning_enty_id = entity_dof_id / n_dofs_per_entity;
552 const index_t enty_multiplicity = entity_dof_id % n_dofs_per_entity;
553 // pass the expanded information to the fe space and update dof_id
554 // from global to local numbering (cell based, not MPI partition based)
555 dof_id = fe_space.dofToCellDof(
556 m_mesh, cell_id, owning_enty_id, enty_dim, enty_multiplicity);
557 }
558 }
559}
560
561template <typename MeshType>
562template <
563 std::size_t Dim,
564 typename FloatType,
565 typename DofPolicy,
566 typename FeSpace>
569 for (std::size_t d = 0; d < FeSpace::dim + 1; ++d) {
570 const auto n_dofs_per_entity = fe_space.getNumDofsForSubdimEntity(d);
571 const auto n_glob_entities = m_mesh.nEntity(d);
572 auto n_loc_entities = m_mesh.nLocEntity(d);
573 if constexpr (MeshType::parallel()) {
574 n_loc_entities += m_mesh.nGhostEntity(d);
575 }
577 m_glob_cum_ndof_per_entity[d] + n_dofs_per_entity * n_glob_entities;
579 m_loc_cum_ndof_per_entity[d] + n_dofs_per_entity * n_loc_entities;
580 }
581}
582
583template <typename MeshType>
584template <
585 std::size_t SubentityDim,
586 std::size_t Dim,
587 typename FloatType,
588 typename DofPolicy,
589 typename FeSpace>
592 auto& dof_to_cell) {
593 const index_t n_dofs_per_entity =
594 fe_space.getNumDofsForSubdimEntity(SubentityDim);
595 if (n_dofs_per_entity > 0) {
596 index_t n_loc_entity = m_mesh.nLocEntity(SubentityDim);
597 if constexpr (MeshType::parallel()) {
598 n_loc_entity += m_mesh.nGhostEntity(SubentityDim);
599 }
600 // for each entity in the mesh, may be vertex, edge, facet, cell
601 for (index_t enty_id = 0; enty_id < n_loc_entity; ++enty_id) {
602 // for each dof that belongs to this entity
603 for (index_t j = 0; j < n_dofs_per_entity; ++j) {
604 // compute global dof id
605 index_t global_enty_id = enty_id;
606 if constexpr (MeshType::parallel()) {
607 global_enty_id = m_mesh.localToGlobal(SubentityDim)[enty_id];
608 }
609 const auto glob_dof_id = m_glob_cum_ndof_per_entity[SubentityDim] +
610 global_enty_id * n_dofs_per_entity + j;
611 auto loc_dof_id = glob_dof_id;
612 if constexpr (MeshType::parallel()) {
613 loc_dof_id = m_local_to_global_dof.size();
614 m_local_to_global_dof.push_back(glob_dof_id);
615 m_global_to_local_dof[glob_dof_id] = loc_dof_id;
616 }
617 // put the `dof_id` in the `dof_to_cell map`
618 // different behavior if we are in a cell or not
619 if constexpr (SubentityDim == Dim) {
620 // we are in a cell, we know to which cell this dof belongs to
621 dof_to_cell[loc_dof_id].push_back(global_enty_id);
622 // in parallel we must keep track of owned and shared dofs
623 if constexpr (MeshType::parallel()) {
624 // we own the cell dof if we own the cell
625 if (enty_id < m_mesh.nLocEntity(SubentityDim)) {
626 m_owned_dofs.push_back(glob_dof_id);
627 m_local_owned_dofs.push_back(loc_dof_id);
628 } else {
629 m_shared_dofs.push_back(glob_dof_id);
630 m_local_shared_dofs.push_back(loc_dof_id);
631 }
632 }
633 } else {
634 const auto& enty_to_cell_map =
635 m_mesh.template getEntityToCellGlobalMap<SubentityDim>();
636 // loop over all the cells to which this entity belongs to
637 for (const auto cell_id : enty_to_cell_map[enty_id]) {
638 // facet mappings always have two elements, one of which may be -1
639 // in this case we skip it
640 if constexpr (SubentityDim == Dim - 1) {
641 if (cell_id == static_cast<decltype(cell_id)>(-1)) {
642 continue;
643 }
644 }
645 dof_to_cell[loc_dof_id].push_back(cell_id);
646 // in parallel we must keep track of owned and shared dofs
647 if constexpr (MeshType::parallel()) {
648 // if the dof belongs to an entity that is on a ghost cell
649 // than it is a shared dof
650 const auto local_cell_id = m_mesh.globalToLocal(Dim).at(cell_id);
651 if ((local_cell_id >= m_mesh.nLocEntity(Dim)) &&
652 (m_shared_dofs.empty() ||
653 m_shared_dofs.back() != glob_dof_id)) {
654 m_shared_dofs.push_back(glob_dof_id);
655 m_local_shared_dofs.push_back(loc_dof_id);
656 }
657 }
658 }
659 // if the dof is not shared, than it is owned
660 if constexpr (MeshType::parallel()) {
661 if (!(m_shared_dofs.size() &&
662 (m_shared_dofs.back() == glob_dof_id))) {
663 m_owned_dofs.push_back(glob_dof_id);
664 m_local_owned_dofs.push_back(loc_dof_id);
665 }
666 }
667 }
668 }
669 }
670 }
671}
672
673template <typename MeshType>
674template <
675 std::size_t Dim,
676 typename FloatType,
677 typename DofPolicy,
678 typename FeSpace>
681 auto& dof_to_cell) {
682 distributeSubentityDofs<0>(fe_space, dof_to_cell);
683 if constexpr (FeSpace::dim > 0) {
684 distributeSubentityDofs<1>(fe_space, dof_to_cell);
685 }
686 if constexpr (FeSpace::dim > 1) {
687 distributeSubentityDofs<2>(fe_space, dof_to_cell);
688 }
689 if constexpr (FeSpace::dim > 2) {
690 distributeSubentityDofs<3>(fe_space, dof_to_cell);
691 }
692}
693
694template <typename MeshType>
696 std::vector<index_t> idxs(m_shared_dofs.size());
697 std::iota(idxs.begin(), idxs.end(), 0);
698 std::sort(idxs.begin(), idxs.end(), [this](auto a, auto b) {
699 return m_shared_dofs[a] < m_shared_dofs[b];
700 });
701 // apply sorting permutation
702 std::vector<index_t> tmp(m_shared_dofs.size());
703 for (std::size_t i = 0; i < idxs.size(); ++i) {
704 tmp[i] = m_shared_dofs[idxs[i]];
705 }
706 std::swap(tmp, m_shared_dofs);
707 for (std::size_t i = 0; i < idxs.size(); ++i) {
708 tmp[i] = m_local_shared_dofs[idxs[i]];
709 }
710 std::swap(tmp, m_local_shared_dofs);
711}
712
713template <typename MeshType>
715 auto& dof_to_cell) {
716 constexpr std::size_t static_buffer_size =
717 vmath::pow((index_t)7, MeshType::self_dim);
719 auto n_loc_cell = m_mesh.nLocEntity(MeshType::self_dim);
720 if constexpr (MeshType::parallel()) {
721 n_loc_cell += m_mesh.nGhostEntity(MeshType::self_dim);
722 }
723 cell_to_dof.resize(n_loc_cell);
724 for (std::size_t dof_id = 0; dof_id < dof_to_cell.size(); ++dof_id) {
725 // we exploit the fact that the dofs are sorted later
726 // when we compute the sparsity pattern
727 // TODO: is this already sorted if in serial?
728 std::sort(dof_to_cell[dof_id].begin(), dof_to_cell[dof_id].end());
729 for (const auto global_cell_id : dof_to_cell[dof_id]) {
730 auto loc_cell_id = global_cell_id;
731 if constexpr (MeshType::parallel()) {
732 loc_cell_id =
733 m_mesh.globalToLocal(MeshType::self_dim).at(global_cell_id);
734 }
735 cell_to_dof[loc_cell_id].push_back(dof_id);
736 }
737 }
738
739 m_dof_to_cell = dof_to_cell.template compress<index_t>();
740 m_cell_to_dof = cell_to_dof.template compress<index_t>();
741}
742
743template <typename MeshType>
745 const auto max_dof_idx =
746 m_cell_to_dof.indices()[m_mesh.nLocEntity(MeshType::self_dim)];
747 const auto& data = m_cell_to_dof.data();
748 boost::unordered_flat_set<index_t> owned_cells_dof(
749 data.begin(), data.begin() + max_dof_idx);
750 m_owned_cells_dofs.assign(owned_cells_dof.begin(), owned_cells_dof.end());
751
752 // find which dofs lie on the partition
753 // i.e. they are both shared and belong to owned cells
754 for (auto loc_dof_id : m_owned_cells_dofs) {
755 const auto glob_dof_id = m_local_to_global_dof[loc_dof_id];
756 const auto it = std::lower_bound(
757 m_shared_dofs.begin(), m_shared_dofs.end(), glob_dof_id);
758 if ((it != m_shared_dofs.end()) && (*it == glob_dof_id)) {
759 m_partition_bnd_dofs.push_back(glob_dof_id);
760 }
761 }
762 std::sort(m_partition_bnd_dofs.begin(), m_partition_bnd_dofs.end());
763}
764
765template <typename MeshType>
766template <
767 std::size_t Dim,
768 typename FloatType,
769 typename DofPolicy,
770 typename FeSpace>
773 // smallest row size that make sense
774 // namely we fill all the space we have in the `SmallVector`
775 constexpr std::size_t static_row_size =
776 sizeof(std::vector<index_t>) / sizeof(index_t);
778 static_assert(FeSpace::dim == MeshType::self_dim);
779
780 computeNumDofs(fe_space);
781 dof_to_cell.resize(m_loc_cum_ndof_per_entity[FeSpace::dim + 1]);
782 PROFILE_INTERVAL(distributeAllSubentityDofs(fe_space, dof_to_cell));
783
784 if (MeshType::parallel()) {
785 // we sort them because it is easier for rank 0 to use them
786 // when computing the global renumbering
788 }
789
791
793
794 if constexpr (MeshType::parallel()) {
796 }
797
799
800 if constexpr (MeshType::parallel()) {
801 m_all_dof_offset.resize(mpi::size() + 1, 0);
802 const auto total_dofs = m_glob_cum_ndof_per_entity.back();
803 for (int p = 0; p < mpi::size(); ++p) {
804 const auto reminder = (p < (total_dofs % mpi::size())) ? 1 : 0;
805 m_all_dof_offset[p + 1] =
806 m_all_dof_offset[p] + total_dofs / mpi::size() + reminder;
807 }
808 }
809}
810
811template <typename MeshType>
812template <bool DofInteractionDistance>
813std::pair<typename MeshType::index_t, typename MeshType::index_t>
815 typename MeshType::index_t dof_id,
816 typename MeshType::index_t* buffer1,
817 typename MeshType::index_t* buffer2) {
818 static std::array<std::size_t, 2> buffers_size = {0, 0};
819 static std::size_t active_buffer = 0;
820 buffers_size = {0, 0};
821 active_buffer = 0;
822 std::array<index_t*, 2> buffers = {buffer1, buffer2};
823
824 // merge all the dofs that belong to this cell (`dofs_view`) and the
825 // others (`buffer[active_buffer]`) into the inactive buffer (`buffer[1 -
826 // active_buffer]`). We assume the dofs are sorted and we remove
827 // duplicates
828 const auto updateBuffer = [&](auto dofs_view) {
829 const index_t* f1 = dofs_view.data();
830 const index_t* l1 = f1 + dofs_view.size();
831 const index_t* f2 = buffers[active_buffer];
832 const index_t* l2 = f2 + buffers_size[active_buffer];
833 index_t* o = buffers[1 - active_buffer];
834 // WARNING: this is not thread-safe
835 buffers_size[1 - active_buffer] =
836 std::distance(o, std::set_union(f1, l1, f2, l2, o));
837 // at each iteration we swap the source buffer with all the dofs and
838 // the destination buffer where we make the union, to avoid an extra
839 // copy
840 buffers_size[active_buffer] = 0;
841 active_buffer = 1 - active_buffer;
842 };
843
844 // for each cell to which this dof belongs to
845 for (index_t global_cell_id : m_dof_to_cell[dof_id]) {
846 auto local_cell_id = global_cell_id;
847 if constexpr (MeshType::parallel()) {
848 local_cell_id =
849 m_mesh.globalToLocal(MeshType::self_dim).at(global_cell_id);
850 }
851 updateBuffer(m_cell_to_dof[local_cell_id]);
852 // if there is interaction with also the neighbours
853 // e.g. if we are in DG each dof belongs to one cell but there
854 // are face couplings
855 if constexpr (DofInteractionDistance) {
856 for (index_t loc_neigh_cell_id : m_mesh.getDualMap()[local_cell_id]) {
857 updateBuffer(m_cell_to_dof[loc_neigh_cell_id]);
858 }
859 }
860 }
861
862 return {active_buffer, buffers_size[active_buffer]};
863}
864
865template <typename MeshType>
866template <typename FeSpace>
868 static constexpr std::size_t n_max_dofs_per_row = 1048576;
869 static std::array<std::array<index_t, n_max_dofs_per_row>, 2> buffers;
870
871 // Probe a good static size for the uncompressed map.
872 // We compute the sparsity pattern for some random dof ids
873 // and check which is the number of nnz at that row.
874 // We then ask for a static size that is greater than the average
875 constexpr index_t probe_size = 1000;
876 index_t nnz = 16;
877 if (m_dof_to_cell.size() > probe_size) {
878 nnz = 0;
879 std::mt19937 gen(0);
880 std::uniform_int_distribution<uint64_t> dis(0, m_dof_to_cell.size() - 1);
881 for (index_t i = 0; i < probe_size; ++i) {
882 const auto random_dof_id = dis(gen);
883 const auto [active_buffer, buffer_size] =
885 random_dof_id, buffers[0].data(), buffers[1].data());
886 nnz += buffer_size;
887 }
888 nnz /= probe_size;
889 }
891 << "Sparsity pattern probing suggested size: " + std::to_string(nnz) +
892 "\n";
893 auto uncompressed_sparsity_pattern =
895 nnz);
896 std::visit(
897 [&](auto& map) { map.resize(m_dof_to_cell.size()); },
898 uncompressed_sparsity_pattern);
899
900 // compute the sparsity pattern for all the dofs
901 for (index_t dof_id = 0; dof_id < m_dof_to_cell.size(); ++dof_id) {
902 const auto [active_buffer, buffer_size] =
904 dof_id, buffers[0].data(), buffers[1].data());
905 const auto nnz_dofid = buffer_size;
906 // copy the sparsity pattern from the static buffer to the uncompressed map
907 std::visit(
908 [dof_id, nnz_dofid, active_buffer](auto& map) {
909 map[dof_id].assign(
910 buffers[active_buffer].data(),
911 buffers[active_buffer].data() + nnz_dofid);
912 },
913 uncompressed_sparsity_pattern);
914 }
915
916 // compress the sparsity pattern
917 m_sparsity_pattern = std::visit(
918 [](const auto& map) { return map.template compress<index_t>(); },
919 uncompressed_sparsity_pattern);
920}
921
922template <typename MeshType>
924 m_has_renumbering = true;
925 const auto size = mpi::size();
926 // collect the size of owned dofs and the list of shared dofs
927 std::vector<std::size_t> cum_dof_offset(size + 1, 0);
928 m_all_shared_dof.resize(size);
929 m_all_partition_bnd_dofs.resize(size);
930
931 if (mpi::root()) {
932 cum_dof_offset[1] = m_owned_dofs.size();
935 for (int p = 1; p < size; ++p) {
936 const auto owned_dof_p = mpi::recv<std::size_t>(p);
937 cum_dof_offset[p + 1] = cum_dof_offset[p] + owned_dof_p;
940 }
941 } else {
942 mpi::send(m_owned_dofs.size(), 0);
945 }
946 // root renumbers the shared dofs and sends them
947 std::vector<index_t> shared_renumbering;
948 m_dof_offset = 0;
949 if (mpi::root()) {
950 // all the shared dofs without duplicates
951 std::vector<index_t> unq_shared_dof;
952 // list of boundary shared dofs "belonging" to proc p
953 // that is a bnd dof is owned by the proc with smallest rank that shares it
954 std::vector<index_t> bnd_dof_belonging_to_p;
955 // global-global old to new numbering
957 std::vector<index_t> tmp_buffer;
958
959 for (int p = 0; p < size - 1; ++p) {
960 // to be numbered, they belong to p
961 std::set_difference(
962 m_all_partition_bnd_dofs[p].begin(),
963 m_all_partition_bnd_dofs[p].end(), unq_shared_dof.begin(),
964 unq_shared_dof.end(), std::back_inserter(bnd_dof_belonging_to_p));
965 // compute the dof offset taking into account the shared between 0 and p
966 for (int i = p; i < size; ++i) {
967 cum_dof_offset[i + 1] += bnd_dof_belonging_to_p.size();
968 }
969 mpi::send(cum_dof_offset[p + 1], p + 1);
970 const auto offset_without_shared =
971 cum_dof_offset[p + 1] - bnd_dof_belonging_to_p.size();
972 for (std::size_t i = 0; i < bnd_dof_belonging_to_p.size(); ++i) {
973 m_all_old_to_new_numbering[bnd_dof_belonging_to_p[i]] =
974 offset_without_shared + i;
975 }
976 // update unq_shared_dof
977 std::set_union(
978 unq_shared_dof.begin(), unq_shared_dof.end(),
979 m_all_partition_bnd_dofs[p].begin(),
980 m_all_partition_bnd_dofs[p].end(), std::back_inserter(tmp_buffer));
981 std::swap(unq_shared_dof, tmp_buffer);
982 bnd_dof_belonging_to_p.resize(0);
983 tmp_buffer.resize(0);
984 }
985
986 // renumber owning according to offset in sequence for self
988 for (std::size_t i = 0; i < m_owned_dofs.size(); ++i) {
991 }
992
993 // receive enumeration from all
994 std::vector<index_t> tmp_own_global_old;
995 std::vector<index_t> tmp_own_global_new;
996 for (int p = 1; p < size; ++p) {
997 mpi::recv(tmp_own_global_old, p);
998 mpi::recv(tmp_own_global_new, p);
999 for (std::size_t i = 0; i < tmp_own_global_old.size(); ++i) {
1000 m_all_old_to_new_numbering[tmp_own_global_old[i]] =
1001 tmp_own_global_new[i];
1002 }
1003 }
1004
1005 // find the enumeration for each proc
1006 for (int p = 1; p < size; ++p) {
1007 shared_renumbering.resize(m_all_shared_dof[p].size());
1008 for (std::size_t i = 0; i < m_all_shared_dof[p].size(); ++i) {
1009 shared_renumbering[i] =
1011 }
1012 mpi::send(shared_renumbering, p);
1013 }
1014 // find the enumeration for self
1015 shared_renumbering.resize(m_all_shared_dof[0].size());
1016 for (std::size_t i = 0; i < m_all_shared_dof[0].size(); ++i) {
1017 shared_renumbering[i] =
1019 }
1020 } else {
1022 // renumber according to offset in sequence
1023 std::vector<index_t> own_global_old;
1024 std::vector<index_t> own_global_new;
1026 for (std::size_t i = 0; i < m_owned_dofs.size(); ++i) {
1027 const auto glob_own_id = m_owned_dofs[i];
1028 const auto loc_own_id = m_global_to_local_dof.at(glob_own_id);
1029 const index_t new_glob_id = i + m_dof_offset;
1030 m_old_to_new_numbering[loc_own_id] = new_glob_id;
1031 own_global_old.push_back(glob_own_id);
1032 own_global_new.push_back(new_glob_id);
1033 }
1034 mpi::send(own_global_old, 0);
1035 mpi::send(own_global_new, 0);
1036 mpi::recv(shared_renumbering, 0);
1037 }
1038 // broadcast the offset
1039 m_all_dof_offset.resize(mpi::size() + 1);
1041 for (int p = 0; p < mpi::size(); ++p) {
1044 }
1045 // apply the shared dof renumbering
1046 assert(shared_renumbering.size() == m_shared_dofs.size());
1047 for (std::size_t i = 0; i < m_shared_dofs.size(); ++i) {
1048 m_old_to_new_numbering[m_local_shared_dofs[i]] = shared_renumbering[i];
1049 }
1050 // invert mapping
1051 m_new_to_old_numbering.clear();
1052 for (std::size_t i = 0; i < m_old_to_new_numbering.size(); ++i) {
1054 }
1055}
1056
1057template <typename MeshType>
1059 const RenumberingFunctor<typename MeshType::index_t>& renumbering_func,
1060 bool reversed) {
1061 m_has_renumbering = true;
1062 assert(m_old_to_new_numbering.size() == m_new_to_old_numbering.size());
1063 using SparsityPatternType = decltype(m_sparsity_pattern);
1064 SparsityPatternType* sparsity_pattern_ptr = &m_sparsity_pattern;
1065 std::shared_ptr<SparsityPatternType> owned_sparsity_pattern;
1066 if (MeshType::parallel()) {
1067 owned_sparsity_pattern =
1068 std::make_shared<SparsityPatternType>(computeOwnedSparsityPattern());
1069 sparsity_pattern_ptr = owned_sparsity_pattern.get();
1070 }
1071 const auto [perm, perm_inv] =
1072 renumbering_func(*sparsity_pattern_ptr, reversed);
1073 assert(perm.size() == perm_inv.size());
1074 // apply perm and perm_inv to mappings
1075 if constexpr (MeshType::parallel()) {
1076 const auto size = mpi::size();
1077 // update the old to new for owned dofs
1078 std::vector<index_t> new_owned_dof_id(m_owned_dofs.size());
1079 {
1080 std::vector<index_t> tmp = m_old_to_new_numbering;
1081 for (std::size_t i = 0; i < perm.size(); ++i) {
1082 tmp[m_local_owned_dofs[i]] =
1084 new_owned_dof_id[i] =
1086 }
1087 m_old_to_new_numbering = std::move(tmp);
1088 }
1089
1090 std::vector<index_t> new_shared_numbering;
1091 if (mpi::root()) {
1092 // get the new numbering of the dofs owned by each proc
1093 std::vector<index_t> owned_dofs_p = m_owned_dofs;
1094 for (int p = 0; p < size; ++p) {
1095 if (p > 0) {
1096 mpi::recv(owned_dofs_p, p);
1097 mpi::recv(new_owned_dof_id, p);
1098 }
1099 assert(new_owned_dof_id.size() == owned_dofs_p.size());
1100 for (std::size_t i = 0; i < new_owned_dof_id.size(); ++i) {
1101 m_all_old_to_new_numbering[owned_dofs_p[i]] = new_owned_dof_id[i];
1102 }
1103 }
1104
1105 // send new numbering of shared
1106 for (int p = 1; p < size; ++p) {
1107 new_shared_numbering.resize(m_all_shared_dof[p].size());
1108 for (std::size_t i = 0; i < m_all_shared_dof[p].size(); ++i) {
1109 new_shared_numbering[i] =
1111 }
1112 mpi::send(new_shared_numbering, p);
1113 }
1114 // do the same for self
1115 new_shared_numbering.resize(m_shared_dofs.size());
1116 for (std::size_t i = 0; i < m_shared_dofs.size(); ++i) {
1117 new_shared_numbering[i] = m_all_old_to_new_numbering[m_shared_dofs[i]];
1118 }
1119 } else {
1121 // new glob ids for m_owned_dofs
1122 mpi::send(new_owned_dof_id, 0);
1123 // new enumeration for shared
1124 mpi::recv(new_shared_numbering, 0);
1125 }
1126 // apply new enumeration for shared
1127 assert(m_local_shared_dofs.size() == new_shared_numbering.size());
1128 for (std::size_t i = 0; i < m_local_shared_dofs.size(); ++i) {
1129 m_old_to_new_numbering[m_local_shared_dofs[i]] = new_shared_numbering[i];
1130 }
1131 // invert the old_to_new
1132 m_new_to_old_numbering.clear();
1133 for (std::size_t i = 0; i < m_old_to_new_numbering.size(); ++i) {
1135 }
1136 } else {
1137 if (m_old_to_new_numbering.size() != perm.size()) {
1138 m_old_to_new_numbering = std::move(perm);
1139 m_new_to_old_numbering = std::move(perm_inv);
1140 } else {
1141 for (std::size_t i = 0; i < m_old_to_new_numbering.size(); ++i) {
1144 }
1145 }
1146 }
1147}
1148
1149template <typename MeshType>
1151 if (MeshType::parallel()) {
1152 // build inverse map (from the local id of an owned dof to the owned id)
1153 const auto n_local_dofs = m_owned_dofs.size() + m_shared_dofs.size();
1154 std::vector<index_t> loc_owned_dofs_inv(n_local_dofs, -1);
1155 for (std::size_t i = 0; i < m_local_owned_dofs.size(); ++i) {
1156 loc_owned_dofs_inv[m_local_owned_dofs[i]] = i;
1157 }
1158 //
1159 std::decay_t<decltype(m_sparsity_pattern)> owned_map({}, {});
1160 const auto& indices = m_sparsity_pattern.indices();
1161 const auto& data = m_sparsity_pattern.data();
1162 owned_map.indices().push_back(0);
1163 for (const auto own_loc_dof_id : m_local_owned_dofs) {
1164 const auto row_start = indices[own_loc_dof_id];
1165 const index_t row_size = indices[own_loc_dof_id + 1] - row_start;
1166 index_t real_size = 0;
1167 for (index_t j = 0; j < row_size; ++j) {
1168 const index_t new_glob_id = data[row_start + j];
1169 const index_t loc_id = m_new_to_old_numbering[new_glob_id];
1170 const index_t old_glob_id = m_local_to_global_dof[loc_id];
1171 const auto it = std::lower_bound(
1172 m_shared_dofs.begin(), m_shared_dofs.end(), old_glob_id);
1173 // if it is not shared, than it is owned
1174 // shared are many less, thus it is quicker than to search in owned
1175 if ((it == m_shared_dofs.end()) || (*it != old_glob_id)) {
1176 owned_map.data().push_back(loc_owned_dofs_inv[loc_id]);
1177 real_size++;
1178 }
1179 }
1180 owned_map.indices().push_back(real_size + owned_map.indices().back());
1181 }
1182 return owned_map;
1183 } else {
1184 return m_sparsity_pattern;
1185 }
1186}
1187
1188template <typename MeshType>
1190 if constexpr (MeshType::parallel()) {
1191 // the parallel renumbering maintains the local numeration of rows
1192 if (m_has_renumbering) {
1193 for (auto& col : m_sparsity_pattern.data()) {
1194 col = m_old_to_new_numbering[col];
1195 }
1196 } else {
1197 for (auto& col : m_sparsity_pattern.data()) {
1198 col = m_local_to_global_dof[col];
1199 }
1200 }
1201 } else {
1202 if (m_has_renumbering) {
1205 }
1206 }
1207
1208 // apply the cell-to-celldof mapping (to account for basis function numbering
1209 // in non-discontinous elements)
1210 assert(m_cell_to_cell_dof.size() == m_cell_to_dof.size());
1211 std::vector<index_t> tmp_buffer;
1212 for (index_t cell_id = 0; cell_id < m_cell_to_dof.size(); ++cell_id) {
1213 assert(m_cell_to_dof[cell_id].size() == m_cell_to_cell_dof[cell_id].size());
1214 const auto row_size = m_cell_to_dof[cell_id].size();
1215 if (tmp_buffer.size() < static_cast<std::size_t>(row_size)) {
1216 tmp_buffer.resize(row_size);
1217 }
1218 for (index_t i = 0; i < row_size; ++i) {
1219 tmp_buffer[m_cell_to_cell_dof[cell_id][i]] = m_cell_to_dof[cell_id][i];
1220 }
1221 std::copy(
1222 tmp_buffer.begin(), tmp_buffer.begin() + row_size,
1223 m_cell_to_dof[cell_id].begin());
1224 }
1225
1226 // apply the local to global to cell-to-dof
1227 if (m_has_renumbering) {
1228 for (auto& loc_dof : m_cell_to_dof.data()) {
1229 loc_dof = m_old_to_new_numbering[loc_dof];
1230 }
1231 } else {
1232 if constexpr (MeshType::parallel()) {
1233 for (auto& loc_dof : m_cell_to_dof.data()) {
1234 loc_dof = m_local_to_global_dof[loc_dof];
1235 }
1236 }
1237 }
1238
1240}
1241
1242template <typename MeshType>
1244 m_ghost_dofs.clear();
1245 m_ghost_dof_to_local.clear();
1246 if constexpr (MeshType::parallel()) {
1247 const auto n_owned = m_mesh.nLocEntity(MeshType::self_dim);
1248 const auto n_ghost = m_mesh.nGhostEntity(MeshType::self_dim);
1249 // A dof on a ghost cell can, at a shared partition boundary, also be
1250 // one of this rank's *owned* dofs (renumberMpiSubdomainWise() assigns
1251 // such shared dofs to a single canonical owner, which may be this
1252 // rank). Exclude those: they are already directly readable via the
1253 // owned range, listing them as ghosts too would be redundant.
1254 const auto lo = static_cast<index_t>(m_all_dof_offset[mpi::rank()]);
1255 const auto hi = static_cast<index_t>(m_all_dof_offset[mpi::rank() + 1]);
1256 for (index_t cell_id = n_owned; cell_id < n_owned + n_ghost; ++cell_id) {
1257 for (const auto dof_id : m_cell_to_dof[cell_id]) {
1258 if (dof_id >= lo && dof_id < hi) {
1259 continue;
1260 }
1261 const auto [it, inserted] = m_ghost_dof_to_local.emplace(
1262 dof_id, static_cast<index_t>(m_ghost_dofs.size()));
1263 if (inserted) {
1264 m_ghost_dofs.push_back(dof_id);
1265 }
1266 }
1267 }
1268 }
1269}
1270
1271template <typename MeshType>
1273 using SpPatternType = datastructure::CrsMap<index_t, index_t>;
1274 using LocToNewMap = std::vector<index_t>;
1275 // recv from ranks the sp-pattern and the loc-to-new
1276 std::vector<SpPatternType> sp_patterns(mpi::size());
1277 std::vector<LocToNewMap> loc_to_new_maps(mpi::size());
1278 std::vector<std::vector<index_t>> all_owned_dofs(mpi::size());
1279 const auto& map =
1281 if (mpi::root()) {
1282 sp_patterns[0] = m_sparsity_pattern;
1283 loc_to_new_maps[0] = map;
1284 all_owned_dofs[0] = m_owned_cells_dofs;
1285 for (int p = 1; p < mpi::size(); ++p) {
1286 mpi::recv(sp_patterns[p], p);
1287 mpi::recv(loc_to_new_maps[p], p);
1288 mpi::recv(all_owned_dofs[p], p);
1289 }
1290 } else {
1292 mpi::send(map, 0);
1294 }
1295
1296 // for each proc; for each row; if empty -> add; else -> check eq;
1298 if (mpi::root()) {
1299 for (int p = 0; p < mpi::size(); ++p) {
1300 for (index_t loc_dof_id = 0; loc_dof_id < sp_patterns[p].size();
1301 ++loc_dof_id) {
1302 const auto glob_dof_id = loc_to_new_maps[p][loc_dof_id];
1303 auto& glob_row = global_sp_pattern.getRow(glob_dof_id);
1304 const auto loc_row = sp_patterns[p][loc_dof_id];
1305 std::sort(loc_row.begin(), loc_row.end());
1306
1307 // the sparsity pattern computed is complete (correct) only
1308 // if the dof belongs to a cell the proc owns.
1309 if (std::find(
1310 all_owned_dofs[p].begin(), all_owned_dofs[p].end(),
1311 loc_dof_id) != all_owned_dofs[p].end()) {
1312 if (glob_row.size()) {
1313 assert(glob_row.size() == static_cast<std::size_t>(loc_row.size()));
1314 assert(
1315 std::equal(glob_row.begin(), glob_row.end(), loc_row.begin()));
1316 } else {
1317 glob_row.assign(loc_row.begin(), loc_row.end());
1318 }
1319 }
1320 }
1321 }
1322 }
1323 return global_sp_pattern.template compress<index_t>();
1324}
1325
1326} // namespace dofs
1327
1328} // namespace vulpes
1329
1330#endif // VULPES_DOFS_DOF_HANDLER_HPP_
A class that behaves like a vector of vectors, providing automatic row range checking.
Definition crs_map.hpp:758
constexpr void resize(std::size_t new_size)
Resizes the map to contain the specified number of SmallVector objects.
Definition crs_map.hpp:807
constexpr void push_back(const SmallVector< DataType, N > &value)
Appends a copy of a SmallVector to the map.
Definition crs_map.hpp:830
SmallVector< DataType, N > & getRow(std::size_t row_idx)
Access a row of the matrix as a mutable reference.
Definition crs_map.hpp:857
Definition crs_map.hpp:72
typename MeshType::index_t index_t
Definition dof_handler.hpp:75
std::vector< index_t > m_owned_cells_dofs
Definition dof_handler.hpp:482
void buildGhostDofs()
Builds m_ghost_dofs/m_ghost_dof_to_local from this rank's ghost cells (mesh-level) and m_cell_to_dof ...
Definition dof_handler.hpp:1243
index_t localGhostedIndex(index_t dof_id) const
Local index, within a Vector built by la::Vector::createGhosted() from this DofHandler,...
Definition dof_handler.hpp:188
void distributeSubentityDofs(const fe::FeSpaceBase< Dim, FloatType, DofPolicy, FeSpace > &fe_space, auto &dof_to_cell)
Distribute the dofs associated to a certain geometric entity.
Definition dof_handler.hpp:590
std::size_t m_owning_matrix_rows
Definition dof_handler.hpp:487
void buildCellToCellDof(const fe::FeSpaceBase< Dim, FloatType, DofPolicy, FeSpace > &fe_space)
Build the local enumeration of the basis functions for each cell.
Definition dof_handler.hpp:530
std::vector< index_t > m_partition_bnd_dofs
Definition dof_handler.hpp:493
std::array< index_t, MeshType::self_dim+2 > m_glob_cum_ndof_per_entity
Definition dof_handler.hpp:407
datastructure::CrsMap< index_t, index_t > m_cell_to_cell_dof
Definition dof_handler.hpp:397
const auto & getRefToCurrNumbering() const
Definition dof_handler.hpp:131
datastructure::CrsMap< index_t, index_t > m_cell_to_dof
Definition dof_handler.hpp:393
void invertDofToCellMappingAndCompress(auto &dof_to_cell)
Invert the dof to cell mapping.
Definition dof_handler.hpp:714
MeshType Mesh
Definition dof_handler.hpp:74
void computeNumDofs(const fe::FeSpaceBase< Dim, FloatType, DofPolicy, FeSpace > &fe_space)
Computes the total number of DoFs.
Definition dof_handler.hpp:567
void distributeDofs(const fe::FeSpaceBase< Dim, FloatType, DofPolicy, FeSpace > &fe_space)
Distribute the DoFs (that is create a cell to dof and dof to cell maps) and create a sparsity pattern...
Definition dof_handler.hpp:771
void renumberMpiSubdomainWise()
Renumber the DoFs in order to minimize the MPI communications.
Definition dof_handler.hpp:923
boost::unordered_flat_map< index_t, index_t > m_global_to_local_dof
Definition dof_handler.hpp:445
std::vector< std::size_t > m_all_dof_offset
Definition dof_handler.hpp:478
void computeSparsityPattern()
Compute the sparsity pattern of the global matrix.
Definition dof_handler.hpp:867
boost::unordered_flat_map< index_t, index_t > m_ghost_dof_to_local
Definition dof_handler.hpp:505
const auto & dofOffset() const
Get the dofs offset of each proc.
Definition dof_handler.hpp:116
std::vector< index_t > m_local_shared_dofs
Definition dof_handler.hpp:467
index_t nOwnedDofs() const
Number of dofs owned by this rank (all of them, for a serial mesh).
Definition dof_handler.hpp:167
std::size_t ndofs() const
Get the total number of dofs for this MPI proc.
Definition dof_handler.hpp:108
index_t ghostDofLocalIndex(index_t dof_id) const
Position of a ghost dof's global id within getGhostDofs(), i.e. its offset within a Vector::createGho...
Definition dof_handler.hpp:159
std::vector< index_t > m_local_to_global_dof
Definition dof_handler.hpp:441
datastructure::CrsMap< index_t, index_t > m_sparsity_pattern
Definition dof_handler.hpp:402
void applyRenumbering(const RenumberingFunctor< index_t > &renumbering_func, bool reversed)
Apply a renumbering to the DoFs to minimize the bandwidth.
Definition dof_handler.hpp:1058
std::vector< index_t > m_old_to_new_numbering
Definition dof_handler.hpp:421
bool hasRenumbering() const
Definition dof_handler.hpp:134
std::size_t ndofsGlobal() const
Get the total number of dofs.
Definition dof_handler.hpp:112
bool m_has_renumbering
Definition dof_handler.hpp:219
const auto & getCellToDof() const
Get the cell to dof map.
Definition dof_handler.hpp:127
std::vector< index_t > m_owned_dofs
Definition dof_handler.hpp:453
std::vector< index_t > m_local_owned_dofs
Definition dof_handler.hpp:463
const auto & getSparsityPattern() const
Get the CrsMap of the sparsity pattern.
Definition dof_handler.hpp:120
const auto & getCurrToRefNumbering() const
Definition dof_handler.hpp:130
std::array< index_t, MeshType::self_dim+2 > m_loc_cum_ndof_per_entity
Definition dof_handler.hpp:436
const auto & getCellToCellDof() const
Definition dof_handler.hpp:129
static constexpr bool parallel
Definition dof_handler.hpp:76
void computeOwnedCellDofsAndBndDofs()
Compute owned cell dofs and boundary dofs.
Definition dof_handler.hpp:744
const auto & getLocToGlobNumbering() const
Definition dof_handler.hpp:133
const auto & getGlobToLocNumbering() const
Definition dof_handler.hpp:132
const MeshType & m_mesh
Definition dof_handler.hpp:381
auto computeOwnedSparsityPattern()
Compute the slice of the sparsity pattern that belongs to this proc.
Definition dof_handler.hpp:1150
void finalize()
Definition dof_handler.hpp:1189
std::vector< std::vector< index_t > > m_all_partition_bnd_dofs
Definition dof_handler.hpp:521
void sortSharedDofs()
Sorts shared dofs following global (geometric) enumeration.
Definition dof_handler.hpp:695
MappingType m_new_to_old_numbering
Definition dof_handler.hpp:426
std::conditional_t< MeshType::parallel(), boost::unordered_flat_map< index_t, index_t >, std::vector< index_t > > MappingType
Definition dof_handler.hpp:413
std::vector< index_t > m_all_old_to_new_numbering
Definition dof_handler.hpp:513
std::vector< index_t > m_shared_dofs
Definition dof_handler.hpp:459
std::vector< index_t > m_ghost_dofs
Definition dof_handler.hpp:500
std::size_t m_dof_offset
Definition dof_handler.hpp:473
datastructure::CrsMap< index_t, index_t > m_dof_to_cell
Definition dof_handler.hpp:386
const std::vector< index_t > & getGhostDofs() const
Global dof indices of dofs living on this rank's ghost cells, i.e. dofs owned by another rank but nee...
Definition dof_handler.hpp:146
std::pair< index_t, index_t > computeSparsityForDof(index_t dof_id, index_t *buffer1, index_t *buffer2)
Compute the sparsity pattern of the global matrix for a certain dof.
DofHandler(const MeshType &mesh)
Definition dof_handler.hpp:78
void distributeAllSubentityDofs(const fe::FeSpaceBase< Dim, FloatType, DofPolicy, FeSpace > &fe_space, auto &dof_to_cell)
Distribute the dofs associated to a all geometric entities.
Definition dof_handler.hpp:679
auto gatherSparsityPatternRank0() const
Compute the global sparsity pattern scattered among MPI procs.
Definition dof_handler.hpp:1272
std::vector< std::vector< index_t > > m_all_shared_dof
Definition dof_handler.hpp:517
Class describing the template for a FeSpace.
Definition fe_space.hpp:77
std::size_t getNumDofsForSubdimEntity(std::size_t dim) const
number of DoFs associated with each geometric entity (vtx = 0, edges = 1, faces = 2 or volume cells =...
Definition fe_space.hpp:132
constexpr MeshType::index_t dofToCellDof(const MeshType &mesh, MeshType::index_t cell_id, MeshType::index_t owning_enty_id, MeshType::index_t enty_dim, MeshType::index_t enty_multiplicity) const
From the global descriptors of a dof, get the dof in local cell enumeration.
Definition fe_space.hpp:166
CrsMapUncompressedVariant< DataType > getUncompressedCrsMapWithStaticStorageGreaterThan(std::size_t static_size)
Function that builds an UncompressedCrsMap with at least a certain static storage,...
Definition crs_map.hpp:936
Definition dof_handler.hpp:50
std::function< Permutation< T >( const datastructure::CrsMap< T, T > &sparsity_pattern, bool reversed)> RenumberingFunctor
Type of a function that renumbers a CrsMap.
Definition numbering.hpp:52
void recv(T *data, int count, int source, MPI_Comm communicator=MPI_COMM_WORLD, MPI_Status *status=MPI_STATUS_IGNORE)
Receive count contiguous values of type T from a source rank.
Definition mpi_wrappers.hpp:311
static int rank()
Return the MPI rank in MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:116
static int size()
Return the size of MPI_COMM_WORLD.
Definition mpi_wrappers.hpp:124
static bool root()
Return true if the rank in MPI_COMM_WORLD is zero.
Definition mpi_wrappers.hpp:132
void send(const T *data, int count, int destination, MPI_Comm communicator=MPI_COMM_WORLD)
Send count contiguous values of type T to a destination rank.
Definition mpi_wrappers.hpp:149
void bcast(T *data, int count, int root, MPI_Comm communicator=MPI_COMM_WORLD)
Broadcast count contiguous values of type T from root.
Definition mpi_wrappers.hpp:495
@ DEBUG
Definition pcout.hpp:37
constexpr U pow(U base, V exp, U result=U(1))
Computes the power of a number.
Definition vmath.hpp:171
Definition cell_manager.hpp:38
vulpes::utils::pcout_t & pcout
Definition pcout.hpp:160
#define PROFILE_INTERVAL(func)
Time a single execution of func under the label #func using Profiler::startInterval()/stopInterval().
Definition profiler.hpp:56