ExaDG
Loading...
Searching...
No Matches
container_interface_data.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 EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_CONTAINER_INTERFACE_DATA_H_
23#define EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_CONTAINER_INTERFACE_DATA_H_
24
25// deal.II
26#include <deal.II/base/tensor.h>
27
28// C/C++
29#include <map>
30#include <tuple>
31#include <vector>
32
33// ExaDG
34#include <exadg/matrix_free/integrators.h>
35#include <exadg/utilities/tensor_utilities.h>
36
37namespace ExaDG
38{
44template<int rank, int dim, typename number_type>
45class ContainerInterfaceData
46{
47public:
48 typedef dealii::Tensor<rank, dim, number_type> data_type;
49
50private:
51 static unsigned int const n_components = rank_to_n_components<rank, dim>();
52
53 using SetBoundaryIDs = std::set<dealii::types::boundary_id>;
54
55 using quad_index = unsigned int;
56
57 using Id = std::tuple<unsigned int /*face*/, unsigned int /*q*/, unsigned int /*v*/>;
58
59 using MapVectorIndex = std::map<Id, dealii::types::global_dof_index>;
60
61 using ArrayQuadraturePoints = std::vector<dealii::Point<dim>>;
62
63 using ArraySolutionValues = std::vector<data_type>;
64
65public:
66 ContainerInterfaceData();
67
68 template<typename Number>
69 void
70 setup(dealii::MatrixFree<dim, Number> const & matrix_free_,
71 unsigned int const dof_index_,
72 std::vector<quad_index> const & quad_indices_,
73 SetBoundaryIDs const & set_bids_)
74 {
75 quad_indices = quad_indices_;
76
77 for(auto q_index : quad_indices)
78 {
79 // initialize maps
80 map_vector_index.emplace(q_index, MapVectorIndex());
81 map_q_points.emplace(q_index, ArrayQuadraturePoints());
82 map_solution.emplace(q_index, ArraySolutionValues());
83
84 MapVectorIndex & map_index = map_vector_index.find(q_index)->second;
85 ArrayQuadraturePoints & array_q_points_dst = map_q_points.find(q_index)->second;
86 ArraySolutionValues & array_solution_dst = map_solution.find(q_index)->second;
87
88 // create map "ID = {face, q, v} <-> vector_index" and fill array of quadrature points
89 for(unsigned int face = matrix_free_.n_inner_face_batches();
90 face < matrix_free_.n_inner_face_batches() + matrix_free_.n_boundary_face_batches();
91 ++face)
92 {
93 // only consider relevant boundary IDs
94 if(set_bids_.find(matrix_free_.get_boundary_id(face)) != set_bids_.end())
95 {
96 FaceIntegrator<dim, n_components, Number> integrator(matrix_free_,
97 true,
98 dof_index_,
99 q_index);
100 integrator.reinit(face);
101
102 for(unsigned int q = 0; q < integrator.n_q_points; ++q)
103 {
104 dealii::Point<dim, dealii::VectorizedArray<Number>> q_points =
105 integrator.quadrature_point(q);
106
107 for(unsigned int v = 0; v < dealii::VectorizedArray<Number>::size(); ++v)
108 {
109 dealii::Point<dim> q_point;
110 for(unsigned int d = 0; d < dim; ++d)
111 q_point[d] = q_points[d][v];
112
113 Id id = std::make_tuple(face, q, v);
114 dealii::types::global_dof_index index = array_q_points_dst.size();
115 map_index.emplace(id, index);
116 array_q_points_dst.push_back(q_point);
117 }
118 }
119 }
120 }
121
122 array_solution_dst.resize(array_q_points_dst.size(), data_type());
123 }
124 }
125
126 std::vector<quad_index> const &
127 get_quad_indices();
128
129 ArrayQuadraturePoints &
130 get_array_q_points(quad_index const & q_index);
131
132 ArraySolutionValues &
133 get_array_solution(quad_index const & q_index);
134
135 data_type
136 get_data(unsigned int const q_index,
137 unsigned int const face,
138 unsigned int const q,
139 unsigned int const v) const;
140
141private:
142 std::vector<quad_index> quad_indices;
143
144 mutable std::map<quad_index, MapVectorIndex> map_vector_index;
145 mutable std::map<quad_index, ArrayQuadraturePoints> map_q_points;
146 mutable std::map<quad_index, ArraySolutionValues> map_solution;
147};
148} // namespace ExaDG
149
150#endif /* EXADG_FUNCTIONS_AND_BOUNDARY_CONDITIONS_CONTAINER_INTERFACE_DATA_H_ */
Definition driver.cpp:33