GCC Code Coverage Report


Directory: Bembel/src/
File: Bembel/src/Potential/Potential.hpp
Date: 2024-03-19 14:38:05
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 4 4 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2022 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11 #ifndef BEMBEL_SRC_POTENTIAL_POTENTIAL_HPP_
12 #define BEMBEL_SRC_POTENTIAL_POTENTIAL_HPP_
13
14 #include <Eigen/Dense>
15
16 #include "../LinearOperator/DifferentialFormEnum.hpp"
17 #include "../LinearOperator/LinearOperatorTraits.hpp"
18 #include "../util/Macros.hpp"
19
20 namespace Bembel {
21 /**
22 * \ingroup Potential
23 * \brief struct containing specifications on the functional
24 * has to be specialized or derived for any particular operator
25 * under consideration
26 */
27 template <typename Derived>
28 struct PotentialTraits {
29 enum { YOU_DID_NOT_SPECIFY_POTENTIAL_TRAITS = 1 };
30 };
31
32 /**
33 * \brief Base case for specifying the return type of the potential.
34 */
35 template <typename S, typename T>
36 struct PotentialReturnScalar {
37 enum { RETURN_TYPE_ONLY_SPECIFIED_FOR_DOUBLE_OR_COMPLEX_DOUBLE = 1 };
38 };
39 /**
40 * \brief Potential return type if the scalar type in both the
41 * LinearOperatorTraits and the PotentialTraits is a double.
42 */
43 template <>
44 struct PotentialReturnScalar<double, double> {
45 typedef double Scalar;
46 };
47 /**
48 * \brief Potential return type if the scalar type in the LinearOperatorTraits
49 * is complex and in the PotentialTraits is a double.
50 */
51 template <>
52 struct PotentialReturnScalar<std::complex<double>, double> {
53 typedef std::complex<double> Scalar;
54 };
55 /**
56 * \brief Potential return type if the scalar type in the LinearOperatorTraits
57 * is double and the PotentialTraits is a complex.
58 */
59 template <>
60 struct PotentialReturnScalar<double, std::complex<double>> {
61 typedef std::complex<double> Scalar;
62 };
63 /**
64 * \brief Potential return type if the scalar type in both LinearOperatorTraits
65 * and the PotentialTraits is a complex.
66 */
67 template <>
68 struct PotentialReturnScalar<std::complex<double>, std::complex<double>> {
69 typedef std::complex<double> Scalar;
70 };
71
72 /**
73 * \ingroup Potential
74 * \brief functional base class. this serves as a common interface for
75 * existing functionals.
76 *
77 * Take a look at the [Design Considerations](\ref CRTPPotential) for
78 * details.
79 **/
80 template <typename Derived, typename LinOp>
81 struct PotentialBase {
82 // Constructors
83 8 PotentialBase() {}
84
85 // the user has to provide the implementation of this function, which
86 // tells
87 // is able to evaluate the integrand of the Galerkin formulation in a
88 // pair
89 // of quadrature points represented as a
90 // Surface point [xi; w; Chi(xi); dsChi(xi); dtChi(xi)]
91 template <typename T>
92 Eigen::Matrix<typename PotentialReturnScalar<
93 typename LinearOperatorTraits<LinOp>::Scalar,
94 typename PotentialTraits<Derived>::Scalar>::Scalar,
95 1, PotentialTraits<Derived>::OutputSpaceDimension>
96 evaluateIntegrand(
97 const AnsatzSpace<LinOp> &ansatz_space,
98 const Eigen::Matrix<
99 typename LinearOperatorTraits<LinOp>::Scalar, Eigen::Dynamic,
100 getFunctionSpaceVectorDimension<LinearOperatorTraits<LinOp>::Form>()>
101 &coeff,
102 const Eigen::VectorXd &point, const SurfacePoint &p) const {
103 return static_cast<const Derived *>(this)->evaluatePotential_impl(
104 ansatz_space, coeff, point, p);
105 }
106 // pointer to the derived object
107 Derived &derived() { return *static_cast<Derived *>(this); }
108 // const pointer to the derived object
109 const Derived &derived() const { return *static_cast<const Derived *>(this); }
110 };
111 } // namespace Bembel
112 #endif // BEMBEL_SRC_POTENTIAL_POTENTIAL_HPP_
113