LORENE
poisson_interne.C
1 
2 /*
3  * Copyright (c) 2004 Francois Limousin
4  *
5  * This file is part of LORENE.
6  *
7  * LORENE is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * LORENE is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with LORENE; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 
24 
25 
26 /*
27  * $Id: poisson_interne.C,v 1.5 2016/12/05 16:18:10 j_novak Exp $
28  * $Log: poisson_interne.C,v $
29  * Revision 1.5 2016/12/05 16:18:10 j_novak
30  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
31  *
32  * Revision 1.4 2014/10/13 08:53:29 j_novak
33  * Lorene classes and functions now belong to the namespace Lorene.
34  *
35  * Revision 1.3 2014/10/06 15:16:09 j_novak
36  * Modified #include directives to use c++ syntax.
37  *
38  * Revision 1.2 2004/11/23 12:51:42 f_limousin
39  * Minor changes.
40  *
41  * Revision 1.1 2004/03/31 11:36:15 f_limousin
42  * First version
43  *
44  *
45  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/poisson_interne.C,v 1.5 2016/12/05 16:18:10 j_novak Exp $
46  *
47  */
48 
49 
50 // Header C :
51 #include <cstdlib>
52 #include <cmath>
53 
54 // Headers Lorene :
55 #include "matrice.h"
56 #include "tbl.h"
57 #include "mtbl_cf.h"
58 #include "map.h"
59 #include "base_val.h"
60 #include "proto.h"
61 #include "type_parite.h"
62 #include "utilitaires.h"
63 
64 
65 
66 
67  //----------------------------------------------
68  // Version Mtbl_cf
69  //----------------------------------------------
70 
71 namespace Lorene {
72 Mtbl_cf sol_poisson_interne (const Map_af& mapping,
73  const Mtbl_cf& source, const Mtbl_cf& lim_der){
74 
75  int nz = source.get_mg()->get_nzone() ;
76 
77  assert(source.get_mg()->get_type_r(0) == RARE) ;
78  assert (lim_der.get_mg() == source.get_mg()->get_angu()) ;
79  assert (source.get_etat() != ETATNONDEF) ;
80  assert (lim_der.get_etat() != ETATNONDEF) ;
81 
82  // Bases spectrales
83  const Base_val& base = source.base ;
84 
85  // donnees sur la zone
86  int nr = source.get_mg()->get_nr(0) ;
87  int nt = source.get_mg()->get_nt(0) ;
88  int np = source.get_mg()->get_np(0) ;;
89  int base_r ;
90  int l_quant, m_quant;
91 
92  double alpha = mapping.get_alpha()[0] ;
93  double beta = mapping.get_beta()[0] ;
94  double facteur ;
95 
96  //Rangement des valeurs intermediaires
97  Tbl *so ;
98  Tbl *sol_hom ;
99  Tbl *sol_part ;
100  Matrice *operateur ;
101  Matrice *nondege ;
102 
103 
104  Mtbl_cf resultat(source.get_mg(), base) ;
105  resultat.annule_hard() ;
106 
107  for (int k=0 ; k<np+1 ; k++)
108  for (int j=0 ; j<nt ; j++)
109  if (nullite_plm(j, nt, k, np, base) == 1)
110  {
111  // calcul des nombres quantiques :
112  donne_lm(nz, 0, j, k, base, m_quant, l_quant, base_r) ;
113 
114  // Construction de l'operateur
115  operateur = new Matrice(laplacien_mat
116  (nr, l_quant, 0., 0, base_r)) ;
117 
118  (*operateur) = combinaison(*operateur, l_quant, 0.,0, base_r) ;
119 
120  // Operateur inversible
121  nondege = new Matrice(prepa_nondege(*operateur, l_quant,
122  0., 0, base_r)) ;
123 
124  // Calcul DE LA SH
125  sol_hom = new Tbl(solh(nr, l_quant, 0., base_r)) ;
126 
127  // Calcul de la SP
128  so = new Tbl(nr) ;
129  so->set_etat_qcq() ;
130  for (int i=0 ; i<nr ; i++)
131  so->set(i) = source(0, k, j, i) ;
132 
133  sol_part = new Tbl (solp(*operateur, *nondege, alpha,
134  beta, *so, 0, base_r)) ;
135 
136  //-------------------------------------------
137  // On est parti pour imposer la boundary
138  //-------------------------------------------
139 
140  // Condition de raccord de type Neumann :
141  double val_der_solp = 0 ;
142  for (int i=0 ; i<nr ; i++)
143  if (m_quant%2 == 0)
144  val_der_solp += (2*i)*(2*i)*(*sol_part)(i)/alpha ;
145  else
146  val_der_solp += (2*i+1)*(2*i+1)*(*sol_part)(i)/alpha ;
147 
148  double val_der_solh = 0 ;
149  for (int i=0 ; i<nr ; i++)
150  if (m_quant%2 == 0)
151  val_der_solh += (2*i)*(2*i)*(*sol_hom)(i)/alpha ;
152  else
153  val_der_solh += (2*i+1)*(2*i+1)*(*sol_hom)(i)/alpha ;
154 
155  if (l_quant != 0){
156  assert (val_der_solh != 0) ;
157 
158  facteur = (lim_der(0, k, j, 0)-val_der_solp) /
159  val_der_solh ;
160 
161  for (int i=0 ; i<nr ; i++)
162  sol_part->set(i) += facteur*(*sol_hom)(i) ;
163  }
164  else {
165  for (int i=0 ; i<nr ; i++)
166  sol_part->set(i) = 0. ;
167  }
168 
169 
170  // solp contient le bon truc (normalement ...)
171  for (int i=0 ; i<nr ; i++)
172  resultat.set(0, k, j, i) = (*sol_part)(i) ;
173 
174  delete operateur ;
175  delete nondege ;
176  delete so ;
177  delete sol_hom ;
178  delete sol_part ;
179  }
180 
181  return resultat ;
182 }
183 }
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Returns the Mg3d on which the Mtbl_cf is defined.
Definition: mtbl_cf.h:463
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465