Flow123d  release_3.0.0-1191-g7740876
intersection_local.cc
Go to the documentation of this file.
1 
2 #include "intersection_local.hh"
3 #include "intersection_aux.hh"
5 #include "mesh/side_impl.hh"
6 #include "mesh/mesh.h"
7 #include "mesh/accessors.hh"
8 
9 #include <iostream>
10 
11 using namespace std;
12 
14 {}
15 
16 
18 {}
19 
20 IntersectionLocalBase::IntersectionLocalBase(unsigned int component_element_idx,
21  unsigned int bulk_element_idx)
22 : component_element_idx_(component_element_idx), bulk_element_idx_(bulk_element_idx)
23 {}
24 
25 
26 template<unsigned int dimA, unsigned int dimB>
28 {}
29 
30 template<unsigned int dimA, unsigned int dimB>
31 IntersectionLocal<dimA,dimB>::IntersectionLocal(unsigned int component_element_idx, unsigned int bulk_element_idx)
32 : IntersectionLocalBase(component_element_idx, bulk_element_idx)
33 {}
34 
35 template<unsigned int dimA, unsigned int dimB>
38 {
39  i_points_.resize(iaux.size());
40  for(unsigned int i = 0; i < iaux.size(); i++)
41  {
43  }
44 }
45 
46 
47 template<unsigned int dimA, unsigned int dimB>
49 {}
50 
51 
52 template<unsigned int dimA, unsigned int dimB>
54 {
55  ASSERT_LT_DBG(i_points_.size(), 3 ); // avoid 2d-3d case and degenerated 2d-2d
56  double length = 0;
57 
58  if(i_points_.size() > 1) // zero measure for point intersections
59  for(unsigned int i=0; i < i_points_.size()-1; i++)
60  {
61  length += abs(i_points_[i].comp_coords()[0] - i_points_[i+1].comp_coords()[0]);
62  }
63  return length;
64 }
65 
66 
67 
68 // 2D-3D
69 template<>
71 {
72  double subtotal = 0.0;
73 
74  if(i_points_.size() > 2)
75  for(unsigned int j = 2; j < i_points_.size();j++){
76  //xprintf(Msg, "volani %d %d\n",j, i_points_.size());
77  subtotal += fabs(i_points_[0].comp_coords()(0)*(i_points_[j-1].comp_coords()(1) - i_points_[j].comp_coords()(1)) +
78  i_points_[j-1].comp_coords()(0)*(i_points_[j].comp_coords()(1) - i_points_[0].comp_coords()(1)) +
79  i_points_[j].comp_coords()(0)*(i_points_[0].comp_coords()(1) - i_points_[j-1].comp_coords()(1)));
80  }
81  return fabs(subtotal/2);
82 }
83 
84 
85 
86 template<unsigned int dimA, unsigned int dimB>
88 {}
89 
90 template<unsigned int dimA, unsigned int dimB>
92 {}
93 
94 template<unsigned int dimA, unsigned int dimB>
96 : comp_coords_(p.local_bcoords_A().subvec(1,dimA)), bulk_coords_(p.local_bcoords_B().subvec(1,dimB))
97 {}
98 
99 template<unsigned int dimA, unsigned int dimB>
101  const arma::vec::fixed< dimB >& bulk_coords)
102 : comp_coords_(comp_coords), bulk_coords_(bulk_coords)
103 {}
104 
105 
106 
107 template<unsigned int dimA, unsigned int dimB>
109 {
110  ASSERT_DBG(dimA == comp_ele.dim());
111 
112  arma::vec3 c;
113  c.zeros();
114  double complement = 1.0;
115  for(unsigned int i=0; i<dimA; i++)
116  {
117  c += comp_coords_[i]*comp_ele.node(i+1)->point();
118  complement -= comp_coords_[i];
119  }
120  c += complement * comp_ele.node(0)->point();
121 
122  return c;
123 }
124 
125 
126 
127 
128 template<unsigned int dimA, unsigned int dimB> ostream& operator<<(ostream& os, const IntersectionLocal<dimA,dimB>& il)
129 {
130  os << "IntersectionLocal<" << dimA << "," << dimB << ">: c " << il.component_element_idx_ << ", b " <<
131  il.bulk_element_idx_ << ", size " << il.i_points_.size() << endl;
132  for (unsigned int i = 0; i < il.i_points_.size(); i++) {
133  os << i << ": " << il[i] << endl;
134  }
135  return os;
136 }
137 
138 template<unsigned int dimA, unsigned int dimB> ostream& operator<<(ostream& os, const IntersectionPoint<dimA,dimB>& ip)
139 {
140  os << "[";
141  for(unsigned j= 0; j < dimA-1; j++)
142  os << ip.comp_coords_[j] << " ";
143  os << ip.comp_coords_[dimA-1] << "]\t[";
144 
145  for(unsigned j= 0; j < dimB-1; j++)
146  os << ip.bulk_coords_[j] << " ";
147  os << ip.bulk_coords_[dimB-1] << "]";
148  os << endl;
149 
150  return os;
151 }
152 
153 
154 template class IntersectionPoint<1,2>;
155 template class IntersectionPoint<2,2>;
156 template class IntersectionPoint<1,3>;
157 template class IntersectionPoint<2,3>;
158 
159 template class IntersectionLocal<1,2>;
160 template class IntersectionLocal<2,2>;
161 template class IntersectionLocal<1,3>;
162 template class IntersectionLocal<2,3>;
163 
164 template ostream& operator<< <1,2>(ostream &os, const IntersectionPoint<1,2>& s);
165 template ostream& operator<< <2,2>(ostream &os, const IntersectionPoint<2,2>& s);
166 template ostream& operator<< <1,3>(ostream &os, const IntersectionPoint<1,3>& s);
167 template ostream& operator<< <2,3>(ostream &os, const IntersectionPoint<2,3>& s);
168 
169 template ostream& operator<< <1,2>(ostream &os, const IntersectionLocal<1,2>& s);
170 template ostream& operator<< <2,2>(ostream &os, const IntersectionLocal<2,2>& s);
171 template ostream& operator<< <1,3>(ostream &os, const IntersectionLocal<1,3>& s);
172 template ostream& operator<< <2,3>(ostream &os, const IntersectionLocal<2,3>& s);
template ostream & operator<< < 2, 3 >(ostream &os, const IntersectionPoint< 2, 3 > &s)
Classes with algorithms for computation of intersections of meshes.
template ostream & operator<< < 1, 2 >(ostream &os, const IntersectionPoint< 1, 2 > &s)
Common base for intersection object.
~IntersectionPoint()
Destructor.
double compute_measure() const override
Computes the relative measure of intersection object.
arma::vec::fixed< dimB > bulk_coords_
Local coordinates of an IP on simplex<dimB>.
IntersectionPoint()
Default constructor.
Class represents an intersection point of simplex<N> and simplex<M>. It contains barycentric coordina...
unsigned int size() const
Returns number of intersection points.
unsigned int bulk_ele_idx() const
Returns index of bulk element.
unsigned int component_ele_idx() const
Returns index of component element.
const arma::vec::fixed< dimA > & comp_coords() const
Returns local coordinates in the Simplex<N>.
const arma::vec::fixed< dimB > & bulk_coords() const
Returns local coordinates in the Simplex<M>.
arma::vec::fixed< dimA > comp_coords_
Local coordinates of an IP on simplex<dimA>.
arma::vec3 coords(ElementAccessor< 3 > comp_ele) const
IntersectionLocal()
Default constructor.
std::vector< IntersectionPoint< dimA, dimB > > i_points_
Vector of intersection points.
template ostream & operator<< < 1, 3 >(ostream &os, const IntersectionPoint< 1, 3 > &s)
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
~IntersectionLocal()
Destructor.
unsigned int dim() const
Definition: accessors.hh:87
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
arma::vec3 & point()
Definition: nodes.hh:67
template ostream & operator<< < 2, 2 >(ostream &os, const IntersectionPoint< 2, 2 > &s)
Internal class representing intersection point.
Internal class representing intersection object.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:299
const Node * node(unsigned int ni) const
Definition: accessors.hh:145