16#include "Vector/vector_dist.hpp"
17#include "Decomposition/CartDecomposition.hpp"
18#include "PSE/Kernels.hpp"
19#include "Plot/util.hpp"
20#include "Plot/GoogleChart.hpp"
21#include "data_type/aggregate.hpp"
32double f_xex2(
double x)
39 return x.get(0)*exp(-x.get(0)*x.get(0));
69 double prp_x = vd.template getProp<0>(key);
72 auto NN = cl.template getNNIterator<NO_CHECK>(cl.getCell(p));
81 double ker = lker.value(p,vd.getPos(nnp));
84 double prp_y = vd.template getProp<0>(nnp);
87 double prp = 1.0/eps/eps * (prp_y - prp_x) * spacing;
129inline void mirror(
vector_dist<1,
double,
aggregate<double,double> > & vd,
vect_dist_key_dx & key,
const Box<1,double> & m_pad,
Box<1,double> & m_pad2,
const Box<1,double> & box)
138 vd.getLastPos()[0] = - vd.getPos(key)[0];
141 vd.template getLastProp<0>() = - vd.template getProp<0>(key);
145 if (m_pad2.
isInsideNB(vd.getPos(key)) ==
true)
154 vd.getLastPos()[0] = 2.0 * box.
getHigh(0) - vd.getPos(key)[0];
157 vd.template getLastProp<0>() = vd.template getProp<0>(key);
167int main(
int argc,
char* argv[])
176 const size_t Npart = 1000;
179 size_t NpartA[1] = {Npart+1};
182 const size_t Nstep = 1000;
185 const double dt = 10.0 / Nstep;
188 const size_t Npad = 20;
194 double spacing = box.
getHigh(0) / Npart;
197 const double eps = 2*spacing;
204 constexpr int Lap_U = 1;
212 openfpm_init(&argc,&argv);
215 size_t bc[1]={NON_PERIODIC};
238 auto itp = vd.getGridIterator(NpartA);
247 auto key = itp.get();
250 vd.getPos(p)[0] = key.get(0) * spacing;
253 vd.template getProp<U>(p) = f_xex2(key.get(0) * spacing);
307 if (Npad * spacing > 0.1)
309 m_pad.
setHigh(0,Npad * spacing);
310 m_pad2.
setLow(0,4.0 - Npad*spacing);
311 enlarge = Npad * spacing;
322 auto it = vd.getDomainIterator();
323 size_t n_part = vd.size_local();
329 mirror(vd,key,m_pad,m_pad2,box);
345 auto cl = vd.getCellList(8*eps,gp);
357 for (
double t = 0; t <= 10.0 ; t += dt)
361 auto it_p = vd.getDomainIterator();
362 while (it_p.isNext())
371 if (x_p.
get(0) < 0.0 || x_p.
get(0) >= 4.0)
378 vd.template getProp<Lap_U>(p) = calcLap(x_p,p,vd,eps,spacing,cl);
389 auto it_p2 = vd.getDomainIterator();
390 while (it_p2.isNext())
393 auto p = it_p2.get();
396 double pse = vd.template getProp<Lap_U>(p);
399 vd.template getProp<0>(p) +=
D * pse * dt;
402 mirror(vd,p,m_pad,m_pad2,box);
428 bool operator<(
const pos_val & p)
const
442 for (
size_t i = 0 ; i < vd.size_local() ; i++)
445 v.get(i).pos = vd.getPos(i)[0];
448 v.get(i).val = vd.template getProp<U>(i);
474 for (
size_t i = 0 ; i < v_tot.
size() ; i++)
477 x.add(v_tot.get(i).pos);
480 y.get(0).add(v_tot.get(i).val);
483 y.get(1).add(f_xex2(v_tot.get(i).pos));
491 options.
yAxis = std::string(
"U Axis");
494 options.
xAxis = std::string(
"X Axis");
506 cg.
write(
"PSE_plot.html");
This class represent an N-dimensional box.
__device__ __host__ T getLow(int i) const
get the i-coordinate of the low bound interval of the 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
bool isInsideNB(const Point< dim, T > &p) const
Check if the point is inside the region excluding the borders.
__device__ __host__ void setLow(int i, T val)
set the low interval of the box
Derivative second order on h (spacing)
Small class to produce graph with Google chart in HTML.
void write(std::string file)
It write the graphs on file in html format using Google charts.
void AddLinesGraphT(openfpm::vector< X > &x, openfpm::vector< Y > &y, const GCoptions &opt)
Add lines graph.
This class implement the point shape in an N-dimensional space.
__device__ __host__ const T & get(unsigned int i) const
Get coordinate.
size_t getProcessUnitID()
Get the process unit id.
Implementation of VCluster class.
bool SGather(T &send, S &recv, size_t root)
Semantic Gather, gather the data from all processors into one node.
Implementation of 1-D std::vector like structure.
Grid key for a distributed grid.
__device__ __host__ size_t getKey() const
Get the key.
std::string xAxis
X axis name.
size_t lineWidth
Width of the line.
std::string yAxis
Y axis name.
Implementation of the Laplacian kernels for PSE.
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...