NiHu  2.0
kltria_surface.mex.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 
21 #include "util/mex_matrix.hpp"
22 #include "library/lib_element.hpp"
23 
24 typedef NiHu::field_dimension::_2d field_dim_t;
25 static const unsigned int field_dim = field_dim_t::value;
27 static const unsigned int space_dim = space_t::dimension;
28 
30 
31 typedef Eigen::Matrix<double, field_dim, field_dim> field_var_t;
32 typedef Eigen::Matrix<double, space_dim, space_dim> space_var_t;
33 
35 
36 // [D, B] = mex(nodes, elements, field_var, space_var);
37 void mexFunction(int nlhs, mxArray *lhs[], int nrhs, mxArray const *rhs[])
38 {
39  dMatrix nodes(rhs[0]), elem(rhs[1]);
40  auto mesh = NiHu::create_mesh(nodes, elem, NiHu::tria_1_tag());
41  auto const &w = NiHu::isoparametric_view(mesh, field_dim_t());
42 
43 
44  field_var_t field_var = dMatrix(rhs[2]);
45  space_var_t space_var = dMatrix(rhs[3]);
46  kernel_t kernel(field_var, space_var);
47  auto C = NiHu::create_integral_operator(kernel);
49 
50  size_t N = w.get_num_dofs();
51  mexPrintf("Number of DOFs: %d\n", N);
52 
53  dMatrix D(N, N, lhs[0]), B(N, N, lhs[1]);
54  D.setZero();
55  B.setZero();
56  mexPrintf("Matrices initialised\n");
57  D << (w * C[w]);
58  mexPrintf("D matrix ready\n");
59  B << (w * I[w]);
60  mexPrintf("B matrix ready\n");
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::function_space_view
A mesh extended with a Field generating option.
Definition: function_space.hpp:116
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
C
Definition: bbfmm_covariance.cpp:47
covariance_kernel.hpp
Implementation of kernels representing covariance functions of stochastic processes.
NiHu::identity_integral_operator
The identity integral operator .
Definition: integral_operator.hpp:310
NiHu::space
class representing a coordinate space with a scalar and a dimension
Definition: space.hpp:36
NiHu::exponential_covariance_kernel
Definition: covariance_kernel.hpp:42
weighted_residual.hpp
declaration of class NiHu::weighted_residual
mex_matrix.hpp
A Matlab mex matrix interface.
NiHu::mex::real_matrix
Definition: mex_matrix_separate.hpp:133
NiHu::isoparametric_view
const function_space_view< Mesh, field_option::isoparametric, Dimension > & isoparametric_view(mesh_base< Mesh > const &msh, Dimension dim=Dimension())
factory function to transform a mesh into an isoparametric function space
Definition: function_space.hpp:291
lib_element.hpp
NiHu::gaussian_covariance_kernel
Definition: covariance_kernel.hpp:148