Debian Codegraph @

C++/Include/scalar.h

raw symbols SCIP
1 /*
2 * Definition of Lorene class Scalar
3 *
4 */
5
6 /*
7 * Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
8 *
9 * Copyright (c) 1999-2000 Jean-Alain Marck (for previous class Cmp)
10 * Copyright (c) 1999-2002 Eric Gourgoulhon (for previous class Cmp)
11 * Copyright (c) 1999-2001 Philippe Grandclement (for previous class Cmp)
12 * Copyright (c) 2000-2002 Jerome Novak (for previous class Cmp)
13 * Copyright (c) 2000-2001 Keisuke Taniguchi (for previous class Cmp)
14 *
15 * This file is part of LORENE.
16 *
17 * LORENE is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * LORENE is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with LORENE; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 *
31 */
32
33
34 #ifndef __SCALAR_H_
35 #define __SCALAR_H_
36
37
38 /*
39 * $Id: scalar.h,v 1.94 2015/12/18 15:52:51 j_novak Exp $
40 * $Log: scalar.h,v $
41 * Revision 1.94 2015/12/18 15:52:51 j_novak
42 * New method is_nan() for class Scalar.
43 *
44 * Revision 1.93 2015/09/10 13:28:05 j_novak
45 * New methods for the class Hot_Eos
46 *
47 * Revision 1.92 2014/10/13 08:52:36 j_novak
48 * Lorene classes and functions now belong to the namespace Lorene.
49 *
50 * Revision 1.91 2013/06/05 15:06:10 j_novak
51 * Legendre bases are treated as standard bases, when the multi-grid
52 * (Mg3d) is built with BASE_LEG.
53 *
54 * Revision 1.90 2013/01/11 15:44:54 j_novak
55 * Addition of Legendre bases (part 2).
56 *
57 * Revision 1.89 2012/12/19 13:59:56 j_penner
58 * added a few lines to the documentation for scalar_match_tau function
59 *
60 * Revision 1.88 2012/01/17 15:05:46 j_penner
61 * *** empty log message ***
62 *
63 * Revision 1.87 2012/01/17 10:16:27 j_penner
64 * functions added: sarra_filter_r, sarra_filter_r_all_domains, Heaviside
65 *
66 * Revision 1.86 2011/04/08 13:13:09 e_gourgoulhon
67 * Changed the comment of function val_point to indicate specifically the
68 * division by r^dzpuis in the compactified external domain.
69 *
70 * Revision 1.85 2008/09/29 13:23:51 j_novak
71 * Implementation of the angular mapping associated with an affine
72 * mapping. Things must be improved to take into account the domain index.
73 *
74 * Revision 1.84 2008/09/22 19:08:01 j_novak
75 * New methods to deal with boundary conditions
76 *
77 * Revision 1.83 2008/05/24 15:05:22 j_novak
78 * New method Scalar::match_tau to match the output of an explicit time-marching scheme with the tau method.
79 *
80 * Revision 1.82 2007/12/21 16:06:16 j_novak
81 * Methods to filter Tensor, Vector and Sym_tensor objects.
82 *
83 * Revision 1.81 2007/10/31 10:33:11 j_novak
84 * Added exponential filters to smooth Gibbs-type phenomena.
85 *
86 * Revision 1.80 2007/06/21 19:56:36 k_taniguchi
87 * Introduction of another filtre_r.
88 *
89 * Revision 1.79 2007/05/06 10:48:08 p_grandclement
90 * Modification of a few operators for the vorton project
91 *
92 * Revision 1.78 2007/01/16 15:05:59 n_vasset
93 * New constructor (taking a Scalar in mono-domain angular grid for
94 * boundary) for function sol_elliptic_boundary
95 *
96 * Revision 1.77 2006/05/26 09:00:09 j_novak
97 * New members for multiplication or division by cos(theta).
98 *
99 * Revision 1.76 2005/11/30 13:48:06 e_gourgoulhon
100 * Replaced M_PI/2 by 1.57... in argument list of sol_elliptic_sin_zec
101 * (in order not to require the definition of M_PI).
102 *
103 * Revision 1.75 2005/11/30 11:09:03 p_grandclement
104 * Changes for the Bin_ns_bh project
105 *
106 * Revision 1.74 2005/11/17 15:29:46 e_gourgoulhon
107 * Added arithmetics with Mtbl.
108 *
109 * Revision 1.73 2005/10/25 08:56:34 p_grandclement
110 * addition of std_spectral_base in the case of odd functions near the origin
111 *
112 * Revision 1.72 2005/09/07 13:10:47 j_novak
113 * Added a filter setting to zero all mulitpoles in a given range.
114 *
115 * Revision 1.71 2005/08/26 14:02:38 p_grandclement
116 * Modification of the elliptic solver that matches with an oscillatory exterior solution
117 * small correction in Poisson tau also...
118 *
119 * Revision 1.70 2005/08/25 12:14:07 p_grandclement
120 * Addition of a new method to solve the scalar Poisson equation, based on a multi-domain Tau-method
121 *
122 * Revision 1.69 2005/06/09 07:56:25 f_limousin
123 * Implement a new function sol_elliptic_boundary() and
124 * Vector::poisson_boundary(...) which solve the vectorial poisson
125 * equation (method 6) with an inner boundary condition.
126 *
127 * Revision 1.68 2005/06/08 12:35:18 j_novak
128 * New method for solving divergence-like ODEs.
129 *
130 * Revision 1.67 2005/05/20 14:42:30 j_novak
131 * Added the method Scalar::get_spectral_base().
132 *
133 * Revision 1.66 2005/04/04 21:28:57 e_gourgoulhon
134 * Added argument lambda to method poisson_angu
135 * to deal with the generalized angular Poisson equation:
136 * Lap_ang u + lambda u = source.
137 *
138 * Revision 1.65 2004/12/14 09:09:39 f_limousin
139 * Modif. comments.
140 *
141 * Revision 1.64 2004/11/23 12:41:53 f_limousin
142 * Intoduce function poisson_dir_neu(...) to solve a scalar poisson
143 * equation with a mixed boundary condition (Dirichlet + Neumann).
144 *
145 * Revision 1.63 2004/10/11 15:09:00 j_novak
146 * The radial manipulation functions take Scalar as arguments, instead of Cmp.
147 * Added a conversion operator from Scalar to Cmp.
148 * The Cmp radial manipulation function make conversion to Scalar, call to the
149 * Map_radial version with a Scalar argument and back.
150 *
151 * Revision 1.62 2004/08/24 09:14:40 p_grandclement
152 * Addition of some new operators, like Poisson in 2d... It now requieres the
153 * GSL library to work.
154 *
155 * Also, the way a variable change is stored by a Param_elliptic is changed and
156 * no longer uses Change_var but rather 2 Scalars. The codes using that feature
157 * will requiere some modification. (It should concern only the ones about monopoles)
158 *
159 * Revision 1.61 2004/07/27 08:24:26 j_novak
160 * Modif. comments
161 *
162 * Revision 1.60 2004/07/26 16:02:21 j_novak
163 * Added a flag to specify whether the primitive should be zero either at r=0
164 * or at r going to infinity.
165 *
166 * Revision 1.59 2004/07/06 13:36:27 j_novak
167 * Added methods for desaliased product (operator |) only in r direction.
168 *
169 * Revision 1.58 2004/06/22 08:49:57 p_grandclement
170 * Addition of everything needed for using the logarithmic mapping
171 *
172 * Revision 1.57 2004/06/14 15:24:23 e_gourgoulhon
173 * Added method primr (radial primitive).
174 *
175 * Revision 1.56 2004/06/11 14:29:56 j_novak
176 * Scalar::multipole_spectrum() is now a const method.
177 *
178 * Revision 1.55 2004/05/24 14:07:31 e_gourgoulhon
179 * Method set_domain now includes a call to del_deriv() for safety.
180 *
181 * Revision 1.54 2004/05/07 11:26:10 f_limousin
182 * New method filtre_r(int*)
183 *
184 * Revision 1.53 2004/03/22 13:12:43 j_novak
185 * Modification of comments to use doxygen instead of doc++
186 *
187 * Revision 1.52 2004/03/17 15:58:47 p_grandclement
188 * Slight modification of sol_elliptic_no_zec
189 *
190 * Revision 1.51 2004/03/11 12:07:30 e_gourgoulhon
191 * Added method visu_section_anim.
192 *
193 * Revision 1.50 2004/03/08 15:45:38 j_novak
194 * Modif. comment
195 *
196 * Revision 1.49 2004/03/05 15:09:40 e_gourgoulhon
197 * Added method smooth_decay.
198 *
199 * Revision 1.48 2004/03/01 09:57:02 j_novak
200 * the wave equation is solved with Scalars. It now accepts a grid with a
201 * compactified external domain, which the solver ignores and where it copies
202 * the values of the field from one time-step to the next.
203 *
204 * Revision 1.47 2004/02/27 09:43:58 f_limousin
205 * New methods filtre_phi(int) and filtre_theta(int).
206 *
207 * Revision 1.46 2004/02/26 22:46:26 e_gourgoulhon
208 * Added methods derive_cov, derive_con and derive_lie.
209 *
210 * Revision 1.45 2004/02/21 17:03:49 e_gourgoulhon
211 * -- Method "point" renamed "val_grid_point".
212 * -- Method "set_point" renamed "set_grid_point".
213 *
214 * Revision 1.44 2004/02/19 22:07:35 e_gourgoulhon
215 * Added argument "comment" in method spectral_display.
216 *
217 * Revision 1.43 2004/02/11 09:47:44 p_grandclement
218 * Addition of a new elliptic solver, matching with the homogeneous solution
219 * at the outer shell and not solving in the external domain (more details
220 * coming soon ; check your local Lorene dealer...)
221 *
222 * Revision 1.42 2004/01/28 16:46:22 p_grandclement
223 * Addition of the sol_elliptic_fixe_der_zero stuff
224 *
225 * Revision 1.41 2004/01/28 13:25:40 j_novak
226 * The ced_mult_r arguments have been suppressed from the Scalar::*dsd* methods.
227 * In the div/mult _r_dzpuis, there is no more default value.
228 *
229 * Revision 1.40 2004/01/28 10:39:17 j_novak
230 * Comments modified.
231 *
232 * Revision 1.39 2004/01/27 15:10:01 j_novak
233 * New methods Scalar::div_r_dzpuis(int) and Scalar_mult_r_dzpuis(int)
234 * which replace div_r_inc*. Tried to clean the dzpuis handling.
235 * WARNING: no testing at this point!!
236 *
237 * Revision 1.38 2004/01/23 13:25:44 e_gourgoulhon
238 * Added methods set_inner_boundary and set_outer_boundary.
239 * Methods set_val_inf and set_val_hor, which are particular cases of
240 * the above, have been suppressed.
241 *
242 * Revision 1.37 2004/01/22 16:10:09 e_gourgoulhon
243 * Added (provisory) method div_r_inc().
244 *
245 * Revision 1.36 2003/12/16 06:32:20 e_gourgoulhon
246 * Added method visu_box.
247 *
248 * Revision 1.35 2003/12/14 21:46:35 e_gourgoulhon
249 * Added argument start_dx in visu_section.
250 *
251 * Revision 1.34 2003/12/11 16:19:38 e_gourgoulhon
252 * Added method visu_section for visualization with OpenDX.
253 *
254 * Revision 1.33 2003/12/11 14:48:47 p_grandclement
255 * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
256 *
257 * Revision 1.32 2003/11/13 13:43:53 p_grandclement
258 * Addition of things needed for Bhole::update_metric (const Etoile_bin&, double, double)
259 *
260 * Revision 1.31 2003/11/06 14:43:37 e_gourgoulhon
261 * Gave a name to const arguments in certain method prototypes (e.g.
262 * constructors) to correct a bug of DOC++.
263 *
264 * Revision 1.30 2003/11/04 22:55:50 e_gourgoulhon
265 * Added new methods mult_cost(), mult_sint() and div_sint().
266 *
267 * Revision 1.29 2003/10/29 13:09:11 e_gourgoulhon
268 * -- Added integer argument to derivative functions dsdr, etc...
269 * so that one can choose the dzpuis of the result (default=2).
270 * -- Change of method name: laplacien --> laplacian.
271 *
272 * Revision 1.28 2003/10/29 11:00:42 e_gourgoulhon
273 * Virtual functions dec_dzpuis and inc_dzpuis have now an integer argument to
274 * specify by which amount dzpuis is to be increased.
275 * Accordingly virtual methods dec2_dzpuis and inc2_dzpuis have been suppressed.
276 *
277 * Revision 1.27 2003/10/20 14:26:02 j_novak
278 * New assignement operators.
279 *
280 * Revision 1.26 2003/10/19 19:46:33 e_gourgoulhon
281 * -- Method spectral_display now virtual (from Tensor), list of argument
282 * changed.
283 *
284 * Revision 1.25 2003/10/17 13:46:14 j_novak
285 * The argument is now between 1 and 3 (instead of 0->2)
286 *
287 * Revision 1.24 2003/10/16 15:23:41 e_gourgoulhon
288 * Name of method div_r_ced() changed to div_r_inc2().
289 * Name of method div_rsint_ced() changed to div_rsint_inc2().
290 *
291 * Revision 1.23 2003/10/15 21:10:11 e_gourgoulhon
292 * Added method poisson_angu().
293 *
294 * Revision 1.22 2003/10/15 16:03:35 j_novak
295 * Added the angular Laplace operator for Scalar.
296 *
297 * Revision 1.21 2003/10/15 10:29:05 e_gourgoulhon
298 * Added new members p_dsdt and p_stdsdp.
299 * Added new methods dsdt(), stdsdp() and div_tant().
300 *
301 * Revision 1.20 2003/10/13 13:52:39 j_novak
302 * Better managment of derived quantities.
303 *
304 * Revision 1.19 2003/10/10 15:57:27 j_novak
305 * Added the state one (ETATUN) to the class Scalar
306 *
307 * Revision 1.18 2003/10/08 14:24:08 j_novak
308 * replaced mult_r_zec with mult_r_ced
309 *
310 * Revision 1.17 2003/10/06 16:16:02 j_novak
311 * New constructor from a Tensor.
312 *
313 * Revision 1.16 2003/10/06 13:58:45 j_novak
314 * The memory management has been improved.
315 * Implementation of the covariant derivative with respect to the exact Tensor
316 * type.
317 *
318 * Revision 1.15 2003/10/05 21:06:31 e_gourgoulhon
319 * - Added new methods div_r_ced() and div_rsint_ced().
320 * - Added new virtual method std_spectral_base()
321 * - Removed method std_spectral_base_scal()
322 *
323 * Revision 1.14 2003/10/01 13:02:58 e_gourgoulhon
324 * Suppressed the constructor from Map* .
325 *
326 * Revision 1.13 2003/09/29 12:52:56 j_novak
327 * Methods for changing the triad are implemented.
328 *
329 * Revision 1.12 2003/09/25 09:33:36 j_novak
330 * Added methods for integral calculation and various manipulations
331 *
332 * Revision 1.11 2003/09/25 09:11:21 e_gourgoulhon
333 * Added functions for radial operations (divr, etc...)
334 *
335 * Revision 1.10 2003/09/25 08:55:23 e_gourgoulhon
336 * Added members raccord*.
337 *
338 * Revision 1.9 2003/09/25 08:50:11 j_novak
339 * Added the members import
340 *
341 * Revision 1.8 2003/09/25 08:13:51 j_novak
342 * Added method for calculating derivatives
343 *
344 * Revision 1.7 2003/09/25 07:59:26 e_gourgoulhon
345 * Added prototypes for PDE resolutions.
346 *
347 * Revision 1.6 2003/09/25 07:17:58 j_novak
348 * Method asymptot implemented.
349 *
350 * Revision 1.5 2003/09/24 20:53:38 e_gourgoulhon
351 * Added -- constructor by conversion from a Cmp
352 * -- assignment from Cmp
353 *
354 * Revision 1.4 2003/09/24 15:10:54 j_novak
355 * Suppression of the etat flag in class Tensor (still present in Scalar)
356 *
357 * Revision 1.3 2003/09/24 12:01:44 j_novak
358 * Added friend functions for math.
359 *
360 * Revision 1.2 2003/09/24 10:22:01 e_gourgoulhon
361 * still in progress...
362 *
363 * Revision 1.1 2003/09/22 12:50:47 e_gourgoulhon
364 * First version: not ready yet!
365 *
366 *
367 * $Header: /cvsroot/Lorene/C++/Include/scalar.h,v 1.94 2015/12/18 15:52:51 j_novak Exp $
368 *
369 */
370
371 // Headers Lorene
372 #include "valeur.h"
373 #include "tensor.h"
374
375 namespace Lorene {
376 class Param ;
377 class Cmp ;
378 class Param_elliptic ;
379
380 /**
381 * Tensor field of valence 0 (or component of a tensorial field).
382 * \ingroup (tensor)
383 *
384 *
385 */
386
387 class Scalar : public Tensor {
388
389 // Data :
390 // -----
391 protected:
392
393 /** The logical state \c ETATNONDEF (undefined), \c ETATZERO (null),
394 * \c ETATUN (one), or \c ETATQCQ (ordinary).
395 */
396 int etat ;
397
398 /**
399 * Power of \e r by which the quantity represented by \c this
400 * must be divided in the compactified external domain (CED) in order
401 * to get the correct physical values
402 */
403 int dzpuis ;
404
405 Valeur va ; ///< The numerical value of the \c Scalar
406
407 // Derived data :
408 // ------------
409 protected:
410 /// Pointer on \f$\partial/\partial r\f$ of \c *this (0x0 if not up to date)
411 mutable Scalar* p_dsdr ;
412
413 /** Pointer on \f$1/r \partial/\partial \theta\f$ of \c *this
414 * (0x0 if not up to date)
415 */
416 mutable Scalar* p_srdsdt ;
417
418 /** Pointer on \f$1/(r\sin\theta) \partial/\partial \phi\f$ of \c *this
419 * (0x0 if not up to date)
420 */
421 mutable Scalar* p_srstdsdp ;
422
423 /// Pointer on \f$\partial/\partial \theta\f$ of \c *this (0x0 if not up to date)
424 mutable Scalar* p_dsdt ;
425
426 /** Pointer on \f$1/\sin\theta \partial/\partial \phi\f$ of \c *this
427 * (0x0 if not up to date)
428 */
429 mutable Scalar* p_stdsdp ;
430
431 /** Pointer on \f$\partial/\partial x\f$ of \c *this ,
432 * where \f$x=r\sin\theta \cos\phi\f$ (0x0 if not up to date)
433 */
434 mutable Scalar* p_dsdx ;
435
436 /** Pointer on \f$\partial/\partial y\f$ of \c *this ,
437 * where \f$y=r\sin\theta \sin\phi\f$(0x0 if not up to date)
438 */
439 mutable Scalar* p_dsdy ;
440
441 /** Pointer on \f$\partial/\partial z\f$ of \c *this ,
442 * where \f$z=r\cos\theta\f$ (0x0 if not up to date)
443 */
444 mutable Scalar* p_dsdz ;
445
446 /** Pointer on the Laplacian of \c *this (0x0 if not up to date)
447 */
448 mutable Scalar* p_lap ;
449
450 /** Pointer on the Laplacian of \c *this (0x0 if not up to date)
451 */
452 mutable Scalar* p_lapang ;
453
454 /// Pointer on \f$\partial/\partial radial \f$ of \c *this
455 mutable Scalar* p_dsdradial ;
456
457 /// Pointer on \f$\partial/\partial \rho \f$ of \c *this
458 mutable Scalar* p_dsdrho ;
459
460 /** Power of \e r by which the last computed Laplacian has been
461 * multiplied in the compactified external domain.
462 */
463 mutable int ind_lap ;
464
465 /** Pointer on the space integral of \c *this (values in each
466 * domain) (0x0 if not up to date)
467 */
468 mutable Tbl* p_integ ;
469
470 // Constructors - Destructor
471 // -------------------------
472
473 public:
474
475 explicit Scalar(const Map& mpi) ; ///< Constructor from mapping
476
477 /// Constructor from a Tensor (must be of valence 0)
478 Scalar(const Tensor& a) ;
479
480 Scalar(const Scalar& a) ; ///< Copy constructor
481
482 Scalar(const Cmp& a) ; ///< Constructor by conversion of a Cmp
483
484 /// Constructor from a file (see \c sauve(FILE*) )
485 Scalar(const Map&, const Mg3d&, FILE* ) ;
486
487 virtual ~Scalar() ; ///< Destructor
488
489
490 // Memory management
491 // -----------------
492 protected:
493 void del_t() ; ///< Logical destructor
494 virtual void del_deriv() const; ///< Logical destructor of the derivatives
495 void set_der_0x0() const; ///< Sets the pointers for derivatives to 0x0
496
497 public:
498
499 /**
500 * Sets the logical state to \c ETATNONDEF (undefined).
501 * Calls the logical destructor of the \c Valeur \c va
502 * deallocates the memory occupied by all the derivatives.
503 */
504 virtual void set_etat_nondef() ;
505
506 /**
507 * Sets the logical state to \c ETATZERO (zero).
508 * Calls the logical destructor of the \c Valeur \c va and
509 * deallocates the memory occupied by all the derivatives.
510 */
511 virtual void set_etat_zero() ;
512
513 /**
514 * Sets the logical state to \c ETATQCQ (ordinary state).
515 * If the state is already \c ETATQCQ , this function does nothing.
516 * Otherwise, it calls the logical destructor of the \c Valeur \c va and
517 * deallocates the memory occupied by all the derivatives.
518 */
519 virtual void set_etat_qcq() ;
520
521 /**
522 * Sets the logical state to \c ETATUN (one).
523 * Fills the \c Valeur \c va with ones and
524 * deallocates the memory occupied by all the derivatives.
525 */
526 void set_etat_one() ;
527
528 /**
529 * Sets the logical state to \c ETATQCQ (ordinary state)
530 * and performs the memory allocation of all the
531 * elements, down to the \c double arrays of the \c Tbl s.
532 * This function performs in fact recursive calls to \c set_etat_qcq()
533 * on each element of the chain \c Scalar ->
534 * \c Valeur -> \c Mtbl -> \c Tbl .
535 */
536 virtual void allocate_all() ;
537
538 /**
539 * Sets the \c Scalar to zero in a hard way.
540 * 1/ Sets the logical state to \c ETATQCQ , i.e. to an ordinary state.
541 * 2/ Fills the \c Valeur \c va with zeros.
542 * NB: this function must be used for debugging purposes only.
543 * For other operations, the functions \c set_etat_zero()
544 * or \c annule(int,int) must be perferred.
545 */
546 void annule_hard() ;
547
548 // Extraction of information
549 // -------------------------
550 public:
551 /** Returns the logical state \c ETATNONDEF (undefined),
552 * \c ETATZERO (null) or \c ETATQCQ (ordinary).
553 */
554 int get_etat() const {return etat;} ;
555
556 /// Returns \c dzpuis
557 int get_dzpuis() const {return dzpuis;} ;
558
559 /** Returns \c true if the last domain is compactified and
560 * \c *this is not zero in this domain
561 */
562 bool dz_nonzero() const ;
563
564 /** Returns \c false if the last domain is compactified
565 * and \c *this is not zero in this domain and \c dzpuis
566 * is not equal to \c dzi , otherwise return true.
567 */
568 bool check_dzpuis(int dzi) const ;
569
570 /** Looks for NaNs (not a number) in the scalar field.
571 * If at least one NaN is found, it returns \c true. If the flag \c verbose
572 * is set to \c true, it outputs to the standard output the indices where NaNs
573 * have been found.
574 */
575 bool is_nan(bool verbose=false) const ;
576
577 // Assignment
578 // -----------
579 public:
580 /// Assignment to another \c Scalar defined on the same mapping
581 void operator=(const Scalar& a) ;
582
583 /// Assignment to a \c Tensor (of valence 0)
584 virtual void operator=(const Tensor& a) ;
585
586 void operator=(const Cmp& a) ; ///< Assignment to a \c Cmp
587 void operator=(const Valeur& a) ; ///< Assignment to a \c Valeur
588 void operator=(const Mtbl& a) ; ///< Assignment to a \c Mtbl
589 void operator=(double ) ; ///< Assignment to a \c double
590 void operator=(int ) ; ///< Assignment to an \c int
591
592 // Conversion oprators
593 //---------------------
594 operator Cmp() const ; ///< Conversion to a \c Cmp
595
596 // Access to individual elements
597 // -----------------------------
598 public:
599
600 /// Returns \c va (read only version)
601 const Valeur& get_spectral_va() const {return va;} ;
602
603 /// Returns \c va (read/write version)
604 Valeur& set_spectral_va() {return va;} ;
605
606 /** Read/write of the value in a given domain.
607 * This method should be used only to set the value in a given
608 * domain (it performs a call to \c del_deriv); for reading the
609 * value in a domain without changing it, the method \c domain(int )
610 * is preferable.
611 *
612 * @param l [input] domain index
613 * @return writable \c Tbl containing the value of the field in domain \c l .
614 */
615 Tbl& set_domain(int l) {
616 assert(etat == ETATQCQ) ;
617 del_deriv() ;
618 return va.set(l) ;
619 };
620
621 /** Read-only of the value in a given domain.
622 * @param l [input] domain index
623 * @return \c Tbl containing the value of the field in domain \c l .
624 */
625 const Tbl& domain(int l) const {
626 assert( (etat == ETATQCQ) || (etat == ETATUN) ) ;
627 return va(l) ;
628 };
629
630
631 /** Returns the value of the field at a specified grid point.
632 * @param l [input] domain index
633 * @param k [input] \f$\phi\f$ index
634 * @param j [input] \f$\theta\f$ index
635 * @param i [input] \e r (\f$\xi\f$) index
636 */
637 double val_grid_point(int l, int k, int j, int i) const {
638 assert(etat != ETATNONDEF) ;
639 if (etat == ETATZERO) {
640 double zero = 0. ;
641 return zero ;
642 }
643 else {
644 if (etat == ETATUN) {
645 double one = 1. ;
646 return one ;
647 }
648 else{
649 return va(l, k, j, i) ;
650 }
651 }
652 };
653
654 /** Computes the value of the field at an
655 * arbitrary point \f$(r, \theta, \phi)\f$, by means of the spectral
656 * expansion.
657 * NB: if \f$(r, \theta, \phi)\f$ is a point of the spectral grid,
658 * the method \c val_grid_point is to be preferred,
659 * being much more efficient.
660 * @param r [input] value of the coordinate \e r
661 * @param theta [input] value of the coordinate \f$\theta\f$
662 * @param phi [input] value of the coordinate \f$\phi\f$
663 * @return value at the point \f$(r, \theta, \phi)\f$
664 * of the field represented by \c *this . NB: in the compactified
665 * external domain, the returned value is the actual value of the field,
666 * i.e. the stored value divided by \f$ r^{\rm dzpuis} \f$.
667 */
668 double val_point(double r, double theta, double phi) const ;
669
670
671 /** Setting the value of the field at a given grid point.
672 * CAUTION: to gain in efficiency (especially when this method is
673 * invoqued inside a loop), the method \c del_deriv() (to delete
674 * the derived members) is not called by \c set_grid_point .
675 * It must thus be invoqued by the user, after all the calls
676 * to \c set_grid_point have been performed.
677 *
678 * @param l [input] domain index
679 * @param k [input] \f$\phi\f$ index
680 * @param j [input] \f$\theta\f$ index
681 * @param i [input] \e r (\f$\xi\f$) index
682 * @return writable value of the field at the specified grid point
683 */
684 double& set_grid_point(int l, int k, int j, int i) {
685 assert(etat == ETATQCQ) ;
686 return va.set(l, k, j, i) ;
687 };
688
689
690 /**
691 * Sets the \c Scalar to zero in several domains.
692 * @param l_min [input] The \c Scalar will be set (logically) to zero
693 * in the domains whose indices are in the range
694 * \c [l_min,l_max] .
695 * @param l_max [input] see the comments for \c l_min .
696 *
697 * Note that \c annule(0,va.mg->get_nzone()-1) is equivalent to
698 * \c set_etat_zero() .
699 */
700 virtual void annule(int l_min, int l_max) ;
701
702 /** Sets the value of the \c Scalar at the inner boundary of a given
703 * domain.
704 * @param l [input] domain index
705 * @param x [input] (constant) value at the inner boundary of domain no. \c l
706 */
707 void set_inner_boundary(int l, double x) ;
708
709 /** Sets the value of the \c Scalar at the outer boundary of a given
710 * domain.
711 * @param l [input] domain index
712 * @param x [input] (constant) value at the outer boundary of domain no. \c l
713 */
714 void set_outer_boundary(int l, double x) ;
715
716 /**
717 * Gives the spectrum in terms of multipolar modes \e l .
718 * @return a \c Tbl of size (nzone, lmax), where lmax is the
719 * maximal multipolar momentum over all domains. The \e l -th
720 * element contains the L1 norm of the \e l -th multipole
721 * (\e i.e. a sum over all \e m of the norms (coefficient space)
722 * of the component of a given \f$Y_l^m\f$.
723 */
724 Tbl multipole_spectrum () const ;
725
726 /** Returns the \c Tbl containing the values of angular coefficients
727 * at the outer boundary.
728 * @param l_dom [input] domain index
729 * @param leave_ylm [input] flag to decide whether the coefficients
730 * are expressed in spherical harmonics or Fourier base
731 */
732 Tbl tbl_out_bound(int l_dom, bool leave_ylm = false) ;
733
734 /** Returns the \c Tbl containing the values of angular coefficients
735 * at the inner boundary.
736 * @param l_dom [input] domain index
737 * @param leave_ylm [input] flag to decide whether the coefficients
738 * are expressed in spherical harmonics or Fourier base
739 */
740 Tbl tbl_in_bound(int n, bool leave_ylm = false) ;
741
742 /** Returns the \c Scalar containing the values of angular coefficients
743 * at the outer boundary.
744 * @param l_dom [input] domain index
745 * @param leave_ylm [input] flag to decide whether the coefficients
746 * are expressed in spherical harmonics or Fourier base
747 */
748 Scalar scalar_out_bound(int n, bool leave_ylm = false) ;
749
750 // Differential operators and others
751 // ---------------------------------
752 public:
753 /** Returns \f$\partial / \partial r\f$ of \c *this .
754 * If \c dzpuis is zero, then the returned \c Scalar has
755 * \c dzpuis = 2. It is increased by 1 otherwise.
756 */
757 const Scalar& dsdr() const ;
758
759 /** Returns \f$1/r \partial / \partial \theta\f$ of \c *this .
760 * If \c dzpuis is zero, then the returned \c Scalar has
761 * \c dzpuis = 2. It is increased by 1 otherwise.
762 */
763 const Scalar& srdsdt() const ;
764
765 /** Returns \f$1/(r\sin\theta) \partial / \partial \phi\f$ of \c *this .
766 * If \c dzpuis is zero, then the returned \c Scalar has
767 * \c dzpuis = 2. It is increased by 1 otherwise.
768 */
769 const Scalar& srstdsdp() const ;
770
771 /** Returns \f$\partial / \partial \theta\f$ of \c *this .
772 */
773 const Scalar& dsdt() const ;
774
775 /** Returns \f$\partial / \partial r\f$ of \c *this if the mapping is
776 * affine (class \c Map_af) and \f$\partial / \partial \ln r\f$
777 * of \c *this if the mapping
778 * is logarithmic (class \c Map_log).
779 * If \c dzpuis is zero, then the returned \c Scalar has
780 * \c dzpuis = 2. It is increased by 1 otherwise.
781 */
782 const Scalar& dsdradial() const ;
783
784 /** Returns \f$\partial / \partial \rho \f$ of \c *this .
785 * If \c dzpuis is zero, then the returned \c Scalar has
786 * \c dzpuis = 2. It is increased by 1 otherwise.
787 */
788 const Scalar& dsdrho() const ;
789
790 /** Returns \f$1/\sin\theta \partial / \partial \phi\f$ of \c *this .
791 */
792 const Scalar& stdsdp() const ;
793
794 /** Returns \f$\partial/\partial x\f$ of \c *this ,
795 * where \f$x=r\sin\theta \cos\phi\f$.
796 * If \c dzpuis is zero, then the returned \c Scalar has
797 * \c dzpuis = 2. It is increased by 1 otherwise.
798 */
799 const Scalar& dsdx() const ;
800
801 /** Returns \f$\partial/\partial y\f$ of \c *this ,
802 * where \f$y=r\sin\theta \sin\phi\f$.
803 * If \c dzpuis is zero, then the returned \c Scalar has
804 * \c dzpuis = 2. It is increased by 1 otherwise.
805 */
806 const Scalar& dsdy() const ;
807
808 /** Returns \f$\partial/\partial z\f$ of \c *this ,
809 * where \f$z=r\cos\theta\f$.
810 * If \c dzpuis is zero, then the returned \c Scalar has
811 * \c dzpuis = 2. It is increased by 1 otherwise.
812 */
813 const Scalar& dsdz() const ;
814
815 /** Returns \f$\partial/\partial x_i\f$ of \c *this ,
816 * where \f$x_i = (x, y, z)\f$.
817 * If \c dzpuis is zero, then the returned \c Scalar has
818 * \c dzpuis = 2. It is increased by 1 otherwise.
819 * @param i [input] i=1 for \e x , i=2 for \e y , i=3 for \e z .
820 */
821 const Scalar& deriv(int i) const ;
822
823 /** Returns the gradient (1-form = covariant vector) of \c *this
824 * @param gam metric components only used to get the triad with
825 * respect to which the components of the result are defined
826 */
827 const Vector& derive_cov(const Metric& gam) const ;
828
829
830 /** Returns the "contravariant" derivative of \c *this with respect
831 * to some metric \f$\gamma\f$, by raising the index of the
832 * gradient (cf. method \c derive_cov() ) with
833 * \f$\gamma\f$.
834 */
835 const Vector& derive_con(const Metric& gam) const ;
836
837 /// Computes the derivative of \c this along a vector field \c v
838 Scalar derive_lie(const Vector& v) const ;
839
840
841 /** Returns the Laplacian of \c *this
842 * @param ced_mult_r [input] Determines the quantity computed in
843 * the compactified external domain (CED)
844 * (\e u in the field represented by \c *this ) :
845 * \li ced_mult_r = 0 : \f$\Delta u\f$
846 * \li ced_mult_r = 2 : \f$r^2 \, \Delta u\f$
847 * \li ced_mult_r = 4 (default) : \f$r^4 \, \Delta u\f$
848 */
849 const Scalar& laplacian(int ced_mult_r = 4) const ;
850
851 /** Returns the angular Laplacian \f$\Delta_{\theta\varphi}\f$ of \c *this ,
852 * where \f$\Delta_{\theta\varphi} f = \frac{\partial^2 f}
853 * {\partial \theta^2} + \frac{1}{\tan \theta} \frac{\partial f}
854 * {\partial \theta} +\frac{1}{\sin^2 \theta}\frac{\partial^2 f}
855 * {\partial \varphi^2}\f$
856 *
857 */
858 const Scalar& lapang() const ;
859
860 /// Division by \e r everywhere; \c dzpuis is not changed.
861 void div_r() ;
862
863 /** Division by \e r everywhere but with the output flag \c dzpuis
864 * set to \c ced_mult_r .
865 * @param ced_mult_r [input] value of \c dzpuis of the result.
866 */
867 void div_r_dzpuis(int ced_mult_r) ;
868
869 /** Division by \e r in the compactified external domain (CED), the
870 * \c dzpuis flag is not changed.
871 */
872 void div_r_ced() ;
873
874 /// Multiplication by \e r everywhere; \c dzpuis is not changed.
875 void mult_r() ;
876
877 /** Multiplication by \e r everywhere but with the output flag \c dzpuis
878 * set to \c ced_mult_r .
879 * @param ced_mult_r [input] value of \c dzpuis of the result.
880 */
881 void mult_r_dzpuis(int ced_mult_r) ;
882
883 /** Multiplication by \e r in the compactified external domain (CED), the
884 * \c dzpuis flag is not changed.
885 */
886 void mult_r_ced() ;
887
888 /// Multiplication by \f$r\sin\theta\f$ everywhere; \c dzpuis is not changed.
889 void mult_rsint() ;
890
891 /** Multiplication by \f$r\sin\theta\f$ but with the output flag \c dzpuis
892 * set to \c ced_mult_r .
893 * @param ced_mult_r [input] value of \c dzpuis of the result.
894 */
895 void mult_rsint_dzpuis(int ced_mult_r) ;
896
897 /// Division by \f$r\sin\theta\f$ everywhere; \c dzpuis is not changed.
898 void div_rsint() ;
899
900 /** Division by \f$r\sin\theta\f$ but with the output flag \c dzpuis
901 * set to \c ced_mult_r .
902 * @param ced_mult_r [input] value of \c dzpuis of the result.
903 */
904 void div_rsint_dzpuis(int ced_mult_r) ;
905
906 void mult_cost() ; ///< Multiplication by \f$\cos\theta\f$
907
908 void div_cost() ; ///< Division by \f$\cos\theta\f$
909
910 void mult_sint() ; ///< Multiplication by \f$\sin\theta\f$
911
912 void div_sint() ; ///< Division by \f$\sin\theta\f$
913
914 void div_tant() ; ///< Division by \f$\tan\theta\f$
915
916 /** Computes the radial primitive which vanishes for \f$r\to \infty\f$.
917 * i.e. the function
918 * \f$ F(r,\theta,\varphi) = \int_r^\infty f(r',\theta,\varphi) \, dr' \f$
919 * where \e f is the function represented by \c *this
920 * (and must have a \c dzpuis = 2).
921 * @param null_infty if true (default), the primitive is null
922 * at infinity (or on the grid boundary). \e F is null at the
923 * center otherwise
924 * @return function \e F
925 */
926 Scalar primr(bool null_infty = true) const ;
927
928 /** Computes the integral over all space of \c *this .
929 * The computed quantity is (\e u being the field represented by
930 * \c *this )
931 * \f$\int u \, r^2 \sin\theta \, dr\, d\theta \, d\phi\f$.
932 * Note that in the compactified external domain (CED), \c dzpuis
933 * must be 4 for the computation to take place.
934 */
935 double integrale() const ;
936
937 /** Computes the integral in each domain of \c *this .
938 * The computed quantity is (\e u being the field represented by
939 * \c *this )
940 * \f$\int u \, r^2 \sin\theta \, dr\, d\theta \, d\phi\f$
941 * in each domain. The result is returned a \c Tbl on the
942 * various domains.
943 * Note that in the compactified external domain (CED), \c dzpuis
944 * must be 4 for the computation to take place.
945 */
946 const Tbl& integrale_domains() const ;
947
948 /** Decreases by \c dec units the value of \c dzpuis and
949 * changes accordingly the values of the \c Scalar in the
950 * compactified external domain (CED).
951 */
952 virtual void dec_dzpuis(int dec = 1) ;
953
954 /** Increases by \c inc units the value of \c dzpuis and
955 * changes accordingly the values of the \c Scalar in the
956 * compactified external domain (CED).
957 */
958 virtual void inc_dzpuis(int inc = 1) ;
959
960 /** Sets a new vectorial basis (triad) of decomposition and modifies
961 * the components accordingly.
962 */
963 virtual void change_triad(const Base_vect& new_triad) ;
964
965 /**
966 * Sets the \c n lasts coefficients in \e r to 0 in the
967 * external domain.
968 */
969 void filtre (int n) ;
970
971 /**
972 * Sets the \c n lasts coefficients in \e r to 0 in all
973 * domains.
974 */
975 void filtre_r (int* nn) ;
976
977 /**
978 * Sets the \c n last coefficients in \e r to 0 in the domain \c nzone .
979 */
980 void filtre_r (int n, int nzone) ;
981
982 /**
983 * Applies an exponential filter to the spectral coefficients in the radial direction.
984 * The filter is of the type: \f$ \forall n\leq N,\, b_n = \sigma(n/N ) a_n\f$, with
985 * \f$ \sigma(x) = \exp\left( -\ln (10^\alpha ) x^{2p} \right) \f$ and \e N the number
986 * of radial coefficients.
987 * @param lzmin, lzmax [input] the indices of the domain where the filter is applied
988 * (in [\c lzmin , \c lzmax ])
989 * @param p [input] the order of the filter
990 * @param alpha [input] \f$\alpha\f$ appearing in the above formula.
991 */
992 // virtual void exponential_filter_r(int lzmin, int lzmax, int p,
993 // double alpha= -16.) ;
994 virtual void exponential_filter_r(int lzmin, int lzmax, int p,
995 double alpha= -16.) ;
996
997 /**
998 * Applies an exponential filter to the spectral coefficients in the radial direction.
999 * The filter is of the type: \f$ \forall n\leq N,\, b_n = \sigma(n/N ) a_n\f$, with
1000 * \f$ \sigma(x) = \exp\left( \alpha x^{p} \right) \f$ and \e N the number
1001 * of radial coefficients.
1002 * @param lzmin, lzmax [input] the indices of the domain where the filter is applied
1003 * (in [\c lzmin , \c lzmax ])
1004 * @param p [input] the order of the filter
1005 * @param alpha [input] \f$\alpha\f$ appearing in the above formula.
1006 */
1007 void sarra_filter_r(int lzmin, int lzmax, double p,
1008 double alpha= -1E-16) ;
1009
1010 /**
1011 * Applies an exponential filter in radial direction in all domains.
1012 * (see \c Scalar:exponential_filter_r ). Note that this may cause
1013 * regularity problems at the origin if applied in a nucleus.
1014 */
1015 void exp_filter_r_all_domains(Scalar &ss, int p, double alpha=-16.) ;
1016
1017 /**
1018 * Applies an exponential filter in radial direction in all domains
1019 * for the case where p is a double
1020 * (see \c Scalar:sarra_filter_r ). Note that this may cause
1021 * regularity problems at the origin if applied in a nucleus.
1022 */
1023 void sarra_filter_r_all_domains(double p, double alpha=1E-16) ;
1024
1025 /**
1026 * Applies an exponential filter to the spectral coefficients in the angular directions.
1027 * The filter is of the type:
1028 * \f$ \forall \ell \leq \ell_{\rm max},\, \forall m,\, b_{\ell m} = \sigma(\ell/\ell_{\rm max} ) a_{\ell m}\f$, with
1029 * \f$ \sigma(x) \f$ defined for \c Scalar::exponential_filter_r and
1030 * \f$\ell_{\rm max}\f$ the number of spherical harmonics used.
1031 */
1032 virtual void exponential_filter_ylm(int lzmin, int lzmax, int p,
1033 double alpha= -16.) ;
1034
1035 /**
1036 * Sets all the multipolar components between \c l_min and \c l_max
1037 * to zero. This is done for [ \c l_min , \c l_max ] and all relevant
1038 * \c m in the spherical harmonics expansion basis. If \c ylm_output
1039 * is set to \c true , then the spectral expansion basis of \c this is
1040 * left to be that of spherical harmonics.
1041 */
1042 void annule_l (int l_min, int l_max, bool ylm_output= false ) ;
1043
1044 /**
1045 * Sets the \c n lasts coefficients in \f$\Phi\f$ to 0 in the
1046 * domain \c zone .
1047 */
1048 void filtre_phi (int n, int zone) ;
1049
1050 /**
1051 * Sets the \c n lasts coefficients in \f$\theta\f$ to 0 in the
1052 * domain \c nz1 to \c nz2 when expressed in spherical harmonics.
1053 */
1054 void filtre_tp(int nn, int nz1, int nz2) ;
1055
1056
1057 /**
1058 * Substracts all the components behaving like \f$r^{-n}\f$ in the external
1059 * domain, with \e n strictly lower than \c puis , so that \c *this
1060 * decreases at least like \f$r^{\tt puis} \f$ at infinity.
1061 */
1062 void fixe_decroissance (int puis) ;
1063
1064 /** Performs a \f$C^k\f$ matching of the last non-compactified shell with
1065 * a decaying function \f$\sum_{j=0}^k {\alpha_j \over r^{\ell+n+j}}\f$ where
1066 * \f$\ell\f$ is the spherical harmonic index and \e n is some
1067 * specifiable parameter.
1068 */
1069 void smooth_decay(int k, int n) ;
1070
1071 /**
1072 * Performs the \f$C^n\f$ matching of the nucleus with respect to the
1073 * first shell.
1074 */
1075 void raccord(int n) ;
1076
1077 /**
1078 * Performs the \f$C^1\f$ matching of the external domain with respect to
1079 * the last shell using function like \f$\frac{1}{r^i}\f$ with
1080 * \f${\tt puis} \leq i \leq {\tt puis+nbre}\f$ for each spherical harmonics
1081 * with \f$l \leq {\tt lmax}\f$.
1082 */
1083 void raccord_c1_zec(int puis, int nbre, int lmax) ;
1084
1085 /**
1086 * Matching of the external domain with the outermost shell
1087 */
1088 void raccord_externe(int puis, int nbre, int lmax) ;
1089
1090 /**
1091 * Method for matching accross domains and imposing boundary condition.
1092 * Matching of the field represented by \c this accross domains and imposition of the
1093 * boundary condition using the tau method.
1094 * @param par_bc [input] \c Param to control the boundary conditions
1095 * par_bc must contain (at a minimum)
1096 * a modifiable Tbl which specifies a physical boundary
1097 * two integers, one specifying the domain that has the boundary
1098 * the other specifying the number of conditions
1099 * 1 -> Dirichlet
1100 * 2 -> Robin (which may reduce to von Neumann, see below)
1101 * two doubles, specifying the Robin BC parameters. If the first is zero, we see that
1102 * Robin will reduce to von Neumann
1103 * @param par_mat [input/output] optional \c Param in which the matching matrices are
1104 * stored (together with their LU decomposition).
1105 */
1106 void match_tau(Param& par_bc, Param* par_mat=0x0) ;
1107
1108 /**
1109 * Method for matching accross domains and imposing boundary condition.
1110 * Matching of the field represented by \c this accross domains and imposition of the
1111 * boundary condition using the tau method.
1112 * @param par_bc [input] \c Param to control the boundary conditions
1113 * @param par_mat [input/output] optional \c Param in which the matching matrices are
1114 * stored (together with their LU decomposition).
1115 */
1116 void match_tau_shell(Param& par_bc, Param* par_mat=0x0) ;
1117
1118 /**
1119 * Method for matching accross domains and imposing boundary condition.
1120 * Matching of the field represented by \c this accross domains and imposition of the
1121 * boundary condition using the collocation method.
1122 * @param par_bc [input] \c Param to control the boundary conditions
1123 * @param par_mat [input/output] optional \c Param in which the matching matrices are
1124 * stored (together with their LU decomposition).
1125 */
1126 void match_collocation(Param& par_bc, Param* par_mat=0x0) ;
1127
1128 // Outputs
1129 // -------
1130 public:
1131 virtual void sauve(FILE *) const ; ///< Save in a file
1132
1133 /** Displays the spectral coefficients and the associated
1134 * basis functions. This function shows only the values greater than a
1135 * given threshold.
1136 * @param comment comment to be printed at top of the display
1137 * (default: 0x0 = nothing printed)
1138 * @param threshold [input] Value above which a coefficient is printed
1139 * (default: 1.e-7)
1140 * @param precision [input] Number of printed digits (default: 4)
1141 * @param ostr [input] Output stream used for the printing (default: cout)
1142 */
1143 virtual void spectral_display(const char* comment = 0x0,
1144 double threshold = 1.e-7, int precision = 4,
1145 ostream& ostr = cout) const ;
1146
1147 /// Display
1148 friend ostream& operator<<(ostream& , const Scalar & ) ;
1149
1150 /** 3D visualization via a plane section.
1151 * Prepares files for visualization by OpenDX of the values of the field in
1152 * a plane x=const, y=const or z=const
1153 *
1154 * @param section_type [input] defines the type of section :
1155 * \li 'x' for a plane x = a with a = const (parameter \c aa )
1156 * \li 'y' for a plane y = a with a = const (parameter \c aa )
1157 * \li 'z' for a plane z = a with a = const (parameter \c aa )
1158 * @param aa [input] constant a defining the section plane
1159 * @param umin [input] defines with \c umax the range of the plane coordinate u
1160 * @param umax [input] defines with \c umin the range of the plane coordinate u
1161 * @param vmin [input] defines with \c vmax the range of the plane coordinate v
1162 * @param vmax [input] defines with \c vmin the range of the plane coordinate v
1163 * @param title [input] title for the graph (for OpenDX legend)
1164 * @param filename [input] name for the file which will be the input for
1165 * OpenDX; the default 0x0 is transformed into "scalar_section"
1166 * @param start_dx [input] determines whether OpenDX must be launched (as a
1167 * subprocess) to view the field; if set to \c false , only input files
1168 * for future usage of OpenDX are created
1169 * @param nu [input] number of points in the u direction (uniform sampling)
1170 * @param nv [input] number of points in the v direction (uniform sampling)
1171 *
1172 */
1173 void visu_section(const char section_type, double aa, double umin, double umax, double vmin,
1174 double vmax, const char* title = 0x0, const char* filename = 0x0,
1175 bool start_dx = true, int nu = 200, int nv = 200) const ;
1176
1177 /** 3D visualization via a plane section.
1178 * Prepares files for visualization by OpenDX of the values of the field in
1179 * any given plane.
1180 *
1181 * @param plane [input] : 2D \c Tbl defining the section plane: \c plane
1182 * must of dimension 3x3 with the following content:
1183 * \li \c plane(0,i) : absolute Cartesian coordinates (xa0,ya0,za0) of some
1184 * point in the plane considered as the origin for the plane coordinates
1185 * (u,v): \c plane(0,0) = xa0 , \c plane(0,1) = ya0 ,
1186 * \li \c plane(0,2) = za0
1187 * \li \c plane(1,i) : components w.r.t. absolute Cartesian coordinates
1188 * of the u-coordinate unit vector in the section plane
1189 * \li \c plane(2,i) : components w.r.t. absolute Cartesian coordinates
1190 * of the v-coordinate unit vector in the section plane
1191 * @param umin [input] defines with \c umax the range of the plane coordinate u
1192 * @param umax [input] defines with \c umin the range of the plane coordinate u
1193 * @param vmin [input] defines with \c vmax the range of the plane coordinate v
1194 * @param vmax [input] defines with \c vmin the range of the plane coordinate v
1195 * @param title [input] title for the graph (for OpenDX legend)
1196 * @param filename [input] name for the file which will be the input for
1197 * OpenDX; the default 0x0 is transformed into "scalar_section"
1198 * @param start_dx [input] determines whether OpenDX must be launched (as a
1199 * subprocess) to view the field; if set to \c false , only input files
1200 * for future usage of OpenDX are created
1201 * @param nu [input] number of points in the u direction (uniform sampling)
1202 * @param nv [input] number of points in the v direction (uniform sampling)
1203 *
1204 */
1205 void visu_section(const Tbl& plane, double umin, double umax, double vmin,
1206 double vmax, const char* title = 0x0, const char* filename = 0x0,
1207 bool start_dx = true, int nu = 200, int nv = 200) const ;
1208
1209 /** 3D visualization via time evolving plane section (animation).
1210 * Prepares files for visualization by OpenDX of the values of the field in
1211 * a plane x=const, y=const or z=const at successive time steps
1212 *
1213 * @param section_type [input] defines the type of section :
1214 * \li 'x' for a plane x = a with a = const (parameter \c aa )
1215 * \li 'y' for a plane y = a with a = const (parameter \c aa )
1216 * \li 'z' for a plane z = a with a = const (parameter \c aa )
1217 * @param aa [input] constant a defining the section plane
1218 * @param umin [input] defines with \c umax the range of the plane coordinate u
1219 * @param umax [input] defines with \c umin the range of the plane coordinate u
1220 * @param vmin [input] defines with \c vmax the range of the plane coordinate v
1221 * @param vmax [input] defines with \c vmin the range of the plane coordinate v
1222 * @param jtime [input] time step label
1223 * @param ttime [input] time t corresponding to \c jtime
1224 * @param jgraph [input] number of time steps between two graphs: the graph
1225 * will be generated only if \c jtime is a multiple of \c jgraph
1226 * @param title [input] title for the graph (for OpenDX legend)
1227 * @param filename_root [input] beginning of the names for the files which will
1228 * be the input for OpenDX (the end of names will be automatically generated
1229 * from the time steps); the default 0x0 is transformed into "anim"
1230 * @param start_dx [input] determines whether OpenDX must be launched (as a
1231 * subprocess) to view the field; if set to \c false , only input files
1232 * for future usage of OpenDX are created
1233 * @param nu [input] number of points in the u direction (uniform sampling)
1234 * @param nv [input] number of points in the v direction (uniform sampling)
1235 *
1236 */
1237 void visu_section_anim(const char section_type, double aa, double umin,
1238 double umax, double vmin, double vmax, int jtime, double ttime,
1239 int jgraph = 1, const char* title = 0x0, const char* filename_root = 0x0,
1240 bool start_dx = false, int nu = 200, int nv = 200) const ;
1241
1242 /** 3D visualization (volume rendering) via OpenDX.
1243 * Prepares files for visualization by OpenDX of the values of the field in
1244 * some rectangular box.
1245 *
1246 * @param xmin [input] defines with \c xmax the x range of the visualization box
1247 * @param xmax [input] defines with \c xmin the x range of the visualization box
1248 * @param ymin [input] defines with \c ymax the y range of the visualization box
1249 * @param ymax [input] defines with \c ymin the y range of the visualization box
1250 * @param zmin [input] defines with \c zmax the z range of the visualization box
1251 * @param zmax [input] defines with \c zmin the z range of the visualization box
1252 * @param title [input] title for the graph (for OpenDX legend)
1253 * @param filename [input] name for the file which will be the input for
1254 * OpenDX; the default 0x0 is transformed into "scalar_box"
1255 * @param start_dx [input] determines whether OpenDX must be launched (as a
1256 * subprocess) to view the field; if set to \c false , only input files
1257 * for future usage of OpenDX are created
1258 * @param nx [input] number of points in the x direction (uniform sampling)
1259 * @param ny [input] number of points in the y direction (uniform sampling)
1260 * @param nz [input] number of points in the z direction (uniform sampling)
1261 *
1262 */
1263 void visu_box(double xmin, double xmax, double ymin, double ymax,
1264 double zmin, double zmax, const char* title0 = 0x0,
1265 const char* filename0 = 0x0, bool start_dx = true, int nx = 40, int ny = 40,
1266 int nz = 40) const ;
1267
1268
1269
1270 // Member arithmetics
1271 // ------------------
1272 public:
1273 void operator+=(const Scalar &) ; ///< += Scalar
1274 void operator-=(const Scalar &) ; ///< -= Scalar
1275 void operator*=(const Scalar &) ; ///< *= Scalar
1276
1277 // Manipulation of spectral bases
1278 // ------------------------------
1279 /** Sets the spectral bases of the \c Valeur \c va to the standard ones
1280 * for a scalar field
1281 */
1282 virtual void std_spectral_base() ;
1283
1284 /** Sets the spectral bases of the \c Valeur \c va to the standard odd ones
1285 * for a scalar field
1286 */
1287 virtual void std_spectral_base_odd() ;
1288
1289 /** Sets the spectral bases of the \c Valeur \c va
1290 */
1291 void set_spectral_base(const Base_val& ) ;
1292
1293 /// Returns the spectral bases of the \c Valeur \c va
1294 const Base_val& get_spectral_base( ) const {return va.base ;} ;
1295
1296 /** Modifies the \c dzpuis flag.
1297 * NB: this method does not change the field values stored in
1298 * the compactified external domain (use methods \c dec_dzpuis() ,
1299 * etc... for this purpose).
1300 */
1301 void set_dzpuis(int ) ;
1302
1303 /** Asymptotic expansion at r = infinity.
1304 *
1305 * Determines the coefficients \f$a_k(\theta, \phi)\f$ of the expansion
1306 * \f[
1307 * \sum_{k=0}^n {a_k(\theta, \phi) \over r^k}
1308 * \f]
1309 * of \c *this when \f$r \rightarrow \infty\f$.
1310 *
1311 * @param n order of the expansion
1312 * @param flag : output
1313 * @return Array of \c n +1 \c Valeur s on \c mg->angu
1314 * describing the coefficients \f$a_k(\theta, \phi)\f$.
1315 * This array is allocated by the routine.
1316 *
1317 */
1318 Valeur** asymptot(int n, const int flag = 0) const ;
1319
1320
1321 // PDE resolution
1322 // --------------
1323 public:
1324 /** Solves the scalar Poisson equation with \c *this as a source.
1325 * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is
1326 * represented by the \c Scalar \c *this .
1327 * Note that \c dzpuis must be equal to 2 or 4, i.e. that the
1328 * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or
1329 * \f$r^4 \sigma\f$ in the compactified external domain.
1330 * The solution \e u with the boundary condition \e u =0 at spatial
1331 * infinity is the returned \c Scalar.
1332 */
1333 Scalar poisson() const ;
1334
1335 /** Solves the scalar Poisson equation with \c *this as a source
1336 * (version with parameters to control the resolution).
1337 * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is
1338 * represented by the \c Scalar \c *this .
1339 * Note that \c dzpuis must be equal to 2 or 4, i.e. that the
1340 * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or
1341 * \f$r^4 \sigma\f$ in the compactified external domain.
1342 * @param par [input/output] possible parameters
1343 * @param uu [input/output] solution \e u with the boundary condition
1344 * \e u =0 at spatial infinity.
1345 */
1346 void poisson(Param& par, Scalar& uu) const ;
1347
1348 /** Solves the scalar Poisson equation with \c *this as a source using a real Tau method
1349 * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is
1350 * represented by the \c Scalar \c *this .
1351 * Note that \c dzpuis must be equal to 2, 3 or 4, i.e. that the
1352 * quantity stored in \c *this is in fact \f$r^2 \sigma\f$, \f$r^3 \sigma\f$ or
1353 * \f$r^4 \sigma\f$ in the compactified external domain.
1354 * The solution \e u with the boundary condition \e u =0 at spatial
1355 * infinity is the returned \c Scalar.
1356 */
1357 Scalar poisson_tau() const ;
1358
1359 /** Solves the scalar Poisson equation with \c *this as a source using a real Tau method
1360 * (version with parameters to control the resolution)
1361 * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is
1362 * represented by the \c Scalar \c *this .
1363 * Note that \c dzpuis must be equal to 2, 3 or 4, i.e. that the
1364 * quantity stored in \c *this is in fact \f$r^2 \sigma\f$, \f$r^3 \sigma\f$ or
1365 * \f$r^4 \sigma\f$ in the compactified external domain.
1366 * The solution \e u with the boundary condition \e u =0 at spatial
1367 * infinity is the returned \c Scalar.
1368 */
1369 void poisson_tau(Param& par, Scalar& uu) const ;
1370
1371 /**
1372 * Is identicall to \c Scalar::poisson() . The regularity condition at the
1373 * origin is replace by a boundary condition of the Dirichlet type.
1374 *
1375 * @param limite [input] : angular function. The boundary condition is
1376 * given by \c limite[num] .
1377 * @param num [input] : index of the boudary at which the condition is to
1378 * be fullfilled.
1379 *
1380 * More precisely we impose the solution is equal to \c limite[num] at the
1381 * boundary between the domains \c num and \c num+1 (the latter one being
1382 * a shell).
1383 *
1384 */
1385 Scalar poisson_dirichlet (const Valeur& limite, int num) const ;
1386
1387 /**
1388 * Idem as \c Scalar::poisson_dirichlet , the boundary condition being on
1389 * the radial derivative of the solution.
1390 */
1391 Scalar poisson_neumann (const Valeur&, int) const ;
1392
1393
1394 /**
1395 * Is identicall to \c Scalar::poisson() . The regularity condition at the
1396 * origin is replace by a mixed boundary condition (Dirichlet + Neumann).
1397 *
1398 * @param limite [input] : angular function. The boundary condition is
1399 * given by \c limite[num] .
1400 * @param num [input] : index of the boudary at which the condition is to
1401 * be fullfilled.
1402 * @param fact_dir [input] : double in front of \f$\Psi\f$ (if \f$\Psi\f$
1403 * is the variable solved).
1404 * @param fact_neu [input] : double in front of the radial derivative
1405 * of \f$\Psi\f$.
1406 *
1407 * More precisely we impose \f$ fact\_dir.\Psi + fact\_neu.\frac{\partial
1408 * \Phi}{\partial r}\f$ is equal to the source at the
1409 * boundary between the domains \c num and \c num+1 (the latter one being
1410 * a shell).
1411 */
1412 Scalar poisson_dir_neu (const Valeur& limite , int num,
1413 double fact_dir, double fact_neu) const ;
1414
1415 /**
1416 * Idem as \c Scalar::poisson_dirichlet , the boundary condition being on
1417 * both the function and its radial derivative. The boundary condition
1418 * at infinity is relaxed.
1419 */
1420
1421 Scalar poisson_frontiere_double (const Valeur&, const Valeur&, int) const ;
1422
1423 /** Solves the scalar Poisson equation with \c *this as a source
1424 * (version with parameters to control the resolution).
1425 * The source \f$\sigma\f$ of the equation \f$\Delta u = \sigma\f$ is
1426 * represented by the \c Scalar \c *this .
1427 * The regularized source
1428 * \f$\sigma_{\rm regu} = \sigma - \sigma_{\rm div}\f$
1429 * is constructed and solved.
1430 * Note that \c dzpuis must be equal to 2 or 4, i.e. that the
1431 * quantity stored in \c *this is in fact \f$r^2 \sigma\f$ or
1432 * \f$r^4 \sigma\f$ in the compactified external domain.
1433 * @param k_div [input] regularization degree of the procedure
1434 * @param nzet [input] number of domains covering the star
1435 * @param unsgam1 [input] parameter \f$1/(\gamma-1)\f$ where \f$\gamma\f$
1436 * denotes the adiabatic index
1437 * @param par [input/output] possible parameters
1438 @param uu [input/output] solution
1439 * @param uu_regu [output] solution of the regular part of
1440 * the source.
1441 * @param uu_div [output] solution of the diverging part of
1442 * the source.
1443 * @param duu_div [output] derivative of the diverging potential.
1444 * @param source_regu [output] regularized source
1445 * @param source_div [output] diverging part of the source
1446 */
1447 void poisson_regular(int k_div, int nzet, double unsgam1, Param& par,
1448 Scalar& uu, Scalar& uu_regu, Scalar& uu_div,
1449 Tensor& duu_div,
1450 Scalar& source_regu, Scalar& source_div) const ;
1451
1452 /** Checks if a Poisson equation with \c *this as a source
1453 * has been correctly solved.
1454 *
1455 * @param uu [input] Solution \e u of the Poisson equation
1456 * \f$\Delta u = \sigma\f$, \f$\sigma\f$ being
1457 * represented by the \c Scalar \c *this .
1458 *
1459 * @param ostr [input/output] Output stream used for displaying
1460 * \c err .
1461 *
1462 * @param detail [input] \li if \c true displays \c err(0,*) ,
1463 * \c err(1,*) and \c err(2,*)
1464 * \li if \c false (default), displays only
1465 * the relative error \c err(0,*) .
1466 *
1467 * @return 2-D \c Tbl \c err decribing the errors in each
1468 * domain:
1469 * \li \c err(0,l) : Relative error in domain no. \c l ,
1470 * defined as the maximum value of
1471 * \f$|\Delta u - \sigma|\f$ in that domain divided by \e M ,
1472 * where \e M is the maximum value of \f$|\sigma|\f$
1473 * over all domains if \c dzpuis = 0 or \f$\sigma\f$ is
1474 * zero in the compactified external domain (CED). If
1475 * \c dzpuis != 0 and \f$\sigma\f$ does not vanish in the
1476 * CED, the value of \e M used in the
1477 * non-compactified domains is the maximum value over
1478 * these domains, whereas the value of \e M used in the
1479 * compactified external domain is the maximum value
1480 * on that particular domain.
1481 * \li \c err(1,l) : Maximum value of the absolute error
1482 * \f$|\Delta u - \sigma|\f$ in domain no. \c l
1483 * \li \c err(2,l) : Maximum value of \f$|\sigma|\f$ in domain
1484 * no. \c l
1485 */
1486 Tbl test_poisson(const Scalar& uu, ostream& ostr,
1487 bool detail = false) const ;
1488
1489 /** Solves the (generalized) angular Poisson equation with \c *this
1490 * as source.
1491 * The generalized angular Poisson equation is
1492 * \f$\Delta_{\theta\varphi} u + \lambda u = \sigma\f$,
1493 * where \f$\Delta_{\theta\varphi} u := \frac{\partial^2 u}
1494 * {\partial \theta^2} + \frac{1}{\tan \theta} \frac{\partial u}
1495 * {\partial \theta} +\frac{1}{\sin^2 \theta}\frac{\partial^2 u}
1496 * {\partial \varphi^2}\f$.
1497 *
1498 * @param lambda [input] coefficient \f$\lambda\f$ in the above equation
1499 * (default value = 0)
1500 * @return solution \e u .
1501 */
1502 Scalar poisson_angu(double lambda =0) const ;
1503
1504 /** Performs one time-step integration (from \f$t=J \to J+1\f$) of the
1505 * scalar d'Alembert equation with \c *this being the value of
1506 * the function \e f at time \e J .
1507 *
1508 * Works only with an affine mapping (class \c Map_af ) and,
1509 * if the last domain is a compactified one, it simply copies
1510 * the value of the field in this last domain at the time-step \e J
1511 * to the last domain of the returned solution.
1512 * @param par [input/output] possible parameters to control the
1513 * resolution of the d'Alembert equation:
1514 * \li \c par.get_double(0) : [input] the time step \e dt ,
1515 * \li \c par.get_int(0) : [input] the type of boundary conditions
1516 * set at the outer boundary (0 : reflexion, 1 : Sommerfeld
1517 * outgoing wave, valid only for \e l=0 components, 2 : Bayliss
1518 * \& Turkel outgoing wave, valid for \e l=0, 1, 2 components)
1519 * \li \c par.get_int_mod(0) : [input/output] set to 0 at first
1520 * call, is used as a working flag after (must not be modified after
1521 * first call)
1522 * \li \c par.get_tensor_mod(0) : [input] (optional) if the wave
1523 * equation is on a curved space-time, this is the potential in front
1524 * of the Laplace operator. It has to be a Scalar and updated at
1525 * every time-step (for a potential depending on time).
1526 * Note: there are many other working objects attached to this
1527 * \c Param , so one should not modify it.
1528 * There should be exactly one \c Param for each wave equation to be
1529 * solved.
1530 * @param fJm1 [input] solution \f$f^{J-1}\f$ at time \e J-1
1531 * @param source [input] source \f$\sigma\f$ of the d'Alembert equation
1532 * \f$\diamond u = \sigma\f$.
1533 * @return solution \f$f^{J+1}\f$ at time \e J+1
1534 * with boundary conditions defined by \c par.get_int(0) .
1535 */
1536 Scalar avance_dalembert(Param& par, const Scalar& fJm1, const Scalar& source)
1537 const ;
1538
1539 /**
1540 * Resolution of a general elliptic equation, putting zero at infinity.
1541 * @param params [input] the operators and variables to be used.
1542 **/
1543 Scalar sol_elliptic(Param_elliptic& params) const ;
1544
1545 /**
1546 * Resolution of a general elliptic equation, putting zero at infinity
1547 * and with inner boundary conditions.
1548 * @param params [input] the operators and variables to be used.
1549 * @param bound [input] : the boundary condition
1550 * @param fact_dir : 1 Dirchlet condition, 0 Neumann condition
1551 * @param fact_neu : 0 Dirchlet condition, 1 Neumann condition
1552
1553 **/
1554 Scalar sol_elliptic_boundary(Param_elliptic& params, const Mtbl_cf& bound,
1555 double fact_dir, double fact_neu) const ;
1556
1557 /** Resolution of general elliptic equation, with inner boundary conditions as Scalars
1558 * on mono-domain angulare grids
1559 **/
1560
1561 Scalar sol_elliptic_boundary(Param_elliptic& params, const Scalar& bound,
1562 double fact_dir, double fact_neu) const ;
1563
1564
1565 /** Solves the scalar 2-dimensional elliptic equation
1566 * with \c *this as a source.
1567 * Note that \c dzpuis must be equal to 2, 3 or 4, i.e.
1568 * The solution \e u with the boundary condition \e u =0 at spatial
1569 * infinity is the returned \c Scalar.
1570 */
1571 Scalar sol_elliptic_2d(Param_elliptic&) const ;
1572
1573 /** Solves a pseudo-1d elliptic equation
1574 * with \c *this as a source.
1575 *
1576 */
1577 Scalar sol_elliptic_pseudo_1d(Param_elliptic&) const ;
1578
1579 /**
1580 * Resolution of a general elliptic equation, putting a given value
1581 * at the outermost
1582 * shell and not solving in the compactified domain.
1583 * @param params [input] the operators and variables to be used.
1584 * @param val [input] value at the last shell.
1585 **/
1586 Scalar sol_elliptic_no_zec(Param_elliptic& params, double val = 0) const ;
1587
1588 /**
1589 * Resolution of a general elliptic equation solving in the
1590 * compactified domain and putting a given value at the inner boundary.
1591 * @param params [input] the operators and variables to be used.
1592 * @param val [input] value at the inner boundary of the external domain.
1593 **/
1594 Scalar sol_elliptic_only_zec(Param_elliptic& params, double val) const ;
1595
1596 /**
1597 * General elliptic solver.
1598 * The equation is not solved in the compactified domain and the
1599 * matching is done with an homogeneous solution.
1600 * @param params [input] the operators and variables to be used.
1601 * @param coef [output] : coefficient of the oscillatory solution
1602 * in the external domain.
1603 * @param phases [output] : phases (i.e. choice of the homogeneous solution to match with).
1604 **/
1605 Scalar sol_elliptic_sin_zec(Param_elliptic& params, double* coefs, double* phases) const ;
1606
1607
1608 /**
1609 * Resolution of a general elliptic equation fixing the dericative at
1610 * the origin and relaxing one continuity condition.
1611 *
1612 * @param val [input] value of the derivative.
1613 * @param params [input] the operators and variables to be used.
1614 **/
1615 Scalar sol_elliptic_fixe_der_zero(double val,
1616 Param_elliptic& params) const ;
1617
1618
1619 /**
1620 * Resolution of a divergence-like equation.
1621 * The equation solved reads: \f$ \frac{\partial \phi}{\partial r} + \frac{n}{r}
1622 * \phi = \sigma\f$, with \f$\phi\f$ the unknown and \f$\sigma\f$ the source
1623 * represented by \c this.
1624 *
1625 * @param n [input] the coefficient in front of the 1/r term.
1626 *
1627 * @return the solution to the equation.
1628 */
1629 Scalar sol_divergence(int n) const ;
1630
1631 // Import from other mapping
1632 // -------------------------
1633
1634 /** Assignment to another \c Scalar defined on a different mapping.
1635 * This assignment is performed point to point by means of the
1636 * spectral expansion of the original \c Scalar.
1637 * @param ci [input] \c Scalar to be imported.
1638 */
1639 void import(const Scalar& ci) ;
1640
1641 /** Assignment to another \c Scalar defined on a different mapping.
1642 * Case where the \c Scalar is symmetric with respect to the plane y=0.
1643 * This assignment is performed point to point by means of the
1644 * spectral expansion of the original \c Scalar.
1645 * @param ci [input] \c Scalar to be imported.
1646 */
1647 void import_symy(const Scalar& ci) ;
1648
1649 /** Assignment to another \c Scalar defined on a different mapping.
1650 * Case where the \c Scalar is antisymmetric with respect to the
1651 * plane y=0.
1652 * This assignment is performed point to point by means of the
1653 * spectral expansion of the original \c Scalar.
1654 * @param ci [input] \c Scalar to be imported.
1655 */
1656 void import_asymy(const Scalar& ci) ;
1657
1658 /** Assignment to another \c Scalar defined on a different mapping.
1659 * This assignment is performed point to point by means of the
1660 * spectral expansion of the original \c Scalar.
1661 * @param nzet [input] Number of domains of the destination
1662 * mapping (i.e. \c this->mp ) where the
1663 * importation is performed: the assignment
1664 * is done for the domains whose indices are
1665 * between 0 and \c nzet-1 . In the other
1666 * domains, \c *this is set to zero.
1667 * @param ci [input] \c Scalar to be imported.
1668 */
1669 void import(int nzet, const Scalar& ci) ;
1670
1671 /** Assignment to another \c Scalar defined on a different mapping.
1672 * Case where the \c Scalar is symmetric with respect to the plane y=0.
1673 * This assignment is performed point to point by means of the
1674 * spectral expansion of the original \c Scalar.
1675 * @param nzet [input] Number of domains of the destination
1676 * mapping (i.e. \c this->mp ) where the
1677 * importation is performed: the assignment
1678 * is done for the domains whose indices are
1679 * between 0 and \c nzet-1 . In the other
1680 * domains, \c *this is set to zero.
1681 * @param ci [input] \c Scalar to be imported.
1682 */
1683 void import_symy(int nzet, const Scalar& ci) ;
1684
1685 /** Assignment to another \c Scalar defined on a different mapping.
1686 * Case where the \c Scalar is antisymmetric with respect to the
1687 * plane y=0.
1688 * This assignment is performed point to point by means of the
1689 * spectral expansion of the original \c Scalar.
1690 * @param nzet [input] Number of domains of the destination
1691 * mapping (i.e. \c this->mp ) where the
1692 * importation is performed: the assignment
1693 * is done for the domains whose indices are
1694 * between 0 and \c nzet-1 . In the other
1695 * domains, \c *this is set to zero.
1696 * @param ci [input] \c Scalar to be imported.
1697 */
1698 void import_asymy(int nzet, const Scalar& ci) ;
1699
1700 protected:
1701 /** Assignment to another \c Scalar defined on a different mapping,
1702 * when the two mappings do not have a particular relative orientation.
1703 *
1704 * This assignment is performed point to point by means of the
1705 * spectral expansion of the original \c Scalar.
1706 * @param nzet [input] Number of domains of the destination
1707 * mapping (i.e. \c this->mp ) where the
1708 * importation is performed: the assignment
1709 * is done for the domains whose indices are
1710 * between 0 and \c nzet-1 . In the other
1711 * domains, \c *this is set to zero.
1712 * @param ci [input] \c Scalar to be imported.
1713 */
1714 void import_gal(int nzet, const Scalar& ci) ;
1715
1716 /** Assignment to another \c Scalar defined on a different mapping,
1717 * when the two mappings have aligned Cartesian axis.
1718 *
1719 * This assignment is performed point to point by means of the
1720 * spectral expansion of the original \c Scalar.
1721 * @param nzet [input] Number of domains of the destination
1722 * mapping (i.e. \c this->mp ) where the
1723 * importation is performed: the assignment
1724 * is done for the domains whose indices are
1725 * between 0 and \c nzet-1 . In the other
1726 * domains, \c *this is set to zero.
1727 * @param ci [input] \c Scalar to be imported.
1728 */
1729 void import_align(int nzet, const Scalar& ci) ;
1730
1731 /** Assignment to another \c Scalar defined on a different mapping,
1732 * when the two mappings have anti-aligned Cartesian axis (i.e.
1733 * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$).
1734 *
1735 * This assignment is performed point to point by means of the
1736 * spectral expansion of the original \c Scalar.
1737 * @param nzet [input] Number of domains of the destination
1738 * mapping (i.e. \c this->mp ) where the
1739 * importation is performed: the assignment
1740 * is done for the domains whose indices are
1741 * between 0 and \c nzet-1 . In the other
1742 * domains, \c *this is set to zero.
1743 * @param ci [input] \c Scalar to be imported.
1744 */
1745 void import_anti(int nzet, const Scalar& ci) ;
1746
1747 /** Assignment to another \c Scalar defined on a different mapping,
1748 * when the two mappings have aligned Cartesian axis.
1749 * Case where the \c Scalar is symmetric with respect to the plane y=0.
1750 *
1751 * This assignment is performed point to point by means of the
1752 * spectral expansion of the original \c Scalar.
1753 * @param nzet [input] Number of domains of the destination
1754 * mapping (i.e. \c this->mp ) where the
1755 * importation is performed: the assignment
1756 * is done for the domains whose indices are
1757 * between 0 and \c nzet-1 . In the other
1758 * domains, \c *this is set to zero.
1759 * @param ci [input] \c Scalar to be imported.
1760 */
1761 void import_align_symy(int nzet, const Scalar& ci) ;
1762
1763 /** Assignment to another \c Scalar defined on a different mapping,
1764 * when the two mappings have anti-aligned Cartesian axis (i.e.
1765 * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$).
1766 * Case where the \c Scalar is symmetric with respect to the plane y=0.
1767 *
1768 * This assignment is performed point to point by means of the
1769 * spectral expansion of the original \c Scalar.
1770 * @param nzet [input] Number of domains of the destination
1771 * mapping (i.e. \c this->mp ) where the
1772 * importation is performed: the assignment
1773 * is done for the domains whose indices are
1774 * between 0 and \c nzet-1 . In the other
1775 * domains, \c *this is set to zero.
1776 * @param ci [input] \c Scalar to be imported.
1777 */
1778 void import_anti_symy(int nzet, const Scalar& ci) ;
1779
1780 /** Assignment to another \c Scalar defined on a different mapping,
1781 * when the two mappings have aligned Cartesian axis.
1782 * Case where the \c Scalar is antisymmetric with respect to the
1783 * plane y=0.
1784 *
1785 * This assignment is performed point to point by means of the
1786 * spectral expansion of the original \c Scalar.
1787 * @param nzet [input] Number of domains of the destination
1788 * mapping (i.e. \c this->mp ) where the
1789 * importation is performed: the assignment
1790 * is done for the domains whose indices are
1791 * between 0 and \c nzet-1 . In the other
1792 * domains, \c *this is set to zero.
1793 * @param ci [input] \c Scalar to be imported.
1794 */
1795 void import_align_asymy(int nzet, const Scalar& ci) ;
1796
1797 /** Assignment to another \c Scalar defined on a different mapping,
1798 * when the two mappings have anti-aligned Cartesian axis (i.e.
1799 * \f$x_1 = - x_2\f$, \f$y_1 = - y_2\f$, \f$z_1 = z_2\f$).
1800 * Case where the \c Scalar is antisymmetric with respect to the
1801 * plane y=0.
1802 *
1803 * This assignment is performed point to point by means of the
1804 * spectral expansion of the original \c Scalar.
1805 * @param nzet [input] Number of domains of the destination
1806 * mapping (i.e. \c this->mp ) where the
1807 * importation is performed: the assignment
1808 * is done for the domains whose indices are
1809 * between 0 and \c nzet-1 . In the other
1810 * domains, \c *this is set to zero.
1811 * @param ci [input] \c Scalar to be imported.
1812 */
1813 void import_anti_asymy(int nzet, const Scalar& ci) ;
1814
1815
1816 friend Scalar operator-(const Scalar& ) ;
1817 friend Scalar operator+(const Scalar&, const Scalar &) ;
1818 friend Scalar operator+(const Scalar&, const Mtbl&) ;
1819 friend Scalar operator+(const Scalar&, double ) ;
1820 friend Scalar operator-(const Scalar &, const Scalar &) ;
1821 friend Scalar operator-(const Scalar&, const Mtbl&) ;
1822 friend Scalar operator-(const Scalar&, double ) ;
1823 friend Scalar operator*(const Scalar &, const Scalar &) ;
1824 friend Scalar operator%(const Scalar &, const Scalar &) ;
1825 friend Scalar operator|(const Scalar &, const Scalar &) ;
1826 friend Scalar operator*(const Mtbl&, const Scalar &) ;
1827 friend Scalar operator*(double, const Scalar &) ;
1828 friend Scalar operator/(const Scalar &, const Scalar &) ;
1829 friend Scalar operator/(const Scalar &, const Mtbl &) ;
1830 friend Scalar operator/(const Mtbl &, const Scalar &) ;
1831 friend Scalar operator/(const Scalar&, double ) ;
1832 friend Scalar operator/(double, const Scalar &) ;
1833
1834 friend Scalar sin(const Scalar& ) ;
1835 friend Scalar cos(const Scalar& ) ;
1836 friend Scalar tan(const Scalar& ) ;
1837 friend Scalar asin(const Scalar& ) ;
1838 friend Scalar acos(const Scalar& ) ;
1839 friend Scalar atan(const Scalar& ) ;
1840 friend Scalar exp(const Scalar& ) ;
1841 friend Scalar Heaviside(const Scalar& ) ;
1842 friend Scalar log(const Scalar& ) ;
1843 friend Scalar log10(const Scalar& ) ;
1844 friend Scalar sqrt(const Scalar& ) ;
1845 friend Scalar racine_cubique (const Scalar& ) ;
1846 friend Scalar pow(const Scalar& , int ) ;
1847 friend Scalar pow(const Scalar& , double ) ;
1848 friend Scalar abs(const Scalar& ) ;
1849
1850 friend double totalmax(const Scalar& ) ;
1851 friend double totalmin(const Scalar& ) ;
1852 friend Tbl max(const Scalar& ) ;
1853 friend Tbl min(const Scalar& ) ;
1854 friend Tbl norme(const Scalar& ) ;
1855 friend Tbl diffrel(const Scalar& a, const Scalar& b) ;
1856 friend Tbl diffrelmax(const Scalar& a, const Scalar& b) ;
1857
1858 };
1859
1860 ostream& operator<<(ostream& , const Scalar & ) ;
1861
1862 // Prototypage de l'arithmetique
1863 /**
1864 * \defgroup sal_mat Scalar mathematics
1865 * \ingroup (tensor)
1866 * @{
1867 */
1868
1869 Scalar operator+(const Scalar& ) ; ///< + Scalar
1870 Scalar operator-(const Scalar& ) ; ///< \c - Scalar
1871 Scalar operator+(const Scalar&, const Scalar &) ; ///< Scalar + Scalar
1872 Scalar operator+(const Scalar&, const Mtbl&) ; ///< Scalar + Mbtl
1873 Scalar operator+(const Mtbl&, const Scalar&) ; ///< Mtbl + Scalar
1874 Scalar operator+(const Scalar&, double ) ; ///< Scalar + double
1875 Scalar operator+(double, const Scalar& ) ; ///< double + Scalar
1876 Scalar operator+(const Scalar&, int ) ; ///< Scalar + int
1877 Scalar operator+(int, const Scalar& ) ; ///< int + Scalar
1878 Scalar operator-(const Scalar &, const Scalar &) ; ///< Scalar - Scalar
1879 Scalar operator-(const Scalar&, const Mtbl&) ; ///< Scalar - Mbtl
1880 Scalar operator-(const Mtbl&, const Scalar&) ; ///< Mtbl - Scalar
1881 Scalar operator-(const Scalar&, double ) ; ///< Scalar - double
1882 Scalar operator-(double, const Scalar& ) ; ///< double - Scalar
1883 Scalar operator-(const Scalar&, int ) ; ///< Scalar - int
1884 Scalar operator-(int, const Scalar& ) ; ///< int - Scalar
1885 Scalar operator*(const Scalar &, const Scalar &) ; ///< Scalar * Scalar
1886
1887 /// Scalar * Scalar with desaliasing
1888 Scalar operator%(const Scalar &, const Scalar &) ;
1889
1890 /// Scalar * Scalar with desaliasing only in \e r
1891 Scalar operator|(const Scalar &, const Scalar &) ;
1892
1893 Scalar operator*(const Mtbl&, const Scalar&) ; ///< Mtbl * Scalar
1894 Scalar operator*(const Scalar&, const Mtbl&) ; ///< Scalar * Mtbl
1895
1896 Scalar operator*(const Scalar&, double ) ; ///< Scalar * double
1897 Scalar operator*(double, const Scalar &) ; ///< double * Scalar
1898 Scalar operator*(const Scalar&, int ) ; ///< Scalar * int
1899 Scalar operator*(int, const Scalar& ) ; ///< int * Scalar
1900 Scalar operator/(const Scalar &, const Scalar &) ; ///< Scalar / Scalar
1901 Scalar operator/(const Scalar&, double ) ; ///< Scalar / double
1902 Scalar operator/(double, const Scalar &) ; ///< double / Scalar
1903 Scalar operator/(const Scalar&, int ) ; ///< Scalar / int
1904 Scalar operator/(int, const Scalar &) ; ///< int / Scalar
1905 Scalar operator/(const Scalar &, const Mtbl&) ; ///< Scalar / Mtbl
1906 Scalar operator/(const Mtbl&, const Scalar &) ; ///< Mtbl / Scalar
1907
1908
1909 Scalar sin(const Scalar& ) ; ///< Sine
1910 Scalar cos(const Scalar& ) ; ///< Cosine
1911 Scalar tan(const Scalar& ) ; ///< Tangent
1912 Scalar asin(const Scalar& ) ; ///< Arcsine
1913 Scalar acos(const Scalar& ) ; ///< Arccosine
1914 Scalar atan(const Scalar& ) ; ///< Arctangent
1915 Scalar exp(const Scalar& ) ; ///< Exponential
1916 Scalar Heaviside(const Scalar& ) ; ///< Heaviside function
1917 Scalar log(const Scalar& ) ; ///< Neperian logarithm
1918 Scalar log10(const Scalar& ) ; ///< Basis 10 logarithm
1919 Scalar sqrt(const Scalar& ) ; ///< Square root
1920 Scalar racine_cubique (const Scalar& ) ; ///< Cube root
1921 Scalar pow(const Scalar& , int ) ; ///< Power \f${\tt Scalar}^{\tt int}\f$
1922 Scalar pow(const Scalar& , double ) ; ///< Power \f${\tt Scalar}^{\tt double}\f$
1923 Scalar abs(const Scalar& ) ; ///< Absolute value
1924
1925 /**
1926 * Maximum values of a \c Scalar in each domain.
1927 * @return 1-D \c Tbl of size the number of domains, the elements of which
1928 * are the set of the maximum values in each domain.
1929 */
1930 double totalmax(const Scalar& ) ;
1931
1932 /**
1933 * Minimum values of a \c Scalar in each domain.
1934 * @return 1-D \c Tbl of size the number of domains, the elements of which
1935 * are the set of the minimum values in each domain.
1936 */
1937 double totalmin(const Scalar& ) ;
1938
1939 /**
1940 * Maximum values of a \c Scalar in each domain.
1941 * @return 1-D \c Tbl of size the number of domains, the elements of which
1942 * are the set of the maximum values in each domain.
1943 */
1944 Tbl max(const Scalar& ) ;
1945
1946 /**
1947 * Minimum values of a \c Scalar in each domain.
1948 * @return 1-D \c Tbl of size the number of domains, the elements of which
1949 * are the set of the minimum values in each domain.
1950 */
1951 Tbl min(const Scalar& ) ;
1952
1953 /**
1954 * Sums of the absolute values of all the values of the \c Scalar
1955 * in each domain.
1956 * @return 1-D \c Tbl of size the number of domains, the elements of which
1957 * are the set of the sums of the absolute values in each domain.
1958 */
1959 Tbl norme(const Scalar& ) ;
1960
1961 /**
1962 * Relative difference between two \c Scalar (norme version).
1963 * @return 1-D \c Tbl of size the number of domains, the elements of which
1964 * are \c norme[a(l)-b(l)]/norme[b(l)] if \c b(l)!=0 and
1965 * \c norme[a(l)-b(l)] if \c b(l)=0 , where \c a(l) and
1966 * \c b(l) denote symbolically the values of \c a and \c b
1967 * in domain no. \c l .
1968 */
1969 Tbl diffrel(const Scalar& a, const Scalar& b) ;
1970
1971 /**
1972 * Relative difference between two \c Scalar (max version).
1973 * @return 1-D \c Tbl of size the number of domains, the elements of which
1974 * are \c max[abs(a(l)-b(l))]/max[abs(b(l))] if \c b(l)!=0 and
1975 * \c max[abs(a(l)-b(l))] if \c b(l)=0 , where \c a(l) and
1976 * \c b(l) denote symbolically the values of \c a and \c b
1977 * in domain no. \c l .
1978 */
1979 Tbl diffrelmax(const Scalar& a, const Scalar& b) ;
1980
1981 /**
1982 * Applies an exponential filter in angular directions in all domains.
1983 * (see \c Scalar:exponential_filter_ylm ).
1984 */
1985 void exp_filter_ylm_all_domains(Scalar& ss, int p, double alpha=-16.) ;
1986
1987 /** @} */
1988 }
1989 #endif