| 1 |
/* |
| 2 |
* Method of the class Map_et for the (iterative) resolution of the scalar |
| 3 |
* Poisson equation. |
| 4 |
* |
| 5 |
* (see file map.h for the documentation). |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
/* |
| 10 |
* Copyright (c) 2004 Francois Limousin |
| 11 |
* Copyright (c) 1999-2003 Eric Gourgoulhon |
| 12 |
* Copyright (c) 2000-2001 Philippe Grandclement |
| 13 |
* |
| 14 |
* This file is part of LORENE. |
| 15 |
* |
| 16 |
* LORENE is free software; you can redistribute it and/or modify |
| 17 |
* it under the terms of the GNU General Public License as published by |
| 18 |
* the Free Software Foundation; either version 2 of the License, or |
| 19 |
* (at your option) any later version. |
| 20 |
* |
| 21 |
* LORENE is distributed in the hope that it will be useful, |
| 22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
* GNU General Public License for more details. |
| 25 |
* |
| 26 |
* You should have received a copy of the GNU General Public License |
| 27 |
* along with LORENE; if not, write to the Free Software |
| 28 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 29 |
* |
| 30 |
*/ |
| 31 |
|
| 32 |
|
| 33 |
char map_et_poisson_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson.C,v 1.7 2014/10/13 08:53:05 j_novak Exp $" ; |
| 34 |
|
| 35 |
|
| 36 |
/* |
| 37 |
* $Id: map_et_poisson.C,v 1.7 2014/10/13 08:53:05 j_novak Exp $ |
| 38 |
* $Log: map_et_poisson.C,v $ |
| 39 |
* Revision 1.7 2014/10/13 08:53:05 j_novak |
| 40 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 41 |
* |
| 42 |
* Revision 1.6 2005/08/25 12:14:09 p_grandclement |
| 43 |
* Addition of a new method to solve the scalar Poisson equation, based on a multi-domain Tau-method |
| 44 |
* |
| 45 |
* Revision 1.5 2005/04/04 21:31:31 e_gourgoulhon |
| 46 |
* Added argument lambda to method poisson_angu |
| 47 |
* to deal with the generalized angular Poisson equation: |
| 48 |
* Lap_ang u + lambda u = source. |
| 49 |
* |
| 50 |
* Revision 1.4 2004/06/22 12:20:17 j_novak |
| 51 |
* *** empty log message *** |
| 52 |
* |
| 53 |
* Revision 1.3 2004/05/25 14:28:01 f_limousin |
| 54 |
* First version of method Map_et::poisson_angu(). |
| 55 |
* |
| 56 |
* Revision 1.2 2003/10/15 21:11:26 e_gourgoulhon |
| 57 |
* Added method poisson_angu. |
| 58 |
* |
| 59 |
* Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 60 |
* LORENE |
| 61 |
* |
| 62 |
* Revision 1.7 2000/05/22 14:55:30 phil |
| 63 |
* ajout du cas dzpuis = 3 |
| 64 |
* |
| 65 |
* Revision 1.6 2000/03/30 09:18:37 eric |
| 66 |
* Modifs affichage. |
| 67 |
* |
| 68 |
* Revision 1.5 2000/03/29 12:01:38 eric |
| 69 |
* *** empty log message *** |
| 70 |
* |
| 71 |
* Revision 1.4 2000/03/29 11:48:09 eric |
| 72 |
* Modifs affichage. |
| 73 |
* |
| 74 |
* Revision 1.3 2000/03/10 15:48:25 eric |
| 75 |
* MODIFS IMPORTANTES: |
| 76 |
* ssj est desormais traitee comme un Cmp (et non plus une Valeur) ce qui |
| 77 |
* permet un traitement automatique du dzpuis associe. |
| 78 |
* Traitement de dzpuis. |
| 79 |
* |
| 80 |
* Revision 1.2 2000/03/07 16:50:57 eric |
| 81 |
* Possibilite d'avoir une source avec dzpuis = 2. |
| 82 |
* |
| 83 |
* Revision 1.1 1999/12/22 17:11:24 eric |
| 84 |
* Initial revision |
| 85 |
* |
| 86 |
* |
| 87 |
* $Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson.C,v 1.7 2014/10/13 08:53:05 j_novak Exp $ |
| 88 |
* |
| 89 |
*/ |
| 90 |
|
| 91 |
// Header Lorene: |
| 92 |
#include "map.h" |
| 93 |
#include "cmp.h" |
| 94 |
#include "scalar.h" |
| 95 |
#include "param.h" |
| 96 |
#include "graphique.h" |
| 97 |
|
| 98 |
//***************************************************************************** |
| 99 |
|
| 100 |
namespace Lorene { |
| 101 |
|
| 102 |
void Map_et::poisson(const Cmp& source, Param& par, Cmp& uu) const { |
| 103 |
|
| 104 |
assert(source.get_etat() != ETATNONDEF) ; |
| 105 |
assert(source.get_mp() == this) ; |
| 106 |
|
| 107 |
assert( source.check_dzpuis(2) || source.check_dzpuis(4) |
| 108 |
|| source.check_dzpuis(3)) ; |
| 109 |
|
| 110 |
assert(uu.get_mp() == this) ; |
| 111 |
assert(uu.check_dzpuis(0)) ; |
| 112 |
|
| 113 |
int nz = mg->get_nzone() ; |
| 114 |
int nzm1 = nz - 1 ; |
| 115 |
|
| 116 |
// Indicator of existence of a compactified external domain |
| 117 |
bool zec = false ; |
| 118 |
if (mg->get_type_r(nzm1) == UNSURR) { |
| 119 |
zec = true ; |
| 120 |
} |
| 121 |
|
| 122 |
//------------------------------- |
| 123 |
// Computation of the prefactor a ---> Cmp apre |
| 124 |
//------------------------------- |
| 125 |
|
| 126 |
Mtbl unjj = 1 + srdrdt*srdrdt + srstdrdp*srstdrdp ; |
| 127 |
|
| 128 |
Mtbl apre1(*mg) ; |
| 129 |
apre1.set_etat_qcq() ; |
| 130 |
for (int l=0; l<nz; l++) { |
| 131 |
*(apre1.t[l]) = alpha[l]*alpha[l] ; |
| 132 |
} |
| 133 |
|
| 134 |
apre1 = apre1 * dxdr * dxdr * unjj ; |
| 135 |
|
| 136 |
Cmp apre(*this) ; |
| 137 |
apre = apre1 ; |
| 138 |
|
| 139 |
Tbl amax0 = max(apre1) ; // maximum values in each domain |
| 140 |
|
| 141 |
// The maximum values of a in each domain are put in a Mtbl |
| 142 |
Mtbl amax1(*mg) ; |
| 143 |
amax1.set_etat_qcq() ; |
| 144 |
for (int l=0; l<nz; l++) { |
| 145 |
*(amax1.t[l]) = amax0(l) ; |
| 146 |
} |
| 147 |
|
| 148 |
Cmp amax(*this) ; |
| 149 |
amax = amax1 ; |
| 150 |
|
| 151 |
|
| 152 |
//------------------- |
| 153 |
// Initializations |
| 154 |
//------------------- |
| 155 |
|
| 156 |
int nitermax = par.get_int() ; |
| 157 |
int& niter = par.get_int_mod() ; |
| 158 |
double lambda = par.get_double() ; |
| 159 |
double unmlambda = 1. - lambda ; |
| 160 |
double precis = par.get_double(1) ; |
| 161 |
|
| 162 |
Cmp& ssj = par.get_cmp_mod() ; |
| 163 |
|
| 164 |
Cmp ssjm1 = ssj ; |
| 165 |
Cmp ssjm2 = ssjm1 ; |
| 166 |
|
| 167 |
Valeur& vuu = uu.va ; |
| 168 |
|
| 169 |
Valeur vuujm1(*mg) ; |
| 170 |
if (uu.get_etat() == ETATZERO) { |
| 171 |
vuujm1 = 1 ; // to take relative differences |
| 172 |
vuujm1.set_base( vuu.base ) ; |
| 173 |
} |
| 174 |
else{ |
| 175 |
vuujm1 = vuu ; |
| 176 |
} |
| 177 |
|
| 178 |
// Affine mapping for the Laplacian-tilde |
| 179 |
|
| 180 |
Map_af mpaff(*this) ; |
| 181 |
Param par_nul ; |
| 182 |
|
| 183 |
cout << "Map_et::poisson : relat. diff. u^J <-> u^{J-1} : " << endl ; |
| 184 |
|
| 185 |
//========================================================================== |
| 186 |
//========================================================================== |
| 187 |
// Start of iteration |
| 188 |
//========================================================================== |
| 189 |
//========================================================================== |
| 190 |
|
| 191 |
Tbl tdiff(nz) ; |
| 192 |
double diff ; |
| 193 |
niter = 0 ; |
| 194 |
|
| 195 |
do { |
| 196 |
|
| 197 |
//==================================================================== |
| 198 |
// Computation of R(u) (the result is put in uu) |
| 199 |
//==================================================================== |
| 200 |
|
| 201 |
|
| 202 |
//----------------------- |
| 203 |
// First operations on uu |
| 204 |
//----------------------- |
| 205 |
|
| 206 |
Valeur duudx = (uu.va).dsdx() ; // d/dx |
| 207 |
|
| 208 |
const Valeur& d2uudtdx = duudx.dsdt() ; // d^2/dxdtheta |
| 209 |
|
| 210 |
const Valeur& std2uudpdx = duudx.stdsdp() ; // 1/sin(theta) d^2/dxdphi |
| 211 |
|
| 212 |
//------------------ |
| 213 |
// Angular Laplacian |
| 214 |
//------------------ |
| 215 |
|
| 216 |
Valeur sxlapang = uu.va ; |
| 217 |
|
| 218 |
sxlapang.ylm() ; |
| 219 |
|
| 220 |
sxlapang = sxlapang.lapang() ; |
| 221 |
|
| 222 |
sxlapang = sxlapang.sx() ; // Lap_ang(uu) /x in the nucleus |
| 223 |
// Lap_ang(uu) in the shells |
| 224 |
// Lap_ang(uu) /(x-1) in the ZEC |
| 225 |
|
| 226 |
//--------------------------------------------------------------- |
| 227 |
// Computation of |
| 228 |
// [ 2 /(dRdx) ( A - 1 ) duu/dx + 1/R (B - 1) Lap_ang(uu) ] / x |
| 229 |
// |
| 230 |
// with A = 1/(dRdx) R/(x+beta_l/alpha_l) unjj |
| 231 |
// B = [1/(dRdx) R/(x+beta_l/alpha_l)]^2 unjj |
| 232 |
// |
| 233 |
// The result is put in uu (via vuu) |
| 234 |
//--------------------------------------------------------------- |
| 235 |
|
| 236 |
Valeur varduudx = duudx ; |
| 237 |
|
| 238 |
if (zec) { |
| 239 |
varduudx.annule(nzm1) ; // term in d/dx set to zero in the ZEC |
| 240 |
} |
| 241 |
|
| 242 |
uu.set_etat_qcq() ; |
| 243 |
|
| 244 |
Base_val sauve_base = varduudx.base ; |
| 245 |
|
| 246 |
vuu = 2. * dxdr * ( rsxdxdr * unjj - 1.) * varduudx |
| 247 |
+ ( rsxdxdr*rsxdxdr * unjj - 1.) * xsr * sxlapang ; |
| 248 |
|
| 249 |
vuu.set_base(sauve_base) ; |
| 250 |
|
| 251 |
vuu = vuu.sx() ; |
| 252 |
|
| 253 |
//--------------------------------------- |
| 254 |
// Computation of R(u) |
| 255 |
// |
| 256 |
// The result is put in uu (via vuu) |
| 257 |
//--------------------------------------- |
| 258 |
|
| 259 |
|
| 260 |
sauve_base = vuu.base ; |
| 261 |
|
| 262 |
vuu = xsr * vuu |
| 263 |
+ 2. * dxdr * ( sr2drdt * d2uudtdx |
| 264 |
+ sr2stdrdp * std2uudpdx ) ; |
| 265 |
|
| 266 |
vuu += dxdr * ( lapr_tp + dxdr * ( |
| 267 |
dxdr* unjj * d2rdx2 |
| 268 |
- 2. * ( sr2drdt * d2rdtdx + sr2stdrdp * sstd2rdpdx ) ) |
| 269 |
) * duudx ; |
| 270 |
|
| 271 |
vuu.set_base(sauve_base) ; |
| 272 |
|
| 273 |
// Since the assignment is performed on vuu (uu.va), the treatment |
| 274 |
// of uu.dzpuis must be performed by hand: |
| 275 |
|
| 276 |
uu.set_dzpuis(4) ; |
| 277 |
|
| 278 |
if (source.get_dzpuis() == 2) { |
| 279 |
uu.dec2_dzpuis() ; // uu.dzpuis: 4 -> 2 |
| 280 |
} |
| 281 |
|
| 282 |
if (source.get_dzpuis() == 3) { |
| 283 |
uu.dec_dzpuis() ; //uu.dzpuis 4 -> 3 |
| 284 |
} |
| 285 |
|
| 286 |
//==================================================================== |
| 287 |
// Computation of the effective source s^J of the ``affine'' |
| 288 |
// Poisson equation |
| 289 |
//==================================================================== |
| 290 |
|
| 291 |
ssj = lambda * ssjm1 + unmlambda * ssjm2 ; |
| 292 |
|
| 293 |
ssj = ( source + uu + (amax - apre) * ssj ) / amax ; |
| 294 |
|
| 295 |
(ssj.va).set_base((source.va).base) ; |
| 296 |
|
| 297 |
//==================================================================== |
| 298 |
// Resolution of the ``affine'' Poisson equation |
| 299 |
//==================================================================== |
| 300 |
|
| 301 |
if ( source.get_dzpuis() == 0 ){ |
| 302 |
ssj.set_dzpuis( 4 ) ; |
| 303 |
} |
| 304 |
else { |
| 305 |
ssj.set_dzpuis( source.get_dzpuis() ) ; // Choice of the resolution |
| 306 |
// dzpuis = 2, 3 or 4 |
| 307 |
} |
| 308 |
|
| 309 |
assert( uu.check_dzpuis( ssj.get_dzpuis() ) ) ; |
| 310 |
|
| 311 |
mpaff.poisson(ssj, par_nul, uu) ; |
| 312 |
|
| 313 |
tdiff = diffrel(vuu, vuujm1) ; |
| 314 |
|
| 315 |
diff = max(tdiff) ; |
| 316 |
|
| 317 |
|
| 318 |
cout << " step " << niter << " : " ; |
| 319 |
for (int l=0; l<nz; l++) { |
| 320 |
cout << tdiff(l) << " " ; |
| 321 |
} |
| 322 |
cout << endl ; |
| 323 |
|
| 324 |
//================================= |
| 325 |
// Updates for the next iteration |
| 326 |
//================================= |
| 327 |
|
| 328 |
ssjm2 = ssjm1 ; |
| 329 |
ssjm1 = ssj ; |
| 330 |
vuujm1 = vuu ; |
| 331 |
|
| 332 |
niter++ ; |
| 333 |
|
| 334 |
} // End of iteration |
| 335 |
while ( (diff > precis) && (niter < nitermax) ) ; |
| 336 |
|
| 337 |
//========================================================================== |
| 338 |
//========================================================================== |
| 339 |
// End of iteration |
| 340 |
//========================================================================== |
| 341 |
//========================================================================== |
| 342 |
|
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
//***************************************************************************** |
| 348 |
// VERSION WITH A TAU METHOD |
| 349 |
//***************************************************************************** |
| 350 |
|
| 351 |
void Map_et::poisson_tau(const Cmp& source, Param& par, Cmp& uu) const { |
| 352 |
|
| 353 |
assert(source.get_etat() != ETATNONDEF) ; |
| 354 |
assert(source.get_mp() == this) ; |
| 355 |
|
| 356 |
assert( source.check_dzpuis(2) || source.check_dzpuis(4) |
| 357 |
|| source.check_dzpuis(3)) ; |
| 358 |
|
| 359 |
assert(uu.get_mp() == this) ; |
| 360 |
assert(uu.check_dzpuis(0)) ; |
| 361 |
|
| 362 |
int nz = mg->get_nzone() ; |
| 363 |
int nzm1 = nz - 1 ; |
| 364 |
|
| 365 |
// Indicator of existence of a compactified external domain |
| 366 |
bool zec = false ; |
| 367 |
if (mg->get_type_r(nzm1) == UNSURR) { |
| 368 |
zec = true ; |
| 369 |
} |
| 370 |
|
| 371 |
//------------------------------- |
| 372 |
// Computation of the prefactor a ---> Cmp apre |
| 373 |
//------------------------------- |
| 374 |
|
| 375 |
Mtbl unjj = 1 + srdrdt*srdrdt + srstdrdp*srstdrdp ; |
| 376 |
|
| 377 |
Mtbl apre1(*mg) ; |
| 378 |
apre1.set_etat_qcq() ; |
| 379 |
for (int l=0; l<nz; l++) { |
| 380 |
*(apre1.t[l]) = alpha[l]*alpha[l] ; |
| 381 |
} |
| 382 |
|
| 383 |
apre1 = apre1 * dxdr * dxdr * unjj ; |
| 384 |
|
| 385 |
Cmp apre(*this) ; |
| 386 |
apre = apre1 ; |
| 387 |
|
| 388 |
Tbl amax0 = max(apre1) ; // maximum values in each domain |
| 389 |
|
| 390 |
// The maximum values of a in each domain are put in a Mtbl |
| 391 |
Mtbl amax1(*mg) ; |
| 392 |
amax1.set_etat_qcq() ; |
| 393 |
for (int l=0; l<nz; l++) { |
| 394 |
*(amax1.t[l]) = amax0(l) ; |
| 395 |
} |
| 396 |
|
| 397 |
Cmp amax(*this) ; |
| 398 |
amax = amax1 ; |
| 399 |
|
| 400 |
|
| 401 |
//------------------- |
| 402 |
// Initializations |
| 403 |
//------------------- |
| 404 |
|
| 405 |
int nitermax = par.get_int() ; |
| 406 |
int& niter = par.get_int_mod() ; |
| 407 |
double lambda = par.get_double() ; |
| 408 |
double unmlambda = 1. - lambda ; |
| 409 |
double precis = par.get_double(1) ; |
| 410 |
|
| 411 |
Cmp& ssj = par.get_cmp_mod() ; |
| 412 |
|
| 413 |
Cmp ssjm1 = ssj ; |
| 414 |
Cmp ssjm2 = ssjm1 ; |
| 415 |
|
| 416 |
Valeur& vuu = uu.va ; |
| 417 |
|
| 418 |
Valeur vuujm1(*mg) ; |
| 419 |
if (uu.get_etat() == ETATZERO) { |
| 420 |
vuujm1 = 1 ; // to take relative differences |
| 421 |
vuujm1.set_base( vuu.base ) ; |
| 422 |
} |
| 423 |
else{ |
| 424 |
vuujm1 = vuu ; |
| 425 |
} |
| 426 |
|
| 427 |
// Affine mapping for the Laplacian-tilde |
| 428 |
|
| 429 |
Map_af mpaff(*this) ; |
| 430 |
Param par_nul ; |
| 431 |
|
| 432 |
cout << "Map_et::poisson_tau : relat. diff. u^J <-> u^{J-1} : " << endl ; |
| 433 |
|
| 434 |
//========================================================================== |
| 435 |
//========================================================================== |
| 436 |
// Start of iteration |
| 437 |
//========================================================================== |
| 438 |
//========================================================================== |
| 439 |
|
| 440 |
Tbl tdiff(nz) ; |
| 441 |
double diff ; |
| 442 |
niter = 0 ; |
| 443 |
|
| 444 |
do { |
| 445 |
|
| 446 |
//==================================================================== |
| 447 |
// Computation of R(u) (the result is put in uu) |
| 448 |
//==================================================================== |
| 449 |
|
| 450 |
|
| 451 |
//----------------------- |
| 452 |
// First operations on uu |
| 453 |
//----------------------- |
| 454 |
|
| 455 |
Valeur duudx = (uu.va).dsdx() ; // d/dx |
| 456 |
|
| 457 |
const Valeur& d2uudtdx = duudx.dsdt() ; // d^2/dxdtheta |
| 458 |
|
| 459 |
const Valeur& std2uudpdx = duudx.stdsdp() ; // 1/sin(theta) d^2/dxdphi |
| 460 |
|
| 461 |
//------------------ |
| 462 |
// Angular Laplacian |
| 463 |
//------------------ |
| 464 |
|
| 465 |
Valeur sxlapang = uu.va ; |
| 466 |
|
| 467 |
sxlapang.ylm() ; |
| 468 |
|
| 469 |
sxlapang = sxlapang.lapang() ; |
| 470 |
|
| 471 |
sxlapang = sxlapang.sx() ; // Lap_ang(uu) /x in the nucleus |
| 472 |
// Lap_ang(uu) in the shells |
| 473 |
// Lap_ang(uu) /(x-1) in the ZEC |
| 474 |
|
| 475 |
//--------------------------------------------------------------- |
| 476 |
// Computation of |
| 477 |
// [ 2 /(dRdx) ( A - 1 ) duu/dx + 1/R (B - 1) Lap_ang(uu) ] / x |
| 478 |
// |
| 479 |
// with A = 1/(dRdx) R/(x+beta_l/alpha_l) unjj |
| 480 |
// B = [1/(dRdx) R/(x+beta_l/alpha_l)]^2 unjj |
| 481 |
// |
| 482 |
// The result is put in uu (via vuu) |
| 483 |
//--------------------------------------------------------------- |
| 484 |
|
| 485 |
Valeur varduudx = duudx ; |
| 486 |
|
| 487 |
if (zec) { |
| 488 |
varduudx.annule(nzm1) ; // term in d/dx set to zero in the ZEC |
| 489 |
} |
| 490 |
|
| 491 |
uu.set_etat_qcq() ; |
| 492 |
|
| 493 |
Base_val sauve_base = varduudx.base ; |
| 494 |
|
| 495 |
vuu = 2. * dxdr * ( rsxdxdr * unjj - 1.) * varduudx |
| 496 |
+ ( rsxdxdr*rsxdxdr * unjj - 1.) * xsr * sxlapang ; |
| 497 |
|
| 498 |
vuu.set_base(sauve_base) ; |
| 499 |
|
| 500 |
vuu = vuu.sx() ; |
| 501 |
|
| 502 |
//--------------------------------------- |
| 503 |
// Computation of R(u) |
| 504 |
// |
| 505 |
// The result is put in uu (via vuu) |
| 506 |
//--------------------------------------- |
| 507 |
|
| 508 |
|
| 509 |
sauve_base = vuu.base ; |
| 510 |
|
| 511 |
vuu = xsr * vuu |
| 512 |
+ 2. * dxdr * ( sr2drdt * d2uudtdx |
| 513 |
+ sr2stdrdp * std2uudpdx ) ; |
| 514 |
|
| 515 |
vuu += dxdr * ( lapr_tp + dxdr * ( |
| 516 |
dxdr* unjj * d2rdx2 |
| 517 |
- 2. * ( sr2drdt * d2rdtdx + sr2stdrdp * sstd2rdpdx ) ) |
| 518 |
) * duudx ; |
| 519 |
|
| 520 |
vuu.set_base(sauve_base) ; |
| 521 |
|
| 522 |
// Since the assignment is performed on vuu (uu.va), the treatment |
| 523 |
// of uu.dzpuis must be performed by hand: |
| 524 |
|
| 525 |
uu.set_dzpuis(4) ; |
| 526 |
|
| 527 |
if (source.get_dzpuis() == 2) { |
| 528 |
uu.dec2_dzpuis() ; // uu.dzpuis: 4 -> 2 |
| 529 |
} |
| 530 |
|
| 531 |
if (source.get_dzpuis() == 3) { |
| 532 |
uu.dec_dzpuis() ; //uu.dzpuis 4 -> 3 |
| 533 |
} |
| 534 |
|
| 535 |
//==================================================================== |
| 536 |
// Computation of the effective source s^J of the ``affine'' |
| 537 |
// Poisson equation |
| 538 |
//==================================================================== |
| 539 |
|
| 540 |
ssj = lambda * ssjm1 + unmlambda * ssjm2 ; |
| 541 |
|
| 542 |
ssj = ( source + uu + (amax - apre) * ssj ) / amax ; |
| 543 |
|
| 544 |
(ssj.va).set_base((source.va).base) ; |
| 545 |
|
| 546 |
//==================================================================== |
| 547 |
// Resolution of the ``affine'' Poisson equation |
| 548 |
//==================================================================== |
| 549 |
|
| 550 |
if ( source.get_dzpuis() == 0 ){ |
| 551 |
ssj.set_dzpuis( 4 ) ; |
| 552 |
} |
| 553 |
else { |
| 554 |
ssj.set_dzpuis( source.get_dzpuis() ) ; // Choice of the resolution |
| 555 |
// dzpuis = 2, 3 or 4 |
| 556 |
} |
| 557 |
|
| 558 |
assert( uu.check_dzpuis( ssj.get_dzpuis() ) ) ; |
| 559 |
|
| 560 |
mpaff.poisson_tau(ssj, par_nul, uu) ; |
| 561 |
|
| 562 |
tdiff = diffrel(vuu, vuujm1) ; |
| 563 |
|
| 564 |
diff = max(tdiff) ; |
| 565 |
|
| 566 |
|
| 567 |
cout << " step " << niter << " : " ; |
| 568 |
for (int l=0; l<nz; l++) { |
| 569 |
cout << tdiff(l) << " " ; |
| 570 |
} |
| 571 |
cout << endl ; |
| 572 |
|
| 573 |
//================================= |
| 574 |
// Updates for the next iteration |
| 575 |
//================================= |
| 576 |
|
| 577 |
ssjm2 = ssjm1 ; |
| 578 |
ssjm1 = ssj ; |
| 579 |
vuujm1 = vuu ; |
| 580 |
|
| 581 |
niter++ ; |
| 582 |
|
| 583 |
} // End of iteration |
| 584 |
while ( (diff > precis) && (niter < nitermax) ) ; |
| 585 |
|
| 586 |
//========================================================================== |
| 587 |
//========================================================================== |
| 588 |
// End of iteration |
| 589 |
//========================================================================== |
| 590 |
//========================================================================== |
| 591 |
} |
| 592 |
|
| 593 |
void Map_et::poisson_angu(const Scalar& source, Param& par, Scalar& uu, |
| 594 |
double lambda) const { |
| 595 |
|
| 596 |
if (lambda != double(0)) { |
| 597 |
cout << |
| 598 |
"Map_et::poisson_angu : the case lambda != 0 is not treated yet !" |
| 599 |
<< endl ; |
| 600 |
abort() ; |
| 601 |
} |
| 602 |
|
| 603 |
assert(source.get_mp() == *this) ; |
| 604 |
assert(uu.get_mp() == *this) ; |
| 605 |
|
| 606 |
int nz = mg->get_nzone() ; |
| 607 |
int nzm1 = nz - 1 ; |
| 608 |
|
| 609 |
int* nrm6 = new int[nz]; |
| 610 |
for (int l=0; l<=nzm1; l++) |
| 611 |
nrm6[l] = mg->get_nr(l) - 6 ; |
| 612 |
|
| 613 |
//## // Indicator of existence of a compactified external domain |
| 614 |
// bool zec = false ; |
| 615 |
// if (mg->get_type_r(nzm1) == UNSURR) { |
| 616 |
// zec = true ; |
| 617 |
// } |
| 618 |
|
| 619 |
//------------------- |
| 620 |
// Initializations |
| 621 |
//------------------- |
| 622 |
|
| 623 |
int nitermax = par.get_int() ; |
| 624 |
int& niter = par.get_int_mod() ; |
| 625 |
double relax = par.get_double() ; |
| 626 |
double precis = par.get_double(1) ; |
| 627 |
|
| 628 |
Cmp& ssjcmp = par.get_cmp_mod() ; |
| 629 |
|
| 630 |
Scalar ssj (ssjcmp) ; |
| 631 |
Scalar ssjm1 (ssj) ; |
| 632 |
|
| 633 |
int dzpuis = source.get_dzpuis() ; |
| 634 |
ssj.set_dzpuis(dzpuis) ; |
| 635 |
uu.set_dzpuis(dzpuis) ; |
| 636 |
ssjm1.set_dzpuis(dzpuis) ; |
| 637 |
|
| 638 |
Valeur& vuu = uu.set_spectral_va() ; |
| 639 |
|
| 640 |
Valeur vuujm1(*mg) ; |
| 641 |
if (uu.get_etat() == ETATZERO) { |
| 642 |
vuujm1 = 1 ; // to take relative differences |
| 643 |
vuujm1.set_base( vuu.base ) ; |
| 644 |
} |
| 645 |
else{ |
| 646 |
vuujm1 = vuu ; |
| 647 |
} |
| 648 |
|
| 649 |
// Affine mapping for the Laplacian-tilde |
| 650 |
|
| 651 |
Map_af mpaff(*this) ; |
| 652 |
Param par_nul ; |
| 653 |
|
| 654 |
cout << "Map_et::poisson angu : relat. diff. u^J <-> u^{J-1} : " << endl ; |
| 655 |
|
| 656 |
//========================================================================== |
| 657 |
//========================================================================== |
| 658 |
// Start of iteration |
| 659 |
//========================================================================== |
| 660 |
//========================================================================== |
| 661 |
|
| 662 |
|
| 663 |
Tbl tdiff(nz) ; |
| 664 |
double diff ; |
| 665 |
niter = 0 ; |
| 666 |
|
| 667 |
do { |
| 668 |
|
| 669 |
//==================================================================== |
| 670 |
// Computation of R(u) (the result is put in uu) |
| 671 |
//==================================================================== |
| 672 |
|
| 673 |
//----------------------- |
| 674 |
// First operations on uu |
| 675 |
//----------------------- |
| 676 |
|
| 677 |
Valeur duudx = (uu.set_spectral_va()).dsdx() ; // d/dx |
| 678 |
|
| 679 |
const Valeur& d2uudxdx = duudx.dsdx() ; // d^2/dxdx |
| 680 |
|
| 681 |
|
| 682 |
const Valeur& d2uudtdx = duudx.dsdt() ; // d^2/dxdtheta |
| 683 |
|
| 684 |
const Valeur& std2uudpdx = duudx.stdsdp() ; // 1/sin(theta) d^2/dxdphi |
| 685 |
|
| 686 |
//--------------------------------------- |
| 687 |
// Computation of R(u) |
| 688 |
// |
| 689 |
// The result is put in uu (via vuu) |
| 690 |
//--------------------------------------- |
| 691 |
|
| 692 |
Mtbl unjj = srdrdt*srdrdt + srstdrdp*srstdrdp ; |
| 693 |
|
| 694 |
Base_val sauve_base = vuu.base ; |
| 695 |
|
| 696 |
vuu = - d2uudxdx * dxdr * dxdr * unjj |
| 697 |
+ 2. * dxdr * ( sr2drdt * d2uudtdx |
| 698 |
+ sr2stdrdp * std2uudpdx ) ; |
| 699 |
|
| 700 |
vuu.set_base(sauve_base) ; |
| 701 |
|
| 702 |
vuu += dxdr * ( lapr_tp + dxdr * ( |
| 703 |
dxdr * unjj * d2rdx2 |
| 704 |
- 2. * ( sr2drdt * d2rdtdx + sr2stdrdp * sstd2rdpdx ) ) |
| 705 |
) * duudx ; |
| 706 |
|
| 707 |
vuu.set_base(sauve_base) ; |
| 708 |
|
| 709 |
uu.mult_r() ; |
| 710 |
uu.mult_r() ; |
| 711 |
|
| 712 |
//==================================================================== |
| 713 |
// Computation of the effective source s^J of the ``affine'' |
| 714 |
// Poisson equation |
| 715 |
//==================================================================== |
| 716 |
|
| 717 |
uu.filtre_r(nrm6) ; |
| 718 |
// uu.filtre_phi(1) ; |
| 719 |
// uu.filtre_theta(1) ; |
| 720 |
|
| 721 |
ssj = source + uu ; |
| 722 |
|
| 723 |
ssj = (1-relax) * ssj + relax * ssjm1 ; |
| 724 |
|
| 725 |
(ssj.set_spectral_va()).set_base((source.get_spectral_va()).base) ; |
| 726 |
|
| 727 |
|
| 728 |
//==================================================================== |
| 729 |
// Resolution of the ``affine'' Poisson equation |
| 730 |
//==================================================================== |
| 731 |
|
| 732 |
mpaff.poisson_angu(ssj, par_nul, uu) ; |
| 733 |
|
| 734 |
tdiff = diffrel(vuu, vuujm1) ; |
| 735 |
|
| 736 |
diff = max(tdiff) ; |
| 737 |
|
| 738 |
|
| 739 |
cout << " step " << niter << " : " ; |
| 740 |
for (int l=0; l<nz; l++) { |
| 741 |
cout << tdiff(l) << " " ; |
| 742 |
} |
| 743 |
cout << endl ; |
| 744 |
|
| 745 |
//================================= |
| 746 |
// Updates for the next iteration |
| 747 |
//================================= |
| 748 |
|
| 749 |
vuujm1 = vuu ; |
| 750 |
ssjm1 = ssj ; |
| 751 |
|
| 752 |
niter++ ; |
| 753 |
|
| 754 |
} // End of iteration |
| 755 |
while ( (diff > precis) && (niter < nitermax) ) ; |
| 756 |
|
| 757 |
//========================================================================== |
| 758 |
//========================================================================== |
| 759 |
// End of iteration |
| 760 |
//========================================================================== |
| 761 |
//========================================================================== |
| 762 |
|
| 763 |
uu.set_dzpuis( source.get_dzpuis() ) ; // dzpuis unchanged |
| 764 |
|
| 765 |
} |
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
} |