27#include "Grid/grid_dist_id.hpp"
28#include "data_type/aggregate.hpp"
29#include "VCluster/VCluster.hpp"
30#include "Vector/Vector.hpp"
31#include "FiniteDifference/util/common.hpp"
32#include "FiniteDifference/eq.hpp"
33#include "FiniteDifference/FD_op.hpp"
36constexpr int SIM_DIM = 3;
37constexpr int POLY_ORDER = 5;
38constexpr int SIM_GRID_SIZE = 64;
39constexpr double PI = 3.141592653589793;
45const long int sz[SIM_DIM] = {SIM_GRID_SIZE, SIM_GRID_SIZE, SIM_GRID_SIZE};
46const size_t szu[SIM_DIM] = {(size_t) sz[0], (
size_t) sz[1], (size_t) sz[2]};
62constexpr int narrow_band_half_width = 8;
73template<const
unsigned int phi_field,
typename gr
id_type>
83 double posx = coords.
get(x);
84 double posy = coords.
get(y);
85 double posz = coords.
get(z);
87 double phi_val = 1.0 - sqrt(((posx - params.origin[0])/params.radiusA)*((posx - params.origin[0])/params.radiusA) + ((posy - params.origin[1])/params.radiusB)*((posy - params.origin[1])/params.radiusB) + ((posz - params.origin[2])/params.radiusC)*((posz - params.origin[2])/params.radiusC));
88 gd.template get<phi_field>(key) = (phi_val<0)?-1.0:1.0;
96 double max_phi_err = -1.0;
98 gd.template ghost_get<phi>(KEEP_PROPERTIES);
105 double posx = coords.
get(0);
106 double posy = coords.
get(1);
107 double posz = coords.
get(2);
109 double exact_phi_val = 1.0 - sqrt(((posx - params.origin[0])/params.radiusA)*((posx - params.origin[0])/params.radiusA) + ((posy - params.origin[1])/params.radiusB)*((posy - params.origin[1])/params.radiusB) + ((posz - params.origin[2])/params.radiusC)*((posz - params.origin[2])/params.radiusC));
111 double phi_err = std::abs(exact_phi_val - gd.template get<phi>(key));
113 if(phi_err > max_phi_err)
114 max_phi_err = phi_err;
118 std::cout<<
"Error in redistancing = "<<max_phi_err<<
"\n";
123int main(
int argc,
char* argv[])
126 openfpm_init(&argc, &argv);
132 Ghost <SIM_DIM, long int> grid_ghost(2*narrow_band_half_width);
133 GridDist gdist(szu, domain, grid_ghost, grid_bc);
136 openfpm::vector < std::string > prop_names;
137 prop_names.add(
"ls_phi");
138 prop_names.add(
"closest_point");
139 gdist.setPropNames(prop_names);
142 params.origin[x] = 0.0;
143 params.origin[y] = 0.0;
144 params.origin[z] = 0.0;
145 params.radiusA = 1.0;
146 params.radiusB = 1.0;
147 params.radiusC = 1.0;
149 initializeIndicatorFunc<phi>(gdist, params);
150 nb_gamma = narrow_band_half_width * gdist.spacing(0);
152 std::cout<<
"Grid spacing = "<<gdist.spacing(x)<<
"\n";
158 estimateClosestPoint<phi, cp, POLY_ORDER>(gdist, 3.0);
161 reinitializeLS<phi, cp, POLY_ORDER>(gdist, 3.0);
164 estimateErrorInReinit(gdist, params);
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
Implementation of VCluster class.
This is a distributed grid.
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_iterator()), FIXED > getDomainGhostIterator() const
It return an iterator that span the grid domain + ghost part.
Point< dim, St > getPos(const grid_dist_key_dx< dim, bg_key > &v1)
Get the reference of the selected element.
grid_dist_iterator< dim, device_grid, decltype(device_grid::type_of_subiterator()), FREE > getDomainIterator() const
It return an iterator that span the full grid domain (each processor span its local domain)
Functions for level set reinitialization and extension on OpenFPM grids based on closest point method...