NiHu  2.0
bbfmm_covariance.cpp
1 #include "fmm/black_box_fmm.hpp"
2 #include "fmm/cluster_tree.hpp"
3 #include "fmm/divide.hpp"
5 #include "fmm/lists.hpp"
6 #include "fmm/fmm_integrated.hpp"
7 #include "fmm/fmm_indexed.hpp"
8 #include "fmm/fmm_precompute.hpp"
10 #include "fmm/fmm_matrix.hpp"
13 #include "library/lib_element.hpp"
14 #include "core/function_space.hpp"
15 
16 typedef NiHu::exponential_covariance_kernel<NiHu::space_2d<>, NiHu::field_dimension::_1d> kernel_t;
26 
28 typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> dmatrix_t;
36 
37 typedef NiHu::fmm::fmm_matrix<
38  p2p_pre_t,
39  p2m_pre_t,
40  p2l_pre_t,
41  m2p_pre_t,
42  l2p_pre_t,
43  m2m_pre_t,
44  l2l_pre_t,
46 
47 class C
48 {
49 public:
50  C(int argc, char const *argv[])
51  : m_kernel(kernel_t::field_variance_t(1.0), .1)
52  , m_bbfmm(m_kernel)
53  , m_mesh(NiHu::read_off_mesh(argv[1], elem_tag_t()))
54  , m_space(NiHu::constant_view(m_mesh))
55  , m_tree(NiHu::fmm::create_elem_center_iterator(m_mesh.begin<elem_t>()),
56  NiHu::fmm::create_elem_center_iterator(m_mesh.end<elem_t>()),
58  , m_lists(m_tree)
59  {
60  for (size_t i = 0; i < m_tree.get_n_clusters(); ++i)
61  m_tree[i].set_chebyshev_order(5);
62 
63  auto int_fctr = NiHu::fmm::create_integrated_functor(
64  field_tag_t(), field_tag_t(), 5, true);
65 
66  auto idx_fctr = NiHu::fmm::create_indexed_functor(
67  m_space.field_begin<field_t>(),
68  m_space.field_end<field_t>(),
69  m_space.field_begin<field_t>(),
70  m_space.field_end<field_t>(),
71  m_tree);
72 
73  auto pre_fctr = NiHu::fmm::create_precompute_functor(m_tree, m_lists);
74 
75  m_mat = new mat_t(NiHu::fmm::create_fmm_matrix(
76  pre_fctr(idx_fctr(int_fctr(m_bbfmm.create_p2p()))),
77  pre_fctr(idx_fctr(int_fctr(m_bbfmm.create_p2m()))),
78  pre_fctr(idx_fctr(int_fctr(m_bbfmm.create_p2l()))),
79  pre_fctr(idx_fctr(int_fctr(m_bbfmm.create_m2p()))),
80  pre_fctr(idx_fctr(int_fctr(m_bbfmm.create_l2p()))),
81  pre_fctr(idx_fctr(m_bbfmm.create_m2m())),
82  pre_fctr(idx_fctr(m_bbfmm.create_l2l())),
83  pre_fctr(idx_fctr(m_bbfmm.create_m2l())),
84  m_tree,
85  m_lists));
86 
87  Eigen::Matrix<double, Eigen::Dynamic, 1> xct(m_mat->cols(), 1);
88  xct.setConstant(1.0);
89  auto res = (*m_mat) * xct;
90 
91  delete m_mat;
92 
93  std::cout << res << std::endl;
94  }
95 
96 private:
97 
98  kernel_t const m_kernel;
99  fmm_t const m_bbfmm;
100  mesh_t const m_mesh;
101  space_t const &m_space;
102  cluster_tree_t m_tree;
103  NiHu::fmm::interaction_lists const m_lists;
104  mat_t *m_mat;
105 };
106 
107 int main(int argc, char const *argv[])
108 {
109  C c(argc, argv);
110  return 0;
111 }
112 
NiHu::type2tag
Metafunction assigning a tag to a type.
Definition: type2tag.hpp:17
NiHu::volume_element
class describing a volume element that has no normal vector
Definition: element.hpp:455
NiHu::fmm::black_box_fmm::create_p2m
auto create_p2m() const
return the p2m operator instance
Definition: black_box_fmm.hpp:429
NiHu::fmm::black_box_fmm
Black box FMM for a smooth kernel.
Definition: black_box_fmm.hpp:61
NiHu::function_space_view
A mesh extended with a Field generating option.
Definition: function_space.hpp:116
NiHu::fmm::black_box_fmm::create_l2p
auto create_l2p() const
return the l2p operator instance
Definition: black_box_fmm.hpp:453
NiHu::fmm::cluster_tree::get_n_clusters
size_t get_n_clusters() const
return number of clusters
Definition: cluster_tree.hpp:282
C
Definition: bbfmm_covariance.cpp:47
NiHu::fmm::p2p_precompute
Precomputed P2P operator.
Definition: p2p_precompute.hpp:265
NiHu::fmm::chebyshev_cluster
Cluster class of the Black Box FMM.
Definition: chebyshev_cluster.hpp:28
covariance_kernel.hpp
Implementation of kernels representing covariance functions of stochastic processes.
fmm_precompute.hpp
Operator pre-computation interface.
NiHu::exponential_covariance_kernel
Definition: covariance_kernel.hpp:42
NiHu::function_space_view::field_end
traits_t::template iterator< FieldType >::type field_end() const
last field of given element type
Definition: function_space.hpp:231
NiHu::fmm::black_box_fmm::create_m2p
auto create_m2p() const
return the m2p operator instance
Definition: black_box_fmm.hpp:445
NiHu::fmm::fmm_matrix
Matrix representation of the FMM method.
Definition: fmm_matrix.hpp:69
NiHu::fmm::cluster_tree< cluster_t >
NiHu::fmm::x2x_precompute
Precomputation for M2M, M2L, and L2L operators.
Definition: x2x_precompute.hpp:39
NiHu::fmm::p2x_precompute
Definition: leaf_precompute.hpp:32
NiHu::fmm::divide_num_nodes
Class representing a cluster division based on number of nodes.
Definition: divide.hpp:74
NiHu::fmm::black_box_fmm::create_m2l
m2l create_m2l() const
return the m2l operator instance
Definition: black_box_fmm.hpp:477
cluster_tree.hpp
Implementation of class NiHu::fmm::cluster_tree.
lists.hpp
Definition of class NiHu::fmm::interaction_lists.
read_off_mesh.hpp
export NiHu mesh from OFF format
fmm_integrated.hpp
Integrated operators (P2P, P2X, X2P)
divide.hpp
Cluster division strategies.
fmm_operator_collection.hpp
Implementation of NiHu::fmm::fmm_operator_collection.
NiHu::fmm::black_box_fmm::create_p2p
auto create_p2p() const
return the p2p operator instance
Definition: black_box_fmm.hpp:421
black_box_fmm.hpp
Implementation of the Black Box FMM using Chebyshev interpolation.
NiHu::function_space_view::field_begin
traits_t::template iterator< FieldType >::type field_begin() const
first field of given element type
Definition: function_space.hpp:220
NiHu::field_view
Field automatically generated from an element using a field generation option.
Definition: field.hpp:222
lib_element.hpp
elem_center_iterator.hpp
Classes for iterating through elements and fields.
fmm_matrix.hpp
Class NiHu::fmm::fmm_matrix.
function_space.hpp
declaration of class function_space
NiHu::fmm::fmm_matrix::cols
size_t cols() const
return number of columns of the matrix
Definition: fmm_matrix.hpp:191
NiHu::mesh
container class for a mesh
Definition: mesh.hpp:110
NiHu::fmm::interaction_lists
class storing the different interaction lists of a tree
Definition: lists.hpp:22
fmm_indexed.hpp
Interface for indexing FMM operators.
NiHu::fmm::black_box_fmm::create_l2l
l2l create_l2l() const
return the l2l operator instance
Definition: black_box_fmm.hpp:469
NiHu::fmm::black_box_fmm::create_p2l
p2l create_p2l() const
return the p2l operator instance
Definition: black_box_fmm.hpp:437
NiHu::fmm::x2p_precompute
Definition: leaf_precompute.hpp:162
NiHu::fmm::black_box_fmm::create_m2m
m2m create_m2m() const
return the m2m operator instance
Definition: black_box_fmm.hpp:461