OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
DrawDisk.hpp
1//
2// Created by jstark on 2020-08-18.
3//
12#ifndef ACCURACY_TESTS_CIRCLE_HPP
13#define ACCURACY_TESTS_CIRCLE_HPP
14
15#include <iostream>
16
27template <typename point_type, typename radius_type>
28bool inside_disk(point_type coords, radius_type radius, double center_x=0, double center_y=0)
29{
30 const double EPSILON = std::numeric_limits<double>::epsilon();
31 const double X = coords.get(0), Y = coords.get(1);
32 return (X - center_x) * (X - center_x)
33 + (Y - center_y) * (Y - center_y)
34 <= radius * radius + EPSILON;
35}
36
53template <size_t Phi_0, typename grid_type, typename radius_type>
54void init_grid_with_disk(grid_type & grid, radius_type radius, double center_x=0, double center_y=0)
55{
56 // assign pixel values to domain. For each pixel get factor_refinement number of grid points with corresponding value
57 auto dom = grid.getDomainIterator();
58 while(dom.isNext())
59 {
60 auto key = dom.get();
61
62 Point<grid_type::dims, double> coords = grid.getPos(key);
63
64 if (inside_disk(coords, radius, center_x, center_y))
65 {
66 grid.template get<Phi_0> (key) = 1;
67 }
68 else
69 {
70 grid.template get<Phi_0> (key) = -1;
71 }
72 ++dom;
73 }
74}
75
76
77#endif //ACCURACY_TESTS_CIRCLE_HPP
This class implement the point shape in an N-dimensional space.
Definition Point.hpp:28
This is a distributed grid.