LORENE
map_et_poisson_ylm.C
1/*
2 * Method of the class Map_et for the (iterative) resolution of the scalar
3 * Poisson equation with a multipole falloff condition at the outer boundary
4 *
5 * (see file map.h for documentation).
6 *
7 */
8
9/*
10 * Copyright (c) 2004 Joshua A. Faber
11 *
12 * This file is part of LORENE.
13 *
14 * LORENE is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License version 2
16 * as published by the Free Software Foundation.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29
30
31/*
32 * $Id: map_et_poisson_ylm.C,v 1.3 2016/12/05 16:17:58 j_novak Exp $
33 * $Log: map_et_poisson_ylm.C,v $
34 * Revision 1.3 2016/12/05 16:17:58 j_novak
35 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36 *
37 * Revision 1.2 2014/10/13 08:53:05 j_novak
38 * Lorene classes and functions now belong to the namespace Lorene.
39 *
40 * Revision 1.1 2004/12/30 15:56:42 k_taniguchi
41 * *** empty log message ***
42 *
43 *
44 * $Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson_ylm.C,v 1.3 2016/12/05 16:17:58 j_novak Exp $
45 *
46 */
47
48// Lorene headers
49#include "map.h"
50#include "cmp.h"
51#include "param.h"
52
53//*****************************************************************************
54
55namespace Lorene {
56
57void Map_et::poisson_ylm(const Cmp& source, Param& par, Cmp& uu, int nylm, double* intvec) const {
58
59 assert(source.get_etat() != ETATNONDEF) ;
60 assert(source.get_mp() == this) ;
61
62 assert(uu.get_mp() == this) ;
63
64
65 int nz = mg->get_nzone() ;
66
67 //-------------------------------
68 // Computation of the prefactor a ---> Cmp apre
69 //-------------------------------
70
71 Mtbl unjj = 1 + srdrdt*srdrdt + srstdrdp*srstdrdp ;
72
73 Mtbl apre1(*mg) ;
74 apre1.set_etat_qcq() ;
75 for (int l=0; l<nz; l++) {
76 *(apre1.t[l]) = alpha[l]*alpha[l] ;
77 }
78
79 apre1 = apre1 * dxdr * dxdr * unjj ;
80
81
82 Cmp apre(*this) ;
83 apre = apre1 ;
84
85 Tbl amax0 = max(apre1) ; // maximum values in each domain
86
87 // The maximum values of a in each domain are put in a Mtbl
88 Mtbl amax1(*mg) ;
89 amax1.set_etat_qcq() ;
90 for (int l=0; l<nz; l++) {
91 *(amax1.t[l]) = amax0(l) ;
92 }
93
94 Cmp amax(*this) ;
95 amax = amax1 ;
96
97 //-------------------
98 // Initializations
99 //-------------------
100
101 int nitermax = par.get_int() ;
102 int& niter = par.get_int_mod() ;
103 double lambda = par.get_double() ;
104 lambda=1.0;
105 double unmlambda = 1. - lambda ;
106 double precis = par.get_double(1) ;
107
108 cout <<"relax in map_et:"<<lambda<<" "<<unmlambda<<endl;
109
110 Cmp& ssj = par.get_cmp_mod() ;
111
112 Cmp ssjm1 = ssj ;
113 Cmp ssjm2 = ssjm1 ;
114
115 Valeur& vuu = uu.va ;
116
117 Valeur vuujm1(*mg) ;
118 if (uu.get_etat() == ETATZERO) {
119 vuujm1 = 1 ; // to take relative differences
120 vuujm1.set_base( vuu.base ) ;
121 }
122 else{
123 vuujm1 = vuu ;
124 }
125
126 // Affine mapping for the Laplacian-tilde
127
128 Map_af mpaff(*this) ;
129 Param par_nul ;
130
131 cout << "Map_et::poisson : relat. diff. u^J <-> u^{J-1} : " << endl ;
132
133//==========================================================================
134//==========================================================================
135// Start of iteration
136//==========================================================================
137//==========================================================================
138
139 Tbl tdiff(nz) ;
140 double diff ;
141 niter = 0 ;
142
143 do {
144
145 //====================================================================
146 // Computation of R(u) (the result is put in uu)
147 //====================================================================
148
149
150 //-----------------------
151 // First operations on uu
152 //-----------------------
153
154 Valeur duudx = (uu.va).dsdx() ; // d/dx
155
156 const Valeur& d2uudtdx = duudx.dsdt() ; // d^2/dxdtheta
157
158 const Valeur& std2uudpdx = duudx.stdsdp() ; // 1/sin(theta) d^2/dxdphi
159
160 //------------------
161 // Angular Laplacian
162 //------------------
163
164 Valeur sxlapang = uu.va ;
165
166 sxlapang.ylm() ;
167
168 sxlapang = sxlapang.lapang() ;
169
170 sxlapang = sxlapang.sx() ; // Lap_ang(uu) /x in the nucleus
171 // Lap_ang(uu) in the shells
172 // Lap_ang(uu) /(x-1) in the ZEC
173
174 //---------------------------------------------------------------
175 // Computation of
176 // [ 2 /(dRdx) ( A - 1 ) duu/dx + 1/R (B - 1) Lap_ang(uu) ] / x
177 //
178 // with A = 1/(dRdx) R/(x+beta_l/alpha_l) unjj
179 // B = [1/(dRdx) R/(x+beta_l/alpha_l)]^2 unjj
180 //
181 // The result is put in uu (via vuu)
182 //---------------------------------------------------------------
183
184 Valeur varduudx = duudx ;
185
186 uu.set_etat_qcq() ;
187
188 Base_val sauve_base = varduudx.base ;
189
190 vuu = 2. * dxdr * ( rsxdxdr * unjj - 1.) * varduudx
191 + ( rsxdxdr*rsxdxdr * unjj - 1.) * xsr * sxlapang ;
192
193 vuu.set_base(sauve_base) ;
194
195 vuu = vuu.sx() ;
196
197 //---------------------------------------
198 // Computation of R(u)
199 //
200 // The result is put in uu (via vuu)
201 //---------------------------------------
202
203
204 sauve_base = vuu.base ;
205
206 vuu = xsr * vuu
207 + 2. * dxdr * ( sr2drdt * d2uudtdx
208 + sr2stdrdp * std2uudpdx ) ;
209
210 vuu += dxdr * ( lapr_tp + dxdr * (
211 dxdr* unjj * d2rdx2
212 - 2. * ( sr2drdt * d2rdtdx + sr2stdrdp * sstd2rdpdx ) )
213 ) * duudx ;
214
215 vuu.set_base(sauve_base) ;
216
217 // Since the assignment is performed on vuu (uu.va), the treatment
218 // of uu.dzpuis must be performed by hand:
219
220
221 //====================================================================
222 // Computation of the effective source s^J of the ``affine''
223 // Poisson equation
224 //====================================================================
225
226 ssj = lambda * ssjm1 + unmlambda * ssjm2 ;
227
228 ssj = ( source + uu + (amax - apre) * ssj ) / amax ;
229
230 (ssj.va).set_base((source.va).base) ;
231
232 //====================================================================
233 // Resolution of the ``affine'' Poisson equation
234 //====================================================================
235
236 // *****************************************************************
237
238 mpaff.poisson_ylm(ssj, par_nul, uu, nylm, intvec) ;
239
240 // *****************************************************************
241
242 tdiff = diffrel(vuu, vuujm1) ;
243
244 diff = max(tdiff) ;
245
246
247 cout << " iter: " << niter << " : " ;
248 for (int l=0; l<nz; l++) {
249 cout << tdiff(l) << " " ;
250 }
251 cout << endl ;
252
253 //=================================
254 // Updates for the next iteration
255 //=================================
256
257 ssjm2 = ssjm1 ;
258 ssjm1 = ssj ;
259 vuujm1 = vuu ;
260
261 niter++ ;
262
263 } // End of iteration
264 while ( (diff > precis) && (niter < nitermax) ) ;
265
266//==========================================================================
267//==========================================================================
268// End of iteration
269//==========================================================================
270//==========================================================================
271
272
273
274}
275
276
277}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
Coord rsxdxdr
in the nucleus; \ in the shells; \ in the outermost compactified domain.
Definition map.h:2852
double * alpha
Array (size: mg->nzone ) of the values of in each domain.
Definition map.h:2776
Coord d2rdx2
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1634
Coord sr2drdt
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1615
Coord srstdrdp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1607
Coord d2rdtdx
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1655
Coord sstd2rdpdx
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1663
Coord lapr_tp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1646
Coord sr2stdrdp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1623
Coord srdrdt
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1599
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1564
Coord dxdr
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1575
Parameter storage.
Definition param.h:125
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition cmp_math.C:507
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition cmp_math.C:438
Lorene prototypes.
Definition app_hor.h:67