20 #ifndef __mast__fem_operator_matrix_h__ 21 #define __mast__fem_operator_matrix_h__ 36 template <
typename ScalarType>
56 void print(std::ostream& o);
66 uint_t n_discrete_dofs_per_var);
75 template <
typename VecType>
78 const VecType& shape_func);
80 template <
typename VecType>
85 const VecType& shape_func);
92 template <
typename VecType>
94 const VecType& shape_func);
106 template <
typename T1,
typename T2>
113 template <
typename T>
120 template <
typename T>
127 template <
typename T>
136 template <
typename T1,
typename T2>
143 template <
typename T>
176 template <
typename ScalarType>
186 template <
typename ScalarType>
193 template <
typename ScalarType>
202 index = j*_n_interpolated_vars+i;
208 o << std::setw(15) << 0.;
215 template <
typename ScalarType>
225 typename std::vector<ScalarType*>::iterator
229 for ( ; it!=end; it++)
239 template <
typename ScalarType>
245 uint_t n_discrete_dofs_per_var) {
256 template <
typename ScalarType>
257 template <
typename VecType>
263 const VecType& shape_func) {
271 "Invalid interpolation variable index");
274 "Invalid discrete variable index");
277 "Invalid basis function vector size.");
284 vec =
new ScalarType[shape_func.size()];
289 vec[i] = shape_func(i);
294 template <
typename ScalarType>
295 template <
typename VecType>
302 const VecType& shape_func) {
310 "Invalid interpolation variable index");
313 "Invalid discrete variable index");
316 "Invalid basis function vector size.");
323 vec =
new ScalarType[shape_func.size()];
328 vec[i] = v*shape_func(i);
334 template <
typename ScalarType>
335 template <
typename VecType>
340 const VecType& shape_func) {
349 for (
uint_t i=0; i<n_vars; i++)
353 vec[i] = shape_func(i);
360 template <
typename ScalarType>
361 template <
typename T>
369 "Incompatible vector size.");
372 "Incompatible vector size");
379 index = j*_n_interpolated_vars+i;
387 template <
typename ScalarType>
388 template <
typename T1,
typename T2>
396 "Incompatible vector size");
399 "Incompatible vector size");
401 res.setZero(res.size());
406 index = j*_n_interpolated_vars+i;
409 res(j*_n_dofs_per_var+k) +=
416 template <
typename ScalarType>
417 template <
typename T>
425 "Incompatible matrix row dimension");
428 "Incompatible matrix column dimension");
431 "Incompatible matrix row dimension");
438 index = j*_n_interpolated_vars+i;
440 for (
uint_t l=0; l<m.cols(); l++)
451 template <
typename ScalarType>
452 template <
typename T>
460 "Incompatible matrix row dimension");
463 "Incompatible matrix column dimension");
466 "Incompatible matrix row dimension");
468 r.setZero(r.rows(), r.cols());
473 index = j*_n_interpolated_vars+i;
475 for (
uint_t l=0; l<m.cols(); l++)
477 r(j*_n_dofs_per_var+k,l) +=
485 template <
typename ScalarType>
486 template <
typename T>
494 "Incompatible matrix row dimension");
497 "Incompatible matrix column dimension");
500 "Incompatible number of variables");
503 uint_t index_i, index_j = 0;
508 index_i = i*_n_interpolated_vars+k;
517 r (i*_n_dofs_per_var+i_n1,
526 template <
typename ScalarType>
527 template <
typename T1,
typename T2>
535 "Incompatible matrix rows");
538 "Incompatible matrix columns");
541 "Incompatible matrix columns");
543 r.setZero(r.rows(), r.cols());
548 index = j*_n_interpolated_vars+i;
550 for (
uint_t l=0; l<m.rows(); l++)
552 r(l,j*_n_dofs_per_var+k) +=
560 template <
typename ScalarType>
561 template <
typename T>
569 "Incompatible matrix rows");
572 "Incompatible matrix columns");
575 "Incompatible matrix columns");
582 index = j*_n_interpolated_vars+i;
584 for (
uint_t l=0; l<m.rows(); l++)
594 #endif // __mast__fem_operator_matrix_h__ void print(std::ostream &o)
void left_multiply_transpose(T &r, const T &m) const
[R] = [M] * [this]^T
void right_multiply(T &r, const T &m) const
[R] = [this] * [M]
void vector_mult_transpose(T1 &res, const T2 &v) const
res = v^T * [this]
void clear()
clears the data structures
uint_t _n_dofs_per_var
number of dofs for each variable
uint_t _n_interpolated_vars
number of rows of the operator
virtual ~FEMOperatorMatrix()
void right_multiply_transpose(T &r, const T &m) const
[R] = [this]^T * [M]
void left_multiply(T1 &r, const T2 &m) const
[R] = [M] * [this]
std::vector< ScalarType * > _var_shape_functions
stores the shape function values that defines the coupling of i_th interpolated var and j_th discrete...
void vector_mult(T &res, const T &v) const
res = [this] * v
#define Assert0(cond, msg)
void set_shape_function(uint_t interpolated_var, uint_t discrete_var, const VecType &shape_func)
sets the shape function values for the block corresponding to interpolated_var and discrete_var...
#define Assert2(cond, v1, v2, msg)
void reinit(uint_t n_interpolated_vars, uint_t n_discrete_vars, uint_t n_discrete_dofs_per_var)
this initializes the operator for number of rows and variables, assuming that all variables has the s...
uint_t _n_discrete_vars
number of discrete variables in the system