LORENE
map_et.C
1/*
2 * Methods of class Map_et
3 */
4
5/*
6 * Copyright (c) 1999-2001 Eric Gourgoulhon
7 *
8 * This file is part of LORENE.
9 *
10 * LORENE is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * LORENE is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with LORENE; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26
27
28
29/*
30 * $Id: map_et.C,v 1.18 2023/05/26 15:41:17 g_servignat Exp $
31 * $Log: map_et.C,v $
32 * Revision 1.18 2023/05/26 15:41:17 g_servignat
33 * Implemented case P_COSSIN_P to Map_et::adapt() (to be tested)
34 *
35 * Revision 1.17 2016/12/05 16:17:57 j_novak
36 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37 *
38 * Revision 1.16 2014/10/13 08:53:03 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.15 2014/10/06 15:13:13 j_novak
42 * Modified #include directives to use c++ syntax.
43 *
44 * Revision 1.14 2013/06/05 15:10:42 j_novak
45 * Suppression of FINJAC sampling in r. This Jacobi(0,2) base is now
46 * available by setting colloc_r to BASE_JAC02 in the Mg3d constructor.
47 *
48 * Revision 1.13 2008/09/29 13:23:51 j_novak
49 * Implementation of the angular mapping associated with an affine
50 * mapping. Things must be improved to take into account the domain index.
51 *
52 * Revision 1.12 2008/08/27 08:48:26 jl_cornou
53 * Added_R_JACO02 case
54 *
55 * Revision 1.11 2005/11/30 11:09:07 p_grandclement
56 * Changes for the Bin_ns_bh project
57 *
58 * Revision 1.10 2004/03/25 10:29:23 j_novak
59 * All LORENE's units are now defined in the namespace Unites (in file unites.h).
60 *
61 * Revision 1.9 2004/01/29 08:50:03 p_grandclement
62 * Modification of Map::operator==(const Map&) and addition of the surface
63 * integrales using Scalar.
64 *
65 * Revision 1.8 2003/10/15 10:36:52 e_gourgoulhon
66 * In method fait_poly(): changed local variable name x to x1, not to shadow
67 * Coord's x.
68 *
69 * Revision 1.7 2003/07/07 20:01:43 p_grandclement
70 * change assert in constructor for map_et from a surface
71 *
72 * Revision 1.6 2003/06/04 21:11:55 p_grandclement
73 * Correction of separation in odd-even harmonics
74 *
75 * Revision 1.5 2002/10/16 14:36:41 j_novak
76 * Reorganization of #include instructions of standard C++, in order to
77 * use experimental version 3 of gcc.
78 *
79 * Revision 1.4 2002/05/07 07:10:44 e_gourgoulhon
80 * Compatibilty with xlC compiler on IBM SP2:
81 * suppressed the parenthesis around argument of instruction new:
82 * e.g. aa = new (Tbl*[nzone]) ---> aa = new Tbl*[nzone]
83 * result = new (Param) ---> result = new Param
84 *
85 * Revision 1.3 2002/01/15 15:53:06 p_grandclement
86 * I have had a constructor fot map_et using the equation of the surface
87 * of the star.
88 *
89 * Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon
90 *
91 * All writing/reading to a binary file are now performed according to
92 * the big endian convention, whatever the system is big endian or
93 * small endian, thanks to the functions fwrite_be and fread_be
94 *
95 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
96 * LORENE
97 *
98 * Revision 1.11 2001/02/28 11:04:20 eric
99 * 1ere version testee de resize.
100 *
101 * Revision 1.10 2001/02/26 17:29:42 eric
102 * Ajout de la fonction resize.
103 *
104 * Revision 1.9 2000/08/18 11:10:48 eric
105 * Ajout de l'operateur d'affectation a un autre Map_et.
106 *
107 * Revision 1.8 2000/01/24 16:42:36 eric
108 * Ajout de la fonction virtuelle operator=(const Map_af& ).
109 *
110 * Revision 1.7 2000/01/24 11:03:28 eric
111 * Correction d'une erreur dans le constructeur par lecture de fichier:
112 * ff et gg doivent etre construits sur mgi.get_angu() et non sur mgi.
113 *
114 * Revision 1.6 1999/12/20 10:24:49 eric
115 * Ajout des fonctions de lecture des parametres de Map_et:
116 * get_alpha(), get_beta(), get_ff(), get_gg().
117 *
118 * Revision 1.5 1999/12/17 11:20:08 eric
119 * Ajout de la fonction homothetie.
120 *
121 * Revision 1.4 1999/12/17 09:14:30 eric
122 * Amelioration de l'affichage.
123 *
124 * Revision 1.3 1999/11/24 16:31:41 eric
125 * Ajout des fonctions set_ff et set_gg.
126 *
127 * Revision 1.2 1999/11/24 11:22:44 eric
128 * Map_et : fonctions de constructions amies.
129 *
130 * Revision 1.1 1999/11/22 10:37:36 eric
131 * Initial revision
132 *
133 *
134 * $Header: /cvsroot/Lorene/C++/Source/Map/map_et.C,v 1.18 2023/05/26 15:41:17 g_servignat Exp $
135 *
136 */
137
138// headers C
139#include <cmath>
140
141// headers Lorene
142#include "proto.h"
143#include "map.h"
144#include "utilitaires.h"
145#include "unites.h"
146
147 //--------------//
148 // Constructors //
149 //--------------//
150
151// -----------------------
152// Constructor from a grid
153// -----------------------
154namespace Lorene {
155Map_et::Map_et(const Mg3d& mgrille, const double* bornes)
156 : Map_radial(mgrille),
157 aasx( mgrille.get_nr(0) ),
158 aasx2( mgrille.get_nr(0) ),
159 zaasx( mgrille.get_nr(mgrille.get_nzone()-1) ),
160 zaasx2( mgrille.get_nr(mgrille.get_nzone()-1) ),
161 bbsx( mgrille.get_nr(0) ),
162 bbsx2( mgrille.get_nr(0) ),
163 ff(mgrille.get_angu()) ,
164 gg(mgrille.get_angu())
165{
166 // The Coord rsxdxdr and rsx2drdx are constructed by the default Coord
167 // constructor
168
169 // Assignement of the building functions of the Coord's
170 // ----------------------------------------------------
171 set_coord() ;
172
173
174 // alpha and beta
175 // --------------
176 int nzone = mg->get_nzone() ;
177
178 alpha = new double[nzone] ;
179 beta = new double[nzone] ;
180
181 for (int l=0 ; l<nzone ; l++) {
182 switch (mg->get_type_r(l)) {
183 case RARE: {
184 alpha[l] = bornes[l+1] - bornes[l] ;
185 beta[l] = bornes[l] ;
186 break ;
187 }
188
189 case FIN: {
190 alpha[l] = (bornes[l+1] - bornes[l]) * .5 ;
191 beta[l] = (bornes[l+1] + bornes[l]) * .5 ;
192 break ;
193 }
194
195 case UNSURR: {
196 double umax = double(1) / bornes[l] ;
197 double umin = double(1) /bornes[l+1] ;
198 alpha[l] = (umin - umax) * double(0.5) ; // u est une fonction decroissante
199 beta[l] = (umin + umax) * double(0.5) ; // de l'indice i en r
200 break ;
201 }
202
203 default: {
204 cout << "Map_et::Map_et: unkown type_r ! " << endl ;
205 abort () ;
206 break ;
207 }
208
209 }
210 } // End of the loop onto the domains
211
212
213 // Radial polynomials A(x) and B(x)
214 // --------------------------------
215
216 fait_poly() ;
217
218 // Initialisation at zero of the functions F(theta',phi') and G(theta',phi')
219 // -------------------------------------------------------------------------
220
221 ff.set_etat_zero() ;
222 gg.set_etat_zero() ;
223
224 ff.std_base_scal() ; // Standard spectral bases for F
225 gg.std_base_scal() ; // Standard spectral bases for G
226
227}
228
229Map_et::Map_et(const Mg3d& grille, const double* r_lim, const Tbl& S_0) :
230 Map_radial(grille),
231 aasx(grille.get_nr(0) ),
232 aasx2(grille.get_nr(0) ),
233 zaasx(grille.get_nr(grille.get_nzone()-1) ),
234 zaasx2(grille.get_nr(grille.get_nzone()-1) ),
235 bbsx(grille.get_nr(0) ),
236 bbsx2(grille.get_nr(0) ),
237 ff(grille.get_angu()) ,
238 gg(grille.get_angu()) {
239
240 assert (S_0.get_ndim() == 2) ;
241 assert (S_0.get_dim(0) == grille.get_nt(0)) ;
242 assert (S_0.get_dim(1) == grille.get_np(0)) ;
243
244 Map_et mapping (grille, r_lim) ;
245
246 int nz = grille.get_nzone() ;
247 assert (nz >2) ;
248
249 // Le noyau :
250 int np = grille.get_np(0) ;
251 int nt = grille.get_nt(0) ;
252
253 double * cf = new double [nt*(np+2)] ;
254 for (int k=0 ; k<np ; k++)
255 for (int j=0 ; j<nt ; j++)
256 cf[k*nt+j] = S_0(k,j) - S_0(0,0) ;
257
258 int* deg = new int [3] ;
259 deg[0] = np ;
260 deg[1] = nt ;
261 deg[2] = 1 ;
262
263 int* dim = new int [3] ;
264 dim[0] = np+2 ;
265 dim[1] = nt ;
266 dim[2] = 1 ;
267
268 Tbl ff_nucleus (np,nt) ;
269 ff_nucleus.set_etat_qcq() ;
270
271 Tbl gg_nucleus (np,nt) ;
272 gg_nucleus.set_etat_qcq() ;
273
274 // On recupere la base en phi :
275 int base_p = grille.std_base_scal().get_base_p(0) ;
276 // Selon les cas (pas tres propre mais bon ...)
277 double * odd ;
278 double * even ;
279 double * coloc_odd ;
280 double * coloc_even ;
281
282 switch (base_p) {
283 case P_COSSIN: {
284 cfpcossin (deg,dim,cf) ;
285
286 // Separation des harmoniques paires et impaires :
287 odd = new double [nt*(np+2)] ;
288 even = new double [nt*(np+2)] ;
289
290
291 for (int k=0 ; k<np+2 ; k++)
292 if ((k%4 == 0) || (k%4==1))
293 for (int j=0 ; j<nt ; j++) {
294 odd[k*nt+j] = 0 ;
295 even[k*nt+j] = cf[k*nt+j] ;
296 }
297 else
298 if ((k%4 == 2) || (k%4 == 3))
299 for (int j=0 ; j<nt ; j++) {
300 even[k*nt+j] = 0 ;
301 odd[k*nt+j] = cf[k*nt+j] ;
302 }
303
304 else {
305 cout << "Erreur bizzare..." << endl ;
306 abort() ;
307 }
308
309 coloc_odd = new double [nt*np] ;
310 coloc_even = new double [nt*np] ;
311
312 cipcossin (deg,dim,deg,odd,coloc_odd) ;
313 cipcossin (deg,dim,deg,even,coloc_even) ;
314 for (int k=0 ; k<np ; k++)
315 for (int j=0 ; j<nt ; j++) {
316 gg_nucleus.set(k,j) = coloc_even[k*nt+j] ;
317 ff_nucleus.set(k,j) = coloc_odd[k*nt+j] ;
318 }
319
320 delete [] even ;
321 delete [] odd ;
322 delete [] coloc_even ;
323 delete [] coloc_odd ;
324 delete[] dim ;
325 delete [] deg ;
326 delete [] cf ;
327
328 break;
329 }
330 case P_COSSIN_P: {
331
332 for (int k=0 ; k<np ; k++)
333 for (int j=0 ; j<nt ; j++) {
334 gg_nucleus.set(k,j) = S_0(k,j) - S_0(0,0) ;
335 ff_nucleus.set(k,j) = 0. ;
336 }
337
338 delete[] dim ;
339 delete [] deg ;
340 delete [] cf ;
341
342
343 break;
344 }
345 default:{
346 cout << "Base_p != P_COSSIN not implemented in Map_et constructor" <<
347 endl ;
348 abort() ;
349 }
350 }
351
352 double mu_nucleus = - min(gg_nucleus) ;
353 double alpha_nucleus = S_0(0,0)-mu_nucleus ;
354
355 ff_nucleus /= alpha_nucleus ;
356 gg_nucleus += mu_nucleus ;
357 gg_nucleus /= alpha_nucleus ;
358
359 // First shell : much simpler no ?
360 Tbl ff_shell (np,nt) ;
361 ff_shell.set_etat_qcq() ;
362 ff_shell = S_0 - S_0(0,0) ;
363
364 double lambda_shell = -max(ff_shell) ;
365
366 double R_ext = r_lim[2] ;
367
368 double beta_shell = (R_ext+S_0(0,0)-lambda_shell)/2. ;
369 double alpha_shell = (R_ext-S_0(0,0)+lambda_shell)/2. ;
370
371 ff_shell += lambda_shell ;
372 ff_shell /= alpha_shell ;
373
374 ff.annule_hard() ;
375 gg.annule_hard() ;
376
377 ff.set_etat_c_qcq() ;
378 gg.set_etat_c_qcq() ;
379
380 for (int k=0 ; k<np ; k++)
381 for (int j=0 ; j<nt ; j++) {
382 ff.set(0,k,j,0) = ff_nucleus(k,j) ;
383 gg.set(0,k,j,0) = gg_nucleus(k,j) ;
384 ff.set(1,k,j,0) = ff_shell(k,j) ;
385 }
386
387 gg.annule(1,nz-1) ;
388 ff.annule(2,nz-1) ;
389
390 ff.std_base_scal() ;
391 gg.std_base_scal() ;
392
393 alpha = new double[nz] ;
394 alpha[0] = alpha_nucleus ;
395 alpha[1] = alpha_shell ;
396
397 beta = new double[nz] ;
398 beta[0] = 0 ;
399 beta[1] = beta_shell ;
400 for (int i=2 ; i<nz ; i++) {
401 alpha[i] = mapping.get_alpha()[i] ;
402 beta[i] = mapping.get_beta()[i] ;
403 }
404
405 fait_poly() ;
406 set_coord() ;
407}
408// ------------------
409// Copy constructor
410// ------------------
411Map_et::Map_et(const Map_et& mpi) : Map_radial(mpi) ,
412 aasx( mpi.aasx ),
413 aasx2( mpi.aasx2 ),
414 zaasx( mpi.zaasx ),
415 zaasx2( mpi.zaasx2 ),
416 bbsx( mpi.bbsx ),
417 bbsx2( mpi.bbsx2 ),
418 ff(mpi.ff) ,
419 gg(mpi.gg)
420{
421 // Assignement of the building functions of the Coord's
422 // ----------------------------------------------------
423 set_coord() ;
424
425 // alpha and beta
426 // --------------
427 int nzone = mg->get_nzone() ;
428
429 alpha = new double[nzone] ;
430 beta = new double[nzone] ;
431
432 for (int l=0 ; l<nzone ; l++) {
433 alpha[l] = mpi.alpha[l] ;
434 beta[l] = mpi.beta[l] ;
435 }
436
437 // Radial polynomials A(x) and B(x)
438 // --------------------------------
439
440 fait_poly() ;
441
442}
443 //------------------------------------------//
444 // Modification of the mapping parameters //
445 //------------------------------------------//
446
447void Map_et::set_alpha(double alpha0, int l) {
448
449 assert(l>=0) ;
450 assert(l<mg->get_nzone()) ;
451
452 alpha[l] = alpha0 ;
453
454 reset_coord() ;
455
456}
457
458void Map_et::set_beta(double beta0, int l) {
459
460 assert(l>=0) ;
461 assert(l<mg->get_nzone()) ;
462
463 beta[l] = beta0 ;
464
465 reset_coord() ;
466
467}
468
469// ---------------------
470// Constructor from file
471// ---------------------
472Map_et::Map_et(const Mg3d& mgi, FILE* fich)
473 : Map_radial(mgi, fich),
474 aasx( mgi.get_nr(0) ),
475 aasx2( mgi.get_nr(0) ),
476 zaasx( mgi.get_nr(mgi.get_nzone()-1) ),
477 zaasx2( mgi.get_nr(mgi.get_nzone()-1) ),
478 bbsx( mgi.get_nr(0) ),
479 bbsx2( mgi.get_nr(0) ),
480 ff(*(mgi.get_angu()), fich) ,
481 gg(*(mgi.get_angu()), fich)
482{
483 // The Coord rsxdxdr and rsx2drdx are constructed by the default Coord
484 // constructor
485
486 // alpha and beta
487 // --------------
488 int nz = mg->get_nzone() ;
489 alpha = new double[nz] ;
490 beta = new double[nz] ;
491 fread_be(alpha, sizeof(double), nz, fich) ;
492 fread_be(beta, sizeof(double), nz, fich) ;
493
494 // Assignement of the building functions of the Coord's
495 // ----------------------------------------------------
496 set_coord() ;
497
498 // Radial polynomials A(x) and B(x)
499 // --------------------------------
500
501 fait_poly() ;
502
503}
504
505 //------------//
506 // Destructor //
507 //------------//
508
510
511 delete [] alpha ;
512 delete [] beta ;
513
514 for (int l=0 ; l<mg->get_nzone(); l++) {
515 delete aa[l] ;
516 delete daa[l] ;
517 delete ddaa[l] ;
518 delete bb[l] ;
519 delete dbb[l] ;
520 delete ddbb[l] ;
521 }
522 delete [] aa ;
523 delete [] daa ;
524 delete [] ddaa ;
525 delete [] bb ;
526 delete [] dbb ;
527 delete [] ddbb ;
528
529}
530
531
532 //------------//
533 // Assignment //
534 //------------//
535
536void Map_et::operator=(const Map_et& mpi) {
537
538 assert(mpi.get_mg() == mg) ;
539
540 set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ;
541
542 set_rot_phi( mpi.get_rot_phi() ) ;
543
544 // The members bvect_spher and bvect_cart are treated by the functions
545 // set_ori and set_rot_phi.
546
547 for (int l=0; l<mg->get_nzone(); l++){
548 alpha[l] = mpi.get_alpha()[l] ;
549 beta[l] = mpi.get_beta()[l] ;
550 }
551
552 ff = mpi.ff ;
553 gg = mpi.gg ;
554
555 reset_coord() ; // update of all the Coords
556
557}
558
559
560
561
562void Map_et::operator=(const Map_af& mpi) {
563
564 assert(mpi.get_mg() == mg) ;
565
566 set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ;
567
568 set_rot_phi( mpi.get_rot_phi() ) ;
569
570 // The members bvect_spher and bvect_cart are treated by the functions
571 // set_ori and set_rot_phi.
572
573 for (int l=0; l<mg->get_nzone(); l++){
574 alpha[l] = mpi.get_alpha()[l] ;
575 beta[l] = mpi.get_beta()[l] ;
576 }
577
578 ff = 0 ;
579 gg = 0 ;
580
581 reset_coord() ; // update of all the Coords
582
583}
584
585void Map_et::set_ff(const Valeur& ffi) {
586
587 ff = ffi ;
588
589 reset_coord() ; // update of all the Coords
590
591}
592
593void Map_et::set_gg(const Valeur& ggi) {
594
595 gg = ggi ;
596
597 reset_coord() ; // update of all the Coords
598
599}
600
601
602
603 //-------------------------------------------------//
604 // Assignment of the Coord building functions //
605 //-------------------------------------------------//
606
608
609 // ... Coord's introduced by the base class Map :
610 r.set(this, map_et_fait_r) ;
611 tet.set(this, map_et_fait_tet) ;
612 phi.set(this, map_et_fait_phi) ;
613 sint.set(this, map_et_fait_sint) ;
614 cost.set(this, map_et_fait_cost) ;
615 sinp.set(this, map_et_fait_sinp) ;
616 cosp.set(this, map_et_fait_cosp) ;
617
618 x.set(this, map_et_fait_x) ;
619 y.set(this, map_et_fait_y) ;
620 z.set(this, map_et_fait_z) ;
621
622 xa.set(this, map_et_fait_xa) ;
623 ya.set(this, map_et_fait_ya) ;
624 za.set(this, map_et_fait_za) ;
625
626 // ... Coord's introduced by the base class Map_radial :
627 xsr.set(this, map_et_fait_xsr) ;
628 dxdr.set(this, map_et_fait_dxdr) ;
629 drdt.set(this, map_et_fait_drdt) ;
630 stdrdp.set(this, map_et_fait_stdrdp) ;
631 srdrdt.set(this, map_et_fait_srdrdt) ;
632 srstdrdp.set(this, map_et_fait_srstdrdp) ;
633 sr2drdt.set(this, map_et_fait_sr2drdt) ;
634 sr2stdrdp.set(this, map_et_fait_sr2stdrdp) ;
635 d2rdx2.set(this, map_et_fait_d2rdx2) ;
636 lapr_tp.set(this, map_et_fait_lapr_tp) ;
637 d2rdtdx.set(this, map_et_fait_d2rdtdx) ;
638 sstd2rdpdx.set(this, map_et_fait_sstd2rdpdx) ;
639 sr2d2rdt2.set(this, map_et_fait_sr2d2rdt2) ;
640
641 //... Coord's which belong to the class Map_et only :
642 rsxdxdr.set(this, map_et_fait_rsxdxdr) ;
643 rsx2drdx.set(this, map_et_fait_rsx2drdx) ;
644
645}
646
647 //--------------------------//
648 // Reset of the Coord's //
649 //--------------------------//
650
652
653 // Coord's of all the class derived from Map_radial:
654
656
657 // Coord's specific to Map_et
658
659 rsxdxdr.del_t() ;
660 rsx2drdx.del_t() ;
661
662}
663
664 //------------------------------------------------------//
665 // Construction of the radial polynomials A(x) and B(x) //
666 //------------------------------------------------------//
667
669
670 int nzone = mg->get_nzone() ;
671
672 aa = new Tbl*[nzone] ;
673 daa = new Tbl*[nzone] ;
674 ddaa = new Tbl*[nzone] ;
675 bb = new Tbl*[nzone] ;
676 dbb = new Tbl*[nzone] ;
677 ddbb = new Tbl*[nzone] ;
678
679 for (int l=0; l<nzone; l++) {
680 int nr = mg->get_nr(l) ;
681 aa[l] = new Tbl(nr) ;
682 daa[l] = new Tbl(nr) ;
683 ddaa[l] = new Tbl(nr) ;
684 bb[l] = new Tbl(nr) ;
685 dbb[l] = new Tbl(nr) ;
686 ddbb[l] = new Tbl(nr) ;
687 }
688
689 // Values in the nucleus
690 // ---------------------
691 assert( mg->get_type_r(0) == RARE || mg->get_type_r(0) == FIN ) ;
692
693 aa[0]->set_etat_qcq() ; // Memory allocation for the Tbl
694 daa[0]->set_etat_qcq() ;
695 ddaa[0]->set_etat_qcq() ;
696 aasx.set_etat_qcq() ;
697 aasx2.set_etat_qcq() ;
698
699 bb[0]->set_etat_qcq() ;
700 dbb[0]->set_etat_qcq() ;
701 ddbb[0]->set_etat_qcq() ;
702 bbsx.set_etat_qcq() ;
703 bbsx2.set_etat_qcq() ;
704
705 for (int i=0; i<mg->get_nr(0); i++) {
706
707 double x1 = (mg->get_grille3d(0))->x[i] ;
708 double x2 = x1 * x1 ;
709 double x3 = x1 * x2 ;
710
711 //##...... A(x) = 2 x^2 - x^4 :
712 // (aa[0])->t[i] = x2 * (2. - x2) ;
713 // (daa[0])->t[i] = 4. * x * (1. + x) * (1. - x) ;
714 // (ddaa[0])->t[i] = 4. *(1. - 3.* x2) ;
715 // aasx->t[i] = x * (2. - x2) ;
716 // aasx2->t[i] = 2. - x2 ;
717
718 //...... A(x) = 3 x^4 - 2 x^6 :
719
720 aa[0]->set(i) = x2 * x2 * (3. - 2.*x2) ;
721 daa[0]->set(i) = 12. * x3 * (1. + x1) * (1. - x1) ;
722 ddaa[0]->set(i) = 12. *x2 *(3. - 5.* x2) ;
723 aasx.set(i) = x3 * (3. - 2.*x2) ;
724 aasx2.set(i) = x2 * (3. - 2.*x2) ;
725
726 //... B(x) = 5/2 x^3 - 3/2 x^5 :
727
728 bb[0]->set(i) = 0.5 * x3 * (5. - 3.* x2) ;
729 dbb[0]->set(i) = 7.5 * x2 * (1. + x1) * (1. - x1) ;
730 ddbb[0]->set(i) = 15. * x1 * ( 1. - 2.*x2 ) ;
731 bbsx.set(i) = 0.5 * x2 * (5. - 3.* x2) ;
732 bbsx2.set(i) = 0.5 * x1 * (5. - 3.* x2) ;
733 }
734
735 // Values in the shells and the outermost domain
736 // ---------------------------------------------
737
738 for (int l=1; l<nzone; l++) {
739
740 assert( (mg->get_type_r(l) == FIN)|| (mg->get_type_r(l) == UNSURR) ) ;
741
742 aa[l]->set_etat_qcq() ; // Memory allocation for the Tbl
743 daa[l]->set_etat_qcq() ;
744 ddaa[l]->set_etat_qcq() ;
745
746 bb[l]->set_etat_qcq() ;
747 dbb[l]->set_etat_qcq() ;
748 ddbb[l]->set_etat_qcq() ;
749
750 for (int i=0; i<mg->get_nr(l); i++) {
751
752 double x1 = (mg->get_grille3d(l))->x[i] ;
753 double xm1 = x1 - 1. ;
754 double xp1 = x1 + 1. ;
755
756 //... A(x) = 1/4 (x-1)^2 (x+2) = 1/4(x^3 -3x +2) :
757
758 aa[l]->set(i) = 0.25* xm1 * xm1 * (x1 + 2.) ;
759 daa[l]->set(i) = 0.75* xm1 * xp1 ;
760 ddaa[l]->set(i) = 1.5* x1 ;
761
762 //... B(x) = 1/4 (x+1)^2 (-x+2) = 1/4(-x^3 +3x +2) :
763
764 bb[l]->set(i) = 0.25* xp1 * xp1 * (2. - x1) ;
765 dbb[l]->set(i) = - 0.75* xm1 * xp1 ;
766 ddbb[l]->set(i) = - 1.5* x1 ;
767 }
768
769 } // End of the loop onto the domains
770
771 // Special case of a compactified outermost domain
772 // -----------------------------------------------
773
774 int nzm1 = nzone - 1 ;
775 if ( mg->get_type_r(nzm1) == UNSURR ) {
776
777 zaasx.set_etat_qcq() ; // Memory allocation for the Tbl
778 zaasx2.set_etat_qcq() ;
779
780 for (int i=0; i<mg->get_nr(nzm1); i++) {
781
782 double x1 = (mg->get_grille3d(nzm1))->x[i] ;
783 zaasx.set(i) = 0.25 * (x1 - 1.) * (2. + x1) ; // A(x)/(x-1)
784 zaasx2.set(i) = 0.25 * (2. + x1) ; // A(x)/(x-1)^2
785
786 }
787
788 bb[nzm1]->set_etat_zero() ;
789 dbb[nzm1]->set_etat_zero() ;
790 ddbb[nzm1]->set_etat_zero() ;
791
792 }
793
794}
795
796
797
798 //----------------//
799 // Save in a file //
800 //----------------//
801
802void Map_et::sauve(FILE* fich) const {
803
804 Map_radial::sauve(fich) ; // Write of the elements common to all the
805 // classes derived from Map_radial
806
807 ff.sauve(fich) ; // Write of F(theta',phi')
808 gg.sauve(fich) ; // Write of G(theta',phi')
809
810 // Write of alpha and beta :
811 int nz = mg->get_nzone() ;
812 fwrite_be(alpha, sizeof(double), nz, fich) ;
813 fwrite_be(beta, sizeof(double), nz, fich) ;
814
815}
816
817 //---------------------------//
818 // Printing //
819 //---------------------------//
820
821ostream & Map_et::operator>>(ostream & ost) const {
822
823 using namespace Unites ;
824
825 ost <<
826 "Radial mapping of form r = xi + A(xi)F(t,p) + B(xi)G(t,p) (class Map_et)"
827 << endl ;
828 int nz = mg->get_nzone() ;
829 for (int l=0; l<nz; l++) {
830 ost << " Domain #" << l << " : alpha_l = " << alpha[l]
831 << " , beta_l = " << beta[l] << endl ;
832 }
833 ost << endl << "Function F(theta', phi') : " << endl ;
834 ost << "------------------------- " << endl ;
835 ff.affiche_seuil(ost) ;
836 ost << endl <<"Function G(theta', phi') : " << endl ;
837 ost << "------------------------- " << endl ;
838 gg.affiche_seuil(ost) ;
839
840 int type_t = mg->get_type_t() ;
841 int type_p = mg->get_type_p() ;
842
843 ost << endl
844 << "Values of r at the outer boundary of each domain [km] :" << endl ;
845 ost << "------------------------------------------------------" << endl ;
846 ost << " 1/ for theta = Pi/2 and phi = 0 : " << endl ;
847 ost << " val_r : " ;
848 for (int l=0; l<nz; l++) {
849 ost << " " << val_r(l, 1., M_PI/2, 0) / km ;
850 }
851 ost << endl ;
852
853 if ( type_t == SYM ) {
854 assert( (type_p == SYM) || (type_p == NONSYM) ) ;
855 ost << " Coord r : " ;
856 for (int l=0; l<nz; l++) {
857 int nrm1 = mg->get_nr(l) - 1 ;
858 int ntm1 = mg->get_nt(l) - 1 ;
859 ost << " " << (+r)(l, 0, ntm1, nrm1) / km ;
860 }
861 ost << endl ;
862 }
863
864 ost << " 2/ for theta = Pi/2 and phi = Pi/2 : " << endl ;
865 ost << " val_r : " ;
866 for (int l=0; l<nz; l++) {
867 ost << " " << val_r(l, 1., M_PI/2, M_PI/2) / km ;
868 }
869 ost << endl ;
870
871 if ( type_t == SYM ) {
872 ost << " Coord r : " ;
873 for (int l=0; l<nz; l++) {
874 int nrm1 = mg->get_nr(l) - 1 ;
875 int ntm1 = mg->get_nt(l) - 1 ;
876 int np = mg->get_np(l) ;
877 if ( (type_p == NONSYM) && (np % 4 == 0) ) {
878 ost << " " << (+r)(l, np/4, ntm1, nrm1) / km ;
879 }
880 if ( type_p == SYM ) {
881 ost << " " << (+r)(l, np/2, ntm1, nrm1) / km ;
882 }
883 }
884 ost << endl ;
885 }
886
887 ost << " 3/ for theta = Pi/2 and phi = Pi : " << endl ;
888 ost << " val_r : " ;
889 for (int l=0; l<nz; l++) {
890 ost << " " << val_r(l, 1., M_PI/2, M_PI) / km ;
891 }
892 ost << endl ;
893
894 if ( (type_t == SYM) && (type_p == NONSYM) ) {
895 ost << " Coord r : " ;
896 for (int l=0; l<nz; l++) {
897 int nrm1 = mg->get_nr(l) - 1 ;
898 int ntm1 = mg->get_nt(l) - 1 ;
899 int np = mg->get_np(l) ;
900 ost << " " << (+r)(l, np/2, ntm1, nrm1) / km ;
901 }
902 ost << endl ;
903 }
904
905 ost << " 4/ for theta = 0 : " << endl ;
906 ost << " val_r : " ;
907 for (int l=0; l<nz; l++) {
908 ost << " " << val_r(l, 1., 0., 0.) / km ;
909 }
910 ost << endl ;
911
912 ost << " Coord r : " ;
913 for (int l=0; l<nz; l++) {
914 int nrm1 = mg->get_nr(l) - 1 ;
915 ost << " " << (+r)(l, 0, 0, nrm1) / km ;
916 }
917 ost << endl ;
918
919 return ost ;
920
921}
922
923 //------------------//
924 // Homothetie //
925 //------------------//
926
927
928void Map_et::homothetie(double fact) {
929
930 int nz = mg->get_nzone() ;
931
932 for (int l=0; l<nz; l++) {
933 if (mg->get_type_r(l) == UNSURR) {
934 alpha[l] /= fact ;
935 beta[l] /= fact ;
936 }
937 else {
938 alpha[l] *= fact ;
939 beta[l] *= fact ;
940 }
941 }
942
943 reset_coord() ;
944
945}
946
947 //----------------------------//
948 // Rescaling of one domain //
949 //----------------------------//
950
951void Map_et::resize(int l, double lambda) {
952
953 // Protections
954 // -----------
955 if (mg->get_type_r(l) != FIN) {
956 cout << "Map_et::resize can be applied only to a shell !" << endl ;
957 abort() ;
958 }
959
960 // New values of alpha, beta, F and G in domain l :
961 // ----------------------------------------------
962 double n_alpha = 0.5 * ( (lambda + 1.) * alpha[l] +
963 (lambda - 1.) * beta[l] ) ;
964
965 double n_beta = 0.5 * ( (lambda - 1.) * alpha[l] +
966 (lambda + 1.) * beta[l] ) ;
967
968 ff.set(l) = alpha[l] / n_alpha * ff(l) ;
969 gg.set(l) = lambda * alpha[l] / n_alpha * gg(l) ;
970
971 alpha[l] = n_alpha ;
972 beta[l] = n_beta ;
973
974 // New values of alpha, beta, F and G in in domain l+1 :
975 // ----------------------------------------------------
976 assert(l<mg->get_nzone()-1) ;
977 int lp1 = l + 1 ;
978
979 if (mg->get_type_r(lp1) == UNSURR) { // compactified case
980
981 assert(ff(lp1).get_etat() == ETATZERO ) ;
982 assert(gg(lp1).get_etat() == ETATZERO ) ;
983
984 alpha[lp1] = - 0.5 / ( alpha[l] + beta[l] ) ;
985 beta[lp1] = - alpha[lp1] ;
986
987 }
988 else{ // non-compactified case
989
990 assert( mg->get_type_r(lp1) == FIN ) ;
991 n_alpha = 0.5 * ( alpha[lp1] - alpha[l] + beta[lp1] - beta[l] ) ;
992 n_beta = 0.5 * ( alpha[lp1] + alpha[l] + beta[lp1] + beta[l] ) ;
993
994 ff.set(lp1) = alpha[l] / n_alpha * gg(l) ;
995 gg.set(lp1) = alpha[lp1] / n_alpha * gg(lp1) ;
996
997 alpha[lp1] = n_alpha ;
998 beta[lp1] = n_beta ;
999 }
1000
1001 // The coords are no longer up to date :
1002 reset_coord() ;
1003}
1004
1005
1006// Comparison operator :
1007bool Map_et::operator==(const Map& mpi) const {
1008
1009 // Precision of the comparison
1010 double precis = 1e-10 ;
1011 bool resu = true ;
1012
1013 // Dynamic cast pour etre sur meme Map...
1014 const Map_et* mp0 = dynamic_cast<const Map_et*>(&mpi) ;
1015 if (mp0 == 0x0)
1016 resu = false ;
1017 else {
1018 if (*mg != *(mpi.get_mg()))
1019 resu = false ;
1020
1021 if (fabs(ori_x-mpi.get_ori_x()) > precis) resu = false ;
1022 if (fabs(ori_y-mpi.get_ori_y()) > precis) resu = false ;
1023 if (fabs(ori_z-mpi.get_ori_z()) > precis) resu = false ;
1024
1025 if (bvect_spher != mpi.get_bvect_spher()) resu = false ;
1026 if (bvect_cart != mpi.get_bvect_cart()) resu = false ;
1027
1028 int nz = mg->get_nzone() ;
1029 for (int i=0 ; i<nz ; i++) {
1030 if (fabs(alpha[i]-mp0->alpha[i])/fabs(alpha[i]) > precis)
1031 resu = false ;
1032 if ((i!=0) && (i!=nz-1))
1033 if (fabs(beta[i]-mp0->beta[i])/fabs(beta[i]) > precis)
1034 resu = false ;
1035 }
1036
1037 if (max(diffrelmax(ff, mp0->ff)) > precis)
1038 resu = false ;
1039 if (max(diffrelmax(gg, mp0->gg)) > precis)
1040 resu = false ;
1041 }
1042
1043 return resu ;
1044}
1045 //--------------------------------------//
1046 // Extraction of the mapping parameters //
1047 //--------------------------------------//
1048
1049const double* Map_et::get_alpha() const {
1050 return alpha ;
1051}
1052
1053const double* Map_et::get_beta() const {
1054 return beta ;
1055}
1056
1057const Valeur& Map_et::get_ff() const {
1058 return ff ;
1059}
1060
1061const Valeur& Map_et::get_gg() const {
1062 return gg ;
1063}
1064
1065
1066// To be done
1067//-----------
1068const Map_af& Map_et::mp_angu(int) const {
1069 const char* f = __FILE__ ;
1070 c_est_pas_fait(f) ;
1071 p_mp_angu = new Map_af(*this) ;
1072 return *p_mp_angu ;
1073}
1074
1075}
int get_base_p(int l) const
Returns the expansion basis for functions in the domain of index l (e.g.
Definition base_val.h:425
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
const Valeur & get_ff() const
Returns a (constant) reference to the function .
Definition map_et.C:1057
const double * get_alpha() const
Returns a pointer on the array alpha (values of in each domain).
Definition map_et.C:1049
double * beta
Array (size: mg->nzone ) of the values of in each domain.
Definition map.h:2778
Tbl ** ddaa
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2793
virtual double val_r(int l, double xi, double theta, double pphi) const
Returns the value of the radial coordinate r for a given in a given domain.
virtual void operator=(const Map_et &mp)
Assignment to another Map_et.
Definition map_et.C:536
virtual const Map_af & mp_angu(int) const
Returns the "angular" mapping for the outside of domain l_zone.
Definition map_et.C:1068
virtual ostream & operator>>(ostream &) const
Operator >>.
Definition map_et.C:821
Tbl ** ddbb
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2824
Tbl zaasx2
Values at the nr collocation points of in the outermost compactified domain.
Definition map.h:2809
Coord rsx2drdx
in the nucleus and the shells; \ in the outermost compactified domain.
Definition map.h:2859
virtual bool operator==(const Map &) const
Comparison operator (egality).
Definition map_et.C:1007
Tbl bbsx
Values at the nr collocation points of in the nucleus.
Definition map.h:2827
void set_gg(const Valeur &)
Assigns a given value to the function .
Definition map_et.C:593
const Valeur & get_gg() const
Returns a (constant) reference to the function .
Definition map_et.C:1061
Map_et(const Mg3d &mgrille, const double *r_limits)
Standard Constructor.
Definition map_et.C:155
Tbl ** dbb
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2819
void fait_poly()
Construction of the polynomials and .
Definition map_et.C:668
virtual void homothetie(double lambda)
Sets a new radial scale.
Definition map_et.C:928
Tbl aasx
Values at the nr collocation points of in the nucleus.
Definition map.h:2796
const double * get_beta() const
Returns a pointer on the array beta (values of in each domain).
Definition map_et.C:1053
Tbl aasx2
Values at the nr collocation points of in the nucleus.
Definition map.h:2799
Tbl zaasx
Values at the nr collocation points of in the outermost compactified domain.
Definition map.h:2804
Tbl ** daa
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2788
void set_coord()
Assignement of the building functions to the member Coords.
Definition map_et.C:607
Coord rsxdxdr
in the nucleus; \ in the shells; \ in the outermost compactified domain.
Definition map.h:2852
void set_beta(double beta0, int l)
Modifies the value of in domain no. l.
Definition map_et.C:458
Tbl ** aa
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2783
Valeur ff
Values of the function at the nt*np angular collocation points in each domain.
Definition map.h:2837
void set_alpha(double alpha0, int l)
Modifies the value of in domain no. l.
Definition map_et.C:447
Tbl ** bb
Array (size: mg->nzone ) of Tbl which stores the values of in each domain.
Definition map.h:2814
virtual ~Map_et()
Destructor.
Definition map_et.C:509
double * alpha
Array (size: mg->nzone ) of the values of in each domain.
Definition map.h:2776
Tbl bbsx2
Values at the nr collocation points of in the nucleus.
Definition map.h:2830
Valeur gg
Values of the function at the nt*np angular collocation points in each domain.
Definition map.h:2844
virtual void sauve(FILE *) const
Save in a file.
Definition map_et.C:802
void set_ff(const Valeur &)
Assigns a given value to the function .
Definition map_et.C:585
virtual void resize(int l, double lambda)
Rescales the outer boundary of one domain.
Definition map_et.C:951
virtual void reset_coord()
Resets all the member Coords.
Definition map_et.C:651
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
virtual void reset_coord()
Resets all the member Coords.
Definition map_radial.C:129
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 drdt
in the nucleus and in the non-compactified shells; \ in the compactified external domain (CED).
Definition map.h:1583
Coord srdrdt
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1599
Map_radial(const Mg3d &mgrid)
Constructor from a grid (protected to make Map_radial an abstract class).
Definition map_radial.C:92
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1564
virtual void sauve(FILE *) const
Save in a file.
Definition map_radial.C:119
Coord dxdr
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1575
Coord sr2d2rdt2
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Definition map.h:1672
Coord stdrdp
in the nucleus and in the non-compactified shells; \ in the compactified external domain (CED).
Definition map.h:1591
Multi-domain grid.
Definition grilles.h:279
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition grilles.h:479
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:474
int get_nzone() const
Returns the number of domains.
Definition grilles.h:465
Base_val std_base_scal() const
Returns the standard spectral bases for a scalar.
Basic array class.
Definition tbl.h:161
int get_ndim() const
Gives the number of dimensions (ie dim.ndim).
Definition tbl.h:400
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
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i]).
Definition tbl.h:403
Values and coefficients of a (real-value) function.
Definition valeur.h:297
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition cmp_math.C:461
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition cmp_math.C:438
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition cmp_math.C:542
#define P_COSSIN_P
dev. sur Phi = 2*phi, freq. paires
#define P_COSSIN
dev. standart
Base_vect_spher bvect_spher
Base class for coordinate mappings.
Definition map.h:701
void c_est_pas_fait(const char *)
Helpful function to say something is not implemented yet.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:72
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition fwrite_be.C:73
Lorene prototypes.
Definition app_hor.h:67
Map_af * p_mp_angu
Pointer on the "angular" mapping.
Definition map.h:727
Coord z
z coordinate centered on the grid
Definition map.h:740
Base_vect_cart bvect_cart
Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
Definition map.h:709
Coord cost
Definition map.h:734
Coord y
y coordinate centered on the grid
Definition map.h:739
Coord cosp
Definition map.h:736
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:142
Coord phi
coordinate centered on the grid
Definition map.h:732
Coord tet
coordinate centered on the grid
Definition map.h:731
void set_rot_phi(double phi0)
Sets a new rotation angle.
Coord x
x coordinate centered on the grid
Definition map.h:738
Coord xa
Absolute x coordinate.
Definition map.h:742
Coord za
Absolute z coordinate.
Definition map.h:744
void set_ori(double xa0, double ya0, double za0)
Sets a new origin.
Coord sinp
Definition map.h:735
Coord r
r coordinate centered on the grid
Definition map.h:730
Coord ya
Absolute y coordinate.
Definition map.h:743
Coord sint
Definition map.h:733
Standard units of space, time and mass.