deal.II version GIT relicensing-2165-gc91f007519 2024-11-20 01:40:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
solution_transfer.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1999 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_solution_transfer_h
16#define dealii_solution_transfer_h
17
18
19/*---------------------------- solutiontransfer.h ----------------------*/
20
21
22#include <deal.II/base/config.h>
23
26
28
29#include <deal.II/lac/vector.h>
30
31#include <vector>
32
34
35
301template <int dim, typename VectorType = Vector<double>, int spacedim = dim>
303{
304public:
318 const bool average_values = false);
319
323 ~SolutionTransfer() = default;
324
331 void
333 const std::vector<const VectorType *> &all_in);
334
338 void
339 prepare_for_coarsening_and_refinement(const std::vector<VectorType> &all_in);
340
345 void
346 prepare_for_coarsening_and_refinement(const VectorType &in);
347
355 void
356 interpolate(std::vector<VectorType *> &all_out);
357
361 void
362 interpolate(std::vector<VectorType> &all_out);
363
373 void
374 interpolate(VectorType &out);
375
382 void
383 prepare_for_serialization(const VectorType &in);
384
388 void
389 prepare_for_serialization(const std::vector<const VectorType *> &all_in);
390
397 void
398 deserialize(VectorType &in);
399
400
404 void
405 deserialize(std::vector<VectorType *> &all_in);
406
411 DEAL_II_DEPRECATED_EARLY void
412 clear();
413
414private:
421
425 const bool average_values;
426
431 std::vector<const VectorType *> input_vectors;
432
437 unsigned int handle;
438
444 std::vector<char>
447 const CellStatus status);
448
454 void
457 const CellStatus status,
458 const boost::iterator_range<std::vector<char>::const_iterator> &data_range,
459 std::vector<VectorType *> &all_out,
460 VectorType &valence);
461
462
467 void
469};
470
471
472
473namespace Legacy
474{
780 template <int dim, typename VectorType = Vector<double>, int spacedim = dim>
782 {
783 public:
788
793
798 void
799 clear();
800
806 void
808
816 void
818 const std::vector<VectorType> &all_in);
819
824 void
825 prepare_for_coarsening_and_refinement(const VectorType &in);
826
838 void
839 refine_interpolate(const VectorType &in, VectorType &out) const;
840
860 void
861 interpolate(const std::vector<VectorType> &all_in,
862 std::vector<VectorType> &all_out) const;
863
873 void
874 interpolate(const VectorType &in, VectorType &out) const;
875
880 std::size_t
881 memory_consumption() const;
882
888 "You are attempting an operation for which this object is "
889 "not prepared. This may be because you either did not call "
890 "one of the prepare_*() functions at all, or because you "
891 "called the wrong one for the operation you are currently "
892 "attempting.");
893
899 "You are attempting to call one of the prepare_*() functions "
900 "of this object to prepare it for an operation for which it "
901 "is already prepared. Specifically, the object was "
902 "previously prepared for pure refinement.");
903
909 "You are attempting to call one of the prepare_*() functions "
910 "of this object to prepare it for an operation for which it "
911 "is already prepared. Specifically, the object was "
912 "previously prepared for both coarsening and refinement.");
913
914 private:
921
926
947
952
953
959 std::vector<std::vector<types::global_dof_index>> indices_on_cell;
960
973 {
975 : indices_ptr(nullptr)
976 , dof_values_ptr(nullptr)
977 , active_fe_index(0)
978 {}
979 Pointerstruct(std::vector<types::global_dof_index> *indices_ptr_in,
980 const unsigned int active_fe_index_in = 0)
981 : indices_ptr(indices_ptr_in)
982 , dof_values_ptr(nullptr)
983 , active_fe_index(active_fe_index_in)
984 {}
986 std::vector<Vector<typename VectorType::value_type>> *dof_values_ptr_in,
987 const unsigned int active_fe_index_in = 0)
988 : indices_ptr(nullptr)
989 , dof_values_ptr(dof_values_ptr_in)
990 , active_fe_index(active_fe_index_in)
991 {}
992 std::size_t
993 memory_consumption() const;
994
995 std::vector<types::global_dof_index> *indices_ptr;
996 std::vector<Vector<typename VectorType::value_type>> *dof_values_ptr;
997 unsigned int active_fe_index;
998 };
999
1006 std::map<std::pair<unsigned int, unsigned int>, Pointerstruct> cell_map;
1007
1013 std::vector<std::vector<Vector<typename VectorType::value_type>>>
1015 };
1016} // namespace Legacy
1017
1019
1020#endif
CellStatus
Definition cell_status.h:31
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< Vector< typename VectorType::value_type > > > dof_values_on_cell
std::size_t memory_consumption() const
std::vector< std::vector< types::global_dof_index > > indices_on_cell
ObserverPointer< const DoFHandler< dim, spacedim >, SolutionTransfer< dim, VectorType, spacedim > > dof_handler
void prepare_for_coarsening_and_refinement(const std::vector< VectorType > &all_in)
types::global_dof_index n_dofs_old
std::map< std::pair< unsigned int, unsigned int >, Pointerstruct > cell_map
std::vector< const VectorType * > input_vectors
std::vector< char > pack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status)
void unpack_callback(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellStatus status, const boost::iterator_range< std::vector< char >::const_iterator > &data_range, std::vector< VectorType * > &all_out, VectorType &valence)
ObserverPointer< const DoFHandler< dim, spacedim >, SolutionTransfer< dim, VectorType, spacedim > > dof_handler
void deserialize(VectorType &in)
void prepare_for_coarsening_and_refinement(const std::vector< const VectorType * > &all_in)
void prepare_for_serialization(const VectorType &in)
void interpolate(std::vector< VectorType * > &all_out)
~SolutionTransfer()=default
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
static ::ExceptionBase & ExcAlreadyPrepForCoarseAndRef()
#define DeclExceptionMsg(Exception, defaulttext)
Definition exceptions.h:489
static ::ExceptionBase & ExcNotPrepared()
static ::ExceptionBase & ExcAlreadyPrepForRef()
std::vector< types::global_dof_index > * indices_ptr
std::vector< Vector< typename VectorType::value_type > > * dof_values_ptr
Pointerstruct(std::vector< types::global_dof_index > *indices_ptr_in, const unsigned int active_fe_index_in=0)
Pointerstruct(std::vector< Vector< typename VectorType::value_type > > *dof_values_ptr_in, const unsigned int active_fe_index_in=0)