Flow123d  3.9.0-31af398cc
intersection_quadrature.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 /*
19 #include "intersection_quadrature.hh"
20 
21 #include "mesh/mesh.h"
22 
23 #include <boost/tokenizer.hpp>
24 #include "boost/lexical_cast.hpp"
25 #include <armadillo>
26 
27 // inicializovat objekt, cist zbytek tokenu z tok a naplnit map a shift pro master a slave
28 // viz dokumentace k Armadillu
29 IntersectionQuadratureP0::IntersectionQuadratureP0( Mesh &mesh)
30 
31 IntersectionQuadratureP0::reinit(const IntersectionLocalBase *isec)
32 : dim(isec->n_points() - 1),
33  master(ele_master), slave(ele_slave),
34  master_map(master->dim(), dim), slave_map(slave->dim(), dim),
35  master_shift(master->dim()), slave_shift(slave->dim())
36 {
37  master = mesh_.elementisec->component_ele_idx()
38  ///otestuje se jestli dimenze masteru je mensi nez dimenze slave - chybova hlaska (vyjimka - throw)
39  ///pocet pointu=dim+1
40  if (master->dim() > slave->dim()) {
41  cout << "Exception: master->dim() > slave->dim()" << endl;
42  //throw((char*) "master->dim > slave->dim");
43  }
44 
45  intersection_point_to_vectors(isec->get_point(0),master_shift, slave_shift);
46 
47  arma::vec master_tmp(master_shift), slave_tmp(slave_shift);
48  // cyklus pres body pruniku
49  for (unsigned int i = 1; i < (dim + 1); ++i) {
50  intersection_point_to_vectors(isec->get_point(i),master_tmp, slave_tmp);
51  master_tmp -= master_shift;
52  slave_tmp -= slave_shift;
53 
54  master_map.col(i-1) = master_tmp;
55  slave_map.col(i-1) = slave_tmp;
56  }
57 }
58 
59 
60 
61 unsigned int IntersectionQuadrature::master_dim()
62  {return master->dim();}
63 
64 
65 
66 unsigned int IntersectionQuadrature::slave_dim()
67  {return slave->dim();}
68 
69 
70 
71 void IntersectionQuadrature::intersection_point_to_vectors(const IntersectionPoint *point, arma::vec &vec1, arma::vec &vec2)
72 {
73  const vector<double> &coord_el1 = point->el1_coord();
74  ASSERT_EQ(coord_el1.size() , vec1.n_elem);
75  vec1=arma::vec(coord_el1);
76 
77  const vector<double> &coord_el2 = point->el2_coord();
78  ASSERT_EQ(coord_el2.size() , vec2.n_elem);
79  vec2=arma::vec(coord_el2);
80 }
81 
82 
83 arma::vec IntersectionQuadrature::map_to_master(const arma::vec &point) const
84 {
85  //dim = dimenze intersec elementu
86  ASSERT_EQ( point.n_elem, dim ).error("Map to slave: point.n_elem != dim \n");
87  int result_dim = master->dim();
88  arma::vec result(result_dim+1);
89  result(0)=1.0;
90  result.subvec(1, result_dim) = (master_map * point + master_shift);
91  return result;
92 }
93 
94 arma::vec IntersectionQuadrature::map_to_slave(const arma::vec &point) const
95 {
96  ASSERT_EQ( point.n_elem, dim ).error("Map to slave: point.n_elem != dim \n");
97  int result_dim = slave->dim();
98  arma::vec result(result_dim+1);
99  result(0)=1.0;
100  result.subvec(1, result_dim) = (slave_map * point + slave_shift);
101  return result;
102 }
103 
104 double IntersectionQuadrature::intersection_true_size() const {
105 
106  static const double factorial[4] = {1.0, 1.0, 2.0, 6.0};
107  return (master->measure() * det(master_map) / factorial[dim]);
108 }
109 */
110