Debian Codegraph @

Codes/Test/Map/test_map_et_adapt.C

raw
1 /*
2 * Test program for the adapt and reevaluate methods of the Map_et class
3 *
4 */
5
6 /*
7 * Copyright (c) 2000-2001 Eric Gourgoulhon
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 test_map_et_adapt_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Map/test_map_et_adapt.C,v 1.4 2015/08/10 15:32:27 j_novak Exp $" ;
28
29 /*
30 * $Id: test_map_et_adapt.C,v 1.4 2015/08/10 15:32:27 j_novak Exp $
31 * $Log: test_map_et_adapt.C,v $
32 * Revision 1.4 2015/08/10 15:32:27 j_novak
33 * Better calls to Param::add_int(), to avoid weird problems (e.g. with g++ 4.8).
34 *
35 * Revision 1.3 2014/10/06 15:12:53 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.2 2003/01/09 11:07:53 j_novak
39 * headcpp.h is now compliant with C++ norm.
40 * The include files have been ordered, as well as the local_settings_linux
41 *
42 * Revision 1.1.1.1 2001/11/20 15:19:31 e_gourgoulhon
43 * LORENE
44 *
45 * Revision 1.3 2000/02/15 15:20:08 eric
46 * *** empty log message ***
47 *
48 * Revision 1.2 2000/02/15 15:18:29 eric
49 * Changement du parametre Param dans Map_et::adapt : fact_echelle est
50 * desormais passe en double_mod.
51 *
52 * Revision 1.1 2000/01/04 16:48:56 eric
53 * Initial revision
54 *
55 *
56 * $Header: /cvsroot/Lorene/Codes/Test/Map/test_map_et_adapt.C,v 1.4 2015/08/10 15:32:27 j_novak Exp $
57 *
58 */
59
60 // headers C
61 #include <cstdlib>
62
63 // headers Lorene
64 #include "type_parite.h"
65 #include "cmp.h"
66 #include "param.h"
67 #include "utilitaires.h"
68 #include "graphique.h"
69 #include "nbr_spx.h"
70
71 //******************************************************************************
72
73 void main(){
74
75 // Identification of all the subroutines called by the code :
76
77 system("ident test_map_et_adapt") ;
78
79 //-----------------------------------------------------------------------
80 // Input data : number of points, types of sampling, etc...
81 //-----------------------------------------------------------------------
82
83 int nt = 9 ; // Number of points in theta
84 int np = 8 ; // Number of points in phi
85 int nz = 3 ; // Number of domains
86
87 int* nr = new int[nz];
88 int* nt_tab = new int[nz];
89 int* np_tab = new int[nz];
90 double* bornes = new double[nz+1];
91 int* type_r = new int[nz];
92
93 for (int l=0; l<nz; l++) {
94 nr[l] = 13 ;
95 np_tab[l] = np ;
96 nt_tab[l] = nt ;
97 }
98
99 bornes[0] = 0. ;
100 bornes[1] = 2. ;
101 bornes[2] = 3.5 ;
102 bornes[3] = __infinity ;
103
104 type_r[0] = RARE ;
105 type_r[1] = FIN ;
106 type_r[2] = UNSURR ;
107
108 int type_t = SYM ;
109
110 int type_p = NONSYM ;
111
112
113 //-----------------------------------------------------------------------
114 // Construction of a multi-grid
115 //-----------------------------------------------------------------------
116
117 Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ;
118
119 cout << endl << "Grid mg : " << mg << endl ;
120
121
122 //----------------------------
123 // Construction of the Map_et
124 //----------------------------
125
126 Map_et mp(mg, bornes) ;
127
128 cout << endl << "Mapping mp (before adaptation) : " << endl ;
129 cout << mp << endl ;
130
131 // const Coord& r = mp.r ;
132 const Coord& x = mp.x ;
133 const Coord& y = mp.y ;
134 const Coord& z = mp.z ;
135 // const Coord& cost = mp.cost ;
136 // const Coord& sint = mp.sint ;
137 // const Coord& cosp = mp.cosp ;
138 // const Coord& sinp = mp.sinp ;
139
140 //-----------------------------------------------------------------------
141 // Construction of a Cmp
142 //-----------------------------------------------------------------------
143
144 Cmp ent(mp) ;
145
146 ent = 1 - x*x/9 - y*y/4 - z*z ;
147 ent.annule(nz-1) ;
148 ent.std_base_scal() ;
149
150
151 des_coupe_x(ent, 0., -3., 3., -3., 3., "Before mapping adaptation (x=0)",
152 &ent, 25) ;
153 des_coupe_y(ent, 0., -3., 3., -3., 3., "Before mapping adaptation (y=0)",
154 &ent, 25) ;
155 des_coupe_z(ent, 0., -3., 3., -3., 3., "Before mapping adaptation (z=0)",
156 &ent, 25) ;
157
158
159 //-----------------------------------------------------------------------
160 // Adaptation of the Map_et to the Cmp
161 //-----------------------------------------------------------------------
162
163 // Save the old value of the mapping :
164 Map_et mp_prev = mp ;
165
166 int nzet = 1 ;
167 int nitermax = 100 ;
168 int niter ;
169 double precis = 1.e-15 ;
170 int j_bord = mg.get_nt(0) - 1 ;
171 int k_bord = 0 ;
172 double fact_echelle = 1 ;
173 double fact_lamu = 1 ;
174
175 Tbl ent_limit(nzet) ;
176 ent_limit.set_etat_qcq() ;
177 ent_limit.set(0) = 0 ;
178
179 int i_one = 1 ;
180
181 Param par ;
182 par.add_int(nitermax, 0) ;
183 par.add_int(nzet, 1) ;
184 par.add_int(i_one, 2) ; // 1 = full computation
185 par.add_int(j_bord, 3) ;
186 par.add_int(k_bord, 4) ;
187 par.add_int_mod(niter) ;
188 par.add_double(precis, 0) ;
189 par.add_double(fact_lamu, 1) ;
190 par.add_double_mod(fact_echelle, 0) ;
191 par.add_tbl(ent_limit, 0) ;
192
193 mp.adapt(ent, par) ;
194
195 cout << endl << "Mapping mp (after adaptation) : " << endl ;
196 cout << mp << endl ;
197 arrete() ;
198
199
200 cout << endl << "Coefficients of the mapping functions F and G" << endl ;
201 des_map_et(mp, 0) ;
202 des_map_et(mp, 1) ;
203
204
205 des_coupe_x(ent, 0., -3., 3., -3., 3.,
206 "After mapping adaptation and before reevaluate (x=0)",
207 &ent, 25) ;
208 des_coupe_y(ent, 0., -3., 3., -3., 3.,
209 "After mapping adaptation and before reevaluate (y=0)",
210 &ent, 25) ;
211 des_coupe_z(ent, 0., -3., 3., -3., 3.,
212 "After mapping adaptation and before reevaluate (z=0)",
213 &ent, 25) ;
214
215
216 // Computation of the field ent at the new collocation points
217 // ----------------------------------------------------------
218
219
220 mp.reevaluate(&mp_prev, nz-1, ent) ;
221
222
223 des_coupe_x(ent, 0., -3., 3., -3., 3., "After reevaluate (x=0)",
224 &ent, 25) ;
225 des_coupe_y(ent, 0., -3., 3., -3., 3., "After reevaluate (y=0)",
226 &ent, 25) ;
227 des_coupe_z(ent, 0., -3., 3., -3., 3., "After reevaluate (z=0)",
228 &ent, 25) ;
229
230
231 Cmp ent0(mp) ;
232 ent0 = 1 - x*x/9 - y*y/4 - z*z ;
233 ent0.annule(nz-1) ;
234 ent0.std_base_scal() ;
235
236 cout << "Relative difference between ent and ent0 : " << endl ;
237 cout << " diffrel : " << diffrel(ent, ent0) << endl ;
238 cout << " diffrelmax : " << diffrelmax(ent, ent0) << endl ;
239
240
241
242
243 // Cleaning
244 // --------
245
246 delete [] nr ;
247 delete [] nt_tab ;
248 delete [] np_tab ;
249 delete [] bornes ;
250 delete [] type_r ;
251
252 exit(EXIT_SUCCESS) ;
253
254 }
255