LORENE
scalar_raccord_externe.C
1/*
2 * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
3 *
4 * Copyright (c) 2001 Philippe Grandclement (for preceding Cmp version)
5 *
6 *
7 * This file is part of LORENE.
8 *
9 * LORENE is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * LORENE is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with LORENE; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25
26
27
28/*
29 * $Id: scalar_raccord_externe.C,v 1.5 2016/12/05 16:18:19 j_novak Exp $
30 * $Log: scalar_raccord_externe.C,v $
31 * Revision 1.5 2016/12/05 16:18:19 j_novak
32 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
33 *
34 * Revision 1.4 2014/10/13 08:53:47 j_novak
35 * Lorene classes and functions now belong to the namespace Lorene.
36 *
37 * Revision 1.3 2014/10/06 15:16:16 j_novak
38 * Modified #include directives to use c++ syntax.
39 *
40 * Revision 1.2 2003/09/25 09:22:33 j_novak
41 * Added a #include<math.h>
42 *
43 * Revision 1.1 2003/09/25 08:58:10 e_gourgoulhon
44 * First version.
45 *
46 *
47 * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_raccord_externe.C,v 1.5 2016/12/05 16:18:19 j_novak Exp $
48 *
49 */
50
51
52
53//standard
54#include <cstdlib>
55#include <cmath>
56
57// LORENE
58#include "matrice.h"
59#include "tensor.h"
60#include "proto.h"
61
62namespace Lorene {
63int cnp (int n, int p) ;
64
65// Fait le raccord dans la zec ...
66// Suppose (pour le moment, le meme nbre de points sur les angles ...)
67// et que la zone precedente est une coquille
68
69void Scalar::raccord_externe(int power, int nbre, int lmax) {
70
71 va.coef() ;
72 va.ylm() ;
73
74 Base_val base_devel (va.base) ;
75 int base_r, m_quant, l_quant ;
76
77 // Confort :
78 int zone = mp->get_mg()->get_nzone()-2 ;
79 int nt = mp->get_mg()->get_nt(zone) ;
80 int np = mp->get_mg()->get_np(zone) ;
81 int nr = mp->get_mg()->get_nr(zone) ;
82
83 // Le mapping doit etre affine :
84 const Map_af* map = dynamic_cast<const Map_af*>(mp) ;
85 if (map == 0x0) {
86 cout << "Le mapping doit etre affine" << endl ;
87 abort() ;
88 }
89
90 // Mappinhg en r
91 double alpha = map->get_alpha()[zone] ;
92 double beta = map->get_beta()[zone] ;
93
94 // Mapping en 1/r
95 double new_alpha = -alpha/(beta*beta-alpha*alpha) ;
96 double new_beta = beta/(beta*beta-alpha*alpha) ;
97
98 // Mapping dans la zec :
99 double alpha_zec = map->get_alpha()[zone+1] ;
100
101 // Maintenant on construit les matrices de passage :
102 // Celle de ksi a T
103 Matrice tksi (nbre, nbre) ;
104 tksi.set_etat_qcq() ;
105
106 // Premier polynome
107 tksi.set(0, 0) = sqrt(double(2)) ;
108 for (int i=1 ; i<nbre ; i++)
109 tksi.set(0, i) = 0 ;
110
111 //Second polynome
112 tksi.set(1, 0) = 0 ;
113 tksi.set(1, 1) = sqrt(double(2)) ;
114 for (int i=2 ; i<nbre ; i++)
115 tksi.set(1, i) = 0 ;
116
117 // On recurre :
118 for (int lig=2 ; lig<nbre ; lig++) {
119 tksi.set(lig, 0) = -tksi(lig-2, 0) ;
120 for (int col=1 ; col<nbre ; col++)
121 tksi.set(lig, col) = 2*tksi(lig-1, col-1)-tksi(lig-2, col) ;
122 }
123
124 // Celle de u/new_alpha a ksi :
125 Matrice ksiu (nbre, nbre) ;
126 ksiu.set_etat_qcq() ;
127
128 for (int lig=0 ; lig<nbre ; lig++) {
129 for (int col=0 ; col<=lig ; col++)
130 ksiu.set(lig, col) = cnp(lig, col)*
131 pow(-new_beta/new_alpha, lig-col) ;
132 for (int col = lig+1 ; col<nbre ; col++)
133 ksiu.set(lig, col) = 0 ;
134 }
135
136 // La matrice totale :
137 Matrice tu (nbre, nbre) ;
138 tu.set_etat_qcq() ;
139 double somme ;
140 for (int lig=0 ; lig<nbre ; lig++)
141 for (int col=0 ; col<nbre ; col++) {
142 somme = 0 ;
143 for (int m=0 ; m<nbre ; m++)
144 somme += tksi(lig, m)*ksiu(m, col) ;
145 tu.set(lig, col) = somme ;
146 }
147
148 // On calcul les coefficients de u^n dans la zec
149 Tbl coef_u (nbre+lmax, nr) ;
150 coef_u.set_etat_qcq() ;
151 int* dege = new int [3] ;
152 dege[0] = 1 ; dege[1] = 1 ; dege[2] = nr ;
153 double* ti = new double [nr] ;
154
155 for (int puiss=0 ; puiss<nbre+lmax ; puiss++) {
156 for (int i=0 ; i<nr ; i++)
157 ti[i] = pow(-cos(M_PI*i/(nr-1))-1, puiss) ;
158 cfrcheb (dege, dege, ti, dege, ti) ;
159 for (int i=0 ; i<nr ; i++)
160 coef_u.set(puiss, i) = ti[i] ;
161 }
162
163 // Avant d entrer dans la boucle :
164 dege[2] = nbre ;
165 double *coloc = new double[nbre] ;
166 double *auxi = new double [1] ;
167
168 Tbl coef_zec (np+2, nt, nr) ;
169 coef_zec.annule_hard() ;
170
171 // Boucle sur les harmoniques :
172
173 for (int k=0 ; k<np+2 ; k++)
174 for (int j=0 ; j<nt ; j++)
175 if (nullite_plm (j, nt, k, np, base_devel)==1) {
176 donne_lm (zone+2, zone+1, j, k, base_devel, m_quant,
177 l_quant, base_r) ;
178 if (l_quant <= lmax) {
179
180 // On bosse :
181 // On recupere les valeus aux points de colocation en 1/r :
182 double ksi, air ;
183 for (int i=0 ; i<nbre ; i++) {
184 ksi = -cos(M_PI*i/(nbre-1)) ;
185 air = 1./(new_alpha*ksi+new_beta) ;
186 ksi = (air-beta)/alpha ;
187 for (int m=0 ; m<nr ; m++)
188 ti[m] = (*va.c_cf)(zone, k, j, m) ;
189 som_r_cheb (ti, nr, 1, 1, ksi, auxi) ;
190 coloc[i] = auxi[0]/
191 pow (-new_alpha*cos(M_PI*i/(nbre-1))+new_beta, power+l_quant);
192 }
193
194 cfrcheb (dege, dege, coloc, dege, coloc) ;
195
196 Tbl expansion (nbre) ;
197 expansion.set_etat_qcq() ;
198 for (int i=0 ; i<nbre ; i++) {
199 somme = 0 ;
200 for (int m=0 ; m<nbre ; m++)
201 somme += coloc[m]*tu(m, i) ;
202 expansion.set(i) = somme ;
203 }
204
205 for (int i=0 ; i<nr ; i++) {
206 somme = 0 ;
207 for (int m=0 ; m<nbre ; m++)
208 somme += coef_u(m+l_quant, i)*expansion(m)*
209 pow(alpha_zec, m+l_quant)/
210 pow(new_alpha, m) ;
211 coef_zec.set(k, j, i) = somme ;
212 }
213 }
214 }
215
216 va.set_etat_cf_qcq() ;
217 va.c_cf->set_etat_qcq() ;
218 va.c_cf->t[zone+1]->set_etat_qcq() ;
219
220 for (int k=0 ; k<np+2 ; k++)
221 for (int j=0 ; j<nt ; j++)
222 for (int i=0 ; i<nr ; i++)
223 va.c_cf->set(zone+1, k, j, i) = coef_zec(k, j, i) ;
224
225 set_dzpuis(power) ;
226 va.ylm_i() ;
227
228 delete[] auxi ;
229 delete [] dege ;
230 delete [] ti ;
231 delete [] coloc ;
232}
233}
Bases of the spectral expansions.
Definition base_val.h:325
Affine radial mapping.
Definition map.h:2042
const double * get_beta() const
Returns the pointer on the array beta.
Definition map_af.C:608
const double * get_alpha() const
Returns the pointer on the array alpha.
Definition map_af.C:604
Matrix handling.
Definition matrice.h:152
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition matrice.C:178
double & set(int j, int i)
Read/write of a particuliar element.
Definition matrice.h:277
friend Scalar cos(const Scalar &)
Cosine.
void raccord_externe(int puis, int nbre, int lmax)
Matching of the external domain with the outermost shell.
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition scalar.C:814
Valeur va
The numerical value of the Scalar.
Definition scalar.h:411
friend Scalar sqrt(const Scalar &)
Square root.
friend Scalar pow(const Scalar &, int)
Power .
Basic array class.
Definition tbl.h:161
void annule_hard()
Sets the Tbl to zero in a hard way.
Definition tbl.C:375
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition tbl.C:364
double & set(int i)
Read/write of a particular element (index i) (1D case).
Definition tbl.h:281
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition tensor.h:301
Lorene prototypes.
Definition app_hor.h:67