Skip to content

Commit

Permalink
Continue [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Oct 19, 2023
1 parent 02dabbb commit 8c12231
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 6 deletions.
13 changes: 8 additions & 5 deletions include/deal.II/matrix_free/constraint_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ namespace internal

inline const typename Number::value_type *
constraint_pool_end(const unsigned int row) const;

// TODO
std::vector<types::global_dof_index> local_dof_indices;
std::vector<types::global_dof_index> local_dof_indices_lex;
std::vector<ConstraintKinds> mask;
};


Expand Down Expand Up @@ -318,10 +323,8 @@ namespace internal
const dealii::AffineConstraints<typename Number::value_type> &constraints,
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner)
{
std::vector<types::global_dof_index> local_dof_indices(
cell->get_fe().n_dofs_per_cell());
std::vector<types::global_dof_index> local_dof_indices_lex(
cell->get_fe().n_dofs_per_cell());
local_dof_indices.resize(cell->get_fe().n_dofs_per_cell());
local_dof_indices_lex.resize(cell->get_fe().n_dofs_per_cell());

if (mg_level == numbers::invalid_unsigned_int)
cell->get_dof_indices(local_dof_indices);
Expand Down Expand Up @@ -375,7 +378,7 @@ namespace internal
AssertIndexRange(cell_no, this->hanging_node_constraint_masks.size());
AssertIndexRange(cell_no, this->active_fe_indices.size());

std::vector<ConstraintKinds> mask(cell->get_fe().n_components());
mask.resize(cell->get_fe().n_components());
hanging_nodes->setup_constraints(
cell, {}, lexicographic_numbering, local_dof_indices_lex, mask);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ namespace internal
const auto cell_fine_raw =
dof_handler_fine.get_triangulation().create_cell_iterator(
cell_id);
return cell_fine_raw->as_dof_handler_iterator(dof_handler_fine)
cell_fine_raw->as_dof_handler_iterator(dof_handler_fine)
->get_dof_indices(dof_indices);
}
else
Expand Down Expand Up @@ -1786,6 +1786,8 @@ namespace internal
transfer.dof_handler_fine = &dof_handler_fine;
transfer.mg_level_fine = mg_level_fine;

auto temp_time = std::chrono::system_clock::now();

std::unique_ptr<FineDoFHandlerViewBase<dim>> dof_handler_fine_view;

if (internal::h_transfer_uses_first_child_policy(dof_handler_fine,
Expand Down Expand Up @@ -1862,6 +1864,13 @@ namespace internal

const auto reference_cell = dof_handler_fine.get_fe(0).reference_cell();

const auto time0 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

// create partitioners and vectors for internal purposes
{
// ... for fine mesh
Expand All @@ -1884,6 +1893,14 @@ namespace internal
}
}


const auto time1 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

// helper function: to process the fine level cells; function @p fu_non_refined is
// performed on cells that are not refined and @fu_refined is performed on
// children of cells that are refined
Expand Down Expand Up @@ -1999,6 +2016,13 @@ namespace internal
n_dof_indices_coarse[i + 1] += n_dof_indices_coarse[i];
}

const auto time2 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

// indices
{
std::vector<types::global_dof_index> local_dof_indices(
Expand Down Expand Up @@ -2132,6 +2156,13 @@ namespace internal
transfer.constraint_info_fine.finalize();
}

const auto time3 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();


// ------------- prolongation matrix (0) -> identity matrix --------------

Expand Down Expand Up @@ -2242,6 +2273,13 @@ namespace internal
}
}

const auto time4 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();


// ------------------------------- weights -------------------------------
if (transfer.fine_element_is_continuous)
Expand Down Expand Up @@ -2293,6 +2331,15 @@ namespace internal
if (is_feq)
compress_weights(transfer);
}

const auto time5 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

if (false)
std::cout << time0 << " " << time1 << " " << time2 << " " << time3
<< " " << time4 << " " << time5 << std::endl;
}


Expand Down Expand Up @@ -4186,10 +4233,38 @@ MGTransferMF<dim, Number>::build(
const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
&external_partitioners)
{
auto temp_time = std::chrono::system_clock::now();
this->initialize_internal_transfer(dof_handler, this->mg_constrained_dofs);
const auto time1 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();
this->initialize_transfer_references(internal_transfer);
const auto time2 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

this->build(external_partitioners);
const auto time3 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();
this->fill_and_communicate_copy_indices(dof_handler);
const auto time4 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

if (false)
std::cout << time1 << " " << time2 << " " << time3 << " " << time4
<< std::endl;
}


Expand Down
31 changes: 31 additions & 0 deletions source/multigrid/mg_transfer_matrix_free.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ MGTransferMatrixFree<dim, Number>::build(
const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
&external_partitioners)
{
auto temp_time = std::chrono::system_clock::now();

Assert(dof_handler.has_level_dofs(),
ExcMessage(
"The underlying DoFHandler object has not had its "
Expand All @@ -123,6 +125,15 @@ MGTransferMatrixFree<dim, Number>::build(

this->fill_and_communicate_copy_indices(dof_handler);



const auto time0 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

vector_partitioners.resize(0,
dof_handler.get_triangulation().n_global_levels() -
1);
Expand Down Expand Up @@ -159,6 +170,15 @@ MGTransferMatrixFree<dim, Number>::build(
else
this->ghosted_level_vector[level].reinit(vector_partitioners[level]);



const auto time1 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

// unpack element info data
fe_degree = elem_info.fe_degree;
element_is_continuous = elem_info.element_is_continuous;
Expand Down Expand Up @@ -195,6 +215,17 @@ MGTransferMatrixFree<dim, Number>::build(
}
}



const auto time2 = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::system_clock::now() - temp_time)
.count() /
1e9;

temp_time = std::chrono::system_clock::now();

std::cout << time0 << " " << time1 << " " << time2 << std::endl;

evaluation_data.resize(n_child_cell_dofs);
}

Expand Down

0 comments on commit 8c12231

Please sign in to comment.