Skip to content

Commit

Permalink
INCOMPLETE REFACTORING
Browse files Browse the repository at this point in the history
  • Loading branch information
tamiko committed Aug 16, 2024
1 parent 75f5db5 commit 3cbe610
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 93 deletions.
18 changes: 14 additions & 4 deletions include/deal.II/dofs/dof_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,13 @@ class DoFHandler : public Subscriptor
* function set_fe().
*/
void
distribute_dofs(const FiniteElement<dim, spacedim> &fe,
const dealii::types::global_dof_index &virtual_dofs = 0);
distribute_dofs(const FiniteElement<dim, spacedim> &fe);

/**
* Same as above but taking an hp::FECollection object.
*/
void
distribute_dofs(const hp::FECollection<dim, spacedim> &fe,
const dealii::types::global_dof_index &virtual_dofs = 0);
distribute_dofs(const hp::FECollection<dim, spacedim> &fe);

/**
* Distribute level degrees of freedom on each level for geometric
Expand All @@ -707,6 +705,16 @@ class DoFHandler : public Subscriptor
void
distribute_mg_dofs();

/**
* FIXME: documentation
*
* Distribute virtual degrees of freedom. [...]
*
* @pre The locally owned index set must be contiguous.
*/
void
distribute_virtual_dofs(const dealii::types::global_dof_index virtual_dofs);

/**
* Returns whether this DoFHandler has hp-capabilities.
*/
Expand Down Expand Up @@ -1190,6 +1198,8 @@ class DoFHandler : public Subscriptor
locally_owned_dofs() const;

/**
* FIXME: documentation
*
* Return an IndexSet describing the subset of locally owned virtual DoFs.
*/
const IndexSet &
Expand Down
52 changes: 38 additions & 14 deletions include/deal.II/dofs/dof_handler_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace internal
* argument.
*/
virtual NumberCache
distribute_dofs(const types::global_dof_index virtual_dofs) const = 0;
distribute_dofs() const = 0;

/**
* Distribute the multigrid dofs on each level of the DoFHandler
Expand All @@ -83,14 +83,22 @@ namespace internal
virtual std::vector<NumberCache>
distribute_mg_dofs() const = 0;

/**
* FIXME: documentation
*/
virtual NumberCache
distribute_virtual_dofs(
const types::global_dof_index virtual_dofs) const = 0;

/**
* Renumber degrees of freedom as specified by the first argument.
*
* Return an updated NumberCache for the DoFHandler after renumbering.
*/
virtual NumberCache
renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers) const = 0;
const std::vector<types::global_dof_index> &new_numbers,
const types::global_dof_index &n_locally_owned_dofs) const = 0;

/**
* Renumber multilevel degrees of freedom on one level of a multigrid
Expand Down Expand Up @@ -124,17 +132,21 @@ namespace internal

// documentation is inherited
virtual NumberCache
distribute_dofs(
const types::global_dof_index virtual_dofs) const override;
distribute_dofs() const override;

// documentation is inherited
virtual std::vector<NumberCache>
distribute_mg_dofs() const override;

virtual NumberCache
distribute_virtual_dofs(
const types::global_dof_index virtual_dofs) const override;

// documentation is inherited
virtual NumberCache
renumber_dofs(const std::vector<types::global_dof_index> &new_numbers)
const override;
renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers,
const types::global_dof_index &n_locally_owned_dofs) const override;

// documentation is inherited
virtual NumberCache
Expand Down Expand Up @@ -175,15 +187,21 @@ namespace internal
* number_cache.locally_owned_dofs are updated consistently.
*/
virtual NumberCache
distribute_dofs(
const types::global_dof_index virtual_dofs) const override;
distribute_dofs() const override;

/**
* This function is not yet implemented.
*/
virtual std::vector<NumberCache>
distribute_mg_dofs() const override;

/**
* This function is not yet implemented.
*/
virtual NumberCache
distribute_virtual_dofs(
const types::global_dof_index virtual_dofs) const override;

/**
* Renumber degrees of freedom as specified by the first argument.
*
Expand All @@ -194,8 +212,9 @@ namespace internal
* parallel::distributed case.
*/
virtual NumberCache
renumber_dofs(const std::vector<types::global_dof_index> &new_numbers)
const override;
renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers,
const types::global_dof_index &n_locally_owned_dofs) const override;

// documentation is inherited
virtual NumberCache
Expand Down Expand Up @@ -228,17 +247,22 @@ namespace internal

// documentation is inherited
virtual NumberCache
distribute_dofs(
const types::global_dof_index virtual_dofs) const override;
distribute_dofs() const override;

// documentation is inherited
virtual std::vector<NumberCache>
distribute_mg_dofs() const override;

// documentation is inherited
virtual NumberCache
renumber_dofs(const std::vector<types::global_dof_index> &new_numbers)
const override;
distribute_virtual_dofs(
const types::global_dof_index virtual_dofs) const override;

// documentation is inherited
virtual NumberCache
renumber_dofs(
const std::vector<types::global_dof_index> &new_numbers,
const types::global_dof_index &n_locally_owned_dofs) const override;

// documentation is inherited
virtual NumberCache
Expand Down
27 changes: 17 additions & 10 deletions source/dofs/dof_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2133,19 +2133,17 @@ std::size_t DoFHandler<dim, spacedim>::memory_consumption() const
template <int dim, int spacedim>
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
void DoFHandler<dim, spacedim>::distribute_dofs(
const FiniteElement<dim, spacedim> &fe,
const dealii::types::global_dof_index &virtual_dofs)
const FiniteElement<dim, spacedim> &fe)
{
this->distribute_dofs(hp::FECollection<dim, spacedim>(fe), virtual_dofs);
this->distribute_dofs(hp::FECollection<dim, spacedim>(fe));
}



template <int dim, int spacedim>
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
void DoFHandler<dim, spacedim>::distribute_dofs(
const hp::FECollection<dim, spacedim> &ff,
const dealii::types::global_dof_index &virtual_dofs)
const hp::FECollection<dim, spacedim> &ff)
{
Assert(this->tria != nullptr,
ExcMessage(
Expand Down Expand Up @@ -2256,7 +2254,7 @@ void DoFHandler<dim, spacedim>::distribute_dofs(
}

// hand the actual work over to the policy
this->number_cache = this->policy->distribute_dofs(virtual_dofs);
this->number_cache = this->policy->distribute_dofs();

// do some housekeeping: compress indices
// if(hp_capability_enabled)
Expand Down Expand Up @@ -2313,6 +2311,16 @@ void DoFHandler<dim, spacedim>::distribute_mg_dofs()



template <int dim, int spacedim>
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
void DoFHandler<dim, spacedim>::distribute_virtual_dofs(
const types::global_dof_index virtual_dofs)
{
this->number_cache = this->policy->distribute_virtual_dofs(virtual_dofs);
}



template <int dim, int spacedim>
DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
void DoFHandler<dim, spacedim>::initialize_local_block_info()
Expand Down Expand Up @@ -2410,11 +2418,10 @@ void DoFHandler<dim, spacedim>::renumber_dofs(
// [0...n_dofs()) into itself but only globally, not on each processor
if (this->n_locally_owned_dofs() == this->n_dofs())
{
std::vector<types::global_dof_index> tmp(new_numbers);
auto tmp = new_numbers;
std::sort(tmp.begin(), tmp.end());
std::vector<types::global_dof_index>::const_iterator p = tmp.begin();
types::global_dof_index i = 0;
for (; p != tmp.end(); ++p, ++i)
types::global_dof_index i = 0;
for (auto p = tmp.begin(); p != tmp.end(); ++p, ++i)
Assert(*p == i, ExcNewNumbersNotConsecutive(i));
}
else
Expand Down
Loading

0 comments on commit 3cbe610

Please sign in to comment.