LORENE
valeur_smooth.C
1 /*
2  * Method of the class Valeur to make a function be smooth
3  * between the nucleus and the first shell.
4  *
5  * (see file valeur.h for the documentation).
6  */
7 
8 /*
9  * Copyright (c) 2000-2001 Keisuke Taniguchi
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 char valeur_smooth_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_smooth.C,v 1.4 2014/10/13 08:53:51 j_novak Exp $" ;
31 
32 /*
33  * $Id: valeur_smooth.C,v 1.4 2014/10/13 08:53:51 j_novak Exp $
34  * $Log: valeur_smooth.C,v $
35  * Revision 1.4 2014/10/13 08:53:51 j_novak
36  * Lorene classes and functions now belong to the namespace Lorene.
37  *
38  * Revision 1.3 2014/10/06 15:13:24 j_novak
39  * Modified #include directives to use c++ syntax.
40  *
41  * Revision 1.2 2002/10/16 14:37:16 j_novak
42  * Reorganization of #include instructions of standard C++, in order to
43  * use experimental version 3 of gcc.
44  *
45  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
46  * LORENE
47  *
48  * Revision 1.4 2001/10/10 13:56:07 eric
49  * Modif Joachim: pow(-1,i) --> pow(-1.,i).
50  *
51  * Revision 1.3 2001/01/16 16:11:41 keisuke
52  * Correct the initialization of the summation
53  * and insert some explanations.
54  *
55  * Revision 1.2 2001/01/16 15:15:12 keisuke
56  * change the argument and correct some errors.
57  *
58  * Revision 1.1 2001/01/16 14:54:54 keisuke
59  * Initial revision
60  *
61  *
62  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_smooth.C,v 1.4 2014/10/13 08:53:51 j_novak Exp $
63  *
64  */
65 
66 // Headers C
67 #include <cstdlib>
68 #include <cmath>
69 
70 // Headers Lorene
71 #include "valeur.h"
72 
73 //********************************************************************
74 
75 namespace Lorene {
76 
77 void Valeur::smooth(int nzet, Valeur& uuva) const {
78 
79  int nucl = nzet - 1 ;
80  int nr = mg->get_nr(nucl) ;
81  int nt = mg->get_nt(nucl) ;
82  int np = mg->get_np(nucl) ;
83 
84  // Protections
85  // -----------
86  assert(etat == ETATQCQ) ;
87  assert(nzet > 0) ;
88  assert(nr == mg->get_nr(nzet)) ;
89  assert(nt == mg->get_nt(nzet)) ;
90  assert(np == mg->get_np(nzet)) ;
91 
92  Valeur pot(mg) ;
93  (*this).coef() ; // the spectral coefficients are required
94  pot = *((*this).c_cf) ;
95 
96  Tbl& ccf_nucl = *((pot.c_cf)->t[nucl]) ;
97  Tbl& ccf_shell = *((pot.c_cf)->t[nzet]) ;
98 
99 
100  // Get the values at the outer boundary of the nucleus
101  //-----------------------------------------------------
102 
103  Tbl nucl_kj(np, nt) ;
104  nucl_kj.set_etat_qcq() ;
105 
106  for (int k=0 ; k<np ; k++) {
107  for (int j=0 ; j<nt ; j++) {
108 
109  double tmp = 0. ;
110  for (int i=0 ; i<nr ; i++) {
111 
112  tmp += ccf_nucl(k, j, i) ;
113 
114  }
115  nucl_kj.set(k, j) = tmp ;
116  }
117  }
118 
119 
120  // Get the values at the inner boundary of the first shell
121  // without the last coefficient
122  //---------------------------------------------------------
123 
124  Tbl shell_kj(np, nt) ;
125  shell_kj.set_etat_qcq() ;
126 
127  for (int k=0 ; k<np ; k++) {
128  for (int j=0 ; j<nt ; j++) {
129 
130  double tmp2 = 0. ;
131  for (int i=0 ; i<nr-1 ; i++) {
132 
133  tmp2 += pow(-1., i) * ccf_shell(k, j, i) ;
134 
135  }
136  shell_kj.set(k, j) = tmp2 ;
137  }
138  }
139 
140 
141  // Set the last coefficient of the first shell
142  //---------------------------------------------
143 
144  uuva.set_etat_cf_qcq() ;
145  uuva.c_cf->set_etat_qcq() ;
146  uuva.c_cf->t[nzet]->set_etat_qcq() ;
147 
148  Mtbl_cf& uuva_cf = *(uuva.c_cf) ;
149 
150  for (int k=0 ; k<np ; k++) {
151  for (int j=0 ; j<nt ; j++) {
152 
153  uuva_cf.set(nzet, k, j, nr-1) = nucl_kj(k, j) - shell_kj(k, j) ;
154 
155  }
156  }
157 
158  uuva.coef_i() ;
159 
160 }
161 }
Lorene::Tbl::set
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:281
Lorene::Mg3d::get_np
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:462
Lorene::Valeur::set_etat_cf_qcq
void set_etat_cf_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl_cf c_c...
Definition: valeur.C:712
Lorene::Valeur
Values and coefficients of a (real-value) function.
Definition: valeur.h:287
Lorene::Mtbl_cf::t
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's which contain the spectral coefficients in each domain.
Definition: mtbl_cf.h:205
Lorene::Valeur::c_cf
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:302
Lorene::Mg3d::get_nt
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:457
Lorene
Lorene prototypes.
Definition: app_hor.h:64
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:348
Lorene::Mtbl_cf::set
Tbl & set(int l)
Read/write of the Tbl containing the coefficients in a given domain.
Definition: mtbl_cf.h:294
Lorene::Tbl::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:361
Lorene::Valeur::mg
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition: valeur.h:292
Lorene::Valeur::etat
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: valeur.h:295
Lorene::Tbl
Basic array class.
Definition: tbl.h:161
Lorene::Mg3d::get_nr
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:452
Lorene::Mtbl_cf::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: mtbl_cf.C:300
Lorene::Valeur::coef_i
void coef_i() const
Computes the physical value of *this.
Definition: valeur_coef_i.C:140
Lorene::Mtbl_cf
Coefficients storage for the multi-domain spectral method.
Definition: mtbl_cf.h:186
Lorene::Valeur::smooth
void smooth(int nzet, Valeur &uuva) const
Changes the function *this as a smooth one when there exists a discontinuity between the nucleus and ...
Definition: valeur_smooth.C:77