Skip to content

Commit

Permalink
Replace level_mg_handler by mg_level
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Oct 17, 2019
1 parent 082d75b commit e059d9f
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 62 deletions.
4 changes: 4 additions & 0 deletions doc/news/changes/incompatibilities/20191017PeterMunch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Changed: The variable level_mg_handler has been renamed
to mg_level in MatrixFree and its associated AdditionalData.
<br>
(Peter Munch, 2019/10/17)
2 changes: 1 addition & 1 deletion examples/step-37/step-37.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ namespace Step37
MatrixFree<dim, float>::AdditionalData::none;
additional_data.mapping_update_flags =
(update_gradients | update_JxW_values | update_quadrature_points);
additional_data.level_mg_handler = level;
additional_data.mg_level = level;
std::shared_ptr<MatrixFree<dim, float>> mg_mf_storage_level(
new MatrixFree<dim, float>());
mg_mf_storage_level->reinit(dof_handler,
Expand Down
2 changes: 1 addition & 1 deletion examples/step-59/step-59.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ namespace Step59
(update_gradients | update_JxW_values);
additional_data.mapping_update_flags_boundary_faces =
(update_gradients | update_JxW_values);
additional_data.level_mg_handler = level;
additional_data.mg_level = level;
const auto mg_mf_storage_level =
std::make_shared<MatrixFree<dim, float>>();
mg_mf_storage_level->reinit(dof_handler,
Expand Down
4 changes: 2 additions & 2 deletions include/deal.II/matrix_free/face_setup_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ namespace internal
std::vector<std::pair<unsigned int, unsigned int>> &cell_levels)
{
use_active_cells =
additional_data.level_mg_handler == numbers::invalid_unsigned_int;
additional_data.mg_level == numbers::invalid_unsigned_int;

# ifdef DEBUG
// safety check
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace internal
// inside the domain in case of multigrid separately
else if ((dcell->at_boundary(f) == false ||
dcell->has_periodic_neighbor(f)) &&
additional_data.level_mg_handler !=
additional_data.mg_level !=
numbers::invalid_unsigned_int &&
dcell->neighbor_or_periodic_neighbor(f)->level() <
dcell->level())
Expand Down
47 changes: 28 additions & 19 deletions include/deal.II/matrix_free/matrix_free.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ class MatrixFree : public Subscriptor
* local time stepping where one would like to control which elements
* together form a batch of cells. The array `cell_vectorization_categories`
* is accessed by the number given by cell->active_cell_index() when working
* on the active cells with `level_mg_handler` set to `-1` and by
* cell->index() for the level cells. By default, the different categories
* in `cell_vectorization_category` can be mixed and the algorithm is
* allowed to merge lower category numbers with the next higher categories
* on the active cells with `mg_level` set to `numbers::invalid_unsigned_int`
* and by cell->index() for the level cells. By default, the different
* categories in `cell_vectorization_category` can be mixed and the algorithm
* is allowed to merge lower category numbers with the next higher categories
* if it is necessary inside the algorithm, in order to avoid partially
* filled SIMD lanes as much as possible. This gives a better utilization of
* the vectorization but might need special treatment, in particular for
Expand Down Expand Up @@ -218,7 +218,7 @@ class MatrixFree : public Subscriptor
const UpdateFlags mapping_update_flags_boundary_faces = update_default,
const UpdateFlags mapping_update_flags_inner_faces = update_default,
const UpdateFlags mapping_update_flags_faces_by_cells = update_default,
const unsigned int level_mg_handler = numbers::invalid_unsigned_int,
const unsigned int mg_level = numbers::invalid_unsigned_int,
const bool store_plain_indices = true,
const bool initialize_indices = true,
const bool initialize_mapping = true,
Expand All @@ -231,7 +231,8 @@ class MatrixFree : public Subscriptor
, mapping_update_flags_boundary_faces(mapping_update_flags_boundary_faces)
, mapping_update_flags_inner_faces(mapping_update_flags_inner_faces)
, mapping_update_flags_faces_by_cells(mapping_update_flags_faces_by_cells)
, level_mg_handler(level_mg_handler)
, mg_level(mg_level)
, level_mg_handler(this->mg_level)
, store_plain_indices(store_plain_indices)
, initialize_indices(initialize_indices)
, initialize_mapping(initialize_mapping)
Expand Down Expand Up @@ -381,7 +382,14 @@ class MatrixFree : public Subscriptor
* to work on a level, its dofs must be distributed by using
* <code>dof_handler.distribute_mg_dofs(fe);</code>.
*/
unsigned int level_mg_handler;
unsigned int mg_level;

/**
* Alias for mg_level
*
* @deprecated Use mg_level instead.
*/
DEAL_II_DEPRECATED unsigned int &level_mg_handler;

/**
* Controls whether to allow reading from vectors without resolving
Expand Down Expand Up @@ -442,7 +450,7 @@ class MatrixFree : public Subscriptor
* control which elements together form a batch of cells.
*
* This array is accessed by the number given by cell->active_cell_index()
* when working on the active cells with @p level_mg_handler set to -1 and
* when working on the active cells with @p mg_level set to numbers::invalid_unsigned_int and
* by cell->index() for the level cells.
*
* @note This field is empty upon construction of AdditionalData. It is
Expand Down Expand Up @@ -1602,10 +1610,11 @@ class MatrixFree : public Subscriptor
mapping_initialized() const;

/**
* Return the level of the mesh to be worked on.
* Return the level of the mesh to be worked on. Returns
* numbers::invalid_unsigned_int if working on active cells.
*/
unsigned int
get_level_mg_handler() const;
get_mg_level() const;

/**
* Return an approximation of the memory consumption of this class in
Expand Down Expand Up @@ -1938,7 +1947,7 @@ class MatrixFree : public Subscriptor
/**
* Stored the level of the mesh to be worked on.
*/
unsigned int level_mg_handler;
unsigned int mg_level;
};


Expand Down Expand Up @@ -2494,9 +2503,9 @@ MatrixFree<dim, Number, VectorizedArrayType>::mapping_initialized() const

template <int dim, typename Number, typename VectorizedArrayType>
inline unsigned int
MatrixFree<dim, Number, VectorizedArrayType>::get_level_mg_handler() const
MatrixFree<dim, Number, VectorizedArrayType>::get_mg_level() const
{
return level_mg_handler;
return mg_level;
}


Expand Down Expand Up @@ -2644,7 +2653,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(

std::vector<IndexSet> locally_owned_sets =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handlers, additional_data.level_mg_handler);
dof_handlers, additional_data.mg_level);

std::vector<hp::QCollection<1>> quad_hp;
quad_hp.emplace_back(quad);
Expand Down Expand Up @@ -2678,7 +2687,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(

std::vector<IndexSet> locally_owned_sets =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handlers, additional_data.level_mg_handler);
dof_handlers, additional_data.mg_level);

std::vector<hp::QCollection<1>> quad_hp;
quad_hp.emplace_back(quad);
Expand All @@ -2705,7 +2714,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(
{
std::vector<IndexSet> locally_owned_set =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handler, additional_data.level_mg_handler);
dof_handler, additional_data.mg_level);
std::vector<hp::QCollection<1>> quad_hp;
for (unsigned int q = 0; q < quad.size(); ++q)
quad_hp.emplace_back(quad[q]);
Expand All @@ -2731,7 +2740,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(
{
std::vector<IndexSet> locally_owned_set =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handler, additional_data.level_mg_handler);
dof_handler, additional_data.mg_level);
std::vector<hp::QCollection<1>> quad_hp;
quad_hp.emplace_back(quad);
internal_reinit(StaticMappingQ1<dim>::mapping,
Expand All @@ -2757,7 +2766,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(
{
std::vector<IndexSet> locally_owned_set =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handler, additional_data.level_mg_handler);
dof_handler, additional_data.mg_level);
std::vector<hp::QCollection<1>> quad_hp;
quad_hp.emplace_back(quad);
internal_reinit(mapping,
Expand All @@ -2783,7 +2792,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::reinit(
{
std::vector<IndexSet> locally_owned_set =
internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
dof_handler, additional_data.level_mg_handler);
dof_handler, additional_data.mg_level);
std::vector<hp::QCollection<1>> quad_hp;
for (unsigned int q = 0; q < quad.size(); ++q)
quad_hp.emplace_back(quad[q]);
Expand Down
23 changes: 11 additions & 12 deletions include/deal.II/matrix_free/matrix_free.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::MatrixFree()
: Subscriptor()
, indices_are_initialized(false)
, mapping_is_initialized(false)
, level_mg_handler(numbers::invalid_unsigned_int)
, mg_level(numbers::invalid_unsigned_int)
{}


Expand Down Expand Up @@ -250,7 +250,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::copy_from(
task_info = v.task_info;
indices_are_initialized = v.indices_are_initialized;
mapping_is_initialized = v.mapping_is_initialized;
level_mg_handler = v.level_mg_handler;
mg_level = v.mg_level;
}


Expand All @@ -268,7 +268,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::internal_reinit(
&additional_data)
{
// Store the level of the mesh to be worked on.
this->level_mg_handler = additional_data.level_mg_handler;
this->mg_level = additional_data.mg_level;

// Reads out the FE information and stores the shape function values,
// gradients and Hessians for quadrature points.
Expand Down Expand Up @@ -431,7 +431,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::internal_reinit(
&additional_data)
{
// Store the level of the mesh to be worked on.
this->level_mg_handler = additional_data.level_mg_handler;
this->mg_level = additional_data.mg_level;

// Reads out the FE information and stores the shape function values,
// gradients and Hessians for quadrature points.
Expand Down Expand Up @@ -658,7 +658,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_handlers(
{
cell_level_index.clear();
dof_handlers.active_dof_handler = DoFHandlers::usual;
dof_handlers.level = additional_data.level_mg_handler;
dof_handlers.level = additional_data.mg_level;
dof_handlers.n_dof_handlers = dof_handler.size();
dof_handlers.dof_handler.resize(dof_handlers.n_dof_handlers);
for (unsigned int no = 0; no < dof_handlers.n_dof_handlers; ++no)
Expand All @@ -676,7 +676,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_handlers(

const Triangulation<dim> &tria =
dof_handlers.dof_handler[0]->get_triangulation();
const unsigned int level = additional_data.level_mg_handler;
const unsigned int level = additional_data.mg_level;
if (level == numbers::invalid_unsigned_int)
{
if (n_mpi_procs == 1)
Expand Down Expand Up @@ -727,7 +727,7 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_dof_handlers(
{
cell_level_index.clear();
dof_handlers.active_dof_handler = DoFHandlers::hp;
dof_handlers.level = additional_data.level_mg_handler;
dof_handlers.level = additional_data.mg_level;
Assert(dof_handlers.level == numbers::invalid_unsigned_int,
ExcNotImplemented());
dof_handlers.n_dof_handlers = dof_handler.size();
Expand Down Expand Up @@ -1039,19 +1039,18 @@ MatrixFree<dim, Number, VectorizedArrayType>::initialize_indices(
for (unsigned int no = 0; no < n_fe; ++no)
{
if (do_face_integrals &&
additional_data.level_mg_handler != numbers::invalid_unsigned_int)
additional_data.mg_level != numbers::invalid_unsigned_int)
{
// in case of adaptivity, go through the cells on the next finer
// level and check whether we need to get read access to some of
// those entries for the mg flux matrices
const DoFHandler<dim> &dof_handler = *dof_handlers.dof_handler[no];
std::vector<types::global_dof_index> dof_indices;
if (additional_data.level_mg_handler + 1 <
if (additional_data.mg_level + 1 <
dof_handler.get_triangulation().n_global_levels())
for (typename DoFHandler<dim>::cell_iterator cell =
dof_handler.begin(additional_data.level_mg_handler + 1);
cell !=
dof_handler.end(additional_data.level_mg_handler + 1);
dof_handler.begin(additional_data.mg_level + 1);
cell != dof_handler.end(additional_data.mg_level + 1);
++cell)
if (cell->level_subdomain_id() == task_info.my_pid)
for (unsigned int f = 0;
Expand Down
2 changes: 1 addition & 1 deletion tests/mappings/mapping_q_eulerian_08.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ test(const unsigned int n_ref = 0)
mg_additional_data;
mg_additional_data.tasks_parallel_scheme =
MatrixFree<dim, LevelNumberType>::AdditionalData::partition_color;
mg_additional_data.level_mg_handler = level;
mg_additional_data.mg_level = level;
mg_additional_data.mapping_update_flags =
update_values | update_gradients | update_JxW_values |
update_quadrature_points;
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/cell_categorization_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test()
.cell_vectorization_category[cell->index()] = cell->material_id();
}

mg_additional_data[level].level_mg_handler = level;
mg_additional_data[level].mg_level = level;
}

std::vector<std::shared_ptr<MatrixFree<dim, float>>> mg_mf_data(max_level +
Expand Down
4 changes: 2 additions & 2 deletions tests/matrix_free/cell_level_and_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ test(const bool adaptive_ref = true)

{
std::cout << "Compare level indices." << std::endl;
const unsigned int level = tria.n_global_levels() - 1;
additional_data.level_mg_handler = level;
const unsigned int level = tria.n_global_levels() - 1;
additional_data.mg_level = level;
mf_data->reinit(dof, constraints, quad, additional_data);
compare_indices(mf_data.get());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/compare_faces_by_cells.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class LaplaceOperator : public Subscriptor
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.tasks_block_size = 3;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;
addit_data.mapping_update_flags_inner_faces =
update_JxW_values | update_normal_vectors | update_jacobians;
addit_data.mapping_update_flags_boundary_faces =
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/dg_pbc_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test()
for (unsigned int level = 0; level < tria.n_global_levels(); ++level)
{
MatrixFree<dim> mf_data;
data.level_mg_handler = level;
data.mg_level = level;
mf_data.reinit(dof, constraints, quad, data);
std::vector<unsigned int> n_inner_faces(2 * dim),
n_inner_other_faces(2 * dim), n_boundary_faces(2 * dim);
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/matrix_vector_mg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test()
mg_constraints[level].add_line(*bc_it);
mg_constraints[level].close();
typename MatrixFree<dim>::AdditionalData data;
data.level_mg_handler = level;
data.mg_level = level;
mg_matrices[level].reinit(
mapping, dof, mg_constraints[level], quad, data);

Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/multigrid_dg_periodic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LaplaceOperator : public Subscriptor
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.tasks_block_size = 3;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;
addit_data.mapping_update_flags_inner_faces =
(update_gradients | update_JxW_values);
addit_data.mapping_update_flags_boundary_faces =
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/multigrid_dg_sip_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class LaplaceOperator : public Subscriptor
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.tasks_block_size = 3;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;
addit_data.mapping_update_flags_inner_faces =
(update_gradients | update_JxW_values);
addit_data.mapping_update_flags_boundary_faces =
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/multigrid_dg_sip_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LaplaceOperator : public Subscriptor
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.tasks_block_size = 3;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;
addit_data.mapping_update_flags_inner_faces =
update_JxW_values | update_normal_vectors | update_jacobians;
addit_data.mapping_update_flags_boundary_faces =
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/parallel_multigrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class LaplaceOperator : public Subscriptor
typename MatrixFree<dim, number>::AdditionalData addit_data;
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;

// extract the constraints due to Dirichlet boundary conditions
AffineConstraints<double> constraints;
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/parallel_multigrid_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ do_test(const DoFHandler<dim> &dof)
typename MatrixFree<dim, number>::AdditionalData mg_additional_data;
mg_additional_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
mg_additional_data.level_mg_handler = level;
mg_additional_data.mg_level = level;

AffineConstraints<double> level_constraints;
IndexSet relevant_dofs;
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/parallel_multigrid_adaptive_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class LaplaceOperator : public Subscriptor
addit_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
addit_data.tasks_block_size = 3;
addit_data.level_mg_handler = level;
addit_data.mg_level = level;
AffineConstraints<double> constraints;
if (level == numbers::invalid_unsigned_int)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/matrix_free/parallel_multigrid_adaptive_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ do_test(const DoFHandler<dim> &dof)
mg_additional_data.tasks_parallel_scheme =
MatrixFree<dim, number>::AdditionalData::none;
mg_additional_data.tasks_block_size = 3;
mg_additional_data.level_mg_handler = level;
mg_additional_data.mg_level = level;

AffineConstraints<double> level_constraints;
IndexSet relevant_dofs;
Expand Down

0 comments on commit e059d9f

Please sign in to comment.