44 template <
int dim,
typename VectorType,
typename DoFHandlerType>
46 const DoFHandlerType &dof)
47 : dof_handler(&dof, typeid(*this).name())
52 DoFHandlerType::dimension,
53 DoFHandlerType::space_dimension
> *>(
55 ExcMessage(
"You are calling the ::SolutionTransfer class " 56 "with a DoF handler that is built on a " 57 "parallel::distributed::Triangulation. This will not " 58 "work for parallel computations. You probably want to " 59 "use the parallel::distributed::SolutionTransfer class."));
64 template <
int dim,
typename VectorType,
typename DoFHandlerType>
72 template <
int dim,
typename VectorType,
typename DoFHandlerType>
85 template <
int dim,
typename VectorType,
typename DoFHandlerType>
103 typename DoFHandlerType::active_cell_iterator cell =
107 for (
unsigned int i = 0; cell != endc; ++cell, ++i)
117 cell_map[std::make_pair(cell->level(), cell->index())] =
125 template <
int dim,
typename VectorType,
typename DoFHandlerType>
136 ExcMessage(
"Vectors cannot be used as input and output" 137 " at the same time!"));
141 typename DoFHandlerType::cell_iterator cell =
dof_handler->begin(),
144 typename std::map<std::pair<unsigned int, unsigned int>,
148 for (; cell != endc; ++cell)
151 cell_map.find(std::make_pair(cell->level(), cell->index()));
153 if (pointerstruct != cell_map_end)
161 const unsigned int this_fe_index =
162 pointerstruct->second.active_fe_index;
163 const unsigned int dofs_per_cell =
164 cell->get_dof_handler().get_fe(this_fe_index).n_dofs_per_cell();
165 local_values.
reinit(dofs_per_cell,
true);
170 Assert(dofs_per_cell == (*pointerstruct->second.indices_ptr).size(),
172 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
174 in, (*pointerstruct->second.indices_ptr)[i]);
175 cell->set_dof_values_by_interpolation(local_values,
199 template <
int dim,
int spacedim>
204 if (dof.has_hp_capabilities() ==
false)
207 const ::hp::FECollection<dim, spacedim> &fe = dof.get_fe_collection();
208 matrices.reinit(fe.size(), fe.size());
209 for (
unsigned int i = 0; i < fe.size(); ++i)
210 for (
unsigned int j = 0; j < fe.size(); ++j)
213 matrices(i, j).reinit(fe[i].n_dofs_per_cell(),
214 fe[j].n_dofs_per_cell());
225 fe[i].get_interpolation_matrix(fe[j], matrices(i, j));
228 ExcInterpolationNotImplemented &)
230 matrices(i, j).reinit(0, 0);
236 template <
int dim,
int spacedim>
239 std::vector<std::vector<bool>> &)
242 template <
int dim,
int spacedim>
245 std::vector<std::vector<bool>> &restriction_is_additive)
247 restriction_is_additive.resize(fe.size());
248 for (
unsigned int f = 0; f < fe.size(); ++f)
250 restriction_is_additive[f].resize(fe[f].n_dofs_per_cell());
251 for (
unsigned int i = 0; i < fe[f].n_dofs_per_cell(); ++i)
252 restriction_is_additive[f][i] = fe[f].restriction_is_additive(i);
259 template <
int dim,
typename VectorType,
typename DoFHandlerType>
268 const unsigned int in_size = all_in.size();
270 ExcMessage(
"The array of input vectors you pass to this " 271 "function has no elements. This is not useful."));
277 (void)n_active_cells;
280 for (
unsigned int i = 0; i < in_size; ++i)
289 unsigned int n_cells_to_coarsen = 0;
290 unsigned int n_cells_to_stay_or_refine = 0;
291 for (
const auto &act_cell :
dof_handler->active_cell_iterators())
293 if (act_cell->coarsen_flag_set())
294 ++n_cells_to_coarsen;
296 ++n_cells_to_stay_or_refine;
298 Assert((n_cells_to_coarsen + n_cells_to_stay_or_refine) == n_active_cells,
301 unsigned int n_coarsen_fathers = 0;
302 for (
typename DoFHandlerType::cell_iterator cell =
dof_handler->begin();
305 if (!cell->is_active() && cell->child(0)->coarsen_flag_set())
312 std::vector<std::vector<types::global_dof_index>>(n_cells_to_stay_or_refine)
315 std::vector<std::vector<Vector<typename VectorType::value_type>>>(
317 std::vector<Vector<typename VectorType::value_type>>(in_size))
321 std::vector<std::vector<bool>> restriction_is_additive;
325 restriction_is_additive);
330 unsigned int n_sr = 0, n_cf = 0;
331 for (
typename DoFHandlerType::cell_iterator cell =
dof_handler->begin();
336 if (cell->is_active() && !cell->coarsen_flag_set())
338 const unsigned int dofs_per_cell = cell->get_fe().n_dofs_per_cell();
345 cell_map[std::make_pair(cell->level(), cell->index())] =
351 else if (cell->has_children() && cell->child(0)->coarsen_flag_set())
359 std::set<unsigned int> fe_indices_children;
360 for (
const auto &child : cell->child_iterators())
362 Assert(child->is_active() && child->coarsen_flag_set(),
364 dim>::ExcInconsistentCoarseningFlags());
366 fe_indices_children.insert(child->active_fe_index());
370 const unsigned int target_fe_index =
371 dof_handler->get_fe_collection().find_dominated_fe_extended(
372 fe_indices_children, 0);
375 (typename ::DoFCellAccessor<
377 DoFHandlerType::space_dimension,
378 false>::ExcNoDominatedFiniteElementOnChildren()));
380 const unsigned int dofs_per_cell =
381 dof_handler->get_fe(target_fe_index).n_dofs_per_cell();
383 std::vector<Vector<typename VectorType::value_type>>(
393 for (
unsigned int j = 0; j < in_size; ++j)
394 cell->get_interpolated_dof_values(all_in[j],
397 cell_map[std::make_pair(cell->level(), cell->index())] =
410 template <
int dim,
typename VectorType,
typename DoFHandlerType>
415 std::vector<VectorType> all_in(1, in);
421 template <
int dim,
typename VectorType,
typename DoFHandlerType>
424 const std::vector<VectorType> &all_in,
425 std::vector<VectorType> & all_out)
const 428 const unsigned int size = all_in.size();
430 for (
unsigned int i = 0; i < size; ++i)
433 for (
unsigned int i = 0; i < all_out.size(); ++i)
436 for (
unsigned int i = 0; i < size; ++i)
437 for (
unsigned int j = 0; j < size; ++j)
438 Assert(&all_in[i] != &all_out[j],
439 ExcMessage(
"Vectors cannot be used as input and output" 440 " at the same time!"));
443 std::vector<types::global_dof_index> dofs;
445 typename std::map<std::pair<unsigned int, unsigned int>,
453 for (
const auto &cell :
dof_handler->cell_iterators())
456 cell_map.find(std::make_pair(cell->level(), cell->index()));
458 if (pointerstruct != cell_map_end)
460 const std::vector<types::global_dof_index> *
const indexptr =
461 pointerstruct->second.indices_ptr;
463 const std::vector<Vector<typename VectorType::value_type>>
464 *
const valuesptr = pointerstruct->second.dof_values_ptr;
471 const unsigned int old_fe_index =
472 pointerstruct->second.active_fe_index;
476 unsigned int in_size = indexptr->size();
477 for (
unsigned int j = 0; j < size; ++j)
479 tmp.
reinit(in_size,
true);
480 for (
unsigned int i = 0; i < in_size; ++i)
485 cell->set_dof_values_by_interpolation(tmp,
496 const unsigned int dofs_per_cell =
497 cell->get_fe().n_dofs_per_cell();
498 dofs.resize(dofs_per_cell);
501 cell->get_dof_indices(dofs);
504 for (
unsigned int j = 0; j < size; ++j)
511 const unsigned int active_fe_index = cell->active_fe_index();
512 if (active_fe_index != pointerstruct->second.active_fe_index)
514 const unsigned int old_index =
515 pointerstruct->second.active_fe_index;
517 interpolation_hp(active_fe_index, old_index);
520 if (interpolation_matrix.
empty())
521 tmp.
reinit(dofs_per_cell,
false);
524 tmp.
reinit(dofs_per_cell,
true);
526 interpolation_matrix.
n());
528 interpolation_matrix.
vmult(tmp, (*valuesptr)[j]);
533 data = &(*valuesptr)[j];
536 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
551 template <
int dim,
typename VectorType,
typename DoFHandlerType>
561 std::vector<VectorType> all_in(1);
563 std::vector<VectorType> all_out(1);
571 template <
int dim,
typename VectorType,
typename DoFHandlerType>
588 template <
int dim,
typename VectorType,
typename DoFHandlerType>
593 return sizeof(*this);
598 #define SPLIT_INSTANTIATIONS_COUNT 4 599 #ifndef SPLIT_INSTANTIATIONS_INDEX 600 # define SPLIT_INSTANTIATIONS_INDEX 0 602 #include "solution_transfer.inst"
static const unsigned int invalid_unsigned_int
#define AssertDimension(dim1, dim2)
types::global_dof_index n_dofs_old
std::size_t memory_consumption() const
SmartPointer< const DoFHandlerType, SolutionTransfer< dim, VectorType, DoFHandlerType > > dof_handler
static ::ExceptionBase & ExcAlreadyPrepForRef()
static ::ExceptionBase & ExcNotPrepared()
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
void extract_interpolation_matrices(const ::DoFHandler< dim, spacedim > &dof, ::Table< 2, FullMatrix< double >> &matrices)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::map< std::pair< unsigned int, unsigned int >, Pointerstruct > cell_map
std::vector< std::vector< types::global_dof_index > > indices_on_cell
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void restriction_additive(const FiniteElement< dim, spacedim > &, std::vector< std::vector< bool >> &)
void prepare_for_pure_refinement()
static ::ExceptionBase & ExcAlreadyPrepForCoarseAndRef()
#define DEAL_II_NAMESPACE_CLOSE
void swap(SmartPointer< T, Q > &tt)
unsigned int n_active_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
TriangulationBase< dim, spacedim > Triangulation
SolutionTransfer(const DoFHandlerType &dof)
static VectorType::value_type get(const VectorType &V, const types::global_dof_index i)
void swap(MemorySpaceData< Number, MemorySpace > &, MemorySpaceData< Number, MemorySpace > &)
void prepare_for_coarsening_and_refinement(const std::vector< VectorType > &all_in)
void refine_interpolate(const VectorType &in, VectorType &out) const
#define DEAL_II_NAMESPACE_OPEN
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
std::vector< std::vector< Vector< typename VectorType::value_type > > > dof_values_on_cell
std::size_t memory_consumption() const
PreparationState prepared_for
void interpolate(const std::vector< VectorType > &all_in, std::vector< VectorType > &all_out) const
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
void restriction_additive(const ::hp::FECollection< dim, spacedim > &fe, std::vector< std::vector< bool >> &restriction_is_additive)
static ::ExceptionBase & ExcInternalError()