LORENE
cmp_raccord_zec.C
1 /*
2  * Copyright (c) 2000-2001 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 as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * LORENE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with LORENE; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 
24 
25 /*
26  * $Id: cmp_raccord_zec.C,v 1.5 2016/12/05 16:17:49 j_novak Exp $
27  * $Log: cmp_raccord_zec.C,v $
28  * Revision 1.5 2016/12/05 16:17:49 j_novak
29  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30  *
31  * Revision 1.4 2014/10/13 08:52:48 j_novak
32  * Lorene classes and functions now belong to the namespace Lorene.
33  *
34  * Revision 1.3 2014/10/06 15:13:04 j_novak
35  * Modified #include directives to use c++ syntax.
36  *
37  * Revision 1.2 2003/10/03 15:58:45 j_novak
38  * Cleaning of some headers
39  *
40  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
41  * LORENE
42  *
43  * Revision 2.7 2001/03/30 13:38:32 phil
44  * *** empty log message ***
45  *
46  * Revision 2.6 2001/03/22 10:25:01 phil
47  * changement complet : cas plus general
48  *
49  * Revision 2.5 2001/02/08 14:21:32 phil
50  * correction de raccord_zec.C (on prend en compte le dernier coef ...)
51  *
52  * Revision 2.4 2001/01/02 11:25:37 phil
53  * *** empty log message ***
54  *
55  * Revision 2.3 2000/12/13 14:59:18 phil
56  * *** empty log message ***
57  *
58  * Revision 2.2 2000/12/13 14:49:54 phil
59  * changement nom variable appel
60  * /
61  *
62  * Revision 2.1 2000/12/13 14:12:29 phil
63  * correction bugs
64  *
65  * Revision 2.0 2000/12/13 14:09:31 phil
66  * *** empty log message ***
67  *
68  *
69  * $Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_raccord_zec.C,v 1.5 2016/12/05 16:17:49 j_novak Exp $
70  *
71  */
72 
73 //standard
74 #include <cstdlib>
75 #include <cmath>
76 
77 // LORENE
78 #include "matrice.h"
79 #include "cmp.h"
80 #include "proto.h"
81 
82 // Fait le raccord C1 dans la zec ...
83 namespace Lorene {
84 // Suppose (pour le moment, le meme nbre de points sur les angles ...)
85 // et que la zone precedente est une coquille
86 
87 void Cmp::raccord_c1_zec (int puis, int nbre, int lmax) {
88 
89  assert (nbre>0) ;
90  assert (etat != ETATNONDEF) ;
91  if (etat == ETATZERO)
92  return ;
93 
94  // Le mapping doit etre affine :
95  const Map_af* map = dynamic_cast<const Map_af*>(mp) ;
96  if (map == 0x0) {
97  cout << "Le mapping doit etre affine" << endl ;
98  abort() ;
99  }
100 
101  int nz = map->get_mg()->get_nzone() ;
102  int nr = map->get_mg()->get_nr (nz-1) ;
103  int nt = map->get_mg()->get_nt (nz-1) ;
104  int np = map->get_mg()->get_np (nz-1) ;
105 
106  double alpha = map->get_alpha()[nz-1] ;
107  double r_cont = -1./2./alpha ; //Rayon de debut de la zec.
108 
109  // On calcul les coefficients des puissances de 1./r
110  Tbl coef (nbre+2*lmax, nr) ;
111  coef.set_etat_qcq() ;
112 
113  int* deg = new int[3] ;
114  deg[0] = 1 ; deg[1] = 1 ; deg[2] = nr ;
115  double* auxi = new double[nr] ;
116 
117  for (int conte=0 ; conte<nbre+2*lmax ; conte++) {
118  for (int i=0 ; i<nr ; i++)
119  auxi[i] = pow(-1-cos(M_PI*i/(nr-1)), (conte+puis)) ;
120 
121  cfrcheb(deg, deg, auxi, deg, auxi) ;
122  for (int i=0 ; i<nr ; i++)
123  coef.set(conte, i) = auxi[i]*pow (alpha, conte+puis) ;
124  }
125 
126  delete[] deg ;
127  // Maintenant on va calculer les valeurs de la ieme derivee :
128  Tbl valeurs (nbre, nt, np+1) ;
129  valeurs.set_etat_qcq() ;
130 
131  Cmp courant (*this) ;
132  double* res_val = new double[1] ;
133 
134  for (int conte=0 ; conte<nbre ; conte++) {
135 
136  courant.va.coef() ;
137  courant.va.ylm() ;
138  courant.va.c_cf->t[nz-1]->annule_hard() ;
139 
140  int base_r = courant.va.base.get_base_r(nz-2) ;
141  for (int k=0 ; k<np+1 ; k++)
142  for (int j=0 ; j<nt ; j++)
143  if (nullite_plm(j, nt, k, np, courant.va.base) == 1) {
144 
145  for (int i=0 ; i<nr ; i++)
146  auxi[i] = (*courant.va.c_cf)(nz-2, k, j, i) ;
147 
148  switch (base_r) {
149  case R_CHEB :
150  som_r_cheb (auxi, nr, 1, 1, 1, res_val) ;
151  break ;
152  default :
153  cout << "Cas non prevu dans raccord_zec" << endl ;
154  abort() ;
155  break ;
156  }
157  valeurs.set(conte, k, j) = res_val[0] ;
158  }
159  Cmp copie (courant) ;
160  copie.dec2_dzpuis() ;
161  courant = copie.dsdr() ;
162  }
163 
164  delete [] auxi ;
165  delete [] res_val ;
166 
167  // On boucle sur les harmoniques : construction de la matrice
168  // et du second membre
169  va.coef() ;
170  va.ylm() ;
171  va.c_cf->t[nz-1]->annule_hard() ;
172  va.set_etat_cf_qcq() ;
173 
174  const Base_val& base = va.base ;
175  int base_r, l_quant, m_quant ;
176  for (int k=0 ; k<np+1 ; k++)
177  for (int j=0 ; j<nt ; j++)
178  if (nullite_plm(j, nt, k, np, va.base) == 1) {
179 
180  donne_lm (nz, nz-1, j, k, base, m_quant, l_quant, base_r) ;
181 
182  if (l_quant<=lmax) {
183 
184  Matrice systeme (nbre, nbre) ;
185  systeme.set_etat_qcq() ;
186 
187  for (int col=0 ; col<nbre ; col++)
188  for (int lig=0 ; lig<nbre ; lig++) {
189 
190  int facteur = (lig%2==0) ? 1 : -1 ;
191  for (int conte=0 ; conte<lig ; conte++)
192  facteur *= puis+col+conte+2*l_quant ;
193  systeme.set(lig, col) = facteur/pow(r_cont, puis+col+lig+2*l_quant) ;
194  }
195 
196  systeme.set_band(nbre, nbre) ;
197  systeme.set_lu() ;
198 
199  Tbl sec_membre (nbre) ;
200  sec_membre.set_etat_qcq() ;
201  for (int conte=0 ; conte<nbre ; conte++)
202  sec_membre.set(conte) = valeurs(conte, k, j) ;
203 
204  Tbl inv (systeme.inverse(sec_membre)) ;
205 
206  for (int conte=0 ; conte<nbre ; conte++)
207  for (int i=0 ; i<nr ; i++)
208  va.c_cf->set(nz-1, k, j, i)+=
209  inv(conte)*coef(conte+2*l_quant, i) ;
210  }
211  else for (int i=0 ; i<nr ; i++)
212  va.c_cf->set(nz-1, k, j, i)
213  = 0 ;
214  }
215 
216  va.ylm_i() ;
217  set_dzpuis (0) ;
218 }
219 }
const Cmp & dsdr() const
Returns of *this .
Definition: cmp_deriv.C:87
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:312
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
const double * get_alpha() const
Returns the pointer on the array alpha.
Definition: map_af.C:607
void ylm_i()
Inverse of ylm()
Definition: valeur_ylm_i.C:134
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
void set_etat_cf_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl_cf c_c...
Definition: valeur.C:715
void coef() const
Computes the coeffcients of *this.
Definition: valeur_coef.C:151
void set_lu() const
Calculate the LU-representation, assuming the band-storage has been done.
Definition: matrice.C:395
Lorene prototypes.
Definition: app_hor.h:67
Tbl & set(int l)
Read/write of the Tbl containing the coefficients in a given domain.
Definition: mtbl_cf.h:304
Tbl inverse(const Tbl &sec_membre) const
Solves the linear system represented by the matrix.
Definition: matrice.C:427
void ylm()
Computes the coefficients of *this.
Definition: valeur_ylm.C:141
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:783
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: cmp.h:454
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
int get_base_r(int l) const
Returns the expansion basis for r ( ) functions in the domain of index l (e.g.
Definition: base_val.h:403
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
void raccord_c1_zec(int puis, int nbre, int lmax)
Performs the matching of the external domain with respect to the last shell using function like wit...
Matrix handling.
Definition: matrice.h:152
Base_val base
Bases on which the spectral expansion is performed.
Definition: valeur.h:315
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
void dec2_dzpuis()
Decreases by 2 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
Definition: cmp_r_manip.C:183
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
double & set(int j, int i)
Read/write of a particuliar element.
Definition: matrice.h:277
void set_band(int up, int low) const
Calculate the band storage of *std.
Definition: matrice.C:367
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Bases of the spectral expansions.
Definition: base_val.h:325
Affine radial mapping.
Definition: map.h:2048
const Map * mp
Reference mapping.
Definition: cmp.h:451
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: matrice.C:178
void set_dzpuis(int)
Set a value to dzpuis.
Definition: cmp.C:657
Basic array class.
Definition: tbl.h:164
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
void annule_hard()
Sets the Tbl to zero in a hard way.
Definition: tbl.C:375
Valeur va
The numerical value of the Cmp.
Definition: cmp.h:464
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s which contain the spectral coefficients in each domain...
Definition: mtbl_cf.h:215
#define R_CHEB
base de Chebychev ordinaire (fin)
Definition: type_parite.h:166