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;
38constexpr int PCURV=10;
41typedef aggregate<double,double,double,double,Point<3,double>,
Point<3,double>,double,double,
Point<3,double>,
double[3][3],
double[3]>
prop;
42openfpm::vector<std::string> propNames{{
"Gauss",
"Mean",
"AnaMean",
"ErrorMean",
"Normal",
"PCOORD",
"AnaGauss",
"ErrorGauss",
"Pos",
"CurvatureTensor",
"PrincipalCurvature"}};
45int main(
int argc,
char * argv[]) {
46 openfpm_init(&argc,&argv);
47 auto & v_cl = create_vcluster();
53 double grid_spacing_surf,sc;
58 std::cout <<
"Error: The executable requires the following arguments: number_grid_points" << std::endl;
62 n = std::stoi(argv[1]);
63 ord = std::stoi(argv[2]);
64 sc = std::stoi(argv[3]);
71 std::string cwd{boost::filesystem::current_path().string()};
72 std::string output_dir{cwd +
"/output_Ellipsoid"};
74 p_output = output_dir +
"/particles";
77 double boxP1{-1.5}, boxP2{1.5};
78 double boxSize{boxP2 - boxP1};
79 size_t sz[3] = {n,n,n};
80 double grid_spacing{boxSize/(sz[0]-1)};
81 grid_spacing_surf=grid_spacing*sc;
82 rCut=2.9 * grid_spacing_surf;
83 double a=1.0,b=0.8,c=0.75;
85 Box<3,double> domain{{boxP1,boxP1,boxP1},{boxP2,boxP2,boxP2}};
86 size_t bc[3] = {NON_PERIODIC,NON_PERIODIC,NON_PERIODIC};
94 double theta{0.0},phi{0.0};
95 double dtheta{M_PI/double(n-1)};
96 double dphi{2*M_PI/double(2.0*n-1)};
97 double Golden_angle=M_PI * (3.0 - sqrt(5.0));
98 if (v_cl.rank() == 0) {
100 {
for(
int j=0;j<2*n-1;j++)
103 double xp=a*std::sin(theta)*std::cos(phi);
104 double yp=b*std::sin(theta)*std::sin(phi);
105 double zp=c*std::cos(theta);
112 double rm=sqrt(4*(xp*xp/(a*a*a*a)+yp*yp/(b*b*b*b)+zp*zp/(c*c*c*c)));
120 particles.
getLastProp<ANADF>() = (a*b*c)*(3*(a*a+b*b)+2*c*c+(a*a+b*b-2*c*c)*std::cos(2*theta)-2*(a*a-b*b)*std::cos(2*phi)*std::sin(theta)*std::sin(theta))/(8*openfpm::math::intpowlog(sqrt((a*a*b*b*std::cos(theta)*std::cos(theta)+c*c*(b*b*std::cos(phi)*std::cos(phi)+a*a*std::sin(phi)*std::sin(phi))*std::sin(theta)*std::sin(theta))),3));
121 particles.
getLastProp<ANAG>() = (a*a*b*b*c*c)/(openfpm::math::intpowlog((a*a*b*b*std::cos(theta)*std::cos(theta)+c*c*(b*b*std::cos(phi)*std::cos(phi)+a*a*std::sin(phi)*std::sin(phi))*std::sin(theta)*std::sin(theta)),2));
129 std::cout <<
"n: " << n*2*n <<
" - grid spacing: " << grid_spacing <<
" - rCut: " << rCut <<
"Nspacing" << grid_spacing_surf<<
" - dTheta: "<<dtheta<<
" - dPhi: "<<dphi <<std::endl;
138 auto &bulkIds=particles_bulk.getIds();
139 auto &bdrIds=particles_boundary.getIds();
149 SurfaceDerivative_x<NORMAL> Sdx{
particles,ord,rCut,grid_spacing_surf};
150 SurfaceDerivative_y<NORMAL> Sdy{
particles,ord,rCut,grid_spacing_surf};
151 SurfaceDerivative_z<NORMAL> Sdz{
particles,ord,rCut,grid_spacing_surf};
153 auto Na=Sdx(N[0]),Nb=Sdy(N[0]),Nc=Sdz(N[0]),
154 Nd=Sdx(N[1]),Ne=Sdy(N[1]),Nf=Sdz(N[1]),
155 Ng=Sdx(N[2]),Nh=Sdy(N[2]),Ni=Sdz(N[2]);
177 typedef EMatrix<double, Eigen::Dynamic, Eigen::Dynamic> MatrixType;
185 double a=CT.eigenvalues()[0].real(),b=CT.eigenvalues()[1].real(),c=CT.eigenvalues()[2].real();
186 if (a > c) std::swap(a, c);
187 if (a > b) std::swap(a, b);
188 if (b > c) std::swap(b, c);
206 double MaxError=0,L2=0,MaxErrorG=0,L2G=0;
207 for (
int j = 0; j < bulkIds.size(); j++) {
208 auto p = bulkIds.get<0>(j);
227 std::cout.precision(16);
229 std::cout<<
"Mean Curvature L2:"<<L2<<std::endl;
230 std::cout<<
"Mean Curvature L_inf:"<<MaxError<<std::endl;
231 std::cout<<
"Gauss Curvature L2:"<<L2G<<std::endl;
232 std::cout<<
"Gauss Curvature L_inf:"<<MaxErrorG<<std::endl;
241 if (v_cl.rank() == 0)
242 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...