20#include "Vector/vector_dist_subset.hpp"
21#include "DCPSE/DCPSE_op/DCPSE_surface_op.hpp"
22#include "DCPSE/DCPSE_op/DCPSE_Solver.hpp"
23#include "util/SphericalHarmonics.hpp"
32constexpr int NORMAL=4;
33constexpr int PCOORD=5;
39int main(
int argc,
char * argv[]) {
40 openfpm_init(&argc,&argv);
41 auto & v_cl = create_vcluster();
46 double grid_spacing_surf;
51 std::cout <<
"Maybe Error: The executable requires the following arguments: number_grid_points order_of_operator" << std::endl;
53 n = std::stoi(argv[1]);
54 unsigned int ord=std::stoi(argv[2]);
60 std::string cwd{boost::filesystem::current_path().string()};
61 std::string output_dir{cwd +
"/output_Sphere"};
63 p_output = output_dir +
"/particles";
66 double boxP1{-1.5}, boxP2{1.5};
67 double boxSize{boxP2 - boxP1};
68 size_t sz[3] = {n,n,n};
69 double grid_spacing{0.8/((std::pow(sz[0],1/3.0)-1))};;
70 grid_spacing_surf=grid_spacing;
71 rCut=2.9 * grid_spacing_surf;
73 Box<3,double> domain{{boxP1,boxP1,boxP1},{boxP2,boxP2,boxP2}};
74 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
84 double Golden_angle=M_PI * (3.0 - sqrt(5.0));
85 if (v_cl.rank() == 0) {
86 for(
int i=1;i<n_sp-1;i++)
88 double y = 1.0 - (i /double(n_sp - 1.0)) * 2.0;
89 double radius = sqrt(1 - y * y);
90 double Golden_theta = Golden_angle * i;
91 double x = cos(Golden_theta) * radius;
92 double z = sin(Golden_theta) * radius;
97 double rm=sqrt(x*x+y*y+z*z);
129 double rm=sqrt(x*x+y*y+z*z);
144 rm=sqrt(x*x+y*y+z*z);
152 std::cout <<
"n: " << n <<
" - grid spacing: " << grid_spacing <<
" - rCut: " << rCut <<
"YDtheta" << grid_spacing_surf<<std::endl;
160 auto &bulkIds=particles_bulk.getIds();
161 auto &bdrIds=particles_boundary.getIds();
162 std::unordered_map<const lm,double,key_hash,key_equal> Alm;
165 for(
int l=0;l<=K;l++){
166 for(
int m=-l;m<=l;m++){
167 Alm[std::make_tuple(l,m)]=0;
171 Alm[std::make_tuple(K,0)]=1;
176 while (it2.isNext()) {
185 particles.
getProp<ANADF>(p)=openfpm::math::sumY_Scalar<K>(xP[0],xP[1],xP[2],Alm);
186 particles.
getProp<DF>(p)=-(K)*(K+1)*openfpm::math::sumY_Scalar<K>(xP[0],xP[1],xP[2],Alm);
194 SurfaceDerivative_xx<NORMAL> Sdxx{
particles,ord,rCut,grid_spacing_surf};
195 SurfaceDerivative_yy<NORMAL> Sdyy{
particles,ord,rCut,grid_spacing_surf};
196 SurfaceDerivative_zz<NORMAL> Sdzz{
particles,ord,rCut,grid_spacing_surf};
198 DErr=(Sdxx(Af)+Sdyy(Af)+Sdzz(Af))-f;
204 auto Eig = Sdxx(f)+Sdyy(f)+Sdzz(f);
205 Solver.impose(Eig, bulkIds, Df);
206 Solver.impose(f, bdrIds, Af);
210 double MaxError=0,L2=0;
211 for (
int j = 0; j < bulkIds.size(); j++) {
212 auto p = bulkIds.get<0>(j);
223 std::cout.precision(16);
225 std::cout<<
"L2:"<<L2<<std::endl;
226 std::cout<<
"L_inf:"<<MaxError<<std::endl;
234 if (v_cl.rank() == 0)
235 std::cout <<
"Simulation took: " << tt.
getcputime() <<
" s (CPU) - " << tt.
getwct() <<
" s (wall)\n";
Header file containing functions for creating files and folders.
static void create_directory_if_not_exist(std::string path, bool silent=0)
Creates a directory if not already existent.
This class represent an N-dimensional box.
This class implement the point shape in an N-dimensional space.
Implementation of 1-D std::vector like structure.
Class for cpu time benchmarking.
void stop()
Stop the timer.
double getcputime()
Return the cpu time.
void start()
Start the timer.
double getwct()
Return the elapsed real time.
vect_dist_key_dx get()
Get the actual key.
bool write_frame(std::string out, size_t iteration, int opt=VTK_WRITER)
Output particle position and properties.
auto getProp(vect_dist_key_dx vec_key) -> decltype(v_prp.template get< id >(vec_key.getKey()))
Get the property of an element.
auto getLastProp() -> decltype(v_prp.template get< id >(0))
Get the property of the last element.
void setPropNames(const openfpm::vector< std::string > &names)
Set the properties names.
vector_dist_iterator getDomainIterator() const
Get an iterator that traverse the particles in the domain.
void ghost_get(size_t opt=WITH_POSITION)
It synchronize the properties and position of the ghost particles.
void map(size_t opt=NONE)
It move all the particles that does not belong to the local processor to the respective processor.
bool write(std::string out, int opt=VTK_WRITER)
Output particle position and properties.
auto getLastPos() -> decltype(v_pos.template get< 0 >(0))
Get the position of the last element.
void add()
Add local particle.
void deleteGhost()
Delete the particles on the ghost.
[v_transform metafunction]
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...