| 1 |
/* |
| 2 |
* Test program the Laplacian operator of the Cmp class with Map_et mapping |
| 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_lap_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Map/test_map_et_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_map_et_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $ |
| 31 |
* $Log: test_map_et_lap.C,v $ |
| 32 |
* Revision 1.3 2014/10/06 15:12:53 j_novak |
| 33 |
* Modified #include directives to use c++ syntax. |
| 34 |
* |
| 35 |
* Revision 1.2 2003/01/09 11:07:53 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/25 09:34:18 eric |
| 43 |
* Initial revision |
| 44 |
* |
| 45 |
* |
| 46 |
* $Header: /cvsroot/Lorene/Codes/Test/Map/test_map_et_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $ |
| 47 |
* |
| 48 |
*/ |
| 49 |
|
| 50 |
// headers C |
| 51 |
#include <cstdlib> |
| 52 |
|
| 53 |
// headers Lorene |
| 54 |
#include "type_parite.h" |
| 55 |
#include "cmp.h" |
| 56 |
#include "nbr_spx.h" |
| 57 |
|
| 58 |
//****************************************************************************** |
| 59 |
|
| 60 |
void main(){ |
| 61 |
|
| 62 |
// Identification of all the subroutines called by the code : |
| 63 |
|
| 64 |
system("ident test_map_et_lap") ; |
| 65 |
|
| 66 |
//----------------------------------------------------------------------- |
| 67 |
// Input data : number of points, types of sampling, etc... |
| 68 |
//----------------------------------------------------------------------- |
| 69 |
|
| 70 |
int nt = 21 ; // Number of points in theta |
| 71 |
int np = 20 ; // Number of points in phi |
| 72 |
int nz = 3 ; // Number of domains |
| 73 |
|
| 74 |
int* nr = new int[nz]; |
| 75 |
int* nt_tab = new int[nz]; |
| 76 |
int* np_tab = new int[nz]; |
| 77 |
double* bornes = new double[nz+1]; |
| 78 |
int* type_r = new int[nz]; |
| 79 |
|
| 80 |
for (int l=0; l<nz; l++) { |
| 81 |
nr[l] = 33 ; // Number of points in r |
| 82 |
np_tab[l] = np ; |
| 83 |
nt_tab[l] = nt ; |
| 84 |
} |
| 85 |
|
| 86 |
bornes[0] = 0. ; |
| 87 |
bornes[1] = 2. ; |
| 88 |
bornes[2] = 3. ; |
| 89 |
bornes[3] = __infinity ; |
| 90 |
|
| 91 |
type_r[0] = RARE ; |
| 92 |
type_r[1] = FIN ; |
| 93 |
type_r[2] = UNSURR ; |
| 94 |
|
| 95 |
int type_t = SYM ; |
| 96 |
|
| 97 |
int type_p = NONSYM ; |
| 98 |
|
| 99 |
|
| 100 |
//----------------------------------------------------------------------- |
| 101 |
// Construction of a multi-grid |
| 102 |
//----------------------------------------------------------------------- |
| 103 |
|
| 104 |
|
| 105 |
Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 106 |
|
| 107 |
cout << endl << "Grid mg : " << mg << endl ; |
| 108 |
|
| 109 |
//----------------------------------------------------------------------- |
| 110 |
// Construction of a pure angular mapping of class Map_af |
| 111 |
//----------------------------------------------------------------------- |
| 112 |
|
| 113 |
Map_af mp0( *(mg.get_angu()), bornes ) ; |
| 114 |
|
| 115 |
cout << endl << "Mapping mp0 : " << endl ; |
| 116 |
cout << mp0 << endl ; |
| 117 |
|
| 118 |
const Coord& cost0 = mp0.cost ; |
| 119 |
const Coord& sint0 = mp0.sint ; |
| 120 |
const Coord& cosp0 = mp0.cosp ; |
| 121 |
const Coord& sinp0 = mp0.sinp ; |
| 122 |
|
| 123 |
//----------------------------------------------------------------------- |
| 124 |
// Functions F_l and G_l corresponding to a triaxial ellipsoid |
| 125 |
//----------------------------------------------------------------------- |
| 126 |
|
| 127 |
//--------------------------- |
| 128 |
// Triaxial ellipsoid x^2/a^2 + y^2/b^2 + z^2/c^2 = 1 |
| 129 |
//--------------------------- |
| 130 |
|
| 131 |
Valeur ff0( *(mg.get_angu()) ) ; |
| 132 |
Valeur gg0( *(mg.get_angu()) ) ; |
| 133 |
|
| 134 |
double bsa = 0.8 ; // axis ratio b/a |
| 135 |
double csa = 0.7 ; // axis ratio c/a |
| 136 |
|
| 137 |
gg0 = 1. / sqrt( sint0*sint0 * ( cosp0*cosp0 + sinp0*sinp0 / (bsa*bsa) ) |
| 138 |
+ cost0*cost0 / (csa*csa) ) - 1. ; |
| 139 |
gg0.annule(nz-2, nz-1) ; // 0 in the external domains |
| 140 |
|
| 141 |
gg0.std_base_scal() ; |
| 142 |
|
| 143 |
// F in domain 0 : |
| 144 |
ff0.set_etat_c_qcq() ; |
| 145 |
ff0.c->set_etat_qcq() ; |
| 146 |
ff0.annule(0) ; // the ellipsoid contains only even m |
| 147 |
|
| 148 |
// F in other domains is deduced from G by maching domain l and domain l+1 : |
| 149 |
|
| 150 |
const double* alpha = mp0.get_alpha() ; |
| 151 |
|
| 152 |
for (int l=1; l<nz-1; l++) { |
| 153 |
*(ff0.c->t[l]) = alpha[l-1] / alpha[l] * (*(gg0.c->t[l-1])) ; |
| 154 |
} |
| 155 |
|
| 156 |
ff0.annule(nz-1) ; |
| 157 |
|
| 158 |
ff0.std_base_scal() ; |
| 159 |
|
| 160 |
//---------------------------- |
| 161 |
// Construction of the Map_et |
| 162 |
//---------------------------- |
| 163 |
|
| 164 |
Map_et mp(mg, bornes) ; |
| 165 |
|
| 166 |
mp.set_ff(ff0) ; |
| 167 |
mp.set_gg(gg0) ; |
| 168 |
|
| 169 |
cout << endl << "Mapping mp : " << endl ; |
| 170 |
cout << mp << endl ; |
| 171 |
|
| 172 |
|
| 173 |
//----------------------------------------------------------------------- |
| 174 |
// Construction of a Cmp |
| 175 |
//----------------------------------------------------------------------- |
| 176 |
|
| 177 |
Cmp aa(mp) ; |
| 178 |
Cmp aa_ext(mp) ; |
| 179 |
Cmp lap_ana(mp) ; |
| 180 |
Cmp lap_ana_ext(mp) ; |
| 181 |
|
| 182 |
const Coord& r = mp.r ; |
| 183 |
const Coord& x = mp.x ; |
| 184 |
const Coord& y = mp.y ; |
| 185 |
const Coord& z = mp.z ; |
| 186 |
const Coord& cost = mp.cost ; |
| 187 |
const Coord& sint = mp.sint ; |
| 188 |
const Coord& cosp = mp.cosp ; |
| 189 |
const Coord& sinp = mp.sinp ; |
| 190 |
|
| 191 |
aa = 0.3 * y - x + (x + z*z) * ( x*x + x*y + pow(z, 6) ) ; |
| 192 |
|
| 193 |
lap_ana = 2*(3*x + x*x + y + x*y + z*z + 15*x*pow(+z, 4) |
| 194 |
+ 28*pow(+z,6) ) ; |
| 195 |
|
| 196 |
int nzm1 = nz-1 ; |
| 197 |
aa.annule(nzm1) ; |
| 198 |
lap_ana.annule(nzm1) ; |
| 199 |
|
| 200 |
Mtbl x1 = sint * cosp ; |
| 201 |
Mtbl y1 = sint * sinp ; |
| 202 |
Mtbl z1 = cost ; |
| 203 |
|
| 204 |
aa_ext = 1 / pow(+r, 8) + (x1*x1 - 3*x1*y1 + z1*z1) / pow(+r, 6) |
| 205 |
+ (x1*z1*z1) / pow(+r, 5) ; |
| 206 |
|
| 207 |
lap_ana_ext = 2. / pow(+r, 3) * ( 28 / pow(+r, 3) |
| 208 |
+ ( 14 *x1*x1 - 36 *x1*y1 + 2*y1*y1 + 14*z1*z1 ) / pow(+r, 1) |
| 209 |
+ ( x1*x1*x1 + x1*y1*y1 + 5*x1*z1*z1 ) ) ; |
| 210 |
|
| 211 |
aa_ext.annule(0, nzm1-1) ; |
| 212 |
lap_ana_ext.annule(0, nzm1-1) ; |
| 213 |
|
| 214 |
aa = aa + aa_ext ; |
| 215 |
lap_ana = lap_ana + lap_ana_ext ; |
| 216 |
|
| 217 |
aa.std_base_scal() ; |
| 218 |
lap_ana.std_base_scal() ; |
| 219 |
|
| 220 |
lap_ana.set_dzpuis(4) ; |
| 221 |
|
| 222 |
Cmp lap = aa.laplacien(4) ; |
| 223 |
|
| 224 |
cout << "Diffrel lap <-> lap_ana : " << endl ; |
| 225 |
cout << diffrel(lap, lap_ana) << endl ; |
| 226 |
|
| 227 |
cout << "Diffrelmax lap <-> lap_ana : " << endl ; |
| 228 |
cout << diffrelmax(lap, lap_ana) << endl ; |
| 229 |
|
| 230 |
exit(-1) ; |
| 231 |
|
| 232 |
} |
| 233 |
|