LORENE
ope_helmholtz_minus_pseudo_1d_solh.C
1 /*
2  * Copyright (c) 2004 Philippe Grandclement
3  *
4  * This file is part of LORENE.
5  *
6  * LORENE is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2
8  * as published by the Free Software Foundation.
9  *
10  * LORENE is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with LORENE; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  */
20 
21 
22 
23 /*
24  * $Id: ope_helmholtz_minus_pseudo_1d_solh.C,v 1.5 2016/12/05 16:18:12 j_novak Exp $
25  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_pseudo_1d/ope_helmholtz_minus_pseudo_1d_solh.C,v 1.5 2016/12/05 16:18:12 j_novak Exp $
26  *
27  */
28 #include <cmath>
29 #include <cstdlib>
30 #include <gsl/gsl_sf_bessel.h>
31 
32 #include "proto.h"
33 #include "ope_elementary.h"
34 
35  //------------------------------------
36  // Routine pour les cas non prevus --
37  //------------------------------------
38 namespace Lorene {
39 Tbl _solh_helmholtz_minus_pseudo_1d_pas_prevu (int, int,
40  double, double, double) {
41 
42  cout << " Solution homogene pas prevue ..... : "<< endl ;
43  exit(-1) ;
44  Tbl res(1) ;
45  return res;
46 }
47 
48 
49  //-------------------
50  //-- R_CHEBU -----
51  //-------------------
52 
53 Tbl _solh_helmholtz_minus_pseudo_1d_r_chebu (int n, int l,
54  double masse,
55  double alpha, double) {
56 
57 
58  Tbl res(n) ;
59  res.set_etat_qcq() ;
60  double* coloc = new double[n] ;
61 
62  int * deg = new int[3] ;
63  deg[0] = 1 ;
64  deg[1] = 1 ;
65  deg[2] = n ;
66 
67  for (int i=0 ; i<n-1 ; i++) {
68  double air = 1./(alpha*(-1-cos(M_PI*i/(n-1)))) ;
69  if ((l !=0) && (l!=1))
70  coloc[i] = gsl_sf_bessel_kl_scaled (l-1, masse*air) / exp(masse*air) * air;
71  else
72  coloc[i] = exp(-masse*air) ;
73  }
74  coloc[n-1] = 0 ;
75 
76  cfrcheb(deg, deg, coloc, deg, coloc) ;
77  for (int i=0 ; i<n ;i++)
78  res.set(i) = coloc[i] ;
79 
80  delete [] coloc ;
81  delete [] deg ;
82 
83  return res ;
84 }
85 
86 
88 
89  // Routines de derivation
90  static Tbl (*solh_helmholtz_minus_pseudo_1d[MAX_BASE]) (int, int, double, double, double) ;
91  static int nap = 0 ;
92 
93  // Premier appel
94  if (nap==0) {
95  nap = 1 ;
96  for (int i=0 ; i<MAX_BASE ; i++) {
97  solh_helmholtz_minus_pseudo_1d[i] = _solh_helmholtz_minus_pseudo_1d_pas_prevu ;
98  }
99  // Les routines existantes
100  solh_helmholtz_minus_pseudo_1d[R_CHEBU >> TRA_R] = _solh_helmholtz_minus_pseudo_1d_r_chebu ;
101  }
102 
103  Tbl res(solh_helmholtz_minus_pseudo_1d[base_r](nr, l_quant, masse, alpha, beta)) ;
104 
105  // Un peu tricky...
106 
107  if (res.get_ndim() == 1) {
108  Tbl val_lim (val_solp (res, alpha, base_r)) ;
109  val_lim *= sqrt (double(2)) ;
110 
111  s_one_plus = val_lim(0) ;
112  s_one_minus = val_lim(1) ;
113  ds_one_plus = val_lim(2) ;
114  ds_one_minus = val_lim(3) ;
115 
116  }
117  else {
118  Tbl auxi (nr) ;
119  auxi.set_etat_qcq() ;
120  for (int i=0 ; i<nr ; i++)
121  auxi.set(i) = res(0,i) ;
122 
123  Tbl val_one (val_solp (auxi, alpha, base_r)) ;
124  val_one *= sqrt (double(2)) ;
125 
126  s_one_plus = val_one(0) ;
127  s_one_minus = val_one(1) ;
128  ds_one_plus = val_one(2) ;
129  ds_one_minus = val_one(3) ;
130 
131  for (int i=0 ; i<nr ; i++)
132  auxi.set(i) = res(1,i) ;
133 
134  Tbl val_two (val_solp (auxi, alpha, base_r)) ;
135  val_two *= sqrt(double(2)) ;
136 
137  s_two_plus = val_two(0) ;
138  s_two_minus = val_two(1) ;
139  ds_two_plus = val_two(2) ;
140  ds_two_minus = val_two(3) ;
141 
142  }
143 
144  return res ;
145 }
146 }
double alpha
Parameter of the associated mapping.
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
double s_one_minus
Value of the first homogeneous solution at the inner boundary.
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
double ds_two_minus
Value of the derivative of the second homogeneous solution at the inner boundary. ...
double beta
Parameter of the associated mapping.
Lorene prototypes.
Definition: app_hor.h:67
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
double ds_two_plus
Value of the derivative of the second homogeneous solution at the outer boundary. ...
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
int base_r
Radial basis of decomposition.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Definition: type_parite.h:158
double ds_one_plus
Value of the derivative of the first homogeneous solution at the outer boundary.
int get_ndim() const
Gives the number of dimensions (ie dim.ndim)
Definition: tbl.h:420
double s_two_minus
Value of the second homogeneous solution at the inner boundary.
double s_one_plus
Value of the first homogeneous solution at the outer boundary.
virtual Tbl get_solh() const
Computes the homogeneous solutions(s).
int nr
Number of radial points.
double ds_one_minus
Value of the derivative of the first homogeneous solution at the inner boundary.
Basic array class.
Definition: tbl.h:164
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
Definition: type_parite.h:180
double s_two_plus
Value of the second homogeneous solution at the outer boundary.
#define MAX_BASE
Nombre max. de bases differentes.
Definition: type_parite.h:144