ExaDG
Loading...
Searching...
No Matches
interpolate.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2024 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 EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_INTERPOLATE_H_
23#define EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_INTERPOLATE_H_
24
25#include <deal.II/numerics/vector_tools.h>
26
27#include <type_traits>
28
29namespace ExaDG
30{
31namespace Utilities
32{
33template<int dim,
34 int spacedim,
35 typename Number,
36 template<typename>
37 typename VectorType,
38 typename FunctionNumber>
39void
40interpolate(dealii::DoFHandler<dim, spacedim> const & dof_handler,
41 dealii::Function<spacedim, FunctionNumber> const & function,
43{
44 if constexpr(std::is_same_v<Number, FunctionNumber>)
45 {
46 dealii::VectorTools::interpolate(dof_handler, function, vec);
47 }
48 else
49 {
51 vec_fn.reinit(vec);
52 dealii::VectorTools::interpolate(dof_handler, function, vec_fn);
53 vec.copy_locally_owned_data_from(vec_fn);
54 }
55}
56
57template<int dim, int spacedim, typename VectorType, typename FunctionNumber>
58void
59interpolate(dealii::DoFHandler<dim, spacedim> const & dof_handler,
60 dealii::Function<spacedim, FunctionNumber> & function,
61 VectorType & vec,
62 double const time)
63{
64 function.set_time(time);
65 interpolate(dof_handler, function, vec);
66}
67
68template<int dim,
69 int spacedim,
70 typename Number,
71 template<typename>
72 typename VectorType,
73 typename FunctionNumber>
74void
75interpolate(dealii::Mapping<dim, spacedim> const & mapping,
76 dealii::DoFHandler<dim, spacedim> const & dof_handler,
77 dealii::Function<spacedim, FunctionNumber> const & function,
79{
80 if constexpr(std::is_same_v<Number, FunctionNumber>)
81 {
82 dealii::VectorTools::interpolate(mapping, dof_handler, function, vec);
83 }
84 else
85 {
87 vec_fn.reinit(vec);
88 dealii::VectorTools::interpolate(mapping, dof_handler, function, vec_fn);
89 vec.copy_locally_owned_data_from(vec_fn);
90 }
91}
92
93template<int dim, int spacedim, typename VectorType, typename FunctionNumber>
94void
95interpolate(dealii::Mapping<dim, spacedim> const & mapping,
96 dealii::DoFHandler<dim, spacedim> const & dof_handler,
97 dealii::Function<spacedim, FunctionNumber> & function,
98 VectorType & vec,
99 double const time)
100{
101 function.set_time(time);
102 interpolate(mapping, dof_handler, function, vec);
103}
104
105
106} // namespace Utilities
107} // namespace ExaDG
108
109
110#endif /*EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_INTERPOLATE_H_*/
Definition interpolate.h:32
Definition driver.cpp:33