NiHu  2.0
laplace_single_integral.cpp
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #include <boost/math/constants/constants.hpp>
20 
23 #include "library/lib_element.hpp"
24 
25 typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> dMatrix;
26 typedef Eigen::Matrix<unsigned, Eigen::Dynamic, Eigen::Dynamic> uMatrix;
27 
28 int main()
29 {
30  using namespace boost::math::double_constants;
31 
33  dMatrix nodes(4,3);
34  nodes << 0., 0., 0., /*|*/ 1., 0., 0., /*|*/ 1., 1., 0., /*|*/ 0., 1., 0.;
35  uMatrix elements(1, 1+4);
36  elements << NiHu::quad_1_elem::id, 0, 1, 2, 3;
37  auto msh = NiHu::create_mesh(nodes, elements, NiHu::quad_1_tag());
39 
41  auto const &trial = NiHu::constant_view(msh);
42  auto const &test = NiHu::dirac(trial);
44 
46  dMatrix A(1, 1);
47  A.setZero();
48 
50  A << test * K[trial];
52 
54  std::cout << "WR matrix: " << A << std::endl;
55 
56  double anal = std::log(1. + root_two) / pi;
57  std::cout << "log10 error = " << std::log10(std::abs(A.sum() / anal - 1.)) << std::endl;
59 
60  return 0;
61 }
62 
NiHu::create_integral_operator
integral_operator< Kernel > create_integral_operator(Kernel &&kernel)
factory function of an integral operator
Definition: integral_operator.hpp:421
NiHu::type2tag
Metafunction assigning a tag to a type.
Definition: type2tag.hpp:17
NiHu::bessel::K
make_complex< T >::type K(T const &z)
K_nu(z) modified Bessel function.
NiHu::create_mesh
mesh< tmp::vector< typename tag2type< Args >::type... > > create_mesh(nodes_t const &nodes, elements_t const &elements, Args...)
factory function to create a mesh from nodes and elements matrices
Definition: mesh.hpp:298
laplace_kernel.hpp
implementation of kernels of the Laplace equation
NiHu::constant_view
const function_space_view< Mesh, field_option::constant, Dimension > & constant_view(mesh_base< Mesh > const &msh, Dimension dim=Dimension())
factory function to transform a mesh into a constant function space
Definition: function_space.hpp:304
weighted_residual.hpp
declaration of class NiHu::weighted_residual
NiHu::mex::real_matrix
Definition: mex_matrix_separate.hpp:133
NiHu::dirac
const dirac_space< FuncSpace > & dirac(function_space_base< FuncSpace > const &space)
factory function to convert a function space into a dirac space
Definition: function_space.hpp:400
NiHu::normal_derivative_kernel
Normal derivative of a distance dependent kernel.
Definition: normal_derivative_kernel.hpp:26
lib_element.hpp