| 1 |
/* |
| 2 |
* Methods of class Map_af |
| 3 |
* |
| 4 |
* (see file map.h for documentation) |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 1999-2003 Eric Gourgoulhon |
| 10 |
* Copyright (c) 1999-2001 Philippe Grandclement |
| 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 as published by |
| 16 |
* the Free Software Foundation; either version 2 of the License, or |
| 17 |
* (at your option) any later version. |
| 18 |
* |
| 19 |
* LORENE is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with LORENE; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
|
| 31 |
char map_af_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_af.C,v 1.19 2014/10/13 08:53:02 j_novak Exp $" ; |
| 32 |
|
| 33 |
/* |
| 34 |
* $Id: map_af.C,v 1.19 2014/10/13 08:53:02 j_novak Exp $ |
| 35 |
* $Log: map_af.C,v $ |
| 36 |
* Revision 1.19 2014/10/13 08:53:02 j_novak |
| 37 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 38 |
* |
| 39 |
* Revision 1.18 2014/10/06 15:13:11 j_novak |
| 40 |
* Modified #include directives to use c++ syntax. |
| 41 |
* |
| 42 |
* Revision 1.17 2013/06/05 15:10:42 j_novak |
| 43 |
* Suppression of FINJAC sampling in r. This Jacobi(0,2) base is now |
| 44 |
* available by setting colloc_r to BASE_JAC02 in the Mg3d constructor. |
| 45 |
* |
| 46 |
* Revision 1.16 2012/01/17 15:34:35 j_penner |
| 47 |
* *** empty log message *** |
| 48 |
* |
| 49 |
* Revision 1.15 2012/01/17 10:31:32 j_penner |
| 50 |
* added access to computational coordinate xi |
| 51 |
* |
| 52 |
* Revision 1.14 2008/09/29 13:23:51 j_novak |
| 53 |
* Implementation of the angular mapping associated with an affine |
| 54 |
* mapping. Things must be improved to take into account the domain index. |
| 55 |
* |
| 56 |
* Revision 1.13 2008/08/19 06:42:00 j_novak |
| 57 |
* Minor modifications to avoid warnings with gcc 4.3. Most of them concern |
| 58 |
* cast-type operations, and constant strings that must be defined as const char* |
| 59 |
* |
| 60 |
* Revision 1.12 2007/12/21 11:05:33 j_novak |
| 61 |
* Put back the constructor from a Mg3d and a Tbl (it had disappeared?). |
| 62 |
* |
| 63 |
* Revision 1.11 2007/12/20 09:11:04 jl_cornou |
| 64 |
* Correction of an error in op_sxpun about Jacobi(0,2) polynomials |
| 65 |
* |
| 66 |
* Revision 1.10 2007/12/11 15:28:14 jl_cornou |
| 67 |
* Jacobi(0,2) polynomials partially implemented |
| 68 |
* |
| 69 |
* Revision 1.9 2006/04/25 07:21:59 p_grandclement |
| 70 |
* Various changes for the NS_BH project |
| 71 |
* |
| 72 |
* Revision 1.8 2005/08/29 15:10:18 p_grandclement |
| 73 |
* Addition of things needed : |
| 74 |
* 1) For BBH with different masses |
| 75 |
* 2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT |
| 76 |
* WORKING YET !!! |
| 77 |
* |
| 78 |
* Revision 1.7 2004/12/02 09:33:06 p_grandclement |
| 79 |
* *** empty log message *** |
| 80 |
* |
| 81 |
* Revision 1.6 2004/03/25 10:29:23 j_novak |
| 82 |
* All LORENE's units are now defined in the namespace Unites (in file unites.h). |
| 83 |
* |
| 84 |
* Revision 1.5 2004/01/29 08:50:03 p_grandclement |
| 85 |
* Modification of Map::operator==(const Map&) and addition of the surface |
| 86 |
* integrales using Scalar. |
| 87 |
* |
| 88 |
* Revision 1.4 2003/10/15 10:33:11 e_gourgoulhon |
| 89 |
* Added new Coord's : drdt, srdrdp. |
| 90 |
* |
| 91 |
* Revision 1.3 2002/10/16 14:36:41 j_novak |
| 92 |
* Reorganization of #include instructions of standard C++, in order to |
| 93 |
* use experimental version 3 of gcc. |
| 94 |
* |
| 95 |
* Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon |
| 96 |
* |
| 97 |
* All writing/reading to a binary file are now performed according to |
| 98 |
* the big endian convention, whatever the system is big endian or |
| 99 |
* small endian, thanks to the functions fwrite_be and fread_be |
| 100 |
* |
| 101 |
* Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon |
| 102 |
* LORENE |
| 103 |
* |
| 104 |
* Revision 2.23 2001/02/28 11:04:05 eric |
| 105 |
* 1ere version testee de resize. |
| 106 |
* |
| 107 |
* Revision 2.22 2001/02/26 17:29:22 eric |
| 108 |
* Ajout de la fonction resize. |
| 109 |
* |
| 110 |
* Revision 2.21 2001/01/10 11:03:13 phil |
| 111 |
* ajout de homothetie interne |
| 112 |
* |
| 113 |
* Revision 2.20 2000/01/24 17:09:13 eric |
| 114 |
* suppression de la fonction convert. |
| 115 |
* suppression du constructeur par convertion d'un Map_et. |
| 116 |
* ajout du constructeur par conversion d'un Map. |
| 117 |
* |
| 118 |
* Revision 2.19 2000/01/24 16:42:48 eric |
| 119 |
* Dans operator=(const Map_af& ), appel de set_rot_phi. |
| 120 |
* Ajout de la fonction convert(const Map& ). |
| 121 |
* |
| 122 |
* Revision 2.18 1999/12/21 16:27:26 eric |
| 123 |
* Ajout du constructeur par conversion Map_af::Map_af(const Map_et&). |
| 124 |
* Ajout des fonctions Map_af::set_alpha et Map_af::set_beta. |
| 125 |
* |
| 126 |
* Revision 2.17 1999/12/17 09:14:43 eric |
| 127 |
* Amelioration de l'affichage. |
| 128 |
* |
| 129 |
* Revision 2.16 1999/12/06 13:12:23 eric |
| 130 |
* Introduction de la fonction homothetie. |
| 131 |
* |
| 132 |
* Revision 2.15 1999/11/25 16:28:53 eric |
| 133 |
* Le calcul des derivees partielles est transfere dans le fichier |
| 134 |
* map_af_deriv.C. |
| 135 |
* |
| 136 |
* Revision 2.14 1999/11/24 14:32:54 eric |
| 137 |
* Les prototypes des fonctions de constructions des coords sont desormais |
| 138 |
* dans map.h. |
| 139 |
* Introduction des fonctions get_alpha() et get_beta(). |
| 140 |
* / |
| 141 |
* |
| 142 |
* Revision 2.13 1999/11/22 10:36:14 eric |
| 143 |
* Introduction de la fonction set_coord(). |
| 144 |
* Fonction del_coord() rebaptisee reset_coord(). |
| 145 |
* |
| 146 |
* Revision 2.12 1999/10/27 08:46:29 eric |
| 147 |
* Introduction de Cmp::va a la place de *(Cmp::c). |
| 148 |
* |
| 149 |
* Revision 2.11 1999/10/15 09:23:10 eric |
| 150 |
* *** empty log message *** |
| 151 |
* |
| 152 |
* Revision 2.10 1999/10/15 09:16:23 eric |
| 153 |
* Changement prototypes: const. |
| 154 |
* |
| 155 |
* Revision 2.9 1999/10/14 14:27:05 eric |
| 156 |
* Depoussierage. |
| 157 |
* |
| 158 |
* Revision 2.8 1999/04/12 12:54:05 phil |
| 159 |
* *** empty log message *** |
| 160 |
* |
| 161 |
* Revision 2.7 1999/04/12 12:09:03 phil |
| 162 |
* Mise a jour des bases dans dsdr() |
| 163 |
* |
| 164 |
* Revision 2.6 1999/03/04 13:11:48 eric |
| 165 |
* Ajout des Coord representant les derivees du changement de variable. |
| 166 |
* |
| 167 |
* Revision 2.5 1999/03/03 11:19:08 hyc |
| 168 |
* *** empty log message *** |
| 169 |
* |
| 170 |
* |
| 171 |
* $Header: /cvsroot/Lorene/C++/Source/Map/map_af.C,v 1.19 2014/10/13 08:53:02 j_novak Exp $ |
| 172 |
* |
| 173 |
*/ |
| 174 |
|
| 175 |
// headers C |
| 176 |
#include <cmath> |
| 177 |
|
| 178 |
// headers Lorene |
| 179 |
#include "cmp.h" |
| 180 |
#include "utilitaires.h" |
| 181 |
#include "proto.h" |
| 182 |
#include "unites.h" |
| 183 |
|
| 184 |
//---------------// |
| 185 |
// Constructeurs // |
| 186 |
//---------------// |
| 187 |
|
| 188 |
// Constructor from a grid |
| 189 |
// ----------------------- |
| 190 |
namespace Lorene { |
| 191 |
Map_af::Map_af(const Mg3d& mgrille, const double* bornes) : Map_radial(mgrille) |
| 192 |
{ |
| 193 |
// Les coordonnees et les derivees du changement de variable |
| 194 |
set_coord() ; |
| 195 |
|
| 196 |
// Les bornes |
| 197 |
int nzone = mg->get_nzone() ; |
| 198 |
|
| 199 |
alpha = new double[nzone] ; |
| 200 |
beta = new double[nzone] ; |
| 201 |
|
| 202 |
for (int l=0 ; l<nzone ; l++) { |
| 203 |
switch (mg->get_type_r(l)) { |
| 204 |
case RARE: { |
| 205 |
alpha[l] = bornes[l+1] - bornes[l] ; |
| 206 |
beta[l] = bornes[l] ; |
| 207 |
break ; |
| 208 |
} |
| 209 |
|
| 210 |
case FIN: { |
| 211 |
alpha[l] = (bornes[l+1] - bornes[l]) * .5 ; |
| 212 |
beta[l] = (bornes[l+1] + bornes[l]) * .5 ; |
| 213 |
break ; |
| 214 |
} |
| 215 |
|
| 216 |
case UNSURR: { |
| 217 |
double umax = 1./bornes[l] ; |
| 218 |
double umin = 1./bornes[l+1] ; |
| 219 |
alpha[l] = (umin - umax) * .5 ; // u est une fonction decroissante |
| 220 |
beta[l] = (umin + umax) * .5 ; // de l'indice i en r |
| 221 |
break ; |
| 222 |
} |
| 223 |
|
| 224 |
default: { |
| 225 |
cout << "Map_af::Map_af: unkown type_r ! " << endl ; |
| 226 |
abort () ; |
| 227 |
break ; |
| 228 |
} |
| 229 |
|
| 230 |
} |
| 231 |
} // Fin de la boucle sur zone |
| 232 |
} |
| 233 |
|
| 234 |
// Constructor from a grid |
| 235 |
// ----------------------- |
| 236 |
Map_af::Map_af(const Mg3d& mgrille, const Tbl& bornes) : Map_radial(mgrille) |
| 237 |
{ |
| 238 |
// Les coordonnees et les derivees du changement de variable |
| 239 |
set_coord() ; |
| 240 |
|
| 241 |
// Les bornes |
| 242 |
int nzone = mg->get_nzone() ; |
| 243 |
|
| 244 |
alpha = new double[nzone] ; |
| 245 |
beta = new double[nzone] ; |
| 246 |
|
| 247 |
for (int l=0 ; l<nzone ; l++) { |
| 248 |
switch (mg->get_type_r(l)) { |
| 249 |
case RARE: { |
| 250 |
alpha[l] = bornes(l+1) - bornes(l) ; |
| 251 |
beta[l] = bornes(l) ; |
| 252 |
break ; |
| 253 |
} |
| 254 |
|
| 255 |
case FIN: { |
| 256 |
alpha[l] = (bornes(l+1) - bornes(l)) * .5 ; |
| 257 |
beta[l] = (bornes(l+1) + bornes(l)) * .5 ; |
| 258 |
break ; |
| 259 |
} |
| 260 |
|
| 261 |
case UNSURR: { |
| 262 |
assert (l==nzone-1) ; |
| 263 |
double umax = 1./bornes(l) ; |
| 264 |
double umin = 0 ; |
| 265 |
alpha[l] = (umin - umax) * .5 ; // u est une fonction decroissante |
| 266 |
beta[l] = (umin + umax) * .5 ; // de l'indice i en r |
| 267 |
break ; |
| 268 |
} |
| 269 |
|
| 270 |
default: { |
| 271 |
cout << "Map_af::Map_af: unkown type_r ! " << endl ; |
| 272 |
abort () ; |
| 273 |
break ; |
| 274 |
} |
| 275 |
|
| 276 |
} |
| 277 |
} // Fin de la boucle sur zone |
| 278 |
} |
| 279 |
|
| 280 |
// Copy constructor |
| 281 |
// ---------------- |
| 282 |
Map_af::Map_af(const Map_af& mp) : Map_radial(mp) |
| 283 |
{ |
| 284 |
// Les coordonnees et les derivees du changement de variable |
| 285 |
set_coord() ; |
| 286 |
|
| 287 |
// Les bornes |
| 288 |
int nzone = mg->get_nzone() ; |
| 289 |
|
| 290 |
alpha = new double[nzone] ; |
| 291 |
beta = new double[nzone] ; |
| 292 |
|
| 293 |
for (int l=0; l<nzone; l++){ |
| 294 |
alpha[l] = mp.alpha[l] ; |
| 295 |
beta[l] = mp.beta[l] ; |
| 296 |
} |
| 297 |
} |
| 298 |
|
| 299 |
// Constructor from file |
| 300 |
// --------------------- |
| 301 |
Map_af::Map_af(const Mg3d& mgi, FILE* fd) : Map_radial(mgi, fd) |
| 302 |
{ |
| 303 |
int nz = mg->get_nzone() ; |
| 304 |
alpha = new double[nz] ; |
| 305 |
beta = new double[nz] ; |
| 306 |
fread_be(alpha, sizeof(double), nz, fd) ; |
| 307 |
fread_be(beta, sizeof(double), nz, fd) ; |
| 308 |
|
| 309 |
// Les coordonnees et les derivees du changement de variable |
| 310 |
set_coord() ; |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
// Constructor from a Map |
| 316 |
// ----------------------- |
| 317 |
Map_af::Map_af(const Map& mpi) : Map_radial(*(mpi.get_mg())) |
| 318 |
{ |
| 319 |
// Les coordonnees et les derivees du changement de variable |
| 320 |
set_coord() ; |
| 321 |
|
| 322 |
// Les bornes |
| 323 |
int nz = mg->get_nzone() ; |
| 324 |
|
| 325 |
alpha = new double[nz] ; |
| 326 |
beta = new double[nz] ; |
| 327 |
|
| 328 |
const Map_af* mp0 = dynamic_cast<const Map_af*>(&mpi) ; |
| 329 |
const Map_et* mp1 = dynamic_cast<const Map_et*>(&mpi) ; |
| 330 |
|
| 331 |
if( (mp0 == 0x0) && (mp1 == 0x0) ) { |
| 332 |
cout << "Map_af::Map_af(const Map& ) : unkown mapping type !" |
| 333 |
<< endl ; |
| 334 |
abort() ; |
| 335 |
} |
| 336 |
|
| 337 |
if (mp0 != 0x0) { |
| 338 |
assert( mp1 == 0x0 ) ; |
| 339 |
for (int l=0; l<nz; l++){ |
| 340 |
alpha[l] = mp0->get_alpha()[l] ; |
| 341 |
beta[l] = mp0->get_beta()[l] ; |
| 342 |
} |
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
if (mp1 != 0x0) { |
| 347 |
assert( mp0 == 0x0 ) ; |
| 348 |
for (int l=0; l<nz; l++){ |
| 349 |
alpha[l] = mp1->get_alpha()[l] ; |
| 350 |
beta[l] = mp1->get_beta()[l] ; |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ; |
| 356 |
|
| 357 |
set_rot_phi( mpi.get_rot_phi() ) ; |
| 358 |
|
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
//--------------// |
| 365 |
// Destructeurs // |
| 366 |
//--------------// |
| 367 |
|
| 368 |
Map_af::~Map_af() { |
| 369 |
delete [] alpha ; |
| 370 |
delete [] beta ; |
| 371 |
} |
| 372 |
|
| 373 |
//-------------// |
| 374 |
// Assignement // |
| 375 |
//-------------// |
| 376 |
|
| 377 |
// From another Map_af |
| 378 |
// ------------------- |
| 379 |
|
| 380 |
void Map_af::operator=(const Map_af & mpi) { |
| 381 |
|
| 382 |
assert(mpi.mg == mg) ; |
| 383 |
|
| 384 |
set_ori( mpi.ori_x, mpi.ori_y, mpi.ori_z ) ; |
| 385 |
|
| 386 |
set_rot_phi( mpi.rot_phi ) ; |
| 387 |
|
| 388 |
for (int l = 0; l<mg->get_nzone(); l++) { |
| 389 |
alpha[l] = mpi.alpha[l] ; |
| 390 |
beta[l] = mpi.beta[l] ; |
| 391 |
} |
| 392 |
|
| 393 |
reset_coord() ; |
| 394 |
} |
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
//-------------------------------------------------// |
| 400 |
// Assignement of the Coord building functions // |
| 401 |
//-------------------------------------------------// |
| 402 |
|
| 403 |
void Map_af::set_coord(){ |
| 404 |
|
| 405 |
// ... Coord's introduced by the base class Map : |
| 406 |
r.set(this, map_af_fait_r) ; |
| 407 |
tet.set(this, map_af_fait_tet) ; |
| 408 |
phi.set(this, map_af_fait_phi) ; |
| 409 |
sint.set(this, map_af_fait_sint) ; |
| 410 |
cost.set(this, map_af_fait_cost) ; |
| 411 |
sinp.set(this, map_af_fait_sinp) ; |
| 412 |
cosp.set(this, map_af_fait_cosp) ; |
| 413 |
|
| 414 |
x.set(this, map_af_fait_x) ; |
| 415 |
y.set(this, map_af_fait_y) ; |
| 416 |
z.set(this, map_af_fait_z) ; |
| 417 |
|
| 418 |
xa.set(this, map_af_fait_xa) ; |
| 419 |
ya.set(this, map_af_fait_ya) ; |
| 420 |
za.set(this, map_af_fait_za) ; |
| 421 |
|
| 422 |
// ... Coord's introduced by the base class Map_radial : |
| 423 |
xsr.set(this, map_af_fait_xsr) ; |
| 424 |
dxdr.set(this, map_af_fait_dxdr) ; |
| 425 |
drdt.set(this, map_af_fait_drdt) ; |
| 426 |
stdrdp.set(this, map_af_fait_stdrdp) ; |
| 427 |
srdrdt.set(this, map_af_fait_srdrdt) ; |
| 428 |
srstdrdp.set(this, map_af_fait_srstdrdp) ; |
| 429 |
sr2drdt.set(this, map_af_fait_sr2drdt) ; |
| 430 |
sr2stdrdp.set(this, map_af_fait_sr2stdrdp) ; |
| 431 |
d2rdx2.set(this, map_af_fait_d2rdx2) ; |
| 432 |
lapr_tp.set(this, map_af_fait_lapr_tp) ; |
| 433 |
d2rdtdx.set(this, map_af_fait_d2rdtdx) ; |
| 434 |
sstd2rdpdx.set(this, map_af_fait_sstd2rdpdx) ; |
| 435 |
sr2d2rdt2.set(this, map_af_fait_sr2d2rdt2) ; |
| 436 |
|
| 437 |
} |
| 438 |
// Comparison operator : |
| 439 |
bool Map_af::operator==(const Map& mpi) const { |
| 440 |
|
| 441 |
// Precision of the comparison |
| 442 |
double precis = 1e-10 ; |
| 443 |
bool resu = true ; |
| 444 |
|
| 445 |
// Dynamic cast pour etre sur meme Map... |
| 446 |
const Map_af* mp0 = dynamic_cast<const Map_af*>(&mpi) ; |
| 447 |
if (mp0 == 0x0) |
| 448 |
resu = false ; |
| 449 |
else { |
| 450 |
if (*mg != *(mpi.get_mg())) |
| 451 |
resu = false ; |
| 452 |
|
| 453 |
if (fabs(ori_x-mpi.get_ori_x()) > precis) resu = false ; |
| 454 |
if (fabs(ori_y-mpi.get_ori_y()) > precis) resu = false ; |
| 455 |
if (fabs(ori_z-mpi.get_ori_z()) > precis) resu = false ; |
| 456 |
|
| 457 |
if (bvect_spher != mpi.get_bvect_spher()) resu = false ; |
| 458 |
if (bvect_cart != mpi.get_bvect_cart()) resu = false ; |
| 459 |
|
| 460 |
int nz = mg->get_nzone() ; |
| 461 |
for (int i=0 ; i<nz ; i++) { |
| 462 |
if (fabs(alpha[i]-mp0->alpha[i])/fabs(alpha[i]) > precis) |
| 463 |
resu = false ; |
| 464 |
if ((i!=0) && (i!=nz-1)) |
| 465 |
if (fabs(beta[i]-mp0->beta[i])/fabs(beta[i]) > precis) |
| 466 |
resu = false ; |
| 467 |
} |
| 468 |
} |
| 469 |
|
| 470 |
return resu ; |
| 471 |
} |
| 472 |
|
| 473 |
//--------------------------------------// |
| 474 |
// Extraction of the mapping parameters // |
| 475 |
//--------------------------------------// |
| 476 |
|
| 477 |
const double* Map_af::get_alpha() const { |
| 478 |
return alpha ; |
| 479 |
} |
| 480 |
|
| 481 |
const double* Map_af::get_beta() const { |
| 482 |
return beta ; |
| 483 |
} |
| 484 |
|
| 485 |
//------------// |
| 486 |
// Sauvegarde // |
| 487 |
//------------// |
| 488 |
|
| 489 |
void Map_af::sauve(FILE* fd) const { |
| 490 |
|
| 491 |
Map_radial::sauve(fd) ; |
| 492 |
|
| 493 |
int nz = mg->get_nzone() ; |
| 494 |
fwrite_be(alpha, sizeof(double), nz, fd) ; |
| 495 |
fwrite_be(beta, sizeof(double), nz, fd) ; |
| 496 |
|
| 497 |
} |
| 498 |
|
| 499 |
//------------// |
| 500 |
// Impression // |
| 501 |
//------------// |
| 502 |
|
| 503 |
ostream & Map_af::operator>>(ostream & ost) const { |
| 504 |
|
| 505 |
using namespace Unites ; |
| 506 |
|
| 507 |
ost << "Affine mapping (class Map_af)" << endl ; |
| 508 |
int nz = mg->get_nzone() ; |
| 509 |
for (int l=0; l<nz; l++) { |
| 510 |
ost << " Domain #" << l << " : alpha_l = " << alpha[l] |
| 511 |
<< " , beta_l = " << beta[l] << endl ; |
| 512 |
} |
| 513 |
|
| 514 |
ost << endl << " Values of r at the outer boundary of each domain [km] :" |
| 515 |
<< endl ; |
| 516 |
ost << " val_r : " ; |
| 517 |
for (int l=0; l<nz; l++) { |
| 518 |
ost << " " << val_r(l, 1., 0., 0.) / km ; |
| 519 |
} |
| 520 |
ost << endl ; |
| 521 |
|
| 522 |
ost << " Coord r : " ; |
| 523 |
for (int l=0; l<nz; l++) { |
| 524 |
int nrm1 = mg->get_nr(l) - 1 ; |
| 525 |
ost << " " << (+r)(l, 0, 0, nrm1) / km ; |
| 526 |
} |
| 527 |
ost << endl ; |
| 528 |
|
| 529 |
return ost ; |
| 530 |
} |
| 531 |
|
| 532 |
//------------------// |
| 533 |
// Homothetie // |
| 534 |
//------------------// |
| 535 |
|
| 536 |
|
| 537 |
void Map_af::homothetie(double fact) { |
| 538 |
|
| 539 |
int nz = mg->get_nzone() ; |
| 540 |
|
| 541 |
for (int l=0; l<nz; l++) { |
| 542 |
if (mg->get_type_r(l) == UNSURR) { |
| 543 |
alpha[l] /= fact ; |
| 544 |
beta[l] /= fact ; |
| 545 |
} |
| 546 |
else { |
| 547 |
alpha[l] *= fact ; |
| 548 |
beta[l] *= fact ; |
| 549 |
} |
| 550 |
} |
| 551 |
|
| 552 |
reset_coord() ; |
| 553 |
|
| 554 |
} |
| 555 |
|
| 556 |
//----------------------------// |
| 557 |
// Rescaling of one domain // |
| 558 |
//----------------------------// |
| 559 |
|
| 560 |
void Map_af::resize(int l, double lambda) { |
| 561 |
|
| 562 |
// Protections |
| 563 |
// ----------- |
| 564 |
if (mg->get_type_r(l) != FIN) { |
| 565 |
cout << "Map_af::resize can be applied only to a shell !" << endl ; |
| 566 |
abort() ; |
| 567 |
} |
| 568 |
|
| 569 |
// New values of alpha and beta in domain l : |
| 570 |
// ---------------------------------------- |
| 571 |
double n_alpha = 0.5 * ( (lambda + 1.) * alpha[l] + |
| 572 |
(lambda - 1.) * beta[l] ) ; |
| 573 |
|
| 574 |
double n_beta = 0.5 * ( (lambda - 1.) * alpha[l] + |
| 575 |
(lambda + 1.) * beta[l] ) ; |
| 576 |
|
| 577 |
alpha[l] = n_alpha ; |
| 578 |
beta[l] = n_beta ; |
| 579 |
|
| 580 |
// New values of alpha and beta in domain l+1 : |
| 581 |
// ------------------------------------------ |
| 582 |
assert(l<mg->get_nzone()-1) ; |
| 583 |
int lp1 = l + 1 ; |
| 584 |
|
| 585 |
if (mg->get_type_r(lp1) == UNSURR) { // compactified case |
| 586 |
|
| 587 |
alpha[lp1] = - 0.5 / ( alpha[l] + beta[l] ) ; |
| 588 |
beta[lp1] = - alpha[lp1] ; |
| 589 |
|
| 590 |
} |
| 591 |
else{ // non-compactified case |
| 592 |
|
| 593 |
assert( mg->get_type_r(lp1) == FIN ) ; |
| 594 |
n_alpha = 0.5 * ( alpha[lp1] - alpha[l] + beta[lp1] - beta[l] ) ; |
| 595 |
n_beta = 0.5 * ( alpha[lp1] + alpha[l] + beta[lp1] + beta[l] ) ; |
| 596 |
alpha[lp1] = n_alpha ; |
| 597 |
beta[lp1] = n_beta ; |
| 598 |
} |
| 599 |
|
| 600 |
// The coords are no longer up to date : |
| 601 |
reset_coord() ; |
| 602 |
|
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
//---------------------------// |
| 610 |
// Homothetie partielle // |
| 611 |
//-------------------------// |
| 612 |
|
| 613 |
|
| 614 |
void Map_af::homothetie_interne(double fact) { |
| 615 |
|
| 616 |
// Dans le noyau |
| 617 |
alpha[0] *= fact ; |
| 618 |
|
| 619 |
// Dans la premiere coquille : |
| 620 |
double asauve = alpha[1] ; |
| 621 |
alpha[1] = (1-fact)/2.*beta[1] + (1+fact)/2. * alpha[1] ; |
| 622 |
beta[1] = (1+fact)/2.*beta[1]+ (1-fact)/2. * asauve ; |
| 623 |
|
| 624 |
reset_coord() ; |
| 625 |
} |
| 626 |
//------------------------------------------// |
| 627 |
// Modification of the mapping parameters // |
| 628 |
//------------------------------------------// |
| 629 |
|
| 630 |
void Map_af::set_alpha(double alpha0, int l) { |
| 631 |
|
| 632 |
assert(l>=0) ; |
| 633 |
assert(l<mg->get_nzone()) ; |
| 634 |
|
| 635 |
alpha[l] = alpha0 ; |
| 636 |
|
| 637 |
reset_coord() ; |
| 638 |
|
| 639 |
} |
| 640 |
|
| 641 |
void Map_af::set_beta(double beta0, int l) { |
| 642 |
|
| 643 |
assert(l>=0) ; |
| 644 |
assert(l<mg->get_nzone()) ; |
| 645 |
|
| 646 |
beta[l] = beta0 ; |
| 647 |
|
| 648 |
reset_coord() ; |
| 649 |
|
| 650 |
} |
| 651 |
|
| 652 |
//------------------------------------// |
| 653 |
// Angular part of the mapping // |
| 654 |
//------------------------------------// |
| 655 |
|
| 656 |
const Map_af& Map_af::mp_angu(int l_zone) const { |
| 657 |
//## the handling of l_zone must be improved |
| 658 |
if (p_mp_angu == 0x0) { |
| 659 |
const Mg3d& g_angu = (*get_mg()->get_angu_1dom()) ; |
| 660 |
double Rb = val_r_jk(l_zone, 1., 0, 0) ; |
| 661 |
Tbl rlim(2) ; |
| 662 |
rlim.set_etat_qcq() ; |
| 663 |
rlim.set(0) = Rb ; |
| 664 |
rlim.set(1) = Rb ; |
| 665 |
p_mp_angu = new Map_af(g_angu, rlim) ; |
| 666 |
} |
| 667 |
return *p_mp_angu ; |
| 668 |
} |
| 669 |
|
| 670 |
// To be done |
| 671 |
//----------- |
| 672 |
|
| 673 |
void Map_af::adapt(const Cmp&, const Param&, int) { |
| 674 |
const char* f = __FILE__ ; |
| 675 |
c_est_pas_fait(f) ; |
| 676 |
} |
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
} |