ExaDG
Loading...
Searching...
No Matches
interface.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 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_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_INTERFACE_H_
23#define INCLUDE_EXADG_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_INTERFACE_H_
24
25// deal.II
26#include <deal.II/lac/la_parallel_vector.h>
27
28// ExaDG
29#include <exadg/time_integration/interpolate.h>
30
31namespace ExaDG
32{
33namespace ConvDiff
34{
35namespace Interface
36{
37template<typename Number>
39{
40public:
41 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
42
43 Operator()
44 {
45 }
46
47 virtual ~Operator()
48 {
49 }
50
51 // explicit time integration: evaluate operator
52 virtual void
53 evaluate_explicit_time_int(VectorType & dst,
54 VectorType const & src,
55 double const evaluation_time,
56 VectorType const * velocity = nullptr) const = 0;
57
58 // implicit time integration: calculate right-hand side of linear system of equations
59 virtual void
60 rhs(VectorType & dst,
61 double const evaluation_time = 0.0,
62 VectorType const * velocity = nullptr) const = 0;
63
64 // implicit time integration: solve linear system of equations
65 virtual unsigned int
66 solve(VectorType & sol,
67 VectorType const & rhs,
68 bool const update_preconditioner,
69 double const scaling_factor = -1.0,
70 double const evaluation_time = -1.0,
71 VectorType const * velocity = nullptr) = 0;
72
73 // time integration: initialize dof vector
74 virtual void
75 initialize_dof_vector(VectorType & src) const = 0;
76
77 virtual void
78 initialize_dof_vector_velocity(VectorType & src) const = 0;
79
80 virtual void
81 project_velocity(VectorType & velocity, double const time) const = 0;
82
83 // time integration: prescribe initial conditions
84 virtual void
85 prescribe_initial_conditions(VectorType & src, double const evaluation_time) const = 0;
86
87 // time step calculation: max efficiency
88 virtual double
89 calculate_time_step_max_efficiency(unsigned int const order_time_integrator) const = 0;
90
91 // time step calculation: global CFL condition
92 virtual double
93 calculate_time_step_cfl_global(double const time) const = 0;
94
95 // time step calculation: local CFL condition
96 virtual double
97 calculate_time_step_cfl_analytical_velocity(double const time) const = 0;
98
99 virtual double
100 calculate_time_step_cfl_numerical_velocity(VectorType const & velocity) const = 0;
101
102 // needed for time step calculation
103 virtual double
104 calculate_time_step_diffusion() const = 0;
105};
106} // namespace Interface
107
108template<typename Number>
110{
111public:
112 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
113
114 OperatorExplRK(std::shared_ptr<ConvDiff::Interface::Operator<Number>> operator_in,
115 bool const numerical_velocity_field_in)
116 : pde_operator(operator_in), numerical_velocity_field(numerical_velocity_field_in)
117 {
118 if(numerical_velocity_field)
119 initialize_dof_vector_velocity(velocity_interpolated);
120 }
121
122 void
123 set_velocities_and_times(std::vector<VectorType const *> const & velocities_in,
124 std::vector<double> const & times_in)
125 {
126 velocities = velocities_in;
127 times = times_in;
128 }
129
130 void
131 evaluate(VectorType & dst, VectorType const & src, double const evaluation_time) const
132 {
133 if(numerical_velocity_field)
134 {
135 interpolate(velocity_interpolated, evaluation_time, velocities, times);
136
137 pde_operator->evaluate_explicit_time_int(dst, src, evaluation_time, &velocity_interpolated);
138 }
139 else
140 {
141 pde_operator->evaluate_explicit_time_int(dst, src, evaluation_time);
142 }
143 }
144
145 void
146 initialize_dof_vector(VectorType & src) const
147 {
148 pde_operator->initialize_dof_vector(src);
149 }
150
151 void
152 initialize_dof_vector_velocity(VectorType & src) const
153 {
154 pde_operator->initialize_dof_vector_velocity(src);
155 }
156
157private:
158 std::shared_ptr<ConvDiff::Interface::Operator<Number>> pde_operator;
159
160 bool numerical_velocity_field;
161 std::vector<VectorType const *> velocities;
162 std::vector<double> times;
163 VectorType mutable velocity_interpolated;
164};
165
166} // namespace ConvDiff
167} // namespace ExaDG
168
169#endif /* INCLUDE_EXADG_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_INTERFACE_H_ */
Definition interface.h:39
Definition interface.h:110
Definition driver.cpp:33