LORENE
scalar_r_manip.C
1/*
2 * Member functions of the class Scalar for various r manipulations
3 *
4 * See file scalar.h for documentation.
5 */
6
7/*
8 * Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
9 *
10 * Copyright (c) 1999-2001 Eric Gourgoulhon (for a preceding Cmp version)
11 * Copyright (c) 1999-2001 Philippe Grandclement (for a preceding Cmp version)
12 * Copyright (c) 2001 Jerome Novak (for a preceding Cmp version)
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
33char scalar_r_manip_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_r_manip.C,v 1.23 2014/10/13 08:53:47 j_novak Exp $" ;
34
35/*
36 * $Id: scalar_r_manip.C,v 1.23 2014/10/13 08:53:47 j_novak Exp $
37 * $Log: scalar_r_manip.C,v $
38 * Revision 1.23 2014/10/13 08:53:47 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.22 2005/05/25 16:11:05 j_novak
42 * Better handling of the case with no compactified domain.␓
43 *
44 * Revision 1.21 2005/05/18 11:45:46 j_novak
45 * Added del_deriv() calls at the end of inc/dec_dzpuis.
46 *
47 * Revision 1.20 2004/10/11 15:09:04 j_novak
48 * The radial manipulation functions take Scalar as arguments, instead of Cmp.
49 * Added a conversion operator from Scalar to Cmp.
50 * The Cmp radial manipulation function make conversion to Scalar, call to the
51 * Map_radial version with a Scalar argument and back.
52 *
53 * Revision 1.19 2004/10/08 13:34:37 j_novak
54 * Scalar::div_r() does not need to pass through Cmp version anymore.
55 *
56 * Revision 1.18 2004/05/12 14:22:12 f_limousin
57 * Treated the case ETATZERO in dec_dzpuis and inc_dzpuis (-> return).
58 *
59 * Revision 1.17 2004/01/29 09:31:44 j_novak
60 * Better treatment of ETATUN
61 *
62 * Revision 1.16 2004/01/28 10:34:27 j_novak
63 * Corrected some errors.
64 *
65 * Revision 1.15 2004/01/27 15:10:02 j_novak
66 * New methods Scalar::div_r_dzpuis(int) and Scalar_mult_r_dzpuis(int)
67 * which replace div_r_inc*. Tried to clean the dzpuis handling.
68 * WARNING: no testing at this point!!
69 *
70 * Revision 1.14 2004/01/22 16:11:30 e_gourgoulhon
71 * Added (provisory method) div_r_inc1().
72 * Case inc = 3 treated in inc_dzpuis.
73 *
74 * Revision 1.13 2003/11/04 23:02:21 e_gourgoulhon
75 * -- Method dec_dzpuis(int decrem) : the case decrem = 1 is now treated.
76 * -- Method div_tant() is now defined in file scalar_th_manip.C.
77 *
78 * Revision 1.12 2003/11/03 22:36:37 e_gourgoulhon
79 * Method dec_dzpuis: changed the name of argument dec --> decrem
80 * (in order not to shadow some globally defined dec).
81 *
82 * Revision 1.11 2003/11/03 10:25:05 e_gourgoulhon
83 * Scalar::dec_dzpuis(int dec) : treated the case dec = 0
84 * Scalar::inc_dzpuis(int inc) : treated the case inc = 0
85 *
86 * Revision 1.10 2003/10/29 11:02:13 e_gourgoulhon
87 * Functions dec_dzpuis and inc_dzpuis have now an integer argument to
88 * specify by which amount dzpuis is to be increased.
89 * Accordingly methods dec2_dzpuis and inc2_dzpuis have been suppressed
90 *
91 * Revision 1.9 2003/10/16 15:29:08 e_gourgoulhon
92 * Name of method div_r_ced() changed to div_r_inc2().
93 * Name of method div_rsint_ced() changed to div_rsint_inc2().
94 *
95 * Revision 1.8 2003/10/15 10:44:21 e_gourgoulhon
96 * Added new method div_tant.
97 *
98 * Revision 1.7 2003/10/13 20:50:16 e_gourgoulhon
99 * Replaced "va.base" by "va.get_base()".
100 *
101 * Revision 1.6 2003/10/10 15:57:29 j_novak
102 * Added the state one (ETATUN) to the class Scalar
103 *
104 * Revision 1.5 2003/10/08 14:24:10 j_novak
105 * replaced mult_r_zec with mult_r_ced
106 *
107 * Revision 1.4 2003/10/08 12:26:03 j_novak
108 * Second part of the bug (sorry!)
109 *
110 * Revision 1.3 2003/10/08 12:19:12 j_novak
111 * Bug corrected, thanks to purify
112 *
113 * Revision 1.2 2003/10/05 21:16:41 e_gourgoulhon
114 * Added methods div_r_ced() and div_rsint_ced().
115 *
116 * Revision 1.1 2003/09/25 09:12:01 e_gourgoulhon
117 * First version (uses Cmp as intermediate variable).
118 *
119 *
120 * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_r_manip.C,v 1.23 2014/10/13 08:53:47 j_novak Exp $
121 *
122 */
123
124#include "tensor.h"
125#include "cmp.h"
126
127
128 //-------------------//
129 // div_r //
130 //-------------------//
131
132namespace Lorene {
134
135 mp->div_r(*this) ; // Call of the appropriate routine of the mapping
136
137 del_deriv() ; // Delete the derived members
138
139}
140
141
142 //---------------------//
143 // div_r_dzpuis //
144 //---------------------//
145
146
148
149 assert (etat != ETATNONDEF) ;
150
152
153 if (etat != ETATZERO) {
154
155 assert((etat == ETATQCQ) || (etat == ETATUN)) ;
156
157 set_etat_qcq() ;
158
159 int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
160 bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
161
162 // Copy of the CED part of *this into uu_ext
163 Scalar uu_ext(*mp) ;
164 if (ced) {
165 uu_ext.allocate_all() ;
166 uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
167 uu_ext.set_domain(nzm1) = domain(nzm1) ;
168 uu_ext.set_spectral_base(va.get_base()) ;
169
170 // Division by r in all domains but the CED
171 annule(nzm1, nzm1) ; // zero in the CED
172 }
173 div_r() ;
174
175 if (ced) { // Add the CED part
176 set_domain(nzm1) = uu_ext.domain(nzm1) ;
177 dzpuis += 1 ;
178 }
179 }
180
183
184 lbase.sx() ;
186
187 del_deriv() ; // Delete the derived members
188
189 return ;
190}
191
192 //---------------------------//
193 // div_r_ced //
194 //---------------------------//
195
197
198 mp->div_r_zec(*this) ; // Call of the appropriate routine of the mapping
199
200 del_deriv() ; // Delete the derived members
201
202}
203
204 //---------------------------//
205 // mult_r //
206 //---------------------------//
207
209
210 mp->mult_r(*this) ; // Call of the appropriate routine of the mapping
211
212 del_deriv() ; // Delete the derived members
213
214}
215
216 //---------------------//
217 // mult_r_dzpuis //
218 //---------------------//
219
220
222
223 assert (etat != ETATNONDEF) ;
224
226
227 if (etat != ETATZERO) {
228
229 assert((etat == ETATQCQ) || (etat == ETATUN)) ;
230
231 set_etat_qcq() ;
232
233 int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
234 bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
235 Scalar uu_ext(*mp) ;
236
237 if (ced) {// Copy of the CED part of *this into uu_ext
238 uu_ext.allocate_all() ;
239 uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
240 uu_ext.set_domain(nzm1) = domain(nzm1) ;
241 uu_ext.set_spectral_base(va.get_base()) ;
242
243 // Division by r in all domains but the CED
244 annule(nzm1, nzm1) ; // zero in the CED
245 }
246 mult_r() ;
247
248 if (ced) {// Add the CED part
249 set_domain(nzm1) = uu_ext.domain(nzm1) ;
250 dzpuis -= 1 ;
251 }
252 }
253
256
257 lbase.mult_x() ;
259
260 del_deriv() ; // Delete the derived members
261
262 return ;
263}
264
265 //---------------------------//
266 // mult_r_ced //
267 //---------------------------//
268
270
271 mp->mult_r_zec(*this) ; // Call of the appropriate routine of the mapping
272
273 del_deriv() ; // Delete the derived members
274
275}
276
277 //---------------------------//
278 // mult_rsint //
279 //---------------------------//
280
282
283 mp->mult_rsint(*this) ; // Call of the appropriate routine of the mapping
284
285 del_deriv() ; // Delete the derived members
286
287}
288
289 //-------------------------//
290 // mult_rsint_dzpuis //
291 //-------------------------//
292
293
295
296 assert (etat != ETATNONDEF) ;
297
299 int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
300 bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
301
302 if (etat != ETATZERO) {
303
304 assert((etat == ETATQCQ) || (etat == ETATUN)) ;
305
306 set_etat_qcq() ;
307 Scalar uu_ext(*mp) ;
308
309 if (ced) {// Copy of the CED part of *this into uu_ext and multiplication by r
310 uu_ext.allocate_all() ;
311 uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
312 uu_ext.set_domain(nzm1) = domain(nzm1) ;
313 uu_ext.set_spectral_base(va.get_base()) ;
314 int dzpuis_ext = dzpuis - 1 ;
315 uu_ext.set_dzpuis(dzpuis_ext) ;
317 (diff_dzpuis >= 0) ? uu_ext.inc_dzpuis(diff_dzpuis)
318 : uu_ext.dec_dzpuis(-diff_dzpuis) ;
319
320 // Multiplication by sin(theta) in the CED :
321 // what follows does not apply if the mapping is not radial:
322 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
323 uu_ext.mult_sint() ;
324
325 // Multiplication by r sin(theta) in all domains but the CED
326 annule(nzm1, nzm1) ; // zero in the CED
327 }
328 mult_rsint() ;
329
330 if (ced) // Add the CED part
331 set_domain(nzm1) = uu_ext.domain(nzm1) ;
332 }
333
334 if (ced) dzpuis = ced_mult_r ;
335
336 lbase.mult_x() ;
337 lbase.mult_sint() ;
339
340 del_deriv() ; // Delete the derived members
341
342}
343
344 //---------------------------//
345 // div_rsint //
346 //---------------------------//
347
349
350 mp->div_rsint(*this) ; // Call of the appropriate routine of the mapping
351
352 del_deriv() ; // Delete the derived members
353
354}
355
356
357 //-------------------------//
358 // div_rsint_dzpuis //
359 //-------------------------//
360
361
363
364 assert (etat != ETATNONDEF) ;
365
367 int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
368 bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
369
370 if (etat != ETATZERO) {
371
372 assert((etat == ETATQCQ) || (etat == ETATUN)) ;
373
374 set_etat_qcq() ;
375 Scalar uu_ext(*mp) ;
376
377 if (ced) {// Copy of the CED part of *this into uu_ext and multiplication by r
378 uu_ext.allocate_all() ;
379 uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
380 uu_ext.set_domain(nzm1) = domain(nzm1) ;
381 uu_ext.set_spectral_base(va.get_base()) ;
382 int dzpuis_ext = dzpuis + 1 ;
383 uu_ext.set_dzpuis(dzpuis_ext) ;
385 (diff_dzpuis >= 0) ? uu_ext.inc_dzpuis(diff_dzpuis)
386 : uu_ext.dec_dzpuis(-diff_dzpuis) ;
387
388 // Division by sin(theta) in the CED :
389 // what follows does not apply if the mapping is not radial:
390 assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ;
391 uu_ext.div_sint() ;
392
393 // Division by r sin(theta) in all domains but the CED
394 annule(nzm1, nzm1) ; // zero in the CED
395 }
396 div_rsint() ;
397
398 if (ced) // Add the CED part
399 set_domain(nzm1) = uu_ext.domain(nzm1) ;
400
401 }
402 if (ced)
404
405 lbase.sx() ;
406 lbase.ssint() ;
408
409 del_deriv() ; // Delete the derived members
410
411}
412
413
414 //-----------------------//
415 // dec_dzpuis //
416 //-----------------------//
417
419
420 if (decrem == 0) return ;
421
422 if (etat == ETATZERO) {
423//## dzpuis -= decrem ; // a voir...
424 return ;
425 }
426
427 switch (decrem) {
428
429 case 0 : {
430 break ;
431 }
432
433 case 1 : {
434 mp->dec_dzpuis(*this) ;
435 break ;
436 }
437
438 case 2 : {
439 mp->dec2_dzpuis(*this) ;
440 break ;
441 }
442
443 case 3 : {
444 mp->dec2_dzpuis(*this) ;
445 mp->dec_dzpuis(*this) ;
446 break ;
447 }
448
449 case 4 : {
450 mp->dec2_dzpuis(*this) ;
451 mp->dec2_dzpuis(*this) ;
452 break ;
453 }
454
455 default : {
456 cout << "Scalar::dec_dzpuis : unexpected value of decrem !"
457 << endl << " decrem = " << decrem << endl ;
458 abort() ;
459 break ;
460 }
461 }
462 del_deriv() ;
463
464}
465
466 //-----------------------//
467 // inc_dzpuis //
468 //-----------------------//
469
471
472 if (inc == 0) return ;
473
474 if (etat == ETATZERO) {
475//## dzpuis += inc ; // a voir ...
476 return ;
477 }
478
479 switch (inc) {
480
481 case 0 : {
482 break ;
483 }
484
485 case 1 : {
486 mp->inc_dzpuis(*this) ;
487 break ;
488 }
489
490 case 2 : {
491 mp->inc2_dzpuis(*this) ;
492 break ;
493 }
494
495 case 3 : {
496 mp->inc_dzpuis(*this) ;
497 mp->inc2_dzpuis(*this) ;
498 break ;
499 }
500
501 case 4 : {
502 mp->inc2_dzpuis(*this) ;
503 mp->inc2_dzpuis(*this) ;
504 break ;
505 }
506
507 default : {
508 cout << "Scalar::inc_dzpuis : unexpected value of inc !"
509 << endl << " inc = " << inc << endl ;
510 abort() ;
511 break ;
512 }
513 }
514 del_deriv() ;
515
516}
517
518
519
520}
Bases of the spectral expansions.
Definition base_val.h:322
Time evolution with partial storage (*** under development ***).
Definition evolution.h:371
Base class for pure radial mappings.
Definition map.h:1536
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
virtual void del_deriv() const
Logical destructor of the derivatives.
Definition scalar.C:287
void div_rsint_dzpuis(int ced_mult_r)
Division by but with the output flag dzpuis set to ced_mult_r .
void div_r_dzpuis(int ced_mult_r)
Division by r everywhere but with the output flag dzpuis set to ced_mult_r .
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition scalar.C:353
virtual void inc_dzpuis(int inc=1)
Increases by inc units the value of dzpuis and changes accordingly the values of the Scalar in the co...
void div_r()
Division by r everywhere; dzpuis is not changed.
Tbl & set_domain(int l)
Read/write of the value in a given domain.
Definition scalar.h:615
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition scalar.C:391
void mult_r_ced()
Multiplication by r in the compactified external domain (CED), the dzpuis flag is not changed.
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary).
Definition scalar.h:396
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
void div_rsint()
Division by everywhere; dzpuis is not changed.
void mult_rsint_dzpuis(int ced_mult_r)
Multiplication by but with the output flag dzpuis set to ced_mult_r .
const Tbl & domain(int l) const
Read-only of the value in a given domain.
Definition scalar.h:625
void mult_r_dzpuis(int ced_mult_r)
Multiplication by r everywhere but with the output flag dzpuis set to ced_mult_r .
Valeur va
The numerical value of the Scalar
Definition scalar.h:405
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values of the Scalar in the co...
void mult_r()
Multiplication by r everywhere; dzpuis is not changed.
void div_r_ced()
Division by r in the compactified external domain (CED), the dzpuis flag is not changed.
void set_spectral_base(const Base_val &)
Sets the spectral bases of the Valeur va
Definition scalar.C:797
int dzpuis
Power of r by which the quantity represented by this must be divided in the compactified external d...
Definition scalar.h:403
const Base_val & get_base() const
Return the bases for spectral expansions (member base )
Definition valeur.h:480
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:305
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition tensor.h:295
Lorene prototypes.
Definition app_hor.h:64