Flow123d  release_2.2.0-914-gf1a3a4f
intersectionquadrature.cc
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file intersection.cc
15  * @brief
16  */
17 
18 #include "mesh/intersection.hh"
19 #include "mesh/mesh.h"
20 
21 #include <boost/tokenizer.hpp>
22 #include "boost/lexical_cast.hpp"
23 #include <armadillo>
24 
25 // inicializovat objekt, cist zbytek tokenu z tok a naplnit map a shift pro master a slave
26 // viz dokumentace k Armadillu
28  const IntersectionLocal *isec)
29 : dim(isec->n_points() - 1),
30  master(ele_master), slave(ele_slave),
31  master_map(master->dim(), dim), slave_map(slave->dim(), dim),
32  master_shift(master->dim()), slave_shift(slave->dim())
33 {
34  ///otestuje se jestli dimenze masteru je mensi nez dimenze slave - chybova hlaska (vyjimka - throw)
35  ///pocet pointu=dim+1
36  if (master->dim() > slave->dim()) {
37  cout << "Exception: master->dim() > slave->dim()" << endl;
38  //throw((char*) "master->dim > slave->dim");
39  }
40 
42 
43  arma::vec master_tmp(master_shift), slave_tmp(slave_shift);
44  // cyklus pres body pruniku
45  for (unsigned int i = 1; i < (dim + 1); ++i) {
46  intersection_point_to_vectors(isec->get_point(i),master_tmp, slave_tmp);
47  master_tmp -= master_shift;
48  slave_tmp -= slave_shift;
49 
50  master_map.col(i-1) = master_tmp;
51  slave_map.col(i-1) = slave_tmp;
52  }
53 }
54 
55 
56 
58  {return master->dim();}
59 
60 
61 
63  {return slave->dim();}
64 
65 
66 
67 void Intersection::intersection_point_to_vectors(const IntersectionPoint *point, arma::vec &vec1, arma::vec &vec2)
68 {
69  const vector<double> &coord_el1 = point->el1_coord();
70  OLD_ASSERT_EQUAL(coord_el1.size() , vec1.n_elem);
71  vec1=arma::vec(coord_el1);
72 
73  const vector<double> &coord_el2 = point->el2_coord();
74  OLD_ASSERT_EQUAL(coord_el2.size() , vec2.n_elem);
75  vec2=arma::vec(coord_el2);
76 }
77 
78 
79 arma::vec Intersection::map_to_master(const arma::vec &point) const
80 {
81  //dim = dimenze intersec elementu
82  OLD_ASSERT(( point.n_elem == dim ),"Map to slave: point.n_elem(%d) != dim(%d) \n", point.n_elem, dim);
83  int result_dim = master->dim();
84  arma::vec result(result_dim+1);
85  result(0)=1.0;
86  result.subvec(1, result_dim) = (master_map * point + master_shift);
87  return result;
88 }
89 
90 arma::vec Intersection::map_to_slave(const arma::vec &point) const
91 {
92  OLD_ASSERT(( point.n_elem == dim ),"Map to slave: point.n_elem(%d) != dim(%d) \n", point.n_elem, dim);
93  int result_dim = slave->dim();
94  arma::vec result(result_dim+1);
95  result(0)=1.0;
96  result.subvec(1, result_dim) = (slave_map * point + slave_shift);
97  return result;
98 }
99 
101 
102  static const double factorial[4] = {1.0, 1.0, 2.0, 6.0};
103  return (master->measure() * det(master_map) / factorial[dim]);
104 }
105 
106 
arma::vec map_to_master(const arma::vec &point) const
Intersection(const ElementFullIter ele_master, const ElementFullIter ele_slave, const IntersectionLocal *isec)
arma::vec map_to_slave(const arma::vec &point) const
ElementFullIter slave
Class represents intersection of two elements.
Class represents an intersection point of simplex<N> and simplex<M>. It contains barycentric coordina...
unsigned int dim
dimenze pruniku
#define OLD_ASSERT(...)
Definition: global_defs.h:131
unsigned int master_dim()
dimension of the master element
arma::Mat< double > master_map
matrix part of linear transform from reference element of intersection to reference element of master...
unsigned int slave_dim()
dimension of the slave element
arma::vec master_shift
shift vector of the linear transform
void intersection_point_to_vectors(const IntersectionPoint *point, arma::vec &vec1, arma::vec &vec2)
arma::Mat< double > slave_map
double intersection_true_size() const
#define OLD_ASSERT_EQUAL(a, b)
Definition: global_defs.h:133
ElementFullIter master