ExaDG
Loading...
Searching...
No Matches
solution_transfer.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_OPERATORS_SOLUTION_TRANSFER_H
23#define INCLUDE_EXADG_OPERATORS_SOLUTION_TRANSFER_H
24
25// deal.II
26#include <deal.II/distributed/solution_transfer.h>
27#include <deal.II/distributed/tria.h>
28#include <deal.II/grid/tria.h>
29
30namespace ExaDG
31{
32template<int dim, typename VectorType>
33class SolutionTransfer
34{
35public:
36 /*
37 * Constructor.
38 */
39 SolutionTransfer(dealii::DoFHandler<dim> const & dof_handler_in)
40 {
41 dof_handler = &dof_handler_in;
42 }
43
44 void
45 prepare_coarsening_and_refinement(std::vector<VectorType *> & vectors)
46 {
47 std::vector<VectorType const *> vectors_old_grid_ptr(vectors.size());
48 for(unsigned int i = 0; i < vectors.size(); ++i)
49 {
50 vectors[i]->update_ghost_values();
51 vectors_old_grid_ptr[i] = vectors[i];
52 }
53
54 pd_solution_transfer =
55 std::make_shared<dealii::parallel::distributed::SolutionTransfer<dim, VectorType>>(
56 *dof_handler);
57
58 pd_solution_transfer->prepare_for_coarsening_and_refinement(vectors_old_grid_ptr);
59 }
60
61 void
62 interpolate_after_coarsening_and_refinement(std::vector<VectorType *> & vectors)
63 {
64 // Note that the sequence of vectors per DofHandler/SolutionTransfer
65 // defined in Operator<dim, Number>::prepare_coarsening_and_refinement()
66 // and solution transfer calls here *need to match*.
67 pd_solution_transfer->interpolate(vectors);
68 }
69
70private:
71 std::shared_ptr<dealii::parallel::distributed::SolutionTransfer<dim, VectorType>>
72 pd_solution_transfer;
73
74 dealii::SmartPointer<dealii::DoFHandler<dim> const> dof_handler;
75};
76} // namespace ExaDG
77
78#endif /* INCLUDE_EXADG_OPERATORS_SOLUTION_TRANSFER_H */
Definition driver.cpp:33