ExaDG
Loading...
Searching...
No Matches
variable_coefficients.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#ifndef INCLUDE_EXADG_OPERATORS_VARIABLE_COEFFICIENTS_H_
22#define INCLUDE_EXADG_OPERATORS_VARIABLE_COEFFICIENTS_H_
23
24namespace ExaDG
25{
38template<typename coefficient_type>
40{
41public:
55 template<int dim, typename Number>
56 void
57 initialize(dealii::MatrixFree<dim, Number> const & matrix_free,
58 unsigned int const quad_index,
59 bool const store_face_data_in,
60 bool const store_cell_based_face_data_in)
61 {
62 if(not store_face_data_in)
63 AssertThrow(not store_cell_based_face_data_in,
64 dealii::ExcMessage("Storing only cell-based face data does not make sense"
65 " if storing face data is disabled."));
66
67 store_face_data = store_face_data_in;
68 store_cell_based_face_data = store_cell_based_face_data_in;
69
70 reinit(matrix_free, quad_index);
71 }
72
76 void
77 set_coefficients(coefficient_type const & constant_coefficient)
78 {
79 fill(constant_coefficient);
80 }
81
85 coefficient_type
86 get_coefficient_cell(unsigned int const cell, unsigned int const q) const
87 {
88 return coefficients_cell[cell][q];
89 }
90
95 void
96 set_coefficient_cell(unsigned int const cell,
97 unsigned int const q,
98 coefficient_type const & coefficient)
99 {
100 coefficients_cell[cell][q] = coefficient;
101 }
102
106 coefficient_type
107 get_coefficient_face(unsigned int const face, unsigned int const q) const
108 {
109 return coefficients_face[face][q];
110 }
111
115 void
116 set_coefficient_face(unsigned int const face,
117 unsigned int const q,
118 coefficient_type const & coefficient)
119 {
120 coefficients_face[face][q] = coefficient;
121 }
122
126 coefficient_type
127 get_coefficient_face_neighbor(unsigned int const face, unsigned int const q) const
128 {
129 return coefficients_face_neighbor[face][q];
130 }
131
136 void
137 set_coefficient_face_neighbor(unsigned int const face,
138 unsigned int const q,
139 coefficient_type const & coefficient)
140 {
141 coefficients_face_neighbor[face][q] = coefficient;
142 }
143
148 coefficient_type
149 get_coefficient_face_cell_based(unsigned int const cell_based_face, unsigned int const q) const
150 {
151 return coefficients_face_cell_based[cell_based_face][q];
152 }
153
158 void
159 set_coefficient_face_cell_based(unsigned int const cell_based_face,
160 unsigned int const q,
161 coefficient_type const & coefficient)
162 {
163 coefficients_face_cell_based[cell_based_face][q] = coefficient;
164 }
165
166private:
171 template<int dim, typename Number>
172 void
173 reinit(dealii::MatrixFree<dim, Number> const & matrix_free, unsigned int const quad_index)
174 {
175 coefficients_cell.reinit(matrix_free.n_cell_batches(), matrix_free.get_n_q_points(quad_index));
176
177 if(store_face_data)
178 {
179 coefficients_face.reinit(matrix_free.n_inner_face_batches() +
180 matrix_free.n_boundary_face_batches(),
181 matrix_free.get_n_q_points_face(quad_index));
182 coefficients_face_neighbor.reinit(matrix_free.n_inner_face_batches(),
183 matrix_free.get_n_q_points_face(quad_index));
184
185 if(store_cell_based_face_data)
186 {
187 unsigned int const n_faces_per_cell =
188 matrix_free.get_dof_handler().get_triangulation().get_reference_cells()[0].n_faces();
189
190 coefficients_face_cell_based.reinit(matrix_free.n_cell_batches() * n_faces_per_cell,
191 matrix_free.get_n_q_points_face(quad_index));
192 }
193 }
194 }
195
199 void
200 fill(coefficient_type const & constant_coefficient)
201 {
202 coefficients_cell.fill(constant_coefficient);
203
204 if(store_face_data)
205 {
206 coefficients_face.fill(constant_coefficient);
207 coefficients_face_neighbor.fill(constant_coefficient);
208
209 if(store_cell_based_face_data)
210 coefficients_face_cell_based.fill(constant_coefficient);
211 }
212 }
213
215 dealii::Table<2, coefficient_type> coefficients_cell;
216
218 dealii::Table<2, coefficient_type> coefficients_face;
219
221 dealii::Table<2, coefficient_type> coefficients_face_neighbor;
222
224 dealii::Table<2, coefficient_type> coefficients_face_cell_based;
225
227 bool store_face_data{false};
228
235 bool store_cell_based_face_data{false};
236};
237
238} // namespace ExaDG
239
240#endif /* INCLUDE_EXADG_OPERATORS_VARIABLE_COEFFICIENTS_H_ */
Definition variable_coefficients.h:40
coefficient_type get_coefficient_cell(unsigned int const cell, unsigned int const q) const
Definition variable_coefficients.h:86
coefficient_type get_coefficient_face_neighbor(unsigned int const face, unsigned int const q) const
Definition variable_coefficients.h:127
void initialize(dealii::MatrixFree< dim, Number > const &matrix_free, unsigned int const quad_index, bool const store_face_data_in, bool const store_cell_based_face_data_in)
Definition variable_coefficients.h:57
void set_coefficient_cell(unsigned int const cell, unsigned int const q, coefficient_type const &coefficient)
Definition variable_coefficients.h:96
void set_coefficient_face(unsigned int const face, unsigned int const q, coefficient_type const &coefficient)
Definition variable_coefficients.h:116
void set_coefficients(coefficient_type const &constant_coefficient)
Definition variable_coefficients.h:77
coefficient_type get_coefficient_face_cell_based(unsigned int const cell_based_face, unsigned int const q) const
Definition variable_coefficients.h:149
void set_coefficient_face_cell_based(unsigned int const cell_based_face, unsigned int const q, coefficient_type const &coefficient)
Definition variable_coefficients.h:159
void set_coefficient_face_neighbor(unsigned int const face, unsigned int const q, coefficient_type const &coefficient)
Definition variable_coefficients.h:137
coefficient_type get_coefficient_face(unsigned int const face, unsigned int const q) const
Definition variable_coefficients.h:107
Definition driver.cpp:33