12 double dangle = M_PI_2/Ni;
13 double dtheta = dangle;
15 double I_riemann = 0.0;
16 for (
int i=0; i<Ni; ++i)
18 double theta = (0.5+i)*dtheta;
19 for (
int j=0; j<Ni; ++j)
21 double phi = (0.5+j)*dphi;
22 double mu_r = cos(phi)*sin(theta);
23 double eta_r= sin(phi)*sin(theta);
24 double xi_r = cos(theta);
26 double fval = (*F)(mu_r,eta_r,xi_r);
28 I_riemann += fval*sin(theta)*dtheta*dphi;
41 double I_quadrature = 0.0;
42 for (
const auto& sq : initial_octant_SQs_)
43 for (
int i=0; i<4; ++i)
45 double mu = sq.sub_sqr_points[i][2];
46 double theta = acos(mu);
47 double phi = acos(sq.sub_sqr_points[i][0]/sin(theta));
49 double mu_r = cos(phi)*sin(theta);
50 double eta_r= sin(phi)*sin(theta);
51 double xi_r = cos(theta);
53 double fval = (*F)(mu_r,eta_r,xi_r);
55 I_quadrature += sq.sub_sqr_weights[i]*fval;
67 {
double operator()(
double mu,
double eta,
double xi)
override
68 {
return pow(mu,1.0)*pow(eta,1.0)*pow(xi,0.0);}};
71 {
double operator()(
double mu,
double eta,
double xi)
override
72 {
return pow(mu,3.0)*pow(eta,1.0)*pow(xi,1.0);}};
75 {
double operator()(
double mu,
double eta,
double xi)
override
76 {
return pow(mu,3.0)*pow(eta,6.0)*pow(xi,15.0);}};
79 {
double operator()(
double mu,
double eta,
double xi)
override
81 double theta = acos(xi);
82 double phi = acos(mu/sin(theta));
90 SphericalHarmonicF SphF;
94 case 1: F = &case1;
break;
95 case 2: F = &case2;
break;
96 case 3: F = &case3;
break;
97 case 4: F = &SphF;
break;
101 const int Nd = initial_octant_SQs_.size() * 4;
102 const int NR = RiemannN;
104 double h = 1.0/sqrt(8.0*Nd);
105 double I_riemann = ref_solution;
107 I_riemann = std::fabs(RiemannIntegral(F,NR));
109 double I_quadrature = std::fabs(QuadratureSSIntegral(F));
111 char buff0[200],buff1[200],buff2[200];
112 snprintf(buff0,200,
"Riemann integral: %.20e\n",I_riemann);
113 snprintf(buff1,200,
"Quadrature integral: %.10e\n",I_quadrature);
114 snprintf(buff2, 200,
"Error_RQ%05d_%06d: %2d %f %e\n", Nd,Nd*8,
115 initial_level_, h, std::fabs((I_riemann - I_quadrature) / ref_solution));
LogStream Log(LOG_LVL level=LOG_0)
double QuadratureSSIntegral(BaseFunctor *F)
double RiemannIntegral(BaseFunctor *F, int Ni=20000)
void TestIntegration(int test_case, double ref_solution, int RiemannN=0)
double Ylm(unsigned int ell, int m, double varphi, double theta)