22#ifndef EXADG_POISSON_SPATIAL_DISCRETIZATION_WEAK_BOUNDARY_CONDITIONS_H_
23#define EXADG_POISSON_SPATIAL_DISCRETIZATION_WEAK_BOUNDARY_CONDITIONS_H_
26#include <exadg/functions_and_boundary_conditions/evaluate_functions.h>
27#include <exadg/matrix_free/integrators.h>
28#include <exadg/operators/operator_type.h>
49template<
int dim,
typename Number,
int n_components,
int rank>
50inline DEAL_II_ALWAYS_INLINE
51 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
52 calculate_interior_value(
unsigned int const q,
53 FaceIntegrator<dim, n_components, Number>
const & integrator,
54 OperatorType
const & operator_type)
56 if(operator_type == OperatorType::full or operator_type == OperatorType::homogeneous)
58 return integrator.get_value(q);
60 else if(operator_type == OperatorType::inhomogeneous)
62 return dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>();
66 AssertThrow(
false, dealii::ExcMessage(
"Specified OperatorType is not implemented!"));
69 return dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>();
72template<
int dim,
typename Number,
int n_components,
int rank>
73inline DEAL_II_ALWAYS_INLINE
74 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
75 calculate_exterior_value(
76 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
const & value_m,
78 FaceIntegrator<dim, n_components, Number>
const & integrator,
79 OperatorType
const & operator_type,
80 BoundaryType
const & boundary_type,
81 dealii::types::boundary_id
const boundary_id,
85 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>> value_p;
87 if(boundary_type == BoundaryType::Dirichlet or boundary_type == BoundaryType::DirichletCached)
89 if(operator_type == OperatorType::full or operator_type == OperatorType::inhomogeneous)
91 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>> g;
93 if(boundary_type == BoundaryType::Dirichlet)
95 auto bc = boundary_descriptor->dirichlet_bc.find(boundary_id)->second;
96 auto q_points = integrator.quadrature_point(q);
98 g = FunctionEvaluator<rank, dim, Number>::value(*bc, q_points, time);
100 else if(boundary_type == BoundaryType::DirichletCached)
102 auto bc = boundary_descriptor->get_dirichlet_cached_data();
103 g = FunctionEvaluator<rank, dim, Number>::value(*bc,
104 integrator.get_current_cell_index(),
106 integrator.get_quadrature_index());
110 AssertThrow(
false, dealii::ExcMessage(
"Not implemented."));
113 value_p = -value_m + dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>(2.0 * g);
115 else if(operator_type == OperatorType::homogeneous)
121 AssertThrow(
false, dealii::ExcMessage(
"Specified OperatorType is not implemented!"));
124 else if(boundary_type == BoundaryType::Neumann)
130 AssertThrow(
false, dealii::ExcMessage(
"Boundary type of face is invalid or not implemented."));
163template<
int dim,
typename Number,
int n_components,
int rank>
164inline DEAL_II_ALWAYS_INLINE
165 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
166 calculate_interior_normal_gradient(
unsigned int const q,
167 FaceIntegrator<dim, n_components, Number>
const & integrator,
168 OperatorType
const & operator_type)
170 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>> normal_gradient_m;
172 if(operator_type == OperatorType::full or operator_type == OperatorType::homogeneous)
174 normal_gradient_m = integrator.get_normal_derivative(q);
176 else if(operator_type == OperatorType::inhomogeneous)
182 AssertThrow(
false, dealii::ExcMessage(
"Specified OperatorType is not implemented!"));
185 return normal_gradient_m;
188template<
int dim,
typename Number,
int n_components,
int rank>
189inline DEAL_II_ALWAYS_INLINE
190 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
191 calculate_exterior_normal_gradient(
192 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
const & normal_gradient_m,
193 unsigned int const q,
194 FaceIntegrator<dim, n_components, Number>
const & integrator,
195 OperatorType
const & operator_type,
196 BoundaryType
const & boundary_type,
197 dealii::types::boundary_id
const boundary_id,
201 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>> normal_gradient_p;
203 if(boundary_type == BoundaryType::Dirichlet or boundary_type == BoundaryType::DirichletCached)
205 normal_gradient_p = normal_gradient_m;
207 else if(boundary_type == BoundaryType::Neumann)
209 if(operator_type == OperatorType::full or operator_type == OperatorType::inhomogeneous)
211 auto bc = boundary_descriptor->neumann_bc.find(boundary_id)->second;
212 auto q_points = integrator.quadrature_point(q);
214 auto h = FunctionEvaluator<rank, dim, Number>::value(*bc, q_points, time);
217 -normal_gradient_m + dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>(2.0 * h);
219 else if(operator_type == OperatorType::homogeneous)
221 normal_gradient_p = -normal_gradient_m;
225 AssertThrow(
false, dealii::ExcMessage(
"Specified OperatorType is not implemented!"));
230 AssertThrow(
false, dealii::ExcMessage(
"Boundary type of face is invalid or not implemented."));
233 return normal_gradient_p;
240template<
int dim,
typename Number,
int n_components,
int rank>
241inline DEAL_II_ALWAYS_INLINE
242 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>>
243 calculate_neumann_value(
unsigned int const q,
244 FaceIntegrator<dim, n_components, Number>
const & integrator,
245 BoundaryType
const & boundary_type,
246 dealii::types::boundary_id
const boundary_id,
250 dealii::Tensor<rank, dim, dealii::VectorizedArray<Number>> normal_gradient;
252 if(boundary_type == BoundaryType::Neumann)
254 auto bc = boundary_descriptor->neumann_bc.find(boundary_id)->second;
255 auto q_points = integrator.quadrature_point(q);
257 normal_gradient = FunctionEvaluator<rank, dim, Number>::value(*bc, q_points, time);
263 Assert(boundary_type == BoundaryType::Dirichlet or
264 boundary_type == BoundaryType::DirichletCached,
265 dealii::ExcMessage(
"Boundary type of face is invalid or not implemented."));
268 return normal_gradient;
Definition boundary_descriptor.h:46