1 #pragma once // Ensure that file is included only once in a single compilation.
35 template <
unsigned int hyEdge_dimT,
36 unsigned int poly_deg,
37 unsigned int quad_deg,
38 typename lSol_float_t =
double>
65 typedef std::array<lSol_float_t, 1U>
error_t;
71 std::array<lSol_float_t, 1U> summed_error;
72 summed_error.fill(0.);
80 for (
unsigned int k = 0; k < summed_error.size(); ++k)
81 summed_error[k] += new_error[k];
89 for (
unsigned int k = 0; k < summed_error.size(); ++k)
90 summed_error[k] = std::sqrt(summed_error[k]);
101 static constexpr
unsigned int hyEdge_dim() {
return hyEdge_dimT; }
196 template <
typename SmallMatT>
205 template <
typename SmallMatT>
207 const SmallMatT& lambda_values)
const
216 <<
"This can happen if quadrature is too inaccurate!");
229 inline std::array<std::array<lSol_float_t, n_shape_bdr_>, 2 * hyEdge_dimT>
primal_at_boundary(
230 const std::array<lSol_float_t, n_loc_dofs_>& coeffs)
const;
240 inline std::array<std::array<lSol_float_t, n_shape_bdr_>, 2 * hyEdge_dimT>
dual_at_boundary(
241 const std::array<lSol_float_t, (hyEdge_dimT + 1) *
n_shape_fct_>& coeffs)
const;
272 template <
typename SmallMatInT,
typename SmallMatOutT>
274 SmallMatOutT& lambda_values_out,
275 const lSol_float_t
UNUSED(time) = 0.)
const
277 hy_assert(lambda_values_in.size() == lambda_values_out.size() &&
278 lambda_values_in.size() == 2 * hyEdge_dimT,
279 "Both matrices must be of same size which corresponds to the number of faces!");
280 for (
unsigned int i = 0; i < lambda_values_in.size(); ++i)
282 lambda_values_in[i].size() == lambda_values_out[i].size() &&
284 "Both matrices must be of same size which corresponds to the number of dofs per face!");
288 std::array<std::array<lSol_float_t, n_shape_bdr_>, 2 * hyEdge_dimT> primals(
292 for (
unsigned int i = 0; i < lambda_values_out.size(); ++i)
293 for (
unsigned int j = 0; j < lambda_values_out[i].size(); ++j)
294 lambda_values_out[i][j] = duals[i][j] +
tau_ * (primals[i][j] - lambda_values_in[i][j]);
296 return lambda_values_out;
308 template <
typename SmallMatInT,
typename SmallMatOutT>
310 SmallMatOutT& lambda_values_out,
311 const lSol_float_t
UNUSED(time) = 0.)
const
313 return lambda_values_out =
trace_to_flux(lambda_values_in, lambda_values_out);
323 template <
typename SmallMatT>
324 std::array<lSol_float_t, 1U>
errors(
const SmallMatT&
UNUSED(lambda_values),
325 const lSol_float_t
UNUSED(time) = 0.)
const
327 return std::array<lSol_float_t, 1U>({0.});
340 template <
typename abscissa_
float_t, std::
size_t abscissas_sizeT,
class input_array_t>
341 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
system_dim>
342 bulk_values(
const std::array<abscissa_float_t, abscissas_sizeT>& abscissas,
343 const input_array_t& lambda_values,
344 const lSol_float_t
UNUSED(time) = 0.)
const;
364 template <
unsigned int hyEdge_dimT,
365 unsigned int poly_deg,
366 unsigned int quad_deg,
367 typename lSol_float_t>
371 const lSol_float_t tau)
373 lSol_float_t integral;
377 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
379 for (
unsigned int j = 0; j < n_shape_fct_; ++j)
382 integral = integrator::integrate_vol_phiphi(i, j);
383 for (
unsigned int dim = 0; dim < hyEdge_dimT; ++dim)
384 local_mat(dim * n_shape_fct_ + i, dim * n_shape_fct_ + j) += integral;
386 for (
unsigned int dim = 0; dim < hyEdge_dimT; ++dim)
390 integral = integrator::integrate_vol_Dphiphi(i, j, dim);
391 local_mat(hyEdge_dimT * n_shape_fct_ + i, dim * n_shape_fct_ + j) -= integral;
392 local_mat(dim * n_shape_fct_ + i, hyEdge_dimT * n_shape_fct_ + j) -= integral;
395 integral = integrator::integrate_bdr_phiphi(i, j, 2 * dim + 1);
396 local_mat(hyEdge_dimT * n_shape_fct_ + i, dim * n_shape_fct_ + j) += integral;
398 local_mat(hyEdge_dimT * n_shape_fct_ + i, hyEdge_dimT * n_shape_fct_ + j) += tau * integral;
400 integral = integrator::integrate_bdr_phiphi(i, j, 2 * dim + 0);
401 local_mat(hyEdge_dimT * n_shape_fct_ + i, dim * n_shape_fct_ + j) -= integral;
403 local_mat(hyEdge_dimT * n_shape_fct_ + i, hyEdge_dimT * n_shape_fct_ + j) += tau * integral;
415 template <
unsigned int hyEdge_dimT,
416 unsigned int poly_deg,
417 unsigned int quad_deg,
418 typename lSol_float_t>
419 template <
typename SmallMatT>
423 const SmallMatT& lambda_values)
const
425 lSol_float_t integral;
429 hy_assert(lambda_values.size() == 2 * hyEdge_dimT,
430 "The size of the lambda values should be twice the dimension of a hyperedge.");
431 for (
unsigned int i = 0; i < 2 * hyEdge_dimT; ++i)
432 hy_assert(lambda_values[i].size() == n_shape_bdr_,
433 "The size of lambda should be the amount of ansatz functions at boundary.");
435 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
437 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
439 for (
unsigned int dim = 0; dim < hyEdge_dimT; ++dim)
441 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 0);
442 right_hand_side[dim * n_shape_fct_ + i] += lambda_values[2 * dim + 0][j] * integral;
443 right_hand_side[hyEdge_dimT * n_shape_fct_ + i] +=
444 tau_ * lambda_values[2 * dim + 0][j] * integral;
446 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 1);
447 right_hand_side[dim * n_shape_fct_ + i] -= lambda_values[2 * dim + 1][j] * integral;
448 right_hand_side[hyEdge_dimT * n_shape_fct_ + i] +=
449 tau_ * lambda_values[2 * dim + 1][j] * integral;
454 return right_hand_side;
461 template <
unsigned int hyEdge_dimT,
462 unsigned int poly_deg,
463 unsigned int quad_deg,
464 typename lSol_float_t>
466 std::array<lSol_float_t,
470 const std::array<lSol_float_t, n_loc_dofs_>& coeffs)
const
472 std::array<std::array<lSol_float_t, n_shape_bdr_>, 2 * hyEdge_dimT> bdr_values;
473 lSol_float_t integral;
475 for (
unsigned int dim_n = 0; dim_n < 2 * hyEdge_dimT; ++dim_n)
476 bdr_values[dim_n].fill(0.);
478 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
480 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
482 for (
unsigned int dim = 0; dim < hyEdge_dimT; ++dim)
484 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 0);
485 bdr_values[2 * dim + 0][j] += coeffs[hyEdge_dimT * n_shape_fct_ + i] * integral;
487 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 1);
488 bdr_values[2 * dim + 1][j] += coeffs[hyEdge_dimT * n_shape_fct_ + i] * integral;
500 template <
unsigned int hyEdge_dimT,
501 unsigned int poly_deg,
502 unsigned int quad_deg,
503 typename lSol_float_t>
505 std::array<lSol_float_t,
509 const std::array<lSol_float_t, (hyEdge_dimT + 1) * n_shape_fct_>& coeffs)
const
511 std::array<std::array<lSol_float_t, n_shape_bdr_>, 2 * hyEdge_dimT> bdr_values;
512 lSol_float_t integral;
514 for (
unsigned int dim_n = 0; dim_n < 2 * hyEdge_dimT; ++dim_n)
515 bdr_values[dim_n].fill(0.);
517 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
519 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
521 for (
unsigned int dim = 0; dim < hyEdge_dimT; ++dim)
523 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 0);
524 bdr_values[2 * dim + 0][j] -= coeffs[dim * n_shape_fct_ + i] * integral;
526 integral = integrator::integrate_bdr_phipsi(i, j, 2 * dim + 1);
527 bdr_values[2 * dim + 1][j] += coeffs[dim * n_shape_fct_ + i] * integral;
539 template <
unsigned int hyEdge_dimT,
540 unsigned int poly_deg,
541 unsigned int quad_deg,
542 typename lSol_float_t>
543 template <
typename abscissa_
float_t, std::
size_t abscissas_sizeT,
class input_array_t>
544 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
547 const std::array<abscissa_float_t, abscissas_sizeT>& abscissas,
548 const input_array_t& lambda_values,
549 const lSol_float_t)
const
555 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
559 for (
unsigned int d = 0; d < system_dim; ++d)
561 for (
unsigned int i = 0; i < coeffs.
size(); ++i)
562 coeffs[i] = coefficients[d * n_shape_fct_ + i];
563 for (
unsigned int pt = 0; pt < Hypercube<hyEdge_dimT>::pow(abscissas_sizeT); ++pt)
564 point_vals[d][pt] = integrator::shape_fun_t::template lin_comb_fct_val<float>(