3 #include "boost/foreach.hpp" 4 #include "../misc/utils.hpp" 9 bool periodic_duplicate_before(std::vector<Vector2D>
const& toadd,
Vector2D const& tocheck,
Vector2D const& ll,
Vector2D const& ur)
11 size_t N = toadd.size();
14 if (tocheck.
x > ur.
x || tocheck.
x<ll.
x || tocheck.
y>ur.
y || tocheck.
y < ll.
y)
17 for (
size_t i = 0; i < N; ++i)
19 for (
size_t i = 0; i < N; ++i)
21 double dV =
fastabs(toadd[i] - tocheck);
30 bool contains(
const vector<int>& v,
const int n)
32 for (
size_t i = 0; i < v.size(); ++i)
40 bool contains(
const vector<int>& v,
const std::vector<Vector2D> & added,
Vector2D const& toadd,
const int n,
43 if (fabs(toadd.
x) > (1.01*(ur.
x - ll.
x)) || fabs(toadd.
y) > (1.01*(ur.
y - ll.
y)))
45 for (
size_t i = 0; i < v.size(); ++i)
86 vector<int> &res, vector<int>& visited, std::vector<Vector2D> &added,
bool periodic,
Vector2D const& toaddsingle,
91 if (contains(visited, visited_add, toaddsingle, index,ll,ur))
95 if (contains(visited, index))
97 visited.push_back(index);
98 visited_add.push_back(toaddsingle);
103 res.push_back(index);
105 added.push_back(toaddsingle);
107 size_t NN = vtemp.size();
108 Vector2D llperiodic = 2.1 * ll - 1.1*ur;
109 Vector2D urperiodic = 2.1 * ur - 1.1*ll;
110 for (
size_t j = 0; j < NN; ++j)
113 find_affected_cells2(tess, vtemp[j], circle, res, visited, added, periodic, toaddsingle,visited_add,ll,ur);
120 if (!periodic_duplicate_before(added, toadd,llperiodic,urperiodic))
124 toadd += toaddsingle;
125 find_affected_cells2(tess, tess.
GetOriginalIndex(vtemp[j]), circle, res, visited, added, periodic,
126 toadd,visited_add,ll,ur);
137 std::vector<Vector2D> &periodic_add)
139 periodic_add.clear();
142 size_t N = vtemp.size();
143 for (
size_t i = 0; i < N; ++i)
148 if (cell_circle_intersect(tess, vtemp[i], circle))
150 res.push_back(vtemp[i]);
162 if (cell_circle_intersect(tess, real_neigh, circle))
164 res.push_back(real_neigh);
165 periodic_add.push_back(toadd);
175 vector<int> &res, std::vector<Vector2D> &added,
bool periodic,
Vector2D const& ll,
Vector2D const& ur)
178 std::vector<Vector2D> visited_add;
181 find_affected_cells2(tess, index, circle, res, visited, added, periodic, toaddsingle, visited_add,ll,ur);
Geometrical calculations.
Abstract class for tessellation.
virtual int GetPointNo(void) const =0
Get Total number of mesh generating points.
virtual int GetOriginalIndex(int point) const
Returns the original index of the duplicated point.
void setCenter(Vector2D const ¢er)
Sets a new center to the circle.
Interface between two cells.
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
double max(vector< double > const &v)
returns the maximal term in a vector
double y
Component in the y direction.
virtual Edge const & GetEdge(int index) const =0
Returns edge (interface between cells)
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
std::pair< Vector2D, Vector2D > vertices
Points at the ends of the edge.
vector< int > find_affected_cells(const Tessellation &tess, int index, Circle &circle, vector< int > &vtemp, bool periodic, std::vector< Vector2D > &periodic_add)
Non recursive version of find affected cells. Only searches one degree of separation.
Vector2D normalize(const Vector2D &v)
Normalized a vector.
double getRadius(void) const
Returns the radius of the circle.
void find_affected_cells_recursive(const Tessellation &tess, int index, const Circle &circle, vector< int > &res, std::vector< Vector2D > &added, bool periodic, Vector2D const &ll, Vector2D const &ur)
Recursively finds all cells that intersect a circle.
bool edge_circle_intersect(const Edge &edge, const Circle &circle)
Determines if an edge and a circle intersect.
virtual vector< int > const & GetCellEdges(int index) const =0
Returns the indexes of a cell's edges.
Determines which cells might be affected by boundary conditions.
virtual vector< int > GetNeighbors(int index) const =0
Returns the indeces of the neighbors.
double fastabs(Vector2D const &v)
Norm of a vector, less accurate.
double x
Component in the x direction.
const Vector2D & getCenter(void) const
Returns the center of the circle.