@@ -2649,8 +2649,7 @@ namespace internal
2649
2649
2650
2650
template <int dim, int spacedim>
2651
2651
NumberCache
2652
- Sequential<dim, spacedim>::distribute_dofs(
2653
- const types::global_dof_index n_virtual_dofs) const
2652
+ Sequential<dim, spacedim>::distribute_dofs() const
2654
2653
{
2655
2654
const types::global_dof_index n_initial_dofs =
2656
2655
Implementation::distribute_dofs (numbers::invalid_subdomain_id,
@@ -2661,7 +2660,34 @@ namespace internal
2661
2660
n_initial_dofs,
2662
2661
/* check_validity=*/ true );
2663
2662
2663
+ return NumberCache (n_dofs);
2664
+ }
2665
+
2666
+
2667
+
2668
+ template <int dim, int spacedim>
2669
+ NumberCache
2670
+ Sequential<dim, spacedim>::distribute_virtual_dofs(
2671
+ const types::global_dof_index n_virtual_dofs) const
2672
+ {
2673
+ const auto &old_locally_owned_dofs =
2674
+ dof_handler->locally_owned_dofs ();
2675
+
2676
+ Assert (old_locally_owned_dofs.is_contiguous (),
2677
+ ExcMessage (
2678
+ " Virtual degrees of freedom can only be distributed when the "
2679
+ " locally owned index range is contiguous." ));
2680
+
2681
+ const auto &old_locally_owned_virtual_dofs =
2682
+ dof_handler->locally_owned_virtual_dofs ();
2683
+
2684
+ Assert (old_locally_owned_virtual_dofs.n_elements () == 0 ,
2685
+ ExcMessage (
2686
+ " Can distribute virtual degrees of freedom only once after "
2687
+ " distribute_dofs()" ));
2688
+
2664
2689
// return a sequential, complete index set
2690
+ const auto n_dofs = old_locally_owned_dofs.size ();
2665
2691
NumberCache number_cache (n_dofs + n_virtual_dofs);
2666
2692
2667
2693
number_cache.locally_owned_virtual_dofs =
@@ -2920,11 +2946,8 @@ namespace internal
2920
2946
2921
2947
template <int dim, int spacedim>
2922
2948
NumberCache
2923
- ParallelShared<dim, spacedim>::distribute_dofs(
2924
- const types::global_dof_index virtual_dofs [[maybe_unused]]) const
2949
+ ParallelShared<dim, spacedim>::distribute_dofs() const
2925
2950
{
2926
- Assert (virtual_dofs == 0 , ExcNotImplemented ());
2927
-
2928
2951
const dealii::parallel::shared::Triangulation<dim, spacedim> *tr =
2929
2952
(dynamic_cast <
2930
2953
const dealii::parallel::shared::Triangulation<dim, spacedim> *>(
@@ -3066,6 +3089,17 @@ namespace internal
3066
3089
3067
3090
3068
3091
3092
+ template <int dim, int spacedim>
3093
+ NumberCache
3094
+ ParallelShared<dim, spacedim>::distribute_virtual_dofs(
3095
+ const types::global_dof_index virtual_dofs) const
3096
+ {
3097
+ // FIXME: implement me
3098
+ AssertThrow (virtual_dofs == 0 , ExcNotImplemented ());
3099
+ }
3100
+
3101
+
3102
+
3069
3103
template <int dim, int spacedim>
3070
3104
std::vector<NumberCache>
3071
3105
ParallelShared<dim, spacedim>::distribute_mg_dofs() const
@@ -3644,8 +3678,7 @@ namespace internal
3644
3678
3645
3679
template <int dim, int spacedim>
3646
3680
NumberCache
3647
- ParallelDistributed<dim, spacedim>::distribute_dofs(
3648
- const types::global_dof_index n_locally_virtual [[maybe_unused]]) const
3681
+ ParallelDistributed<dim, spacedim>::distribute_dofs() const
3649
3682
{
3650
3683
#ifndef DEAL_II_WITH_MPI
3651
3684
DEAL_II_NOT_IMPLEMENTED ();
@@ -3741,13 +3774,9 @@ namespace internal
3741
3774
Utilities::MPI::partial_and_total_sum (
3742
3775
n_locally_owned_dofs, triangulation->get_communicator ());
3743
3776
3744
- const auto [my_shift_virtual, n_global_virtual] =
3745
- Utilities::MPI::partial_and_total_sum (
3746
- n_locally_virtual, triangulation->get_communicator ());
3747
-
3748
3777
// make dof indices globally consecutive
3749
3778
Implementation::enumerate_dof_indices_for_renumbering (
3750
- renumbering, all_constrained_indices, my_shift + my_shift_virtual );
3779
+ renumbering, all_constrained_indices, my_shift);
3751
3780
3752
3781
// now re-enumerate all dofs to this shifted and condensed
3753
3782
// numbering form. we renumber some dofs as invalid, so
@@ -3757,26 +3786,17 @@ namespace internal
3757
3786
*dof_handler,
3758
3787
/* check_validity=*/ false );
3759
3788
3760
-
3761
3789
NumberCache number_cache;
3762
- number_cache.n_global_dofs = n_global_dofs + n_global_virtual;
3763
- number_cache.n_locally_owned_dofs =
3764
- n_locally_owned_dofs + n_locally_virtual;
3790
+ number_cache.n_global_dofs = n_global_dofs;
3791
+ number_cache.n_locally_owned_dofs = n_locally_owned_dofs;
3765
3792
3766
- number_cache.locally_owned_dofs =
3767
- IndexSet (n_global_dofs + n_global_virtual);
3793
+ number_cache.locally_owned_dofs = IndexSet (n_global_dofs);
3768
3794
number_cache.locally_owned_dofs .add_range ( //
3769
- my_shift + my_shift_virtual,
3770
- my_shift + my_shift_virtual + n_locally_owned_dofs +
3771
- n_locally_virtual);
3795
+ my_shift,
3796
+ my_shift + n_locally_owned_dofs);
3772
3797
number_cache.locally_owned_dofs .compress ();
3773
3798
3774
- number_cache.locally_owned_virtual_dofs =
3775
- IndexSet (n_global_dofs + n_global_virtual);
3776
- number_cache.locally_owned_virtual_dofs .add_range (
3777
- my_shift + my_shift_virtual + n_locally_owned_dofs,
3778
- my_shift + my_shift_virtual + n_locally_owned_dofs +
3779
- n_locally_virtual);
3799
+ number_cache.locally_owned_virtual_dofs = IndexSet (n_global_dofs);
3780
3800
number_cache.locally_owned_virtual_dofs .compress ();
3781
3801
3782
3802
@@ -3868,6 +3888,71 @@ namespace internal
3868
3888
3869
3889
3870
3890
3891
+ template <int dim, int spacedim>
3892
+ NumberCache
3893
+ ParallelDistributed<dim, spacedim>::distribute_virtual_dofs(
3894
+ const types::global_dof_index virtual_dofs) const
3895
+ {
3896
+ const auto &old_locally_owned_dofs =
3897
+ dof_handler->locally_owned_dofs ();
3898
+
3899
+ Assert (old_locally_owned_dofs.is_contiguous (),
3900
+ ExcMessage (
3901
+ " Virtual degrees of freedom can only be distributed when the "
3902
+ " locally owned index range is contiguous." ));
3903
+
3904
+ const auto &old_locally_owned_virtual_dofs =
3905
+ dof_handler->locally_owned_virtual_dofs ();
3906
+
3907
+ Assert (old_locally_owned_virtual_dofs.n_elements () == 0 ,
3908
+ ExcMessage (
3909
+ " Can distribute virtual degrees of freedom only once after "
3910
+ " distribute_dofs()" ));
3911
+
3912
+ dealii::parallel::DistributedTriangulationBase<dim, spacedim>
3913
+ *triangulation =
3914
+ (dynamic_cast <
3915
+ dealii::parallel::DistributedTriangulationBase<dim, spacedim> *>(
3916
+ const_cast <dealii::Triangulation<dim, spacedim> *>(
3917
+ &dof_handler->get_triangulation ())));
3918
+ Assert (triangulation != nullptr , ExcInternalError ());
3919
+
3920
+ //
3921
+ // Renumber degrees of freedom by adding a global shift to the
3922
+ // locally owned index range:
3923
+ //
3924
+
3925
+ const auto [my_shift, n_global_virtual_dofs] =
3926
+ Utilities::MPI::partial_and_total_sum (
3927
+ virtual_dofs, triangulation->get_communicator ());
3928
+
3929
+ std::vector<dealii::types::global_dof_index> renumbering (
3930
+ old_locally_owned_dofs.n_elements ());
3931
+ std::generate (renumbering.begin (),
3932
+ renumbering.end (),
3933
+ [my_shift = my_shift,
3934
+ n = *old_locally_owned_dofs.begin ()]() mutable {
3935
+ return my_shift + n++;
3936
+ });
3937
+
3938
+ // FIXME: n_dofs wrong.
3939
+ NumberCache number_cache = this ->renumber_dofs (renumbering);
3940
+
3941
+ return number_cache;
3942
+
3943
+ #if 0
3944
+ // FIXME resume here
3945
+ number_cache.locally_owned_virtual_dofs =
3946
+ number_cache.locally_owned_virtual_dofs.add_range(
3947
+ my_shift + my_shift_virtual + n_locally_owned_dofs,
3948
+ my_shift + my_shift_virtual + n_locally_owned_dofs +
3949
+ n_locally_virtual);
3950
+ number_cache.locally_owned_virtual_dofs.compress();
3951
+ #endif
3952
+ }
3953
+
3954
+
3955
+
3871
3956
template <int dim, int spacedim>
3872
3957
std::vector<NumberCache>
3873
3958
ParallelDistributed<dim, spacedim>::distribute_mg_dofs() const
0 commit comments