Flow123d  release_3.0.0-973-g92f55e826
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>
37 : IntersectionLocalBase(iaux.component_ele_idx(), iaux.bulk_ele_idx())
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>
100 IntersectionPoint<dimA,dimB>::IntersectionPoint(const arma::vec::fixed< dimA >& comp_coords,
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);
ElementAccessor::dim
unsigned int dim() const
Definition: accessors.hh:87
IntersectionPoint::~IntersectionPoint
~IntersectionPoint()
Destructor.
Definition: intersection_local.cc:91
operator<<
ostream & operator<<(ostream &os, const IntersectionLocal< dimA, dimB > &il)
Definition: intersection_local.cc:128
operator<<< 2, 3 >
template ostream & operator<<< 2, 3 >(ostream &os, const IntersectionPoint< 2, 3 > &s)
IntersectionLocal::compute_measure
double compute_measure() const override
Computes the relative measure of intersection object.
Definition: intersection_local.cc:53
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: asserts.hh:349
ElementAccessor< 3 >
arma::vec3
Definition: doxy_dummy_defs.hh:17
ElementAccessor::node
const Node * node(unsigned int ni) const
Definition: accessors.hh:145
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:87
accessors.hh
IntersectionPoint::coords
arma::vec3 coords(ElementAccessor< 3 > comp_ele) const
Definition: intersection_local.cc:108
IntersectionLocalBase::~IntersectionLocalBase
~IntersectionLocalBase()
Definition: intersection_local.cc:17
IntersectionPointAux< dimA, dimB >
operator<<< 2, 2 >
template ostream & operator<<< 2, 2 >(ostream &os, const IntersectionPoint< 2, 2 > &s)
Node::point
arma::vec3 & point()
Definition: nodes.hh:67
mesh.h
IntersectionLocal::i_points_
std::vector< IntersectionPoint< dimA, dimB > > i_points_
Vector of intersection points.
Definition: intersection_local.hh:92
intersection_aux.hh
Internal class representing intersection object.
IntersectionLocalBase::IntersectionLocalBase
IntersectionLocalBase()
Definition: intersection_local.cc:13
IntersectionAux::size
unsigned int size() const
Returns number of intersection points.
Definition: intersection_aux.hh:108
IntersectionAux
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
Definition: compute_intersection.hh:49
std
Definition: doxy_dummy_defs.hh:5
side_impl.hh
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
ASSERT_LT_DBG
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:299
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:27
IntersectionLocal::~IntersectionLocal
~IntersectionLocal()
Destructor.
Definition: intersection_local.cc:48
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.