LORENE
scalar_integ.C
1 /*
2  * Member functions of the Scalar class for the computation of integrals.
3  */
4 
5 /*
6  * Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
7  *
8  * Copyright (c) 1999-2001 Eric Gourgoulhon (Cmp version)
9  *
10  * This file is part of LORENE.
11  *
12  * LORENE is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * LORENE is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with LORENE; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  */
27 
28 
29 
30 
31 /*
32  * $Id: scalar_integ.C,v 1.5 2016/12/05 16:18:18 j_novak Exp $
33  * $Log: scalar_integ.C,v $
34  * Revision 1.5 2016/12/05 16:18:18 j_novak
35  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36  *
37  * Revision 1.4 2014/10/13 08:53:46 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.3 2004/07/26 16:02:23 j_novak
41  * Added a flag to specify whether the primitive should be zero either at r=0
42  * or at r going to infinity.
43  *
44  * Revision 1.2 2004/06/14 15:28:17 e_gourgoulhon
45  * Added method primr().
46  *
47  * Revision 1.1 2003/09/25 09:33:36 j_novak
48  * Added methods for integral calculation and various manipulations
49  *
50  *
51  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_integ.C,v 1.5 2016/12/05 16:18:18 j_novak Exp $
52  *
53  */
54 
55 // Headers Lorene
56 #include "tensor.h"
57 #include "cmp.h"
58 
59  //-----------------------------------//
60  // Integral over all space //
61  //-----------------------------------//
62 
63 namespace Lorene {
64 double Scalar::integrale() const {
65 
66  const Tbl& integ = integrale_domains() ;
67 
68  int nz = mp->get_mg()->get_nzone() ;
69 
70  double resu = integ(0) ;
71  for (int l=1; l<nz; l++) {
72  resu += integ(l) ;
73  }
74 
75  return resu ;
76 }
77 
78  //-----------------------------------//
79  // Integrals in each domain //
80  //-----------------------------------//
81 
83 
84  // Protection
85  assert(etat != ETATNONDEF) ;
86 
87  // If the integrals have not been previously computed, the
88  // computation must be done by the appropriate routine of the mapping :
89 
90  if (p_integ == 0x0) {
91  Cmp orig(*this) ;
92  p_integ = mp->integrale(orig) ;
93  }
94 
95  return *p_integ ;
96 
97 }
98 
99 
100  //----------------------//
101  // Radial primitive //
102  //----------------------//
103 
104 Scalar Scalar::primr(bool null_infty) const {
105 
106  Scalar resu(*mp) ;
107 
108  mp->primr(*this, resu, null_infty) ;
109 
110  return resu ;
111 }
112 
113 
114 
115 
116 }
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
virtual Tbl * integrale(const Cmp &) const =0
Computes the integral over all space of a Cmp .
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:777
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
virtual void primr(const Scalar &uu, Scalar &resu, bool null_infty) const =0
Computes the radial primitive which vanishes for .
double integrale() const
Computes the integral over all space of *this .
Definition: scalar_integ.C:64
Scalar primr(bool null_infty=true) const
Computes the radial primitive which vanishes for .
Definition: scalar_integ.C:104
Tbl * p_integ
Pointer on the space integral of *this (values in each domain) (0x0 if not up to date) ...
Definition: scalar.h:474
const Tbl & integrale_domains() const
Computes the integral in each domain of *this .
Definition: scalar_integ.C:82
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary)...
Definition: scalar.h:402
Basic array class.
Definition: tbl.h:164
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:301