43template <
int dim,
typename VectorType,
int spacedim>
53 ExcMessage(
"You are calling the ::SolutionTransfer class "
54 "with a DoFHandler that is built on a "
55 "parallel::distributed::Triangulation. This will not "
56 "work for parallel computations. You probably want to "
57 "use the parallel::distributed::SolutionTransfer class."));
62template <
int dim,
typename VectorType,
int spacedim>
70template <
int dim,
typename VectorType,
int spacedim>
83template <
int dim,
typename VectorType,
int spacedim>
103 subdomain_modifier(
dof_handler->get_triangulation());
105 const unsigned int n_active_cells =
110 std::vector<std::vector<types::global_dof_index>>(n_active_cells)
113 for (
const auto &cell :
dof_handler->active_cell_iterators())
115 const unsigned int i = cell->active_cell_index();
124 cell_map[std::make_pair(cell->level(), cell->index())] =
132template <
int dim,
typename VectorType,
int spacedim>
135 const VectorType &in,
136 VectorType &out)
const
143 ExcMessage(
"Vectors cannot be used as input and output"
144 " at the same time!"));
156 subdomain_modifier(
dof_handler->get_triangulation());
160 typename std::map<std::pair<unsigned int, unsigned int>,
164 for (
const auto &cell :
dof_handler->cell_iterators())
167 cell_map.find(std::make_pair(cell->level(), cell->index()));
169 if (pointerstruct != cell_map_end)
177 const unsigned int this_fe_index =
178 pointerstruct->second.active_fe_index;
179 const unsigned int dofs_per_cell =
180 cell->get_dof_handler().get_fe(this_fe_index).n_dofs_per_cell();
181 local_values.
reinit(dofs_per_cell,
true);
186 Assert(dofs_per_cell == (*pointerstruct->second.indices_ptr).size(),
188 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
190 in, (*pointerstruct->second.indices_ptr)[i]);
191 cell->set_dof_values_by_interpolation(local_values,
216 template <
int dim,
int spacedim>
225 matrices.reinit(fe.size(), fe.size());
226 for (
unsigned int i = 0; i < fe.size(); ++i)
227 for (
unsigned int j = 0; j < fe.size(); ++j)
230 matrices(i, j).reinit(fe[i].n_dofs_per_cell(),
231 fe[j].n_dofs_per_cell());
242 fe[i].get_interpolation_matrix(fe[j], matrices(i, j));
245 ExcInterpolationNotImplemented &)
247 matrices(i, j).reinit(0, 0);
253 template <
int dim,
int spacedim>
256 std::vector<std::vector<bool>> &)
259 template <
int dim,
int spacedim>
262 std::vector<std::vector<bool>> &restriction_is_additive)
264 restriction_is_additive.resize(fe.size());
265 for (
unsigned int f = 0; f < fe.size(); ++f)
267 restriction_is_additive[f].resize(fe[f].n_dofs_per_cell());
268 for (
unsigned int i = 0; i < fe[f].n_dofs_per_cell(); ++i)
269 restriction_is_additive[f][i] = fe[f].restriction_is_additive(i);
276template <
int dim,
typename VectorType,
int spacedim>
287 const unsigned int in_size = all_in.size();
291 ExcMessage(
"The array of input vectors you pass to this "
292 "function has no elements. This is not useful."));
293 for (
unsigned int i = 0; i < in_size; ++i)
310 subdomain_modifier(
dof_handler->get_triangulation());
315 unsigned int n_cells_to_coarsen = 0;
316 unsigned int n_cells_to_stay_or_refine = 0;
317 for (
const auto &act_cell :
dof_handler->active_cell_iterators())
319 if (act_cell->coarsen_flag_set())
320 ++n_cells_to_coarsen;
322 ++n_cells_to_stay_or_refine;
324 Assert((n_cells_to_coarsen + n_cells_to_stay_or_refine) ==
328 unsigned int n_coarsen_fathers = 0;
329 for (
const auto &cell :
dof_handler->cell_iterators())
330 if (!cell->is_active() && cell->child(0)->coarsen_flag_set())
333 (void)n_cells_to_coarsen;
338 std::vector<std::vector<types::global_dof_index>>(n_cells_to_stay_or_refine)
341 std::vector<std::vector<Vector<typename VectorType::value_type>>>(
343 std::vector<Vector<typename VectorType::value_type>>(in_size))
347 std::vector<std::vector<bool>> restriction_is_additive;
351 restriction_is_additive);
356 unsigned int n_sr = 0, n_cf = 0;
357 for (
const auto &cell :
dof_handler->cell_iterators())
360 if (cell->is_active() && !cell->coarsen_flag_set())
362 const unsigned int dofs_per_cell = cell->get_fe().n_dofs_per_cell();
369 cell_map[std::make_pair(cell->level(), cell->index())] =
375 else if (cell->has_children() && cell->child(0)->coarsen_flag_set())
383 std::set<unsigned int> fe_indices_children;
384 for (
const auto &child : cell->child_iterators())
386 Assert(child->is_active() && child->coarsen_flag_set(),
387 typename ::Triangulation<
388 dim>::ExcInconsistentCoarseningFlags());
390 fe_indices_children.insert(child->active_fe_index());
394 const unsigned int target_fe_index =
395 dof_handler->get_fe_collection().find_dominated_fe_extended(
396 fe_indices_children, 0);
400 ExcNoDominatedFiniteElementOnChildren());
402 const unsigned int dofs_per_cell =
403 dof_handler->get_fe(target_fe_index).n_dofs_per_cell();
405 std::vector<Vector<typename VectorType::value_type>>(
415 for (
unsigned int j = 0; j < in_size; ++j)
416 cell->get_interpolated_dof_values(all_in[j],
419 cell_map[std::make_pair(cell->level(), cell->index())] =
432template <
int dim,
typename VectorType,
int spacedim>
437 std::vector<VectorType> all_in(1, in);
443template <
int dim,
typename VectorType,
int spacedim>
446 const std::vector<VectorType> &all_in,
447 std::vector<VectorType> &all_out)
const
449 const unsigned int size = all_in.size();
453 for (
unsigned int i = 0; i < size; ++i)
456 for (
unsigned int i = 0; i < all_out.size(); ++i)
459 for (
unsigned int i = 0; i < size; ++i)
460 for (
unsigned int j = 0; j < size; ++j)
461 Assert(&all_in[i] != &all_out[j],
462 ExcMessage(
"Vectors cannot be used as input and output"
463 " at the same time!"));
476 subdomain_modifier(
dof_handler->get_triangulation());
479 std::vector<types::global_dof_index> dofs;
481 typename std::map<std::pair<unsigned int, unsigned int>,
489 for (
const auto &cell :
dof_handler->cell_iterators())
492 cell_map.find(std::make_pair(cell->level(), cell->index()));
494 if (pointerstruct != cell_map_end)
496 const std::vector<types::global_dof_index> *
const indexptr =
497 pointerstruct->second.indices_ptr;
499 const std::vector<Vector<typename VectorType::value_type>>
500 *
const valuesptr = pointerstruct->second.dof_values_ptr;
503 if (indexptr !=
nullptr)
507 const unsigned int old_fe_index =
508 pointerstruct->second.active_fe_index;
512 unsigned int in_size = indexptr->size();
513 for (
unsigned int j = 0; j < size; ++j)
515 tmp.
reinit(in_size,
true);
516 for (
unsigned int i = 0; i < in_size; ++i)
521 cell->set_dof_values_by_interpolation(tmp,
533 const unsigned int dofs_per_cell =
534 cell->get_fe().n_dofs_per_cell();
535 dofs.resize(dofs_per_cell);
538 cell->get_dof_indices(dofs);
541 for (
unsigned int j = 0; j < size; ++j)
548 const unsigned int active_fe_index = cell->active_fe_index();
549 if (active_fe_index != pointerstruct->second.active_fe_index)
551 const unsigned int old_index =
552 pointerstruct->second.active_fe_index;
554 interpolation_hp(active_fe_index, old_index);
557 if (interpolation_matrix.empty())
558 tmp.
reinit(dofs_per_cell,
false);
561 tmp.
reinit(dofs_per_cell,
true);
563 interpolation_matrix.
n());
565 interpolation_matrix.
vmult(tmp, (*valuesptr)[j]);
570 data = &(*valuesptr)[j];
573 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
587 for (
auto &vec : all_out)
593template <
int dim,
typename VectorType,
int spacedim>
596 VectorType &out)
const
602 std::vector<VectorType> all_in = {in};
603 std::vector<VectorType> all_out = {out};
612template <
int dim,
typename VectorType,
int spacedim>
629template <
int dim,
typename VectorType,
int spacedim>
634 return sizeof(*this);
639#define SPLIT_INSTANTIATIONS_COUNT 4
640#ifndef SPLIT_INSTANTIATIONS_INDEX
641# define SPLIT_INSTANTIATIONS_INDEX 0
643#include "solution_transfer.inst"
const hp::FECollection< dim, spacedim > & get_fe_collection() const
bool has_hp_capabilities() const
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
void refine_interpolate(const VectorType &in, VectorType &out) const
void interpolate(const std::vector< VectorType > &all_in, std::vector< VectorType > &all_out) const
std::vector< std::vector< types::global_dof_index > > indices_on_cell
types::global_dof_index n_dofs_old
SmartPointer< const DoFHandler< dim, spacedim >, SolutionTransfer< dim, VectorType, spacedim > > dof_handler
std::size_t memory_consumption() const
std::vector< std::vector< Vector< typename VectorType::value_type > > > dof_values_on_cell
void prepare_for_coarsening_and_refinement(const std::vector< VectorType > &all_in)
PreparationState prepared_for
void prepare_for_pure_refinement()
@ coarsening_and_refinement
SolutionTransfer(const DoFHandler< dim, spacedim > &dof)
std::map< std::pair< unsigned int, unsigned int >, Pointerstruct > cell_map
virtual size_type size() const override
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
void compress(VectorOperation::values operation=VectorOperation::unknown) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotPrepared()
static ::ExceptionBase & ExcAlreadyPrepForCoarseAndRef()
static ::ExceptionBase & ExcAlreadyPrepForRef()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define DEAL_II_ASSERT_UNREACHABLE()
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
void restriction_additive(const FiniteElement< dim, spacedim > &, std::vector< std::vector< bool > > &)
void extract_interpolation_matrices(const DoFHandler< dim, spacedim > &dof, ::Table< 2, FullMatrix< double > > &matrices)
static const unsigned int invalid_unsigned_int
void swap(SmartPointer< T, P > &t1, SmartPointer< T, Q > &t2)
std::size_t memory_consumption() const
static VectorType::value_type get(const VectorType &V, const types::global_dof_index i)
static void set(typename VectorType::value_type value, const types::global_dof_index i, VectorType &V)