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