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 char scalar_integ_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_integ.C,v 1.4 2014/10/13 08:53:46 j_novak Exp $" ;
30 
31 /*
32  * $Id: scalar_integ.C,v 1.4 2014/10/13 08:53:46 j_novak Exp $
33  * $Log: scalar_integ.C,v $
34  * Revision 1.4 2014/10/13 08:53:46 j_novak
35  * Lorene classes and functions now belong to the namespace Lorene.
36  *
37  * Revision 1.3 2004/07/26 16:02:23 j_novak
38  * Added a flag to specify whether the primitive should be zero either at r=0
39  * or at r going to infinity.
40  *
41  * Revision 1.2 2004/06/14 15:28:17 e_gourgoulhon
42  * Added method primr().
43  *
44  * Revision 1.1 2003/09/25 09:33:36 j_novak
45  * Added methods for integral calculation and various manipulations
46  *
47  *
48  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_integ.C,v 1.4 2014/10/13 08:53:46 j_novak Exp $
49  *
50  */
51 
52 // Headers Lorene
53 #include "tensor.h"
54 #include "cmp.h"
55 
56  //-----------------------------------//
57  // Integral over all space //
58  //-----------------------------------//
59 
60 namespace Lorene {
61 double Scalar::integrale() const {
62 
63  const Tbl& integ = integrale_domains() ;
64 
65  int nz = mp->get_mg()->get_nzone() ;
66 
67  double resu = integ(0) ;
68  for (int l=1; l<nz; l++) {
69  resu += integ(l) ;
70  }
71 
72  return resu ;
73 }
74 
75  //-----------------------------------//
76  // Integrals in each domain //
77  //-----------------------------------//
78 
80 
81  // Protection
82  assert(etat != ETATNONDEF) ;
83 
84  // If the integrals have not been previously computed, the
85  // computation must be done by the appropriate routine of the mapping :
86 
87  if (p_integ == 0x0) {
88  Cmp orig(*this) ;
89  p_integ = mp->integrale(orig) ;
90  }
91 
92  return *p_integ ;
93 
94 }
95 
96 
97  //----------------------//
98  // Radial primitive //
99  //----------------------//
100 
101 Scalar Scalar::primr(bool null_infty) const {
102 
103  Scalar resu(*mp) ;
104 
105  mp->primr(*this, resu, null_infty) ;
106 
107  return resu ;
108 }
109 
110 
111 
112 
113 }
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:765
virtual void primr(const Scalar &uu, Scalar &resu, bool null_infty) const =0
Computes the radial primitive which vanishes for .
virtual Tbl * integrale(const Cmp &) const =0
Computes the integral over all space of a Cmp .
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:448
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
double integrale() const
Computes the integral over all space of *this .
Definition: scalar_integ.C:61
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary).
Definition: scalar.h:396
Tbl * p_integ
Pointer on the space integral of *this (values in each domain) (0x0 if not up to date)
Definition: scalar.h:468
const Tbl & integrale_domains() const
Computes the integral in each domain of *this .
Definition: scalar_integ.C:79
Scalar primr(bool null_infty=true) const
Computes the radial primitive which vanishes for .
Definition: scalar_integ.C:101
Basic array class.
Definition: tbl.h:161
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:295
Lorene prototypes.
Definition: app_hor.h:64