Debian Codegraph @

Codes/Test/Poisson_scal/log_shell.C

raw
1 /*
2 * Test of scalar Poisson equation for a solution with ln functions in a shell
3 */
4
5 /*
6 * Copyright (c) 2000-2001 Philippe Grandclement
7 *
8 * This file is part of LORENE.
9 *
10 * LORENE is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * LORENE is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with LORENE; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26 char log_shell_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Poisson_scal/log_shell.C,v 1.3 2014/10/06 15:12:54 j_novak Exp $" ;
27
28 /*
29 * $Id: log_shell.C,v 1.3 2014/10/06 15:12:54 j_novak Exp $
30 * $Log: log_shell.C,v $
31 * Revision 1.3 2014/10/06 15:12:54 j_novak
32 * Modified #include directives to use c++ syntax.
33 *
34 * Revision 1.2 2003/01/09 11:07:55 j_novak
35 * headcpp.h is now compliant with C++ norm.
36 * The include files have been ordered, as well as the local_settings_linux
37 *
38 * Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon
39 * LORENE
40 *
41 * Revision 1.1 2000/02/15 14:53:51 phil
42 * Initial revision
43 *
44 *
45 * $Header: /cvsroot/Lorene/Codes/Test/Poisson_scal/log_shell.C,v 1.3 2014/10/06 15:12:54 j_novak Exp $
46 *
47 */
48
49 // LORENE
50
51 #include "type_parite.h"
52 #include "nbr_spx.h"
53 #include "grilles.h"
54 #include "map.h"
55 #include "valeur.h"
56 #include "proto.h"
57 #include "coord.h"
58 #include "cmp.h"
59 #include "graphique.h"
60
61 //standard
62 #include <ctime>
63 #include <cstdlib>
64 #include <cstdio>
65 #include <cmath>
66
67 void main() {
68 int symetrie = NONSYM ;
69
70 // Construction de la grille ...
71 int nz = 3 ;
72 double R_2 = nz-1 ;
73 double R_1 = nz-2 ;
74
75 //Construction du mapping :
76 double* bornes = new double[nz+1] ;
77 for (int i=0 ; i<nz ; i++)
78 bornes[i] = i ;
79 bornes[nz] = __infinity ;
80
81 // echantillonnage en phi :
82 int* np = new int [nz] ;
83 for (int l=0 ; l<nz ; l++)
84 np[l] = 8 ;
85 int type_p = symetrie ;
86
87 // echantillonnage en theta :
88 int* nt = new int [nz] ;
89 for (int l=0 ; l<nz ; l++)
90 nt[l] = 9 ;
91 int type_t = SYM ;
92
93 int nbrer ;
94 cin >> nbrer;
95
96 // echantillonage en r :
97 int* nr = new int [nz] ;
98 for (int l=0 ; l<nz ; l++)
99 nr[l] = nbrer ;
100
101
102 int* type_r = new int[nz] ;
103 type_r[0] = RARE ;
104 for (int l=1 ; l<nz-1 ; l++)
105 type_r[l] = FIN ;
106 type_r[nz-1] = UNSURR ;
107
108 Mg3d grille (nz, nr, type_r, nt, type_t, np, type_p) ;
109
110
111 Map_af mapping(grille, bornes) ;
112
113
114 // Construction de la source .
115 Coord& r = mapping.r ;
116 Coord& z = mapping.z ;
117
118 // Composante x
119 Valeur val_x(&grille) ;
120 val_x = 1./pow(r, 3.) + 3*pow(z, 2.)/pow(r, 2.)-1. ;
121
122 Cmp source(mapping) ;
123 source = val_x ;
124 source.annule(0) ;
125 source.annule(nz-1) ;
126 source.std_base_scal() ;
127
128 // On construit la solution analytique
129
130 Mtbl a_cont(&grille) ;
131 a_cont = 1./R_2-1./R_1 ;
132 Mtbl b_cont(&grille) ;
133 b_cont = (log(R_1)-log(R_2))/5. ;
134 Mtbl c_cont(&grille) ;
135 c_cont = 1./R_2 ;
136 Mtbl d_cont(&grille) ;
137 d_cont = log(R_1)-1. ;
138 Mtbl e_cont(&grille) ;
139 e_cont = -log(R_2)/5.-1./25. ;
140 Mtbl f_cont(&grille) ;
141 f_cont = pow(R_1, 5.)/25.;
142 Mtbl g_cont(&grille) ;
143 g_cont = log(R_1)-log(R_2) ;
144 Mtbl h_cont(&grille) ;
145 h_cont = (pow(R_1, 5.)-pow(R_2, 5.))/25. ;
146
147
148 Valeur sol(&grille) ;
149 sol = a_cont+ b_cont*(3*pow(z, 2.)-pow(r, 2.)) ;
150
151 // Shell ...
152 Valeur sol_shell(&grille) ;
153 sol_shell = (3*pow(z, 2.)/pow(r, 2.)-1.)*
154 (pow(r, 2.)*log(r)/5.+e_cont*pow(r, 2.)+f_cont/pow(r, 3.))
155 -log(r)/r + c_cont +d_cont/r ;
156 *(sol.c->t[nz-2]) = *(sol_shell.c->t[nz-2]) ;
157
158 // ZEC ...
159 Valeur sol_zec(&grille) ;
160 sol_zec = g_cont/r + h_cont*3*pow(z, 2.)/pow(r, 5.)-h_cont/pow(r, 3.) ;
161 for (int k=0 ; k<np[nz-1] ; k++)
162 for (int j=0 ; j<nt[nz-1] ; j++)
163 sol_zec.set(nz-1, k, j, nr[nz-1]-1) = 0. ;
164 *(sol.c->t[nz-1]) = *(sol_zec.c->t[nz-1]) ;
165
166 // On construit le vecteur ...
167 Cmp soluce(mapping) ;
168 soluce = sol ;
169 soluce.set_dzpuis(0) ;
170 soluce.std_base_scal() ;
171
172 Cmp sol_poisson( source.poisson()) ;
173 cout << nbrer << endl ;
174 cout <<"Erreur : " << endl ;
175 cout << diffrelmax(sol_poisson, soluce) << endl ;
176
177 delete [] nr ;
178 delete [] nt ;
179 delete [] np ;
180 delete [] type_r ;
181 delete [] bornes ;
182 }
183