Flow123d  jenkins-Flow123d-linux-release-multijob-282
intersectionLocal.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 #include <stdio.h>
4 #include <vector>
5 #include <cmath>
6 #include <numeric>
7 #include <limits>
8 
9 #include "system/exc_common.hh"
11 
13 
16 }
17 
18 bool eps_double_equal(double a, double b) {
19  return fabs(a-b) < numeric_limits<double>::epsilon();
20 }
21 
23  if (! equal (IP.coord1.begin(), IP.coord1.end(), el1_coord().begin(), eps_double_equal)) return false;
24  if (! equal (IP.coord2.begin(), IP.coord2.end(), el2_coord().begin(), eps_double_equal)) return false;
25  return true;
26 }
27 
29  if (! (A1.el1_coord().size() == 1 && A2.el1_coord().size() == 1 ) ) {
30  THROW( ExcAssertMsg() << EI_Message( "Interpolation of IntersectionPoints with non line first element.") );
31  }
32  if (! (A1.el2_coord().size() == A2.el2_coord().size()) ) {
33  THROW( ExcAssertMsg() << EI_Message( "Interpolation of IntersectionPoints with non matching second element type.") );
34  }
35  std::vector<double> el2_coord(A1.el2_coord().size());
36  for(unsigned int i = 0; i < el2_coord.size(); ++i) {
37  el2_coord[i] = ((t - A1.el1_coord()[0]) / (A2.el1_coord()[0] - A1.el1_coord()[0])) * (A2.el2_coord()[i] - A1.el2_coord()[i]) + A1.el2_coord()[i];
38  }
39  return new IntersectionPoint(std::vector<double>(1,t), el2_coord);
40 }
41 
43 : type(i_type)
44 {
45  id = generateId();
46 }
47 
48 
50  i_points.push_back(new IntersectionPoint(coordin1, coordin2));
51 }
52 
54  i_points.push_back(InPoint);
55 }
56 
57 void IntersectionLocal::print(FILE *out_file) {
58  int size_0 = i_points.size();
59  fprintf(out_file," %d", size_0); //pocet bodu pruniku N
60 
61  // cyklus pres body pruniku
63  i_point != i_points.end();++i_point) {
64 
65  // pocet lokalnich souradnic 1. elementu a jejich vypis
66  int size_1 = (*i_point)->coord1.size();
67  fprintf(out_file, " %d", size_1);
68  for(std::vector<double>::iterator l_coord = (*i_point)->coord1.begin();
69  l_coord != (*i_point)->coord1.end();++l_coord) {
70  float f_1 = *l_coord;
71  fprintf(out_file, " %1.7e", f_1);
72  }
73 
74  // pocet lokalnich souradnic 2. elementu a jejich vypis
75  int size_2 = (*i_point)->coord2.size();
76  fprintf(out_file, " %d", size_2);
77  for(std::vector<double>::iterator l_coord = (*i_point)->coord2.begin();
78  l_coord != (*i_point)->coord2.end();++l_coord) {
79  float f_2 = *l_coord;
80  fprintf(out_file, " %1.7e", f_2);
81  }
82  }
83 }
84 
87  i_point != i_points.end();++i_point) {
88  delete *i_point;
89  }
90 }
std::vector< double > coord2
IntersectionPoint * interpolate(const IntersectionPoint &A1, const IntersectionPoint &A2, double t)
void print(FILE *out_file)
static int numberInstance
const std::vector< double > & el2_coord() const
bool operator==(const IntersectionPoint &)
std::vector< double > coord1
const std::vector< double > & el1_coord() const
void add_local_coord(const std::vector< double > &coordin1, const std::vector< double > &coordin2)
IntersectionLocal(IntersectionType i_type)
std::vector< IntersectionPoint * > i_points
const double epsilon
Definition: mathfce.h:6
bool eps_double_equal(double a, double b)
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:34
void add_local_point(IntersectionPoint *InPoint)