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
24char poisson_interne_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/poisson_interne.C,v 1.4 2014/10/13 08:53:29 j_novak Exp $" ;
25
26/*
27 * $Id: poisson_interne.C,v 1.4 2014/10/13 08:53:29 j_novak Exp $
28 * $Log: poisson_interne.C,v $
29 * Revision 1.4 2014/10/13 08:53:29 j_novak
30 * Lorene classes and functions now belong to the namespace Lorene.
31 *
32 * Revision 1.3 2014/10/06 15:16:09 j_novak
33 * Modified #include directives to use c++ syntax.
34 *
35 * Revision 1.2 2004/11/23 12:51:42 f_limousin
36 * Minor changes.
37 *
38 * Revision 1.1 2004/03/31 11:36:15 f_limousin
39 * First version
40 *
41 *
42 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/poisson_interne.C,v 1.4 2014/10/13 08:53:29 j_novak Exp $
43 *
44 */
45
46
47// Header C :
48#include <cstdlib>
49#include <cmath>
50
51// Headers Lorene :
52#include "matrice.h"
53#include "tbl.h"
54#include "mtbl_cf.h"
55#include "map.h"
56#include "base_val.h"
57#include "proto.h"
58#include "type_parite.h"
59#include "utilitaires.h"
60
61
62
63
64 //----------------------------------------------
65 // Version Mtbl_cf
66 //----------------------------------------------
67
68namespace Lorene {
69Mtbl_cf sol_poisson_interne (const Map_af& mapping,
70 const Mtbl_cf& source, const Mtbl_cf& lim_der){
71
72 int nz = source.get_mg()->get_nzone() ;
73
74 assert(source.get_mg()->get_type_r(0) == RARE) ;
75 assert (lim_der.get_mg() == source.get_mg()->get_angu()) ;
76 assert (source.get_etat() != ETATNONDEF) ;
77 assert (lim_der.get_etat() != ETATNONDEF) ;
78
79 // Bases spectrales
80 const Base_val& base = source.base ;
81
82 // donnees sur la zone
83 int nr = source.get_mg()->get_nr(0) ;
84 int nt = source.get_mg()->get_nt(0) ;
85 int np = source.get_mg()->get_np(0) ;;
86 int base_r ;
87 int l_quant, m_quant;
88
89 double alpha = mapping.get_alpha()[0] ;
90 double beta = mapping.get_beta()[0] ;
91 double facteur ;
92
93 //Rangement des valeurs intermediaires
94 Tbl *so ;
95 Tbl *sol_hom ;
96 Tbl *sol_part ;
97 Matrice *operateur ;
98 Matrice *nondege ;
99
100
101 Mtbl_cf resultat(source.get_mg(), base) ;
102 resultat.annule_hard() ;
103
104 for (int k=0 ; k<np+1 ; k++)
105 for (int j=0 ; j<nt ; j++)
106 if (nullite_plm(j, nt, k, np, base) == 1)
107 {
108 // calcul des nombres quantiques :
109 donne_lm(nz, 0, j, k, base, m_quant, l_quant, base_r) ;
110
111 // Construction de l'operateur
112 operateur = new Matrice(laplacien_mat
113 (nr, l_quant, 0., 0, base_r)) ;
114
115 (*operateur) = combinaison(*operateur, l_quant, 0.,0, base_r) ;
116
117 // Operateur inversible
118 nondege = new Matrice(prepa_nondege(*operateur, l_quant,
119 0., 0, base_r)) ;
120
121 // Calcul DE LA SH
122 sol_hom = new Tbl(solh(nr, l_quant, 0., base_r)) ;
123
124 // Calcul de la SP
125 so = new Tbl(nr) ;
126 so->set_etat_qcq() ;
127 for (int i=0 ; i<nr ; i++)
128 so->set(i) = source(0, k, j, i) ;
129
130 sol_part = new Tbl (solp(*operateur, *nondege, alpha,
131 beta, *so, 0, base_r)) ;
132
133 //-------------------------------------------
134 // On est parti pour imposer la boundary
135 //-------------------------------------------
136
137 // Condition de raccord de type Neumann :
138 double val_der_solp = 0 ;
139 for (int i=0 ; i<nr ; i++)
140 if (m_quant%2 == 0)
141 val_der_solp += (2*i)*(2*i)*(*sol_part)(i)/alpha ;
142 else
143 val_der_solp += (2*i+1)*(2*i+1)*(*sol_part)(i)/alpha ;
144
145 double val_der_solh = 0 ;
146 for (int i=0 ; i<nr ; i++)
147 if (m_quant%2 == 0)
148 val_der_solh += (2*i)*(2*i)*(*sol_hom)(i)/alpha ;
149 else
150 val_der_solh += (2*i+1)*(2*i+1)*(*sol_hom)(i)/alpha ;
151
152 if (l_quant != 0){
153 assert (val_der_solh != 0) ;
154
155 facteur = (lim_der(0, k, j, 0)-val_der_solp) /
156 val_der_solh ;
157
158 for (int i=0 ; i<nr ; i++)
159 sol_part->set(i) += facteur*(*sol_hom)(i) ;
160 }
161 else {
162 for (int i=0 ; i<nr ; i++)
163 sol_part->set(i) = 0. ;
164 }
165
166
167 // solp contient le bon truc (normalement ...)
168 for (int i=0 ; i<nr ; i++)
169 resultat.set(0, k, j, i) = (*sol_part)(i) ;
170
171 delete operateur ;
172 delete nondege ;
173 delete so ;
174 delete sol_hom ;
175 delete sol_part ;
176 }
177
178 return resultat ;
179}
180}
int get_nzone() const
Returns the number of domains.
Definition grilles.h:448
const Mg3d * get_mg() const
Returns the Mg3d on which the Mtbl_cf is defined.
Definition mtbl_cf.h:453
Lorene prototypes.
Definition app_hor.h:64