12#include "Vector/vector_dist.hpp"
13#include "Decomposition/CartDecomposition.hpp"
14#include "PSE/Kernels.hpp"
15#include "data_type/aggregate.hpp"
29double f_xex2(
double x)
36 return x.get(0)*exp(-x.get(0)*x.get(0));
41 return 2.0*x.get(0)*(2.0*x.get(0)*x.get(0) - 3.0)*exp(-x.get(0)*x.get(0));
50int main(
int argc,
char* argv[])
66 const size_t Npart = 125;
69 const size_t Npad = 40;
75 double spacing = box.
getHigh(0) / Npart;
78 const double eps = 2*spacing;
89 openfpm_init(&argc,&argv);
92 size_t bc[1]={NON_PERIODIC};
122 size_t base = vd.init_size_accum(Npart+1);
123 auto it2 = vd.getIterator();
127 auto key = it2.get();
130 vd.getPos(key)[0] = (key.getKey() + base) * spacing;
132 vd.template getProp<0>(key) = f_xex2((key.getKey() + base) * spacing);
171 double enlarge = 0.1;
174 if (Npad * spacing > 0.1)
176 m_pad.
setHigh(0,Npad * spacing);
177 m_pad2.setLow(0,4.0 - Npad*spacing);
178 enlarge = Npad * spacing;
181 auto it = vd.getDomainIterator();
188 if (m_pad.isInsideNB(vd.getPos(key)) ==
true)
191 vd.getLastPos()[0] = - vd.getPos(key)[0];
192 vd.template getLastProp<0>() = - vd.template getProp<0>(key);
196 if (m_pad2.isInsideNB(vd.getPos(key)) ==
true)
199 vd.getLastPos()[0] = 2.0 * box.getHigh(0) - vd.getPos(key)[0];
200 vd.template getLastProp<0>() = f_xex2(vd.getLastPos()[0]);
215 auto cl = vd.getCellList(12*eps,gp);
230 auto it_p = vd.getDomainIterator();
231 while (it_p.isNext())
244 if (p.
get(0) < 0.0 || p.
get(0) >= 4.0)
251 double prp_x = vd.template getProp<0>(key);
254 auto NN = cl.template getNNIterator<NO_CHECK>(cl.getCell(p));
264 double ker = lker.value(p,vd.getPos(nnp));
267 double prp_y = vd.template getProp<0>(nnp);
270 double prp = 1.0/eps/eps * (prp_y - prp_x) * spacing;
281 double sol = Lapf_xex2(p);
283 if (fabs(pse - sol) > linf)
284 linf = fabs(pse - sol);
300 std::cout <<
"Norm infinity: " << linf <<
"\n";
This class represent an N-dimensional box.
__device__ __host__ T getHigh(int i) const
get the high interval of the box
__device__ __host__ void setHigh(int i, T val)
set the high interval of the box
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
void execute()
Execute all the requests.
size_t getProcessUnitID()
Get the process unit id.
void max(T &num)
Get the maximum number across all processors (or reduction with infinity norm)
Implementation of VCluster class.
Grid key for a distributed grid.
__device__ __host__ size_t getKey() const
Get the key.
Implementation of the Laplacian kernels for PSE.