OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
HelpFunctionsForTestingNBCs.hpp
1 //
2 // Created by jstark on 07.06.21.
3 //
4 
5 #ifndef OPENFPM_NUMERICS_HELPFUNCTIONSFORTESTINGNBCS_HPP
6 #define OPENFPM_NUMERICS_HELPFUNCTIONSFORTESTINGNBCS_HPP
7 
8 #include <iostream>
10 
11 template <size_t Phi_SDF_grid, size_t Phi_SDF, size_t dPhi, size_t dPhi_magn, typename grid_in_type, typename
12 vd_in_type>
13 void get_diffusion_domain(grid_in_type & g_dist, vd_in_type & vd, const double b_low, const double b_up)
14 {
15  const double EPSILON = std::numeric_limits<double>::epsilon();
16  const double _b_low = b_low + EPSILON;
17  const double _b_up = b_up - EPSILON;
18  NarrowBand<grid_in_type> narrowBand(g_dist, _b_low, _b_up); // Instantiation of NarrowBand class
19  narrowBand.template get_narrow_band<Phi_SDF_grid, Phi_SDF, dPhi, dPhi_magn>(g_dist, vd);
20 }
21 
28 template <size_t Phi_SDF, typename vd_type>
29 void get_source_particle_ids(vd_type & vd, openfpm::vector<vect_dist_key_dx> & keys_source, const double b_low, const
30 double
31 b_up)
32 {
33  const double EPSILON = std::numeric_limits<double>::epsilon();
34  auto dom = vd.getDomainIterator();
35  while(dom.isNext())
36  {
37  auto key = dom.get();
38  if (vd.template getProp<Phi_SDF>(key) >= b_low + EPSILON && vd.template getProp<Phi_SDF>(key) <= b_up + EPSILON)
39  {
40  keys_source.add(key);
41  }
42  ++dom;
43  }
44 }
45 
46 
47 template <size_t R, size_t U, typename vd_type>
48 void get_IC_Eq28(vd_type &vd, const double a)
49 {
50  auto dom = vd.getDomainIterator();
51  while(dom.isNext())
52  {
53  auto key = dom.get();
54  double r = vd.template getProp<R>(key);
55  if (abs(r) < a) vd.template getProp<U>(key) = cos(M_PI * r / (2*a)) * cos(M_PI * r / (2*a));
56  else vd.template getProp<U>(key) = 0;
57  ++dom;
58  }
59 }
60 
61 template <size_t R, size_t U, typename vd_type>
62 void get_IC_Eq28(vd_type &vd, const double a, const openfpm::vector<aggregate<int>> & pids)
63 {
64  for (int i = 0; i < pids.size(); i++)
65  {
66  auto key = pids.get<0>(i);
67  double r = vd.template getProp<R>(key);
68  if (abs(r) < a) vd.template getProp<U>(key) = cos(M_PI * r / (2*a)) * cos(M_PI * r / (2*a));
69  else vd.template getProp<U>(key) = 0;
70  }
71 }
72 
73 template <size_t U, typename vd_type>
74 void get_FS_Eq29(vd_type &vd, const double a, const double R_disk)
75 {
76  const double R = R_disk;
77  double A = 0;
78  if (a < R) A = M_PI * a*a/2 - 2*R*R/M_PI;
79  if (a >= R) A = M_PI * R*R/2 + a*a*( cos(M_PI * R / a) -1 ) / M_PI + a * R * sin(M_PI * R / a);
80 
81  auto u = getV<U>(vd);
82  u = A / (M_PI * R*R);
83 
84  std::cout << "Analytical steady state concentration = " << A / (M_PI * R*R) << std::endl;
85 }
86 
87 
88 #endif //OPENFPM_NUMERICS_HELPFUNCTIONSFORTESTINGNBCS_HPP
Class for getting the narrow band around the interface.
Definition: NarrowBand.hpp:42
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:214
Class for getting the narrow band around the interface.
Implementation of 1-D std::vector like structure.
Definition: map_vector.hpp:202