File: map_af_deriv.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (850 lines) | stat: -rw-r--r-- 23,017 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
/*
 * Computations of Cmp partial derivatives for a Map_af mapping
 */

/*
 *   Copyright (c) 1999-2004 Eric Gourgoulhon
 *   Copyright (c) 1999-2001 Philippe Grandclement
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


char map_af_deriv_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_af_deriv.C,v 1.13 2014/10/13 08:53:02 j_novak Exp $" ;

/*
 * $Id: map_af_deriv.C,v 1.13 2014/10/13 08:53:02 j_novak Exp $
 * $Log: map_af_deriv.C,v $
 * Revision 1.13  2014/10/13 08:53:02  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.12  2012/01/17 10:32:09  j_penner
 * added a derivative with respect to the computational coordinate xi
 *
 * Revision 1.11  2008/09/21 13:57:21  j_novak
 * Changed the test on the CED in the derivative.
 *
 * Revision 1.10  2004/12/17 13:35:02  m_forot
 * Add the case T_LEG
 *
 * Revision 1.9  2004/06/22 08:49:58  p_grandclement
 * Addition of everything needed for using the logarithmic mapping
 *
 * Revision 1.8  2004/01/27 09:33:48  j_novak
 * New method Map_radial::div_r_zec
 *
 * Revision 1.7  2004/01/26 16:16:17  j_novak
 * Methods of gradient for Scalar s. The input can have any dzpuis.
 *
 * Revision 1.6  2004/01/22 16:13:00  e_gourgoulhon
 * Case dzpuis=2 treated in dsdr, srdsdt and srstdsdp (output: dzpuis =
 * 3).
 * Reorganization cases dzpuis = 0 and 4.
 *
 * Revision 1.5  2003/11/11 15:31:43  j_novak
 * Added a #ifnedef... to prevent warnings.
 *
 * Revision 1.4  2003/10/22 13:08:05  j_novak
 * Better handling of dzpuis flags
 *
 * Revision 1.3  2003/10/20 19:45:27  e_gourgoulhon
 * Treatment of dzpuis in dsdt and stdsdp.
 *
 * Revision 1.2  2003/10/15 10:34:07  e_gourgoulhon
 * Added new methods dsdt and stdsdp.
 *
 * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
 * LORENE
 *
 * Revision 2.12  2000/02/25  08:59:51  eric
 * Remplacement de ci.get_dzpuis() == 0  par ci.check_dzpuis(0).
 * Suppression de l'affectation des dzpuis Mtbl/Mtnl_cf a la fin car
 *   c'est fait par Cmp::set_dzpuis.
 *
 * Revision 2.11  2000/01/26  13:09:18  eric
 * Reprototypage complet des routines de derivation:
 * le resultat est desormais suppose alloue a l'exterieur de la routine
 * et est passe en argument (Cmp& resu), si bien que le prototypage
 * complet devient:
 *             void DERIV(const Cmp& ci, Cmp& resu) const
 *
 * Revision 2.10  1999/11/30  12:51:32  eric
 * Valeur::base est desormais du type Base_val et non plus Base_val*.
 *
 * Revision 2.9  1999/11/26  14:23:55  eric
 * Traitement dzpuis des Cmp.
 *
 * Revision 2.8  1999/11/26  10:58:02  eric
 * Traitement dzpuis.
 *
 * Revision 2.7  1999/11/25  16:29:29  eric
 * Reorganisation complete du calcul des derivees partielles.
 *
 * Revision 2.6  1999/10/27  15:45:23  eric
 * Suppression du membre Cmp::c.
 *
 * Revision 2.5  1999/10/27  08:47:03  eric
 * Introduction de Cmp::va a la place de *(Cmp::c).
 *
 * Revision 2.4  1999/10/22  08:16:21  eric
 * const Map*.
 *
 * Revision 2.3  1999/10/14  14:27:17  eric
 * Methodes const.
 *
 * Revision 2.2  1999/10/13  15:54:40  eric
 * Mg3d* -> const Mg3d*
 *
 * Revision 2.1  1999/09/17  10:01:09  phil
 * correction pour deriv_x et deriv_y
 *
 * Revision 2.0  1999/09/14  16:37:06  phil
 * *** empty log message ***
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Map/map_af_deriv.C,v 1.13 2014/10/13 08:53:02 j_novak Exp $
 *
 */
 
// Header Lorene
#include "map.h"
#include "cmp.h"
#include "tensor.h"


			//-----------------------//
			//        d/d\xi         //
			//-----------------------//
			

namespace Lorene {
void Map_af::dsdxi(const Cmp& ci, Cmp& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp()->get_mg() == mg) ; 

    
    if (ci.get_etat() == ETATZERO) {
	resu.set_etat_zero() ; 
    }
    else {   
	assert( ci.get_etat() == ETATQCQ ) ; 
        

	(ci.va).coef() ;    // (ci.va).c_cf is up to date
	
	int nz = mg->get_nzone() ; 
	int nzm1 = nz - 1 ;

        switch( ci.get_dzpuis() ) {
        
            case 0 : {
	        resu = (ci.va).dsdx() ;     // dsdx == d/d\xi
	
	        if (mg->get_type_r(nzm1) == UNSURR) {
	            resu.set_dzpuis(2) ;    // r^2 d/dr has been computed in the // SOMETHING IS WRONG HERE
					    // external domain
	        } 
                break ; 
            }
            
            case 2 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;
                
	        Valeur tmp((ci.va).dsdx() ) ;
                tmp.annule(nzm1) ;  // zero in the CED

                // Special treatment in the CED
                Valeur tmp_ced = - (ci.va).dsdx() ; 
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED
                tmp_ced.mult_xm1_zec() ; 
                tmp_ced.set(nzm1) -= 2. * ci.va(nzm1) ; 
                
                // Recombination shells + CED : 
                resu = tmp + tmp_ced ;
                
                resu.set_dzpuis(3) ;         
                break ; 
            }
            
            case 4 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;

	        Valeur tmp(ci.va.dsdx()) ;
	        Valeur tmp2 = tmp ;
	        tmp2.base = (ci.va).dsdx().base ;
	        tmp.annule(nzm1) ; // not in the CED
	        tmp2.annule(0, nz-2) ; // special treatment of the CED
	        tmp2.mult_xm1_zec() ;
	        tmp2 = tmp2 / xsr ;
	        tmp2.set(nzm1) -= 4*ci.va(nzm1) ;
	        tmp2.base = ci.va.base ; //Just for the CED
	        tmp2.mult_xm1_zec() ;

	        resu = tmp + tmp2 / xsr  ; // do not know what this is, but for now I can get away with it, no CED
	        resu.set_dzpuis(4) ;
                break ; 
            }
            
            default : {
                cerr << "Map_af::dsdxi: unexpected value of input dzpuis !\n"
                    << "  ci.get_dzpuis() = " << ci.get_dzpuis() << endl ; 
                abort() ; 
                break ; 
            }
            
        }

	  
	(resu.va).set_base( (ci.va).dsdx().get_base() ) ; // same basis as d/dxi

    }
    
}

void Map_af::dsdxi(const Scalar& uu, Scalar& resu) const {

  assert (uu.get_etat() != ETATNONDEF) ; 
  assert (uu.get_mp().get_mg() == mg) ; 

  Mtbl unity = r/r;
    
  if (uu.get_etat() == ETATZERO) {
    resu.set_etat_zero() ; 
  }
  else {   
    assert( uu.get_etat() == ETATQCQ ) ; 

    const Valeur& uuva = uu.get_spectral_va() ; 

    uuva.coef() ;    // (uu.va).c_cf is up to date
	
    int nz = mg->get_nzone() ; 
    int nzm1 = nz - 1 ;

    if ( uu.get_dzpuis() == 0 ) {
      resu = uuva.dsdx() * unity ;     //  dxds == d/d\xi, unity is used to set the correct formated output
	
      if (mg->get_type_r(nzm1) == UNSURR) {
	resu.set_dzpuis(2) ;    // r^2 d/dr has been computed in the
	                        // external domain
      } 
    }
    else {
      int dzp = uu.get_dzpuis() ;
      
      resu = uuva.dsdx() ; 
      if (mg->get_type_r(nzm1) == UNSURR) {
	  resu.annule_domain(nzm1) ;  // zero in the CED
      
	  // Special treatment in the CED
	  Valeur tmp_ced = - uuva.dsdx() ; 
	  tmp_ced.annule(0, nz-2) ; // only non zero in the CED
	  tmp_ced.mult_xm1_zec() ; 
	  tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ; 
	  
	  // Recombination shells + CED : 
	  resu.set_spectral_va() += tmp_ced ;
      }
      resu.set_dzpuis(dzp+1) ;         
    
    }

    resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi

  }
    
}

			//---------------------//
			//        d/dr         //
			//---------------------//
			

void Map_af::dsdr(const Cmp& ci, Cmp& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp()->get_mg() == mg) ; 

    
    if (ci.get_etat() == ETATZERO) {
	resu.set_etat_zero() ; 
    }
    else {   
	assert( ci.get_etat() == ETATQCQ ) ; 
        

	(ci.va).coef() ;    // (ci.va).c_cf is up to date
	
	int nz = mg->get_nzone() ; 
	int nzm1 = nz - 1 ;

        switch( ci.get_dzpuis() ) {
        
            case 0 : {
	        resu = (ci.va).dsdx() * dxdr ;     //  dxdr = dxi/dR, - dxi/dU (ZEC)
	
	        if (mg->get_type_r(nzm1) == UNSURR) {
	            resu.set_dzpuis(2) ;    // r^2 d/dr has been computed in the
					    // external domain
	        } 
                break ; 
            }
            
            case 2 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;
                
	        Valeur tmp((ci.va).dsdx() * dxdr) ;
                tmp.annule(nzm1) ;  // zero in the CED

                // Special treatment in the CED
                Valeur tmp_ced = - (ci.va).dsdx() ; 
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED
                tmp_ced.mult_xm1_zec() ; 
                tmp_ced.set(nzm1) -= 2. * ci.va(nzm1) ; 
                
                // Recombination shells + CED : 
                resu = tmp + tmp_ced ;
                
                resu.set_dzpuis(3) ;         
                break ; 
            }
            
            case 4 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;

	        Valeur tmp(ci.va.dsdx() * dxdr) ;
	        Valeur tmp2 = tmp ;
	        tmp2.base = (ci.va).dsdx().base ;
	        tmp.annule(nzm1) ; // not in the CED
	        tmp2.annule(0, nz-2) ; // special treatment of the CED
	        tmp2.mult_xm1_zec() ;
	        tmp2 = tmp2 / xsr ;
	        tmp2.set(nzm1) -= 4*ci.va(nzm1) ;
	        tmp2.base = ci.va.base ; //Just for the CED
	        tmp2.mult_xm1_zec() ;

	        resu = tmp + tmp2 / xsr  ; 
	        resu.set_dzpuis(4) ;
                break ; 
            }
            
            default : {
                cerr << "Map_af::dsdr: unexpected value of input dzpuis !\n"
                    << "  ci.get_dzpuis() = " << ci.get_dzpuis() << endl ; 
                abort() ; 
                break ; 
            }
            
        }

	  
	(resu.va).set_base( (ci.va).dsdx().get_base() ) ; // same basis as d/dxi

    }
    
}

void Map_af::dsdr(const Scalar& uu, Scalar& resu) const {

  assert (uu.get_etat() != ETATNONDEF) ; 
  assert (uu.get_mp().get_mg() == mg) ; 

    
  if (uu.get_etat() == ETATZERO) {
    resu.set_etat_zero() ; 
  }
  else {   
    assert( uu.get_etat() == ETATQCQ ) ; 

    const Valeur& uuva = uu.get_spectral_va() ; 

    uuva.coef() ;    // (uu.va).c_cf is up to date
	
    int nz = mg->get_nzone() ; 
    int nzm1 = nz - 1 ;

    if ( uu.get_dzpuis() == 0 ) {
      resu = uuva.dsdx() * dxdr ;     //  dxdr = dxi/dR, - dxi/dU (ZEC)
	
      if (mg->get_type_r(nzm1) == UNSURR) {
	resu.set_dzpuis(2) ;    // r^2 d/dr has been computed in the
	                        // external domain
      } 
    }
    else {
      int dzp = uu.get_dzpuis() ;
      
      resu = uuva.dsdx() * dxdr ;
      if (mg->get_type_r(nzm1) == UNSURR) {
	  resu.annule_domain(nzm1) ;  // zero in the CED
      
	  // Special treatment in the CED
	  Valeur tmp_ced = - uuva.dsdx() ; 
	  tmp_ced.annule(0, nz-2) ; // only non zero in the CED
	  tmp_ced.mult_xm1_zec() ; 
	  tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ; 
	  
	  // Recombination shells + CED : 
	  resu.set_spectral_va() += tmp_ced ;
      }
      resu.set_dzpuis(dzp+1) ;         
    
    }

    resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi

  }
    
}
// VARIABLE RADIALE

void Map_af::dsdradial(const Scalar& uu, Scalar& resu) const {

  assert (uu.get_etat() != ETATNONDEF) ; 
  assert (uu.get_mp().get_mg() == mg) ; 

    
  if (uu.get_etat() == ETATZERO) {
    resu.set_etat_zero() ; 
  }
  else {   
    assert( uu.get_etat() == ETATQCQ ) ; 

    const Valeur& uuva = uu.get_spectral_va() ; 

    uuva.coef() ;    // (uu.va).c_cf is up to date
	
    int nz = mg->get_nzone() ; 
    int nzm1 = nz - 1 ;

    if ( uu.get_dzpuis() == 0 ) {
      resu = uuva.dsdx() * dxdr ;     //  dxdr = dxi/dR, - dxi/dU (ZEC)
	
      if (mg->get_type_r(nzm1) == UNSURR) {
	resu.set_dzpuis(2) ;    // r^2 d/dr has been computed in the
	                        // external domain
      } 
    }
    else {
      assert(mg->get_type_r(nzm1) == UNSURR) ;

      int dzp = uu.get_dzpuis() ;
      
      resu = uuva.dsdx() * dxdr ;
      resu.annule_domain(nzm1) ;  // zero in the CED
      
      // Special treatment in the CED
      Valeur tmp_ced = - uuva.dsdx() ; 
      tmp_ced.annule(0, nz-2) ; // only non zero in the CED
      tmp_ced.mult_xm1_zec() ; 
      tmp_ced.set(nzm1) -= dzp * uuva(nzm1) ; 
      
      // Recombination shells + CED : 
      resu.set_spectral_va() += tmp_ced ;
      
      resu.set_dzpuis(dzp+1) ;         
    
    }

    resu.set_spectral_base( uuva.dsdx().get_base() ) ; // same basis as d/dxi

  }
    
}

			//------------------------//
			//      1/r d/dtheta      //
			//------------------------//

void Map_af::srdsdt(const Cmp& ci, Cmp& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp()->get_mg() == mg) ; 
    
    if (ci.get_etat() == ETATZERO) {
	resu.set_etat_zero() ; 
    }
    else {

	assert( ci.get_etat() == ETATQCQ ) ; 

	(ci.va).coef() ;    // (ci.va).c_cf is up to date

	Valeur tmp = ci.va ; 
	
	tmp = tmp.dsdt() ;	// d/dtheta

	int nz = mg->get_nzone() ; 
	int nzm1 = nz - 1 ;

        switch( ci.get_dzpuis() ) {
        
            case 0 : {
	        tmp = tmp.sx() ;	// 1/xi, Id, 1/(xi-1)
	
	        Base_val sauve_base( tmp.get_base() ) ; 

	        tmp = tmp * xsr ;	// xi/R, 1/R, (xi-1)/U

	        tmp.set_base(sauve_base) ;   // The above operation does not the basis
	        resu = tmp ;
	  
	        if (mg->get_type_r(nz-1) == UNSURR) {
	            resu.set_dzpuis(2) ;	    // r d/dtheta has been computed in
					            // the external domain
	        }
                break ; 
            }
            
            case 2 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;
                
                // Special treatment in the CED
                Valeur tmp_ced = tmp ;    // d/dtheta 
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED

                tmp.annule(nzm1) ; 
	        tmp = tmp.sx() ;	// 1/xi, Id
	        Base_val sauve_base( tmp.get_base() ) ; 
	        tmp = tmp * xsr ;	// xi/R, 1/R
	        tmp.set_base(sauve_base) ;   // The above operation does not the basis
                
                // Recombination shells + CED : 
                resu = tmp + tmp_ced ;
                
                resu.set_dzpuis(3) ;         
                break ; 
            }
            
            case 4 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;

                // Special treatment in the CED
	        Valeur tmp_ced = tmp ;  // d/dtheta
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED
	        tmp_ced.mult_xm1_zec() ;

                tmp.annule(nzm1) ; 
	        tmp = tmp.sx() ;	// 1/xi, Id
	        Base_val sauve_base( tmp.get_base() ) ; 
	        tmp = tmp * xsr ;	// xi/R, 1/R

                // Recombination shells + CED : 
	        resu = tmp + tmp_ced / xsr ;

	        resu.va.set_base( sauve_base ) ;
	        resu.set_dzpuis(4) ;
                break ; 
            }
            
            default : {
                cerr << "Map_af::srdsdt: unexpected value of input dzpuis !\n"
                    << "  ci.get_dzpuis() = " << ci.get_dzpuis() << endl ; 
                abort() ; 
                break ; 
            }
            
        }

    }
    
}

void Map_af::srdsdt(const Scalar& uu, Scalar& resu) const {
  assert (uu.get_etat() != ETATNONDEF) ; 
  assert (uu.get_mp().get_mg() == mg) ; 
    
  if (uu.get_etat() == ETATZERO) {
    resu.set_etat_zero() ; 
  }
  else {

    assert( uu.get_etat() == ETATQCQ ) ; 

    const Valeur& uuva = uu.get_spectral_va() ;
    uuva.coef() ;    // (uu.va).c_cf is up to date

    Valeur tmp  = uuva.dsdt() ;	// d/dtheta

    int nz = mg->get_nzone() ; 
    int nzm1 = nz - 1 ;

    if (uu.get_dzpuis() == 0) {
      tmp = tmp.sx() ;	// 1/xi, Id, 1/(xi-1)
	
      Base_val sauve_base( tmp.get_base() ) ; 

      tmp = tmp * xsr ;	// xi/R, 1/R, (xi-1)/U

      tmp.set_base(sauve_base) ;   // The above operation does not change the basis
      resu = tmp ;
	  
      if (mg->get_type_r(nz-1) == UNSURR) {
	resu.set_dzpuis(2) ;	    // r d/dtheta has been computed in
	// the external domain
      }
    }

    else {
      assert(mg->get_type_r(nzm1) == UNSURR) ;
          
      int dzp = uu.get_dzpuis() ;
      // Special treatment in the CED
      Valeur tmp_ced = tmp ;    // d/dtheta 
      tmp_ced.annule(0, nz-2) ; // only non zero in the CED

      tmp.annule(nzm1) ; 
      tmp = tmp.sx() ;	// 1/xi, Id
      Base_val sauve_base( tmp.get_base() ) ; 
      tmp = tmp * xsr ;	// xi/R, 1/R
      tmp.set_base(sauve_base) ;   // The above operation does not change the basis
                
      // Recombination shells + CED : 
      resu = tmp + tmp_ced ;
                
      resu.set_dzpuis(dzp+1) ;         
    }
            
  }
    
}


			//------------------------------------//
			//       1/(r sin(theta))  d/dphi     //
			//------------------------------------//

void Map_af::srstdsdp(const Cmp& ci, Cmp& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp()->get_mg() == mg) ; 
    
    if (ci.get_etat() == ETATZERO) {
	resu.set_etat_zero() ; 
    }
    else {

	assert( ci.get_etat() == ETATQCQ ) ; 

	(ci.va).coef() ;    // (ci.va).c_cf is up to date

	Valeur tmp = ci.va ; 
	
	tmp = tmp.dsdp() ;	// d/dphi
	tmp = tmp.ssint() ;	// 1/sin(theta)

	int nz = mg->get_nzone() ; 
	int nzm1 = nz - 1 ;

        switch( ci.get_dzpuis() ) {
        
            case 0 : {
	        tmp = tmp.sx() ;	// 1/xi, Id, 1/(xi-1)
	
	        Base_val sauve_base( tmp.get_base() ) ; 

	        tmp = tmp * xsr ;	// xi/R, 1/R, (xi-1)/U

	        tmp.set_base(sauve_base) ;   // The above operation does not the basis
	        resu = tmp ;
	  
	        if (mg->get_type_r(nz-1) == UNSURR) {
	            resu.set_dzpuis(2) ;	    // r d/dtheta has been computed in
					            // the external domain
	        }
                break ; 
            }
            
            case 2 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;
                
                // Special treatment in the CED
                Valeur tmp_ced = tmp ;    // 1/sin(theta) d/dphi 
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED

                tmp.annule(nzm1) ; 
	        tmp = tmp.sx() ;	// 1/xi, Id
	        Base_val sauve_base( tmp.get_base() ) ; 
	        tmp = tmp * xsr ;	// xi/R, 1/R
	        tmp.set_base(sauve_base) ;   // The above operation does not the basis
                
                // Recombination shells + CED : 
                resu = tmp + tmp_ced ;
                
                resu.set_dzpuis(3) ;         
                break ; 
            }
            
            case 4 : {
	        assert(mg->get_type_r(nzm1) == UNSURR) ;

                // Special treatment in the CED
	        Valeur tmp_ced = tmp ;  // 1/sin(theta) d/dphi 
                tmp_ced.annule(0, nz-2) ; // only non zero in the CED
	        tmp_ced.mult_xm1_zec() ;

                tmp.annule(nzm1) ; 
	        tmp = tmp.sx() ;	// 1/xi, Id
	        Base_val sauve_base( tmp.get_base() ) ; 
	        tmp = tmp * xsr ;	// xi/R, 1/R

                // Recombination shells + CED : 
	        resu = tmp + tmp_ced / xsr ;

	        resu.va.set_base( sauve_base ) ;
	        resu.set_dzpuis(4) ;
                break ; 
            }
            
            default : {
                cerr << "Map_af::srstdsdp: unexpected value of input dzpuis !\n"
                    << "  ci.get_dzpuis() = " << ci.get_dzpuis() << endl ; 
                abort() ; 
                break ; 
            }
            
        }

    }

    
}

void Map_af::srstdsdp(const Scalar& uu, Scalar& resu) const {

  assert (uu.get_etat() != ETATNONDEF) ; 
  assert (uu.get_mp().get_mg() == mg) ; 
    
  if (uu.get_etat() == ETATZERO) {
    resu.set_etat_zero() ; 
  }
  else {

    assert( uu.get_etat() == ETATQCQ ) ; 

    const Valeur& uuva = uu.get_spectral_va() ;
    uuva.coef() ;    // (uu.va).c_cf is up to date

    Valeur tmp = uuva.dsdp() ;
	
    tmp = tmp.ssint() ;	// 1/sin(theta)

    int nz = mg->get_nzone() ; 
    int nzm1 = nz - 1 ;

    if (uu.get_dzpuis() == 0) {

      tmp = tmp.sx() ;	// 1/xi, Id, 1/(xi-1)
	
      Base_val sauve_base( tmp.get_base() ) ; 

      tmp = tmp * xsr ;	// xi/R, 1/R, (xi-1)/U

      tmp.set_base(sauve_base) ;   // The above operation does not change the basis
      resu = tmp ;
	  
      if (mg->get_type_r(nz-1) == UNSURR) {
	resu.set_dzpuis(2) ;	    // r d/dtheta has been computed in
	// the external domain
      }
    }

    else {
      assert(mg->get_type_r(nzm1) == UNSURR) ;
          
      int dzp = uu.get_dzpuis() ;

      // Special treatment in the CED
      Valeur tmp_ced = tmp ;    // 1/sin(theta) d/dphi 
      tmp_ced.annule(0, nz-2) ; // only non zero in the CED

      tmp.annule(nzm1) ; 
      tmp = tmp.sx() ;	// 1/xi, Id
      Base_val sauve_base( tmp.get_base() ) ; 
      tmp = tmp * xsr ;	// xi/R, 1/R
      tmp.set_base(sauve_base) ;   // The above operation does not change the basis
                
      // Recombination shells + CED : 
      resu = tmp + tmp_ced ;
                
      resu.set_dzpuis(dzp+1) ;         
    }
  }    
}


			//------------------------//
			//       d/dtheta         //
			//------------------------//


void Map_af::dsdt(const Scalar& ci, Scalar& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp().get_mg() == mg) ; 
    
    if (ci.get_etat() == ETATZERO) {
		resu.set_etat_zero() ; 
    }
    else {

		assert( ci.get_etat() == ETATQCQ ) ; 

		resu = ci.get_spectral_va().dsdt() ; 	// d/dtheta
		
    }

    resu.set_dzpuis( ci.get_dzpuis() ) ; 	// dzpuis unchanged
	
}


			//-----------------------------------//
			//       1/sin(theta) d/dphi         //
			//-----------------------------------//


void Map_af::stdsdp(const Scalar& ci, Scalar& resu) const {

    assert (ci.get_etat() != ETATNONDEF) ; 
    assert (ci.get_mp().get_mg() == mg) ; 
    
    if (ci.get_etat() == ETATZERO) {
		resu.set_etat_zero() ; 
    }
    else {

		assert( ci.get_etat() == ETATQCQ ) ; 
	
		resu = ci.get_spectral_va().stdsdp() ; 	// 1/sin(theta) d/dphi
		
    }
	
    resu.set_dzpuis( ci.get_dzpuis() ) ; 	// dzpuis unchanged

}








}