HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
integralweight.hpp
Go to the documentation of this file.
1 // Structure to provide weight functions for integrals: provides value, and polynomial degree (cell by cell)
2 
3 /*
4  *
5  * This library was developed around HHO methods, although some parts of it have a more
6  * general purpose. If you use this code or part of it in a scientific publication,
7  * please mention the following book as a reference for the underlying principles
8  * of HHO schemes:
9  *
10  * The Hybrid High-Order Method for Polytopal Meshes: Design, Analysis, and Applications.
11  * D. A. Di Pietro and J. Droniou. Modeling, Simulation and Applications, vol. 19.
12  * Springer International Publishing, 2020, xxxi + 525p. doi: 10.1007/978-3-030-37203-3.
13  * url: https://hal.archives-ouvertes.fr/hal-02151813.
14  *
15  */
16 
17 #ifndef INTEGRALWEIGHT_HPP
18 #define INTEGRALWEIGHT_HPP
19 
20 #include <mesh.hpp>
21 
22 namespace HArDCore3D
23 {
24 
30  typedef std::function<double (const Cell &, const Eigen::Vector3d &)> IntegralWeightValueType;
31  typedef std::function<size_t (const Cell &)> IntegralWeightDegreeType;
32 
34 
36  {
39  const IntegralWeightValueType _value,
40  const IntegralWeightDegreeType _deg
41  )
42  : value(_value),
43  deg(_deg)
44  {
45  // Do nothing
46  }
47 
49  IntegralWeight(double val)
50  : IntegralWeight( [val](const Cell &T, const Eigen::Vector3d &x)->double {return val;}, [](const Cell &T)->size_t {return 0;} )
51  {
52  // Do nothing
53  }
54 
56  IntegralWeight(const std::function<double(const VectorRd &)> & val, const size_t & deg)
57  : IntegralWeight( [val](const Cell &T, const Eigen::VectorXd &x)->double {return val(x);}, [deg](const Cell &T)->size_t {return deg;} )
58  {
59  // Do nothing
60  }
61 
63  IntegralWeight(const std::function<double(const VectorRd &)> & val)
64  : IntegralWeight(val, 0)
65  {
66  // Do nothing
67  }
68 
71  };
72 
74  inline IntegralWeight operator* (double const & r, IntegralWeight const & weight)
75  {
76  IntegralWeightValueType r_times_value
77  = [weight, r](const Cell & T, const Eigen::Vector3d & x)->double { return r * weight.value(T,x);};
78  IntegralWeightDegreeType deg = weight.deg;
79 
80  return IntegralWeight(r_times_value, deg);
81  }
82 
84  inline IntegralWeight operator+ (IntegralWeight const & weight1, IntegralWeight const & weight2)
85  {
86  IntegralWeightValueType plus_value
87  = [weight1, weight2](const Cell & T, const Eigen::Vector3d & x)->double
88  { return weight1.value(T,x) + weight2.value(T,x);};
90  = [weight1, weight2](const Cell & T)->size_t
91  { return std::max(weight1.deg(T), weight2.deg(T)); };
92 
93  return IntegralWeight(plus_value, max_deg);
94  }
95 
97 
98 } // end of namespace HArDCore3D
99 
100 #endif
std::function< double(const Cell &, const Eigen::Vector3d &)> IntegralWeightValueType
Definition: integralweight.hpp:30
IntegralWeight(const std::function< double(const VectorRd &)> &val, const size_t &deg)
Constructor when the dependency on the cell T is not explicit in the value (and degree is constant)
Definition: integralweight.hpp:56
IntegralWeight(const IntegralWeightValueType _value, const IntegralWeightDegreeType _deg)
Generic constructor.
Definition: integralweight.hpp:38
std::function< size_t(const Cell &)> IntegralWeightDegreeType
Definition: integralweight.hpp:31
IntegralWeight(const std::function< double(const VectorRd &)> &val)
Constructor when the dependency on the cell T is not explicit in the value, and degree is not provide...
Definition: integralweight.hpp:63
IntegralWeight operator*(double const &r, IntegralWeight const &weight)
Operator to multiply an IntegralWeight by a number.
Definition: integralweight.hpp:74
IntegralWeightValueType value
Definition: integralweight.hpp:69
IntegralWeight(double val)
Constructor for constant weights.
Definition: integralweight.hpp:49
IntegralWeight operator+(IntegralWeight const &weight1, IntegralWeight const &weight2)
Operator to add an IntegralWeight to another one.
Definition: integralweight.hpp:84
IntegralWeightDegreeType deg
Definition: integralweight.hpp:70
Definition: ddr-magnetostatics.hpp:40
MeshND::VectorRd< 2 > VectorRd
Definition: Mesh2D.hpp:14
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
Structure for weights (scalar, at the moment) in integral.
Definition: integralweight.hpp:36