LORENE
vector.C
1/*
2 * Methods of class Vector
3 *
4 * (see file vector.h for documentation)
5 *
6 */
7
8/*
9 * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29
30
31
32/*
33 * $Id: vector.C,v 1.31 2016/12/05 16:18:18 j_novak Exp $
34 * $Log: vector.C,v $
35 * Revision 1.31 2016/12/05 16:18:18 j_novak
36 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37 *
38 * Revision 1.30 2014/10/13 08:53:44 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.29 2014/10/06 15:13:20 j_novak
42 * Modified #include directives to use c++ syntax.
43 *
44 * Revision 1.28 2008/10/29 14:09:14 jl_cornou
45 * Spectral bases for pseudo vectors and curl added
46 *
47 * Revision 1.27 2008/08/27 08:52:23 jl_cornou
48 * Added fonctions for angular potential A
49 *
50 * Revision 1.26 2007/12/21 16:07:08 j_novak
51 * Methods to filter Tensor, Vector and Sym_tensor objects.
52 *
53 * Revision 1.25 2005/02/14 13:01:50 j_novak
54 * p_eta and p_mu are members of the class Vector. Most of associated functions
55 * have been moved from the class Vector_divfree to the class Vector.
56 *
57 * Revision 1.24 2005/01/25 15:37:35 j_novak
58 * Solved some dzpuis problem...
59 *
60 * Revision 1.23 2005/01/12 16:48:23 j_novak
61 * Better treatment of the case where all vector components are null in
62 * decompose_div .
63 *
64 * Revision 1.22 2004/10/12 09:58:25 j_novak
65 * Better memory management.
66 *
67 * Revision 1.21 2004/10/11 09:46:31 j_novak
68 * Speed improvements.
69 *
70 * Revision 1.20 2004/05/09 20:55:05 e_gourgoulhon
71 * Added method flux.
72 *
73 * Revision 1.19 2004/03/29 11:57:45 e_gourgoulhon
74 * Added methods ope_killing and ope_killing_conf.
75 *
76 * Revision 1.18 2004/02/26 22:48:50 e_gourgoulhon
77 * -- Method divergence: call to Tensor::divergence and cast of the
78 * result.
79 * -- Added method derive_lie.
80 *
81 * Revision 1.17 2004/02/24 09:46:20 j_novak
82 * Correction to cope with SGI compiler's warnings.
83 *
84 * Revision 1.16 2004/02/20 10:53:04 j_novak
85 * Added the matching of the potential adapted to the case where the
86 * vector is the source of a Poisson equation (dzpuis = 4).
87 *
88 * Revision 1.15 2004/01/30 10:30:17 j_novak
89 * Changed dzpuis handling in Vector::decompose_div (this may be temporary).
90 *
91 * Revision 1.14 2003/12/30 23:09:47 e_gourgoulhon
92 * Change in methods derive_cov() and divergence() to take into account
93 * the change of name: Metric::get_connect() --> Metric::connect().
94 *
95 * Revision 1.13 2003/12/19 15:18:16 j_novak
96 * Shadow variables hunt
97 *
98 * Revision 1.12 2003/10/29 11:04:34 e_gourgoulhon
99 * dec2_dpzuis() replaced by dec_dzpuis(2).
100 * inc2_dpzuis() replaced by inc_dzpuis(2).
101 *
102 * Revision 1.11 2003/10/22 14:24:19 j_novak
103 * *** empty log message ***
104 *
105 * Revision 1.9 2003/10/20 13:00:38 j_novak
106 * Memory error corrected
107 *
108 * Revision 1.8 2003/10/20 09:32:12 j_novak
109 * Members p_potential and p_div_free of the Helmholtz decomposition
110 * + the method decompose_div(Metric).
111 *
112 * Revision 1.7 2003/10/16 14:21:37 j_novak
113 * The calculation of the divergence of a Tensor is now possible.
114 *
115 * Revision 1.6 2003/10/13 13:52:40 j_novak
116 * Better managment of derived quantities.
117 *
118 * Revision 1.5 2003/10/06 13:58:48 j_novak
119 * The memory management has been improved.
120 * Implementation of the covariant derivative with respect to the exact Tensor
121 * type.
122 *
123 * Revision 1.4 2003/10/05 21:14:20 e_gourgoulhon
124 * Added method std_spectral_base().
125 *
126 * Revision 1.3 2003/10/03 14:10:32 e_gourgoulhon
127 * Added constructor from Tensor.
128 *
129 * Revision 1.2 2003/10/03 14:08:46 j_novak
130 * Removed old change_trid...
131 *
132 * Revision 1.1 2003/09/26 08:05:31 j_novak
133 * New class Vector.
134 *
135 *
136 * $Header: /cvsroot/Lorene/C++/Source/Tensor/vector.C,v 1.31 2016/12/05 16:18:18 j_novak Exp $
137 *
138 */
139
140// Headers C
141#include <cstdlib>
142#include <cassert>
143#include <cmath>
144
145// Headers Lorene
146#include "metric.h"
147#include "proto.h"
148#include "matrice.h"
149#include "nbr_spx.h"
150
151
152 //--------------//
153 // Constructors //
154 //--------------//
155
156// Standard constructor
157// --------------------
158namespace Lorene {
159Vector::Vector(const Map& map, int tipe, const Base_vect& triad_i)
160 : Tensor(map, 1, tipe, triad_i) {
161
162 set_der_0x0() ;
163
164}
165
166// Standard constructor with the triad passed as a pointer
167// -------------------------------------------------------
168Vector::Vector(const Map& map, int tipe, const Base_vect* triad_i)
169 : Tensor(map, 1, tipe, *triad_i) {
170
171 set_der_0x0() ;
172}
173
174// Copy constructor
175// ----------------
176Vector::Vector (const Vector& source) :
177 Tensor(source) {
178
179 assert(valence == 1) ;
180 set_der_0x0() ;
181
182}
183
184
185// Constructor from a {\tt Tensor}.
186//--------------------------------
187Vector::Vector(const Tensor& uu) : Tensor(uu) {
188
189 assert(valence == 1) ;
190 set_der_0x0() ;
191
192}
193
194
195// Constructor from a file
196// -----------------------
197Vector::Vector(const Map& mapping, const Base_vect& triad_i, FILE* fd) :
198 Tensor(mapping, triad_i, fd) {
199
200 assert ( (valence == 1) && (n_comp == 3) ) ;
201 set_der_0x0() ;
202
203}
204
205
206 //--------------//
207 // Destructor //
208 //--------------//
209
210
212
214
215}
216
217
218 //-------------------//
219 // Memory managment //
220 //-------------------//
221
222void Vector::del_deriv() const {
223
224 for (int i=0; i<N_MET_MAX; i++)
225 del_derive_met(i) ;
226
227 if (p_A != 0x0) delete p_A ;
228 if (p_eta != 0x0) delete p_eta ;
229 if (p_mu != 0x0) delete p_mu ;
230 set_der_0x0() ;
232
233}
234
236
237 for (int i=0; i<N_MET_MAX; i++)
238 set_der_met_0x0(i) ;
239 p_A = 0x0 ;
240 p_eta = 0x0 ;
241 p_mu = 0x0 ;
242
243}
244
245void Vector::del_derive_met(int j) const {
246
247 assert( (j>=0) && (j<N_MET_MAX) ) ;
248
249 if (met_depend[j] != 0x0) {
250 if (p_potential[j] != 0x0)
251 delete p_potential[j] ;
252 if (p_div_free[j] != 0x0)
253 delete p_div_free[j] ;
254
255 set_der_met_0x0(j) ;
256
258 }
259}
260
261void Vector::set_der_met_0x0(int i) const {
262
263 assert( (i>=0) && (i<N_MET_MAX) ) ;
264
265 p_potential[i] = 0x0 ;
266 p_div_free[i] = 0x0 ;
267
268}
269
270void Vector::operator=(const Vector& t) {
271
272 triad = t.triad ;
273
274 assert(t.type_indice(0) == type_indice(0)) ;
275
276 for (int i=0 ; i<3 ; i++) {
277 *cmp[i] = *t.cmp[i] ;
278 }
279 del_deriv() ;
280}
281
282void Vector::operator=(const Tensor& t) {
283
284 assert (t.valence == 1) ;
285
286 triad = t.triad ;
287
288 assert(t.type_indice(0) == type_indice(0)) ;
289
290 for (int i=0 ; i<3 ; i++) {
291 *cmp[i] = *t.cmp[i] ;
292 }
293 del_deriv() ;
294}
295
296
297
298// Affectation d'une composante :
299Scalar& Vector::set(int index) {
300
301 assert ( (index>=1) && (index<=3) ) ;
302
303 del_deriv() ;
304
305 return *cmp[index - 1] ;
306}
307
308const Scalar& Vector::operator()(int index) const {
309
310 assert ( (index>=1) && (index<=3) ) ;
311
312 return *cmp[index - 1] ;
313
314}
315
316
317// Sets the standard spectal bases of decomposition for each component
318
320
321 Base_val** bases = 0x0 ;
322
323 if ( triad->identify() == (mp->get_bvect_cart()).identify() ) {
324
325 // Cartesian case
326 bases = mp->get_mg()->std_base_vect_cart() ;
327
328 }
329 else {
330 // Spherical case
331 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
332 bases = mp->get_mg()->std_base_vect_spher() ;
333 }
334
335 for (int i=0 ; i<3 ; i++) {
336 cmp[i]->set_spectral_base( *bases[i] ) ;
337 }
338
339 for (int i=0 ; i<3 ; i++) {
340 delete bases[i] ;
341 }
342 delete [] bases ;
343
344
345}
346
347// Sets the standard spectral bases of decomposition for each component for a pseudo vector
348
350
351 Base_val** bases = 0x0 ;
352
353 if ( triad->identify() == (mp->get_bvect_cart()).identify() ) {
354
355 // Cartesian case
356 bases = mp->get_mg()->pseudo_base_vect_cart() ;
357
358 }
359 else {
360 // Spherical case
361 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
362 bases = mp->get_mg()->pseudo_base_vect_spher() ;
363 }
364
365 for (int i=0 ; i<3 ; i++) {
366 cmp[i]->set_spectral_base( *bases[i] ) ;
367 }
368
369 for (int i=0 ; i<3 ; i++) {
370 delete bases[i] ;
371 }
372 delete [] bases ;
373
374
375}
376
377
378
379 //-------------------------------//
380 // Computational methods //
381 //-------------------------------//
382
383
384const Scalar& Vector::divergence(const Metric& metre) const {
385
386 const Scalar* pscal =
387 dynamic_cast<const Scalar*>( &(Tensor::divergence(metre)) ) ;
388
389 assert(pscal != 0x0) ;
390
391 return *pscal ;
392}
393
394
396
397 Vector resu(*mp, type_indice(0), triad) ;
398
399 compute_derive_lie(vv, resu) ;
400
401 return resu ;
402
403}
404
406
407 if ( triad->identify() == (mp->get_bvect_cart()).identify() ) {
408 const Metric_flat& metc = mp->flat_met_cart() ;
409 Vector_divfree resu(*mp, mp->get_bvect_cart(), metc) ;
410 resu.set(1)= cmp[3]->dsdy() - cmp[2]->dsdz();
411 resu.set(2)= cmp[1]->dsdz() - cmp[3]->dsdx();
412 resu.set(3)= cmp[2]->dsdx() - cmp[1]->dsdy();
414 return resu ;
415 }
416 else {
417 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
418 const Metric_flat& mets = mp->flat_met_spher() ;
419 Vector_divfree resu(*mp, mp->get_bvect_spher(), mets);
420 Scalar tmp = *cmp[3] ;
421 tmp.div_tant();
422 tmp += cmp[3]->dsdt();
423 tmp.div_r();
424 resu.set(1) = tmp - cmp[2]->srstdsdp() ;
425 tmp = *cmp[3] ;
426 tmp.mult_r();
427 tmp = tmp.dsdr();
428 tmp.div_r();
429 resu.set(2) = cmp[1]->srstdsdp() - tmp ;
430 tmp = *cmp[2];
431 tmp.mult_r();
432 resu.set(3) = tmp.dsdr() - cmp[1]->dsdt() ;
433 resu.set(3).div_r();
435 return resu ;
436 }
437
438}
439
440
441Sym_tensor Vector::ope_killing(const Metric& gam) const {
442
443 Sym_tensor resu(*mp, type_indice(0), *triad) ;
444
445 if (type_indice(0) == CON ) {
446 for (int i=1; i<=3; i++) {
447 for (int j=i; j<=3; j++) {
448 resu.set(i,j) = derive_con(gam)(i,j) + derive_con(gam)(j,i) ;
449 }
450 }
451 }
452 else {
453 for (int i=1; i<=3; i++) {
454 for (int j=i; j<=3; j++) {
455 resu.set(i,j) = derive_cov(gam)(i,j) + derive_cov(gam)(j,i) ;
456 }
457 }
458 }
459
460 return resu ;
461
462}
463
464
465Sym_tensor Vector::ope_killing_conf(const Metric& gam) const {
466
467 Sym_tensor resu(*mp, type_indice(0), *triad) ;
468
469 if (type_indice(0) == CON ) {
470 for (int i=1; i<=3; i++) {
471 for (int j=i; j<=3; j++) {
472 resu.set(i,j) = derive_con(gam)(i,j) + derive_con(gam)(j,i)
473 - 0.6666666666666666* divergence(gam)
474 * gam.con()(i,j) ;
475 }
476 }
477 }
478 else {
479 for (int i=1; i<=3; i++) {
480 for (int j=i; j<=3; j++) {
481 resu.set(i,j) = derive_cov(gam)(i,j) + derive_cov(gam)(j,i)
482 - 0.6666666666666666* derive_con(gam).trace()
483 * gam.cov()(i,j) ;
484 }
485 }
486 }
487
488 return resu ;
489
490}
491
492
493
494
495const Scalar& Vector::potential(const Metric& metre) const {
496
497 set_dependance(metre) ;
498 int j = get_place_met(metre) ;
499 assert ((j>=0) && (j<N_MET_MAX)) ;
500 if (p_potential[j] == 0x0) {
501 decompose_div(metre) ;
502 }
503
504 return *p_potential[j] ;
505}
506
507const Vector_divfree& Vector::div_free(const Metric& metre) const {
508
509 set_dependance(metre) ;
510 int j = get_place_met(metre) ;
511 assert ((j>=0) && (j<N_MET_MAX)) ;
512 if (p_div_free[j] == 0x0) {
513 decompose_div(metre) ;
514 }
515
516 return *p_div_free[j] ;
517}
518
519void Vector::decompose_div(const Metric& metre) const {
520
521 assert( type_indice(0) == CON ) ; //Only for contravariant vectors...
522
523 set_dependance(metre) ;
524 int ind = get_place_met(metre) ;
525 assert ((ind>=0) && (ind<N_MET_MAX)) ;
526
527 if ( (p_potential[ind] != 0x0) && (p_div_free[ind] != 0x0) )
528 return ; // Nothing to do ...
529
530 else {
531 if (p_div_free[ind] != 0x0)
532 delete p_div_free[ind] ;
533 if (p_potential[ind] != 0x0)
534 delete p_potential[ind] ;
535
536 const Mg3d* mmg = mp->get_mg() ;
537 int nz = mmg->get_nzone() ;
538
539 int dzp = cmp[0]->get_dzpuis() ;
540#ifndef NDEBUG
541 bool dz_zero = cmp[0]->check_dzpuis(0) ;
542 bool dz_four = cmp[0]->check_dzpuis(4) ;
543#endif
544 assert( dz_zero || dz_four) ;
545 assert (cmp[1]->check_dzpuis(dzp)) ;
546 assert (cmp[2]->check_dzpuis(dzp)) ;
547
548 Scalar dive = divergence(metre) ;
549
550 if (dive.get_etat() == ETATZERO) {
551 p_potential[ind] = new Scalar(*mp) ;
552 p_potential[ind]->set_etat_zero() ;
553 p_potential[ind]->set_dzpuis(dzp) ;
554 }
555 else {
556 //No matching of the solution at this point
557 p_potential[ind] = new Scalar(dive.poisson()) ;
558
559 if (dzp == 4) {
560 assert (mmg->get_type_r(nz-1) == UNSURR) ;
561 // Let's now do the matching ... in the case dzpuis = 4
562 const Map_af* mapping = dynamic_cast<const Map_af*>(mp) ;
563 assert (mapping != 0x0) ;
564 Valeur& val = p_potential[ind]->set_spectral_va() ;
565 val.ylm() ;
566 Mtbl_cf& mtc = *val.c_cf ;
567 if (nz > 1) {
568 int np = mmg->get_np(0) ;
569 int nt = mmg->get_nt(0) ;
570#ifndef NDEBUG
571 for (int lz=0; lz<nz; lz++) {
572 assert (mmg->get_np(lz) == np) ;
573 assert (mmg->get_nt(lz) == nt) ;
574 }
575#endif
576 int lmax = 0 ;
577 for (int k=0; k<np+1; k++)
578 for (int j=0; j<nt; j++)
579 if ( nullite_plm(j, nt, k, np, val.base)) {
580 int m_quant, l_quant, base_r ;
581 donne_lm (nz, 0, j, k, val.base, m_quant,
582 l_quant, base_r) ;
583 lmax = (l_quant > lmax ? l_quant : lmax) ;
584 }
585 Scalar** ri = new Scalar*[lmax+1] ;
586 Scalar** rmi = new Scalar*[lmax+1] ;
587 Scalar erre(*mp) ;
588 erre = mp->r ;
589 for (int l=0; l<=lmax; l++) {
590 ri[l] = new Scalar(*mp) ;
591 rmi[l] = new Scalar(*mp) ;
592 if (l == 0) *(ri[l]) = 1. ;
593 else *(ri[l]) = pow(erre, l) ;
594 ri[l]->annule_domain(nz - 1) ;
595 ri[l]->std_spectral_base() ; //exact base in r will be set later
596 if (l==2) *(rmi[l]) = 1 ;
597 else *(rmi[l]) = pow(erre, 2-l) ;
598 rmi[l]->annule(0,nz-2) ;
599 Scalar tmp = pow(erre, -l-1) ;
600 tmp.annule_domain(nz-1) ;
601 tmp.annule_domain(0) ;
602 *(rmi[l]) += tmp ;
603 rmi[l]->set_dzpuis(3) ;
604 rmi[l]->std_spectral_base() ;//exact base in r will be set later
605 }
606
607 for (int k=0; k<np+1; k++) {
608 for (int j=0; j<nt; j++) {
609 if ( nullite_plm(j, nt, k, np, val.base)) {
610 int m_quant, l_quant, base_r, l, c ;
611 donne_lm (nz, 0, j, k, val.base, m_quant, l_quant, base_r) ;
612 bool lzero = (l_quant == 0) || (l_quant == 1) ;
613 int nb_hom_ced = (l_quant < 2 ? 0 : 1) ;
614
615 int taille = 2*(nz-1) - 1 + nb_hom_ced ;
616 Tbl deuz(taille) ;
617 deuz.set_etat_qcq() ;
618 Matrice systeme(taille,taille) ;
619 systeme.set_etat_qcq() ;
620 for (l=0; l<taille; l++)
621 for (c=0; c<taille; c++) systeme.set(l,c) = 0 ;
622 for (l=0; l<taille; l++) deuz.set(l) = 0 ;
623
624 //---------
625 // Nucleus
626 //---------
627 assert(mmg->get_type_r(0) == RARE) ;
628 assert ((base_r == R_CHEBP)||(base_r == R_CHEBI)) ;
629 ri[l_quant]->set_spectral_va().set_base_r(0, base_r) ;
630
631 double alpha = mapping->get_alpha()[0] ;
632 int nr = mmg->get_nr(0) ;
633 Tbl partn(nr) ;
634 partn.set_etat_qcq() ;
635 for (int i=0; i<nr; i++)
636 partn.set(i) = mtc(0, k, j, i) ;
637 l=0 ; c=0 ;
638
639 systeme.set(l,c) += pow(alpha, double(l_quant)) ;
640
641 deuz.set(l) -= val1_dern_1d(0, partn, base_r) ;
642 l++ ;
643
644 if (!lzero) {
645 systeme.set(l,c) += l_quant * pow(alpha, double(l_quant - 1)) ;
646
647 deuz.set(l) -= val1_dern_1d(1, partn, base_r) / alpha ;
648 }
649
650 //----------
651 // Shells
652 //----------
653
654 for (int lz=1; lz<nz-1; lz++) {
655 alpha = mapping->get_alpha()[lz] ;
656 double beta = mapping->get_beta()[lz] ;
657 double xm1 = beta - alpha ;
658 double xp1 = alpha + beta ;
659 nr = mmg->get_nr(lz) ;
660 Tbl parts(nr) ;
661 parts.set_etat_qcq() ;
662 for (int i=0; i<nr; i++)
663 parts.set(i) = mtc(lz, k, j, i) ;
664
665 //Function at x = -1
666 l-- ;
667 c = 2*lz - 1 ;
668 systeme.set(l,c) -= pow(xm1, double(l_quant)) ;
669 c++;
670 systeme.set(l,c) -= pow(xm1, double(-l_quant-1)) ;
671
672 deuz.set(l) += valm1_dern_1d(0, parts, R_CHEB) ;
673
674 if ((lz>1) || (!lzero)) {
675 //First derivative at x=-1
676 l++ ;
677 c-- ;
678 systeme.set(l,c) -= l_quant*pow(xm1, double(l_quant - 1)) ;
679 c++;
680 systeme.set(l,c) -= (-l_quant - 1)*
681 pow(xm1, double(-l_quant - 2)) ;
682
683 deuz.set(l) += valm1_dern_1d(1, parts, R_CHEB) / alpha ;
684 }
685
686 //Function at x = 1
687 l++ ;
688 c-- ;
689 systeme.set(l,c) += pow(xp1, double(l_quant)) ;
690 c++;
691 systeme.set(l,c) += pow(xp1, double(-l_quant-1)) ;
692
693 deuz.set(l) -= val1_dern_1d(0, parts, R_CHEB) ;
694
695 //First derivative at x = 1
696 l++ ;
697 c-- ;
698 systeme.set(l,c) += l_quant*pow(xp1, double(l_quant - 1)) ;
699 c++;
700 systeme.set(l,c) += (-l_quant - 1)*
701 pow(xp1, double(-l_quant - 2)) ;
702
703 deuz.set(l) -= val1_dern_1d(1, parts, R_CHEB) / alpha ;
704
705 } //End of the loop on different shells
706
707 //-------------------------------
708 // Compactified external domain
709 //-------------------------------
710 assert(mmg->get_type_r(nz-1) == UNSURR) ;
711 nr = mmg->get_nr(nz-1) ;
712 Tbl partc(nr) ;
713 partc.set_etat_qcq() ;
714 for (int i=0; i<nr; i++)
715 partc.set(i) = mtc(nz-1, k, j, i) ;
716
717 alpha = mapping->get_alpha()[nz-1] ;
718 double beta = mapping->get_beta()[nz-1] ;
719 double xm1 = beta - alpha ; // 1 / r_left
720 double part0, part1 ;
721 part0 = valm1_dern_1d(0, partc, R_CHEB) ;
722 part1 = xm1*valm1_dern_1d(1, partc, R_CHEB) / alpha ;
723 assert (p_potential[ind]->get_dzpuis() == 3) ;
724
725 //Function at x = -1
726 l--;
727 if (!lzero) {
728 c++;
729 systeme.set(l,c) -= pow(xm1, double(l_quant+1)) ;
730 }
731 deuz.set(l) += part0*xm1*xm1*xm1 ;
732
733 // First derivative at x = -1
734 l++ ;
735 if (!lzero) {
736 systeme.set(l,c) -= (-l_quant - 1)*
737 pow(xm1, double(l_quant + 2)) ;
738 }
739 if ( (nz > 2) || (!lzero))
740 deuz.set(l) += -xm1*xm1*xm1*xm1*(3*part0 + part1) ;
741
742 //--------------------------------------
743 // Solution of the linear system
744 //--------------------------------------
745
746 int inf = 1 + nb_hom_ced;
747 int sup = 3 - nb_hom_ced;
748 systeme.set_band(sup, inf) ;
749 systeme.set_lu() ;
750 Tbl facteur(systeme.inverse(deuz)) ;
751 ri[l_quant]->set_spectral_va().coef() ;
752 rmi[l_quant]->set_spectral_va().coef() ;
753
754 //Linear combination in the nucleus
755 nr = mmg->get_nr(0) ;
756 for (int i=0; i<nr; i++)
757 mtc.set(0, k, j, i) +=
758 facteur(0)*(*(ri[l_quant]->get_spectral_va().c_cf))(0, 0, 0, i) ;
759
760 //Linear combination in the shells
761 for (int lz=1; lz<nz-1; lz++) {
762 nr = mmg->get_nr(lz) ;
763 for (int i=0; i<nr; i++)
764 mtc.set(lz, k, j, i) += facteur(2*lz - 1)*
765 (*(ri[l_quant]->get_spectral_va().c_cf))(lz, 0, 0, i) ;
766 for (int i=0; i<nr; i++)
767 mtc.set(lz, k, j, i) += facteur(2*lz)*
768 (*(rmi[l_quant]->get_spectral_va().c_cf))(lz, 0, 0, i) ;
769 }
770
771 //Linear combination in the CED
772 nr = mmg->get_nr(nz-1) ;
773 if (!lzero) {
774 for (int i=0; i<nr; i++)
775 mtc.set(nz-1, k, j, i) +=
776 facteur(taille - 1)*
777 (*(rmi[l_quant]->get_spectral_va().c_cf))(nz-1, 0, 0, i) ;
778 }
779 } //End of nullite_plm ...
780
781 } //End of j/theta loop
782 } //End of k/phi loop
783
784 for (int l=0; l<=lmax; l++) {
785 delete ri[l] ;
786 delete rmi[l] ;
787 }
788 delete [] ri ;
789 delete [] rmi ;
790
791 } //End of the case of more than one domain
792
793 val.ylm_i() ;
794
795 } //End of the case dzp = 4
796 }
797 p_div_free[ind] = new Vector_divfree(*mp, *triad, metre) ;
798
799 Vector gradient = p_potential[ind]->derive_con(metre) ;
800 if (dzp != 4) gradient.dec_dzpuis(2) ;
801
802 *p_div_free[ind] = ( *this - gradient ) ;
803
804 }
805
806}
807
808
809
810double Vector::flux(double radius, const Metric& met) const {
811
812 assert(type_indice(0) == CON) ;
813
814 const Map_af* mp_af = dynamic_cast<const Map_af*>(mp) ;
815 if (mp_af == 0x0) {
816 cerr <<
817 "Vector::flux : the case of a mapping outside the class Map_af\n"
818 << " is not implemented yet !" << endl ;
819 abort() ;
820 }
821
822 const Metric_flat* ff = dynamic_cast<const Metric_flat*>(&met) ;
823 if (ff == 0x0) {
824 cerr <<
825 "Vector::flux : the case of a non flat metric is not implemented yet !"
826 << endl ;
827 abort() ;
828 }
829
830 const Base_vect_cart* bcart = dynamic_cast<const Base_vect_cart*>(triad) ;
831 Vector* vspher = 0x0 ;
832 if (bcart != 0x0) { // switch to spherical components:
833 vspher = new Vector(*this) ;
834 vspher->change_triad(mp->get_bvect_spher()) ;
835 }
836 else assert( dynamic_cast<const Base_vect_spher*>(triad) != 0x0 ) ;
837
838 const Vector* vv = (bcart != 0x0) ? vspher : this ;
839
840 const Scalar& vr = vv->operator()(1) ;
841
842 double resu ;
843 if (radius == __infinity) {
844 resu = mp_af->integrale_surface_infini(vr) ;
845 }
846 else {
847 resu = mp_af->integrale_surface(vr, radius) ;
848 }
849
850 return resu ;
851}
852
853void Vector::exponential_filter_r(int lzmin, int lzmax, int p,
854 double alpha) {
855 if( triad->identify() == (mp->get_bvect_cart()).identify() )
856 for (int i=0; i<n_comp; i++)
857 cmp[i]->exponential_filter_r(lzmin, lzmax, p, alpha) ;
858 else {
859 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
860 Scalar vr_tmp = operator()(1) ;
861 vr_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
862 Scalar eta_tmp = eta() ;
863 eta_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
864 Scalar mu_tmp = mu() ;
865 mu_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
866 set_vr_eta_mu(vr_tmp, eta_tmp, mu_tmp) ;
867 }
868}
869
870void Vector::exponential_filter_ylm(int lzmin, int lzmax, int p,
871 double alpha) {
872 if( triad->identify() == (mp->get_bvect_cart()).identify() )
873 for (int i=0; i<n_comp; i++)
874 cmp[i]->exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
875 else {
876 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
877 Scalar vr_tmp = operator()(1) ;
878 vr_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
879 Scalar eta_tmp = eta() ;
880 eta_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
881 Scalar mu_tmp = mu() ;
882 mu_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
883 set_vr_eta_mu(vr_tmp, eta_tmp, mu_tmp) ;
884 }
885}
886}
Bases of the spectral expansions.
Definition base_val.h:325
Cartesian vectorial bases (triads).
Definition base_vect.h:201
Spherical orthonormal vectorial bases (triads).
Definition base_vect.h:308
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition base_vect.h:105
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
double integrale_surface_infini(const Cmp &ci) const
Performs the surface integration of ci at infinity.
double integrale_surface(const Cmp &ci, double rayon) const
Performs the surface integration of ci on the sphere of radius rayon .
Matrix handling.
Definition matrice.h:152
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition matrice.C:178
double & set(int j, int i)
Read/write of a particuliar element.
Definition matrice.h:277
Tbl inverse(const Tbl &sec_membre) const
Solves the linear system represented by the matrix.
Definition matrice.C:427
void set_band(int up, int low) const
Calculate the band storage of *std.
Definition matrice.C:367
void set_lu() const
Calculate the LU-representation, assuming the band-storage has been done.
Definition matrice.C:395
Flat metric for tensor calculation.
Definition metric.h:261
virtual const Sym_tensor & con() const
Read-only access to the contravariant representation.
Definition metric.C:293
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Definition metric.C:283
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
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition grilles.h:469
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition grilles.h:491
Coefficients storage for the multi-domain spectral method.
Definition mtbl_cf.h:196
Tbl & set(int l)
Read/write of the Tbl containing the coefficients in a given domain.
Definition mtbl_cf.h:304
Scalar poisson() const
Solves the scalar Poisson equation with *this as a source.
Definition scalar_pde.C:139
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field.
Definition scalar.C:790
void div_r()
Division by r everywhere; dzpuis is not changed.
void div_tant()
Division by .
const Scalar & dsdr() const
Returns of *this .
virtual void exponential_filter_ylm(int lzmin, int lzmax, int p, double alpha=-16.)
Applies an exponential filter to the spectral coefficients in the angular directions.
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Definition scalar.C:397
Valeur & set_spectral_va()
Returns va (read/write version).
Definition scalar.h:610
const Valeur & get_spectral_va() const
Returns va (read only version).
Definition scalar.h:607
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition scalar.h:560
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition scalar.C:814
void mult_r()
Multiplication by r everywhere; dzpuis is not changed.
virtual void exponential_filter_r(int lzmin, int lzmax, int p, double alpha=-16.)
Applies an exponential filter to the spectral coefficients in the radial direction.
Basic array class.
Definition tbl.h:161
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
Values and coefficients of a (real-value) function.
Definition valeur.h:297
void ylm()
Computes the coefficients of *this.
Definition valeur_ylm.C:141
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition valeur.h:312
void coef() const
Computes the coeffcients of *this.
void set_base_r(int l, int base_r)
Sets the expansion basis for r ( ) functions in a given domain.
Definition valeur.C:839
void ylm_i()
Inverse of ylm().
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:315
Divergence-free vectors.
Definition vector.h:724
const Scalar & operator()(int) const
Readonly access to a component.
Definition vector.C:308
Sym_tensor ope_killing(const Metric &gam) const
Computes the Killing operator associated with a given metric.
Definition vector.C:441
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition vector.C:319
void decompose_div(const Metric &) const
Makes the Helmholtz decomposition (see documentation of p_potential ) of this with respect to a given...
Definition vector.C:519
const Scalar & divergence(const Metric &) const
The divergence of this with respect to a Metric .
Definition vector.C:384
Scalar * p_potential[N_MET_MAX]
The potential giving the gradient part in the Helmholtz decomposition of any 3D vector .
Definition vector.h:198
virtual void del_deriv() const
Deletes the derived quantities.
Definition vector.C:222
virtual const Scalar & mu() const
Gives the field such that the angular components of the vector are written:
virtual void del_derive_met(int) const
Logical destructor of the derivatives depending on the i-th element of met_depend in the class Vector...
Definition vector.C:245
double flux(double radius, const Metric &met) const
Computes the flux of the vector accross a sphere r = const.
Definition vector.C:810
Vector(const Map &map, int tipe, const Base_vect &triad_i)
Standard constructor.
Definition vector.C:159
Vector_divfree * p_div_free[N_MET_MAX]
The divergence-free vector of the Helmholtz decomposition of any 3D vector .
Definition vector.h:205
const Vector_divfree curl() const
The curl of this with respect to a (flat) Metric .
Definition vector.C:405
Scalar * p_A
Field defined by.
Definition vector.h:241
virtual const Scalar & eta() const
Gives the field such that the angular components of the vector are written:
virtual void exponential_filter_r(int lzmin, int lzmax, int p, double alpha=-16.)
Applies exponential filters to all components (see Scalar::exponential_filter_r ).
Definition vector.C:853
const Vector_divfree & div_free(const Metric &) const
Returns the div-free vector in the Helmholtz decomposition.
Definition vector.C:507
void set_der_0x0() const
Sets the pointers on derived quantities to 0x0.
Definition vector.C:235
virtual ~Vector()
Destructor.
Definition vector.C:211
virtual void pseudo_spectral_base()
Sets the standard spectal bases of decomposition for each component for a pseudo_vector.
Definition vector.C:349
void set_der_met_0x0(int) const
Sets all the i-th components of met_depend in the class Vector (p_potential , etc....
Definition vector.C:261
Scalar * p_mu
Field such that the angular components of the vector are written:
Definition vector.h:233
Scalar * p_eta
Field such that the angular components of the vector are written:
Definition vector.h:219
Sym_tensor ope_killing_conf(const Metric &gam) const
Computes the conformal Killing operator associated with a given metric.
Definition vector.C:465
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
virtual void operator=(const Vector &a)
Assignment from a Vector.
Definition vector.C:270
const Scalar & potential(const Metric &) const
Returns the potential in the Helmholtz decomposition.
Definition vector.C:495
Scalar & set(int)
Read/write access to a component.
Definition vector.C:299
void set_vr_eta_mu(const Scalar &vr_i, const Scalar &eta_i, const Scalar &mu_i)
Defines the components through potentials and (see members p_eta and p_mu ), as well as the compon...
virtual void exponential_filter_ylm(int lzmin, int lzmax, int p, double alpha=-16.)
Applies exponential filters to all components (see Scalar::exponential_filter_ylm ).
Definition vector.C:870
Vector derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
Definition vector.C:395
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:351
#define R_CHEBI
base de Cheb. impaire (rare) seulement
#define R_CHEB
base de Chebychev ordinaire (fin)
#define R_CHEBP
base de Cheb. paire (rare) seulement
virtual void del_derive_met(int) const
Logical destructor of the derivatives depending on the i-th element of met_depend .
Definition tensor.C:423
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified ext...
Definition tensor.C:817
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition tensor.h:301
int get_place_met(const Metric &) const
Returns the position of the pointer on metre in the array met_depend .
Definition tensor.C:452
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
Definition tensor.C:1023
const Metric * met_depend[N_MET_MAX]
Array on the Metric 's which were used to compute derived quantities, like p_derive_cov ,...
Definition tensor.h:333
Tensor(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
Standard constructor.
Definition tensor.C:211
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...).
Definition tensor.h:304
void set_dependance(const Metric &) const
To be used to describe the fact that the derivatives members have been calculated with met .
Definition tensor.C:462
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition tensor.h:321
void compute_derive_lie(const Vector &v, Tensor &resu) const
Computes the Lie derivative of this with respect to some vector field v (protected method; the public...
int n_comp
Number of stored components, depending on the symmetry.
Definition tensor.h:318
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition tensor.C:675
virtual void del_deriv() const
Deletes the derived quantities.
Definition tensor.C:407
const Tensor & divergence(const Metric &gam) const
Computes the divergence of this with respect to some metric .
Definition tensor.C:1064
const Tensor & derive_cov(const Metric &gam) const
Returns the covariant derivative of this with respect to some metric .
Definition tensor.C:1011
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cov...
Definition tensor.h:316
Tensor trace(int ind1, int ind2) const
Trace on two different type indices.
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
Definition tensor.C:663
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition tensor.h:309
Lorene prototypes.
Definition app_hor.h:67
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:142