Debian Codegraph @

Codes/Test/Poisson_vect/vect_gibbs.C

raw
1 /*
2 * Test of the vectorial Poisson euqation with a "vectorial" Gibbs-like
3 * phenomenon
4 */
5
6 /*
7 * Copyright (c) 2000-2001 Philippe Grandclement
8 *
9 * This file is part of LORENE.
10 *
11 * LORENE is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27 char vect_gibbs_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/vect_gibbs.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $" ;
28
29 /*
30 * $Id: vect_gibbs.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $
31 * $Log: vect_gibbs.C,v $
32 * Revision 1.3 2014/10/06 15:12:55 j_novak
33 * Modified #include directives to use c++ syntax.
34 *
35 * Revision 1.2 2003/01/09 11:07:56 j_novak
36 * headcpp.h is now compliant with C++ norm.
37 * The include files have been ordered, as well as the local_settings_linux
38 *
39 * Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon
40 * LORENE
41 *
42 * Revision 1.1 2000/02/15 14:56:27 phil
43 * Initial revision
44 *
45 *
46 * $Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/vect_gibbs.C,v 1.3 2014/10/06 15:12:55 j_novak Exp $
47 *
48 */
49
50
51 // LORENE
52
53 #include "type_parite.h"
54 #include "nbr_spx.h"
55 #include "grilles.h"
56 #include "map.h"
57 #include "valeur.h"
58 #include "utilitaires.h"
59 #include "coord.h"
60 #include "cmp.h"
61 #include "graphique.h"
62 #include "proto.h"
63 #include "tenseur.h"
64 #include "base_vect.h"
65 #include "param.h"
66
67 //standard
68 #include <ctime>
69 #include <cstdlib>
70 #include <cstdio>
71 #include <cmath>
72
73 void main() {
74
75 int symetrie = NONSYM ;
76 double lambda = 1./3. ;
77
78 // Construction de la grille ...
79 int nz = 3 ;
80 double R = (nz-1) ;
81
82 //Construction du mapping :
83 double* bornes = new double[nz+1] ;
84 for (int i=0 ; i<nz ; i++)
85 bornes[i] = i ;
86 bornes[nz] = __infinity ;
87
88 // echantillonnage en phi :
89 int* np = new int [nz] ;
90 for (int l=0 ; l<nz ; l++)
91 np[l] = 8 ;
92 int type_p = symetrie ;
93
94 // echantillonnage en theta :
95 int* nt = new int [nz] ;
96 for (int l=0 ; l<nz ; l++)
97 nt[l] = 9 ;
98 int type_t = SYM ;
99 int* nr = new int[nz] ;
100 int* type_r = new int[nz] ;
101 int nbrer ;
102
103 cin >> nbrer ;
104
105 // echantillonage en r :
106
107 for (int l=0 ; l<nz ; l++)
108 nr[l] = nbrer ;
109
110 type_r[0] = RARE ;
111 for (int l=1 ; l<nz-1 ; l++)
112 type_r[l] = FIN ;
113 type_r[nz-1] = UNSURR ;
114
115 Mg3d grille (nz, nr, type_r, nt, type_t, np, type_p) ;
116
117
118 Map_af mapping(grille, bornes) ;
119
120
121 // Construction de la source .
122
123 Coord& x = mapping.x ;
124 Coord& y = mapping.y ;
125 Coord& z = mapping.z ;
126 Coord& r = mapping.r ;
127
128 // Composante z
129 Valeur val_z(&grille) ;
130 val_z = z/pow(R, 7.) ;
131 // ZEC ...
132 Valeur val_z_zec(&grille) ;
133 val_z_zec = z/pow(r, 5.) ;
134 for (int k=0 ; k<np[nz-1] ; k++)
135 for (int j=0 ; j<nt[nz-1] ; j++)
136 val_z_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
137 *(val_z.c->t[nz-1]) = *(val_z_zec.c->t[nz-1]) ;
138 val_z.c->dzpuis = 2 ;
139
140 // On construit le vecteur ...
141 Tenseur source (mapping, 1, CON, mapping.get_bvect_cart()) ;
142 source.set_etat_qcq() ;
143 source.set(0) = 0 ;
144 source.set(1) = 0 ;
145 source.set(2) = val_z ;
146 for (int i=0 ; i<3 ; i++)
147 source.set(i).set_dzpuis(2) ;
148 source.set_std_base() ;
149
150
151 // Composante x
152 Valeur sol_x(&grille) ;
153 sol_x = -lambda/2./(lambda+1)*(2.*x*pow(z, 2.)/35./pow(R, 7.)
154 + pow(r, 2.)*x/35./pow(R, 7.)
155 -7.*x/75./pow(R, 5.)) ;
156 ;
157 // ZEC ...
158 Valeur sol_x_zec(&grille) ;
159 sol_x_zec = -lambda/2./(lambda+1.)*(pow(z, 2.)*x/pow(r, 7.)*(-9./14.+log(R)-log(r))
160 +x/pow(r, 5.)*(59./350.+(log(r)-log(R))/5.)
161 -7.*x/30./pow(R, 2.)/pow(r, 3.)
162 +7./10.*pow(z, 2.)*x/pow(R, 2.)/pow(r, 5.));
163 for (int k=0 ; k<np[nz-1] ; k++)
164 for (int j=0 ; j<nt[nz-1] ; j++)
165 sol_x_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
166 *(sol_x.c->t[nz-1]) = *(sol_x_zec.c->t[nz-1]) ;
167
168 // Composante y
169 Valeur sol_y(&grille) ;
170 sol_y = -lambda/2./(lambda+1)*(2.*y*pow(z, 2.)/35./pow(R, 7.)
171 + pow(r, 2.)*y/35./pow(R, 7.)
172 -7.*y/75./pow(R, 5.)) ;
173 // ZEC ...
174 Valeur sol_y_zec(&grille) ;
175 sol_y_zec = -lambda/2./(lambda+1.)*(pow(z, 2.)*y/pow(r, 7.)*(-9./14.+log(R)-log(r))
176 +y/pow(r, 5.)*(59./350.+(log(r)-log(R))/5.)
177 -7.*y/30./pow(R, 2.)/pow(r, 3.)
178 +7./10.*pow(z, 2.)*y/pow(R, 2.)/pow(r, 5.)) ;
179 for (int k=0 ; k<np[nz-1] ; k++)
180 for (int j=0 ; j<nt[nz-1] ; j++)
181 sol_y_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
182 *(sol_y.c->t[nz-1]) = *(sol_y_zec.c->t[nz-1]) ;
183
184 // Composante z
185 Valeur sol_z(&grille) ;
186 sol_z = (lambda+2.)/2./(lambda+1.)*z*(pow(r, 2.)/10./pow(R, 7.)
187 -7./30./pow(R, 5.))
188 -lambda/2./(lambda+1.)*(2.*pow(z, 3.)/35./pow(R, 7.)
189 -z*pow(r, 2.)/70./pow(R, 7.)
190 -7.*z/150./pow(R, 5.)) ;
191 // ZEC ...
192 Valeur sol_z_zec(&grille) ;
193 sol_z_zec = (lambda+2.)/2./(lambda+1.)*z* (1./10./pow(r, 5.)
194 -7./30./pow(R, 2.)/pow(r, 3.))
195 -lambda/2./(lambda+1.)*(pow(z, 3.)/pow(r, 7.)*(-9./14.
196 +log(R)-log(r))
197 +7./10.*pow(z, 3.)/pow(R, 2.)/pow(r, 5.)
198 +z/pow(r, 5.)*(71./175.+3./5.*(log(r)-log(R)))
199 -7./15.*z/pow(R, 2.)/pow(r, 3.)) ;
200 for (int k=0 ; k<np[nz-1] ; k++)
201 for (int j=0 ; j<nt[nz-1] ; j++)
202 sol_z_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
203 *(sol_z.c->t[nz-1]) = *(sol_z_zec.c->t[nz-1]) ;
204
205 // On construit le vecteur ...
206 Tenseur soluce (mapping, 1, CON, mapping.get_bvect_cart()) ;
207 soluce.set_etat_qcq() ;
208 soluce.set(0) = sol_x ;
209 soluce.set(1) = sol_y ;
210 soluce.set(2) = sol_z ;
211 for (int i=0 ; i<3 ; i++)
212 soluce.set(i).set_dzpuis(0) ;
213 soluce.set_std_base() ;
214
215
216 Tenseur vect_auxi (mapping, 1, CON, mapping.get_bvect_cart()) ;
217 vect_auxi.set_etat_qcq() ;
218 Tenseur scal_auxi (mapping) ;
219 scal_auxi.set_etat_qcq() ;
220 Tenseur chi_auxi (mapping) ;
221 chi_auxi.set_etat_qcq() ;
222
223
224 Tenseur shibata (source.poisson_vect(lambda, vect_auxi, scal_auxi)) ;
225 Tenseur oohara (source.poisson_vect_oohara(lambda, chi_auxi)) ;
226
227 cout << "Points en r : " << nbrer << endl ;
228 cout << "Shibata vs analytique" << endl ;
229 for (int i=0 ; i<3 ; i++)
230 cout << diffrelmax(shibata(i), soluce(i)) << endl ;
231
232 cout << "Oohara vs analytique" << endl ;
233 for (int i=0 ; i<3 ; i++)
234 cout << diffrelmax(oohara(i), soluce(i)) << endl ;
235
236
237 delete [] nr ;
238 delete [] nt ;
239 delete [] np ;
240 delete [] type_r ;
241 delete [] bornes ;
242 }