Go to the documentation of this file. 1 #pragma once // Ensure that file is included only once in a single compilation.
19 template <
unsigned int space_dimT,
typename param_
float_t =
double>
20 struct DiffusionParametersDefault
29 static constexpr std::array<unsigned int, 0U>
neumann_nodes{};
34 const param_float_t = 0.)
42 const param_float_t = 0.)
50 const param_float_t = 0.)
58 const param_float_t = 0.)
66 const param_float_t = 0.)
103 template <
unsigned int hyEdge_dimT,
104 unsigned int poly_deg,
105 unsigned int quad_deg,
106 template <
unsigned int,
typename>
typename parametersT = DiffusionParametersDefault,
107 typename lSol_float_t =
double>
140 std::array<lSol_float_t, 1U> summed_error;
141 summed_error.fill(0.);
149 for (
unsigned int k = 0; k < summed_error.size(); ++k)
150 summed_error[k] += new_error[k];
158 for (
unsigned int k = 0; k < summed_error.size(); ++k)
159 summed_error[k] = std::sqrt(summed_error[k]);
171 static constexpr
unsigned int hyEdge_dim() {
return hyEdge_dimT; }
225 template <
typename parameters>
228 return std::find(parameters::dirichlet_nodes.begin(), parameters::dirichlet_nodes.end(),
229 node_type) != parameters::dirichlet_nodes.end();
261 template <
typename hyEdgeT>
264 const lSol_float_t time)
const;
285 template <
typename hyEdgeT,
typename SmallMatT>
287 const SmallMatT& lambda_values,
288 hyEdgeT& hyper_edge)
const;
307 template <
typename hyEdgeT>
310 const lSol_float_t time)
const;
330 template <
typename hyEdgeT,
typename SmallVecT>
332 hyEdgeT& hyper_edge)
const;
344 template <
typename hyEdgeT,
typename SmallMatT>
346 const unsigned int solution_type,
348 const lSol_float_t time)
const
353 if (solution_type == 0)
355 else if (solution_type == 1)
359 hy_assert(0 == 1,
"This has not been implemented!");
365 <<
"This can happen if quadrature is too inaccurate!");
380 template <
typename hyEdgeT>
383 hyEdgeT& hyper_edge)
const;
395 template <
typename hyEdgeT>
398 hyEdgeT& hyper_edge)
const;
432 template <
typename hyEdgeT,
typename SmallMatInT,
typename SmallMatOutT>
434 SmallMatOutT& lambda_values_out,
436 const lSol_float_t time = 0.)
const
438 hy_assert(lambda_values_in.size() == lambda_values_out.size() &&
439 lambda_values_in.size() == 2 * hyEdge_dimT,
440 "Both matrices must be of same size which corresponds to the number of faces!");
441 for (
unsigned int i = 0; i < lambda_values_in.size(); ++i)
443 lambda_values_in[i].size() == lambda_values_out[i].size() &&
445 "Both matrices must be of same size which corresponds to the number of dofs per face!");
455 for (
unsigned int i = 0; i < lambda_values_out.size(); ++i)
456 if (is_dirichlet<parameters>(hyper_edge.node_descriptor[i]))
457 for (
unsigned int j = 0; j < lambda_values_out[i].size(); ++j)
458 lambda_values_out[i][j] = 0.;
460 for (
unsigned int j = 0; j < lambda_values_out[i].size(); ++j)
461 lambda_values_out[i][j] =
462 duals(i, j) +
tau_ * primals(i, j) -
463 tau_ * lambda_values_in[i][j] * hyper_edge.geometry.face_area(i);
465 return lambda_values_out;
470 template <
typename hyEdgeT>
471 std::array<unsigned int, 2 * hyEdge_dimT>
node_types(hyEdgeT& hyper_edge)
const
475 std::array<unsigned int, 2 * hyEdge_dimT> result;
478 for (
unsigned int i = 0; i < 2 * hyEdge_dimT; ++i)
479 if (is_dirichlet<parameters>(hyper_edge.node_descriptor[i]))
496 template <
typename hyEdgeT,
typename SmallMatInT,
typename SmallMatOutT>
498 SmallMatOutT& lambda_values_out,
500 const lSol_float_t time = 0.)
const
502 hy_assert(lambda_values_in.size() == lambda_values_out.size() &&
503 lambda_values_in.size() == 2 * hyEdge_dimT,
504 "Both matrices must be of same size which corresponds to the number of faces!");
505 for (
unsigned int i = 0; i < lambda_values_in.size(); ++i)
507 lambda_values_in[i].size() == lambda_values_out[i].size() &&
509 "Both matrices must be of same size which corresponds to the number of dofs per face!");
519 for (
unsigned int i = 0; i < lambda_values_out.size(); ++i)
521 if (is_dirichlet<parameters>(hyper_edge.node_descriptor[i]))
522 for (
unsigned int j = 0; j < lambda_values_out[i].size(); ++j)
523 lambda_values_out[i][j] = 0.;
525 for (
unsigned int j = 0; j < lambda_values_out[i].size(); ++j)
526 lambda_values_out[i][j] =
527 duals(i, j) +
tau_ * primals(i, j) -
528 tau_ * lambda_values_in[i][j] * hyper_edge.geometry.face_area(i);
531 return lambda_values_out;
543 template <
typename hyEdgeT,
typename SmallMatT>
544 std::array<lSol_float_t, 1U>
errors(
const SmallMatT& lambda_values,
546 const lSol_float_t time = 0.)
const
548 hy_assert(lambda_values.size() == 2 * hyEdge_dimT,
"Matrix must have appropriate size!");
549 for (
unsigned int i = 0; i < lambda_values.size(); ++i)
551 "Matrix must have appropriate size!");
556 return std::array<lSol_float_t, 1U>({integrator::template integrate_vol_diffsquare_discana<
559 hy_edge.geometry, time)});
574 template <
typename abscissa_float_t,
575 std::size_t abscissas_sizeT,
578 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
system_dim>
579 bulk_values(
const std::array<abscissa_float_t, abscissas_sizeT>& abscissas,
580 const input_array_t& lambda_values,
582 const lSol_float_t time = 0.)
const;
601 template <
unsigned int hyEdge_dimT,
602 unsigned int poly_deg,
603 unsigned int quad_deg,
604 template <
unsigned int,
typename>
605 typename parametersT,
606 typename lSol_float_t>
607 template <
typename hyEdgeT>
613 const lSol_float_t time)
const
618 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
620 for (
unsigned int j = 0; j < n_shape_fct_; ++j)
623 local_mat(i, j) += integrator::template integrate_vol_nablaphinablaphifunc<
628 for (
unsigned int face = 0; face < 2 * hyEdge_dimT; ++face)
631 tau_ * integrator::template integrate_bdr_phiphi<decltype(hyEdgeT::geometry)>(
632 i, j, face, hyper_edge.geometry);
633 local_mat(i, j) -= integrator::template integrate_bdr_nablaphiphinufunc<
636 Point<hyEdge_dimT, lSol_float_t> >(j, i, face, hyper_edge.
geometry);
648 template <
unsigned int hyEdge_dimT,
649 unsigned int poly_deg,
650 unsigned int quad_deg,
651 template <
unsigned int,
typename>
652 typename parametersT,
653 typename lSol_float_t>
654 template <
typename hyEdgeT,
typename SmallMatT>
659 const SmallMatT& lambda_values,
660 hyEdgeT& hyper_edge)
const
662 static_assert(std::is_same<typename SmallMatT::value_type::value_type, lSol_float_t>::value,
663 "Lambda values should have same floating point arithmetics as local solver!");
664 hy_assert(lambda_values.size() == 2 * hyEdge_dimT,
665 "The size of the lambda values should be twice the dimension of a hyperedge.");
666 for (
unsigned int i = 0; i < 2 * hyEdge_dimT; ++i)
667 hy_assert(lambda_values[i].size() == n_shape_bdr_,
668 "The size of lambda should be the amount of ansatz functions at boundary.");
672 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
673 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
674 for (
unsigned int face = 0; face < 2 * hyEdge_dimT; ++face)
675 right_hand_side[i] +=
676 tau_ * lambda_values[face][j] *
678 i, j, face, hyper_edge.geometry);
680 return right_hand_side;
687 template <
unsigned int hyEdge_dimT,
688 unsigned int poly_deg,
689 unsigned int quad_deg,
690 template <
unsigned int,
typename>
691 typename parametersT,
692 typename lSol_float_t>
693 template <
typename hyEdgeT>
703 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
705 right_hand_side[i] = integrator::template integrate_vol_phifunc<
708 for (
unsigned int face = 0; face < 2 * hyEdge_dimT; ++face)
710 if (!is_dirichlet<parameters>(hyper_edge.node_descriptor[face]))
712 right_hand_side[i] +=
713 tau_ * integrator::template integrate_bdr_phifunc<
716 Point<hyEdge_dimT, lSol_float_t> >(i, face, hyper_edge.
geometry, time);
720 return right_hand_side;
727 template <
unsigned int hyEdge_dimT,
728 unsigned int poly_deg,
729 unsigned int quad_deg,
730 template <
unsigned int,
typename>
731 typename parametersT,
732 typename lSol_float_t>
733 template <
typename hyEdgeT,
typename SmallVecT>
738 const SmallVecT& coeffs,
739 hyEdgeT& hyper_edge)
const
742 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
743 for (
unsigned int j = 0; j < n_shape_fct_; ++j)
744 right_hand_side[hyEdge_dimT * n_shape_fct_ + i] +=
745 coeffs[j] * integrator::template integrate_vol_phiphi(i, j, hyper_edge.geometry);
747 return right_hand_side;
754 template <
unsigned int hyEdge_dimT,
755 unsigned int poly_deg,
756 unsigned int quad_deg,
757 template <
unsigned int,
typename>
758 typename parametersT,
759 typename lSol_float_t>
760 template <
typename hyEdgeT>
767 hyEdgeT& hyper_edge)
const
771 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
772 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
773 for (
unsigned int face = 0; face < 2 * hyEdge_dimT; ++face)
774 bdr_values(face, j) +=
775 coeffs[i] * integrator::template integrate_bdr_phipsi<decltype(hyEdgeT::geometry)>(
776 i, j, face, hyper_edge.geometry);
785 template <
unsigned int hyEdge_dimT,
786 unsigned int poly_deg,
787 unsigned int quad_deg,
788 template <
unsigned int,
typename>
789 typename parametersT,
790 typename lSol_float_t>
791 template <
typename hyEdgeT>
798 hyEdgeT& hyper_edge)
const
803 for (
unsigned int i = 0; i < n_shape_fct_; ++i)
804 for (
unsigned int j = 0; j < n_shape_bdr_; ++j)
805 for (
unsigned int face = 0; face < 2 * hyEdge_dimT; ++face)
806 bdr_values(face, j) -=
807 integrator::template integrate_bdr_nablaphipsinufunc<
810 Point<hyEdge_dimT, lSol_float_t> >(i, j, face, hyper_edge.
geometry) *
820 template <
unsigned int hyEdge_dimT,
821 unsigned int poly_deg,
822 unsigned int quad_deg,
823 template <
unsigned int,
typename>
824 typename parametersT,
825 typename lSol_float_t>
826 template <
typename abscissa_float_t,
827 std::size_t abscissas_sizeT,
830 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
833 const std::array<abscissa_float_t, abscissas_sizeT>& abscissas,
834 const input_array_t& lambda_values,
836 const lSol_float_t time)
const
839 solve_local_problem(lambda_values, 1U, hyper_edge, time);
843 std::array<std::array<lSol_float_t, Hypercube<hyEdge_dimT>::pow(abscissas_sizeT)>,
847 for (
unsigned int d = 0; d < system_dim; ++d)
849 for (
unsigned int i = 0; i < coeffs.
size(); ++i)
850 coeffs[i] = coefficients[d * n_shape_fct_ + i];
851 for (
unsigned int pt = 0; pt < Hypercube<hyEdge_dimT>::pow(abscissas_sizeT); ++pt)
852 point_vals[d][pt] = integrator::shape_fun_t::template lin_comb_fct_val<float>(
static constexpr unsigned int n_glob_dofs_per_node()
Evaluate amount of global degrees of freedom per hypernode.
Definition: diffusion_ip.hxx:180
SmallMat< 2 *hyEdge_dimT, n_shape_bdr_, lSol_float_t > dual_at_boundary(const SmallVec< n_loc_dofs_, lSol_float_t > &coeffs, hyEdgeT &hyper_edge) const
Evaluate dual variable at boundary.
lSol_float_t constructor_value_type
Class is constructed using a single double indicating the penalty parameter.
Definition: diffusion_ip.hxx:408
const char * what() const
Definition: lapack.hxx:27
static error_t postprocess_error(error_t &summed_error)
Define how global errors should be postprocessed.
Definition: diffusion_ip.hxx:156
A namespace for local solvers.
Definition: advection_parab_ldgh.hxx:11
Define type of (hyperedge related) data that is stored in HyDataContainer.
Definition: diffusion_ip.hxx:114
SmallVec< n_loc_dofs_, lSol_float_t > assemble_rhs_from_coeffs(const SmallVecT &coeffs, hyEdgeT &hyper_edge) const
Assemble local right-hand for the local solver (from volume function coefficients).
SmallVec< n_loc_dofs_, lSol_float_t > assemble_rhs_from_lambda(const SmallMatT &lambda_values, hyEdgeT &hyper_edge) const
Assemble local right-hand for the local solver (from skeletal).
std::array< unsigned int, 2 *hyEdge_dimT > node_types(hyEdgeT &hyper_edge) const
Fill an array with 1 if the node is Dirichlet and 0 otherwise.
Definition: diffusion_ip.hxx:471
static constexpr unsigned int n_shape_fct_
Number of local shape functions (with respect to all spatial dimensions).
Definition: diffusion_ip.hxx:201
static param_float_t dirichlet_value(const Point< space_dimT, param_float_t > &, const param_float_t=0.)
Dirichlet values of solution as analytic function.
Definition: diffusion_ip.hxx:49
static param_float_t neumann_value(const Point< space_dimT, param_float_t > &, const param_float_t=0.)
Neumann values of solution as analytic function.
Definition: diffusion_ip.hxx:57
std::array< lSol_float_t, 1U > errors(const SmallMatT &lambda_values, hyEdgeT &hy_edge, const lSol_float_t time=0.) const
Calculate squared local contribution of L2 error.
Definition: diffusion_ip.hxx:544
Local solver diffusion equation on hypergraph.
Definition: diffusion_ip.hxx:108
static param_float_t diffusion_coeff(const Point< space_dimT, param_float_t > &, const param_float_t=0.)
Diffusion coefficient in PDE as analytic function.
Definition: diffusion_ip.hxx:33
Gauss–Legendre quadrature points and weights in one spatial dimension.
Definition: one_dimensional.hxx:19
static constexpr unsigned int size()
Return size a SmallMat.
Definition: dense_la.hxx:54
Struct that handles the evaluation of tensorial shape functions.
Definition: tensorial.hxx:22
static constexpr unsigned int n_loc_dofs_
Number of (local) degrees of freedom per hyperedge.
Definition: diffusion_ip.hxx:209
static constexpr unsigned int n_shape_bdr_
Number oflocal shape functions (with respect to a face / hypernode).
Definition: diffusion_ip.hxx:205
TPP::Quadrature::Tensorial< TPP::Quadrature::GaussLegendre< quad_deg >, TPP::ShapeFunction< TPP::ShapeType::Tensorial< TPP::ShapeType::Legendre< poly_deg >, hyEdge_dimT > >, lSol_float_t > integrator
An integrator helps to easily evaluate integrals (e.g. via quadrature).
Definition: diffusion_ip.hxx:247
SmallVec< n_loc_dofs_, lSol_float_t > assemble_rhs_from_global_rhs(hyEdgeT &hyper_edge, const lSol_float_t time) const
Assemble local right-hand for the local solver (from global right-hand side).
SmallVec< n_loc_dofs_, lSol_float_t > solve_local_problem(const SmallMatT &lambda_values, const unsigned int solution_type, hyEdgeT &hyper_edge, const lSol_float_t time) const
Solve local problem (with right-hand side from skeletal).
Definition: diffusion_ip.hxx:345
SmallSquareMat< n_loc_dofs_, lSol_float_t > assemble_loc_matrix(hyEdgeT &hyper_edge, const lSol_float_t time) const
Assemble local matrix for the local solver.
Struct that handles different types of evaluation of shape functions.
Definition: shape_function.hxx:15
std::array< lSol_float_t, 1U > error_t
Define the typename returned by function errors.
Definition: diffusion_ip.hxx:134
static param_float_t analytic_result(const Point< space_dimT, param_float_t > &, const param_float_t=0.)
Analytic result of PDE (for convergence tests).
Definition: diffusion_ip.hxx:65
SmallMatOutT & trace_to_flux(const SmallMatInT &lambda_values_in, SmallMatOutT &lambda_values_out, hyEdgeT &hyper_edge, const lSol_float_t time=0.) const
Evaluate local contribution to matrix–vector multiplication.
Definition: diffusion_ip.hxx:433
General integrator class on tensorial hypergraphs.
Definition: tensorial.hxx:24
static error_t sum_error(error_t &summed_error, const error_t &new_error)
Define how local errors should be accumulated.
Definition: diffusion_ip.hxx:147
Define how errors are evaluated.
Definition: diffusion_ip.hxx:129
static param_float_t right_hand_side(const Point< space_dimT, param_float_t > &, const param_float_t=0.)
Right-hand side in PDE as analytic function.
Definition: diffusion_ip.hxx:41
static constexpr std::array< unsigned int, 0U > neumann_nodes
Array containing hypernode types corresponding to Neumann boundary.
Definition: advection_parab_ldgh.hxx:29
std::array< mat_entry_t, size()> & data()
Return data array that allows to manipulate the SmallMat.
Definition: dense_la.hxx:190
Define type of node elements, especially with respect to nodal shape functions.
Definition: diffusion_ip.hxx:120
static constexpr unsigned int node_system_dimension()
Dimension of of the solution evaluated with respect to a hypernode.
Definition: diffusion_ip.hxx:191
SmallMat< 2 *hyEdge_dimT, n_shape_bdr_, lSol_float_t > primal_at_boundary(const SmallVec< n_loc_dofs_, lSol_float_t > &coeffs, hyEdgeT &hyper_edge) const
Evaluate primal variable at boundary.
Exception to be thrown if LAPACK's solve fails.
Definition: lapack.hxx:25
static constexpr unsigned int system_dim
Dimension of of the solution evaluated with respect to a hypernode.
Definition: diffusion_ip.hxx:215
static constexpr std::array< unsigned int, 0U > dirichlet_nodes
Array containing hypernode types corresponding to Dirichlet boundary.
Definition: advection_parab_ldgh.hxx:25
static constexpr unsigned int system_dimension()
Dimension of of the solution evaluated with respect to a hyperedge.
Definition: diffusion_ip.hxx:187
static constexpr unsigned int pow(unsigned int base)
Return n to the power dim.
Definition: hypercube.hxx:25
static constexpr bool is_dirichlet(const unsigned int node_type)
Find out whether a node is of Dirichlet type.
Definition: diffusion_ip.hxx:226
the intent is to exercise the right to control the distribution of derivative or collective works based on the Library In mere aggregation of another work not based on the Library with the you must alter all the notices that refer to this so that they refer to the ordinary GNU General Public instead of to this it is irreversible for that so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy This option is useful when you wish to copy part of the code of the Library into a program that is not a library You may copy and distribute the which must be distributed under the terms of Sections and above on a medium customarily used for software interchange If distribution of object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source even though third parties are not compelled to copy the source along with the object code A program that contains no derivative of any portion of the but is designed to work with the Library by being compiled or linked with is called a work that uses the Library Such a in is not a derivative work of the and therefore falls outside the scope of this License linking a work that uses the Library with the Library creates an executable that is a derivative of the rather than a work that uses the library The executable is therefore covered by this License Section states terms for distribution of such executables When a work that uses the Library uses material from a header file that is part of the the object code for the work may be a derivative work of the Library even though the source code is not Whether this is true is especially significant if the work can be linked without the or if the work is itself a library The threshold for this to be true is not precisely defined by law If such an object file uses only numerical parameters
Definition: License.txt:259
#define hy_assert(Expr, Msg)
The assertion to be used within HyperHDG — deactivate using -DNDEBUG compile flag.
Definition: hy_assert.hxx:38
SmallMatOutT & residual_flux(const SmallMatInT &lambda_values_in, SmallMatOutT &lambda_values_out, hyEdgeT &hyper_edge, const lSol_float_t time=0.) const
Evaluate local contribution to residual .
Definition: diffusion_ip.hxx:497
static constexpr unsigned int node_system_dim
Dimension of of the solution evaluated with respect to a hypernode.
Definition: diffusion_ip.hxx:221
std::array< std::array< lSol_float_t, Hypercube< hyEdge_dimT >::pow(abscissas_sizeT)>, system_dim > bulk_values(const std::array< abscissa_float_t, abscissas_sizeT > &abscissas, const input_array_t &lambda_values, hyEdgeT &hyper_edge, const lSol_float_t time=0.) const
Evaluate local reconstruction at tensorial products of abscissas.
static error_t initial_error()
Define how initial error is generated.
Definition: diffusion_ip.hxx:138
DiffusionIP(const constructor_value_type &tau=1.)
Constructor for local solver.
Definition: diffusion_ip.hxx:414
static constexpr unsigned int hyEdge_dim()
Dimension of hyper edge type that this object solves on.
Definition: diffusion_ip.hxx:171
const lSol_float_t tau_
(Globally constant) penalty parameter for HDG scheme.
Definition: diffusion_ip.hxx:239
std::tuple< TPP::ShapeFunction< TPP::ShapeType::Tensorial< TPP::ShapeType::Legendre< poly_deg >, hyEdge_dimT - 1 > > > functions
Definition: diffusion_ip.hxx:124
This class implements a small/dense matrix.
Definition: dense_la.hxx:34
Helper class containing numbers and functions related to hypercubes.
Definition: hypercube.hxx:12