20 #include "headcpp.hpp"
22 #include "bispheric.hpp"
24 #include "tensor_impl.hpp"
26 #include "utilities.hpp"
28 double eta_lim_chi (
double chi,
double rext,
double a,
double eta_c) ;
29 double chi_lim_eta (
double chi,
double rext,
double a,
double chi_c) ;
31 double zerosec(
double (*f)(
double,
const Param&),
const Param& parf,
32 double x1,
double x2,
double precis,
int nitermax,
int& niter) ;
35 double func_a (
double aa,
const Param& par) {
36 double r1 = par.get_double(0) ;
37 double r2 = par.get_double(1) ;
38 double d = par.get_double(2) ;
39 return (sqrt(aa*aa+r1*r1)+sqrt(aa*aa+r2*r2)-d) ;
57 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
59 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
68 double a_max = distance/2. ;
69 double precis = PRECISION ;
72 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
73 double eta_plus = asinh(aa/r2) ;
74 double eta_minus = -asinh(aa/r1) ;
76 double chi_c = 2*atan(aa/rext) ;
77 double eta_c = log((1+rext/aa)/(rext/aa-1)) ;
78 double eta_lim = eta_c/2. ;
79 double chi_lim = chi_lim_eta (eta_lim, rext, aa, chi_c) ;
83 center.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ; center.
set(2) = 0 ; center.
set(3) = 0 ;
84 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
86 center.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
87 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
118 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
120 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
129 double a_max = distance/2. ;
130 double precis = PRECISION ;
133 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
134 double eta_plus = asinh(aa/r2) ;
135 double eta_minus = -asinh(aa/r1) ;
137 double chi_c = 2*atan(aa/rr(0)) ;
138 double eta_c = log((1+rr(0)/aa)/(rr(0)/aa-1)) ;
139 double eta_lim = eta_c/2. ;
140 double chi_lim = chi_lim_eta (eta_lim, rr(0), aa, chi_c) ;
144 center.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ; center.
set(2) = 0 ; center.
set(3) = 0 ;
145 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
147 center.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
148 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
160 for (
int i=0 ; i<
nshells ; i++)
181 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
183 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
192 double a_max = distance/2. ;
193 double precis = PRECISION ;
196 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
197 double eta_plus = asinh(aa/r2) ;
198 double eta_minus = -asinh(aa/r1) ;
200 double chi_c = 2*atan(aa/rr(0)) ;
201 double eta_c = log((1+rr(0)/aa)/(rr(0)/aa-1)) ;
202 double eta_lim = eta_c/2. ;
203 double chi_lim = chi_lim_eta (eta_lim, rr(0), aa, chi_c) ;
207 center.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ; center.
set(2) = 0 ; center.
set(3) = 0 ;
208 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
210 center.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
211 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
223 for (
int i=0 ; i<
nshells ; i++) {
235 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
244 Space_bispheric::Space_bispheric (
int ttype,
double distance,
int nminus,
const Array<double>& rminus,
int nplus,
const Array<double>& rplus,
int nn,
const Array<double>& rr,
const Array<int>& type_r,
int nr,
bool withnuc) {
258 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
260 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
264 double r1 = rminus(nminus) ;
265 double r2 = rplus(nplus) ;
267 if (fabs(r1-r2)>1e-12) {
268 cerr <<
"Constructor of Space_bispheric not correct for different radii" << endl ;
277 double a_max = distance/2. ;
278 double precis = PRECISION ;
281 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
282 double eta_plus = asinh(aa/r2) ;
283 double eta_minus = -asinh(aa/r1) ;
285 double chi_c = 2*atan(aa/rr(0)) ;
286 double eta_c = log((1+rr(0)/aa)/(rr(0)/aa-1)) ;
287 double eta_lim = eta_c/2. ;
288 double chi_lim = chi_lim_eta (eta_lim, rr(0), aa, chi_c) ;
293 center_minus.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ;
294 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
301 domains[current] =
new Domain_shell(current, ttype, rminus(i), rminus(i+1), center_minus, res) ;
306 center_plus.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
307 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
314 domains[current] =
new Domain_shell(current, ttype, rplus(i), rplus(i+1), center_plus, res) ;
327 for (
int i=0 ; i<
nshells ; i++) {
342 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
351 Space_bispheric::Space_bispheric (
int ttype,
double distance,
int nminus,
const Array<double>& rminus,
const Array<int>& type_r_minus,
int nplus,
const Array<double>& rplus,
const Array<int>& type_r_plus,
int nn,
const Array<double>& rr,
const Array<int>& type_r,
int nr,
bool withnuc) {
365 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
367 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
371 double r1 = rminus(nminus) ;
372 double r2 = rplus(nplus) ;
374 if (fabs(r1-r2)>1e-12) {
375 cerr <<
"Constructor of Space_bispheric not correct for different radii" << endl ;
384 double a_max = distance/2. ;
385 double precis = PRECISION ;
388 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
389 double eta_plus = asinh(aa/r2) ;
390 double eta_minus = -asinh(aa/r1) ;
392 double chi_c = 2*atan(aa/rr(0)) ;
393 double eta_c = log((1+rr(0)/aa)/(rr(0)/aa-1)) ;
394 double eta_lim = eta_c/2. ;
395 double chi_lim = chi_lim_eta (eta_lim, rr(0), aa, chi_c) ;
400 center_minus.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ;
401 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
408 switch (type_r_minus(i)) {
410 domains[current] =
new Domain_shell (current, ttype, rminus(i), rminus(i+1), center_minus, res) ;
422 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
429 center_plus.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
430 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
437 switch (type_r_minus(i)) {
439 domains[current] =
new Domain_shell (current, ttype, rplus(i), rplus(i+1), center_plus, res) ;
451 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
466 for (
int i=0 ; i<
nshells ; i++) {
481 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
504 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
506 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
510 double r1 = rshell1 ;
511 double r2 = rshell2 ;
518 double a_max = distance/2. ;
519 double precis = PRECISION ;
522 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
523 double eta_plus = asinh(aa/r2) ;
524 double eta_minus = -asinh(aa/r1) ;
526 double chi_c = 2*atan(aa/rext) ;
527 double eta_c = log((1+rext/aa)/(rext/aa-1)) ;
528 double eta_lim = eta_c/2. ;
529 double chi_lim = chi_lim_eta (eta_lim, rext, aa, chi_c) ;
533 center_minus.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ;
534 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
537 center_plus.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
538 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
571 double r1 = rshell1 ;
572 double r2 = rshell2 ;
579 double a_max = distance/2. ;
580 double precis = PRECISION ;
583 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
584 double eta_plus = asinh(aa/r2) ;
585 double eta_minus = -asinh(aa/r1) ;
587 double chi_c = 2*atan(aa/rext) ;
588 double eta_c = log((1+rext/aa)/(rext/aa-1)) ;
589 double eta_lim = eta_c/2. ;
590 double chi_lim = chi_lim_eta (eta_lim, rext, aa, chi_c) ;
594 center_minus.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ;
595 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
598 center_plus.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
599 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
630 res.
set(0) = nr ; res.
set(1) = nr ; res.
set(2) = nr-1 ;
632 res_bi.
set(0) = nr ; res_bi.
set(1) = nr ; res_bi.
set(2) = nr ;
636 double r1 = rshell1 ;
637 double r2 = rshell2 ;
639 double rext = rr(0) ;
646 double a_max = distance/2. ;
647 double precis = PRECISION ;
650 double aa = zerosec(func_a, par_a, a_min, a_max, precis, nitermax, niter) ;
651 double eta_plus = asinh(aa/r2) ;
652 double eta_minus = -asinh(aa/r1) ;
654 double chi_c = 2*atan(aa/rext) ;
655 double eta_c = log((1+rext/aa)/(rext/aa-1)) ;
656 double eta_lim = eta_c/2. ;
657 double chi_lim = chi_lim_eta (eta_lim, rext, aa, chi_c) ;
661 center_minus.
set(1) = aa*cosh(eta_minus)/sinh(eta_minus) ;
662 a_minus = aa*cosh(eta_minus)/sinh(eta_minus) ;
665 center_plus.
set(1) = aa*cosh(eta_plus)/sinh(eta_plus) ;
666 a_plus = aa*cosh(eta_plus)/sinh(eta_plus) ;
680 for (
int i=0 ; i<nn ; i++)
688 fread_be (&
ndim,
sizeof(
int), 1, fd) ;
689 fread_be (&
type_base,
sizeof(
int), 1, fd) ;
690 fread_be (&
a_minus,
sizeof(
double), 1, fd) ;
691 fread_be (&
a_plus,
sizeof(
double), 1, fd) ;
695 fread_be (&
ndom_plus,
sizeof(
int), 1, fd) ;
696 fread_be (&
nshells,
sizeof(
int), 1, fd) ;
706 bool nucleus = (nnuc>=2) ?
true :
false ;
744 for (
int i=0 ; i<
nshells ; i++)
745 switch (type_shells) {
759 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
771 fread_be (&
ndim,
sizeof(
int), 1, fd) ;
772 fread_be (&
type_base,
sizeof(
int), 1, fd) ;
773 fread_be (&
a_minus,
sizeof(
double), 1, fd) ;
774 fread_be (&
a_plus,
sizeof(
double), 1, fd) ;
777 fread_be (&
ndom_plus,
sizeof(
int), 1, fd) ;
778 fread_be (&
nshells,
sizeof(
int), 1, fd) ;
782 bool nucleus = (nnuc>=2) ?
true :
false ;
793 switch (type_minus) {
807 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
833 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
850 for (
int i=0 ; i<
nshells ; i++)
851 switch (type_shells) {
865 cerr <<
"Unknown type of shells in Space_bishperic constructor" << endl ;
881 fwrite_be (&
ndim,
sizeof(
int), 1, fd) ;
882 fwrite_be (&
type_base,
sizeof(
int), 1, fd) ;
883 fwrite_be (&
a_minus,
sizeof(
double), 1, fd) ;
884 fwrite_be (&
a_plus,
sizeof(
double), 1, fd) ;
886 fwrite_be (&
ndom_plus,
sizeof(
int), 1, fd) ;
887 fwrite_be (&
nshells,
sizeof(
int), 1, fd) ;
900 res.
set(1,0) = INNER_BC ;
902 res.
set(1,1) = INNER_BC ;
905 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ;
917 res.
set(1,0) = INNER_BC ;
919 res.
set(1,1) = INNER_BC ;
922 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ; abort() ;
933 res.
set(1,0) = OUTER_BC ;
937 res.
set(1,0) = INNER_BC ;
940 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ; abort() ;
951 res.
set(1,0) = OUTER_BC ;
955 res.
set(1,0) = INNER_BC ;
958 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ; abort() ;
970 res.
set(1, 0) = INNER_BC ;
973 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ; abort() ;
984 res.
set(1, 0) = OUTER_BC ;
988 res.
set(1, 0) = INNER_BC ;
991 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ; abort() ;
1002 res.
set(1,0) = OUTER_BC ;
1006 res.
set(1,0) = INNER_BC ;
1009 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ;
1026 for (
int i=0 ; i<5 ; i++)
1027 res.
set(1,i) = OUTER_BC ;
1030 cerr <<
"Bad bound in Space_bispheric::get_indices_matching_non_std" << endl ;
1036 cerr <<
"Bad domain in Space_bispheric::get_indices_matching_non_std" << endl ;
1045 cerr <<
"No compactified domain in Space_bispheric::int_inf" << endl ;
reference set(const Index &pos)
Read/write of an element.
Class for storing the dimensions of an array.
int & set(int i)
Read/write of the size of a given dimension.
Class for bispherical coordinates with a symmetry with respect to the plane .
Class for bispherical coordinates with a symmetry with respect to the plane .
Class for bispherical coordinates with a symmetry with respect to the plane .
Class for a spherical compactified domain and a symmetry with respect to the plane .
virtual double integ(const Val_domain &, int) const
Surface integral on a given boundary.
Class for a spherical domain containing the origin and a symmetry with respect to the plane .
Class for a spherical shell and a symmetry with respect to the plane .
Class for a spherical shell and a symmetry with respect to the plane .
Class for a spherical shell and a symmetry with respect to the plane .
Abstract class that implements the fonctionnalities common to all the type of domains.
virtual double integ(const Val_domain &so, int bound) const
Surface integral on a given boundary.
void add_double(double x, int position=0)
Adds the the address of a new double to the list.
The class Point is used to store the coordinates of a point.
double & set(int i)
Read/write of a coordinate.
The class Scalar does not really implements scalars in the mathematical sense but rather tensorial co...
int nshells
Number of shells outside the bispheric region.
int ndom_minus
Number of spherical domains inside the first sphere.
double int_sphere_one(const Scalar &so) const
Computes the surface integral on the first sphere.
virtual void save(FILE *) const
Saving function.
virtual ~Space_bispheric()
Destructor.
int ndom_plus
Number of spherical domains inside the second sphere.
double int_inf(const Scalar &so) const
Computes the surface integral at infinity.
virtual Array< int > get_indices_matching_non_std(int, int) const
Gives the number of the other domains, touching a given boundary.
Space_bispheric(int ttype, double dist, double r1, double r2, double rext, int nr)
Standard constructor
double a_minus
X-absolute coordinate of the center of the first sphere.
double a_plus
X-absolute coordinate of the center of the second sphere.
double int_sphere_two(const Scalar &so) const
Computes the surface integral on the second sphere.
int type_base
Type of basis used (i.e. using either Chebyshev or Legendre polynomials).
int ndim
Number of dimensions (should be the same for all the Domains).
Domain ** domains
Pointers on the various Domains.
int nbr_domains
Number od Domains.