| 1 |
/* |
| 2 |
* Test program the Laplacian operator of the Cmp 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_af_lap_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Map/test_map_af_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_map_af_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $ |
| 31 |
* $Log: test_map_af_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:21:36 eric |
| 43 |
* Initial revision |
| 44 |
* |
| 45 |
* |
| 46 |
* $Header: /cvsroot/Lorene/Codes/Test/Map/test_map_af_lap.C,v 1.3 2014/10/06 15:12:53 j_novak Exp $ |
| 47 |
* |
| 48 |
*/ |
| 49 |
|
| 50 |
|
| 51 |
// headers C |
| 52 |
#include <cstdlib> |
| 53 |
|
| 54 |
// headers Lorene |
| 55 |
#include "type_parite.h" |
| 56 |
#include "cmp.h" |
| 57 |
#include "nbr_spx.h" |
| 58 |
|
| 59 |
//****************************************************************************** |
| 60 |
|
| 61 |
void main(){ |
| 62 |
|
| 63 |
// Identification of all the subroutines called by the code : |
| 64 |
|
| 65 |
system("ident test_map_af_lap") ; |
| 66 |
|
| 67 |
//----------------------------------------------------------------------- |
| 68 |
// Input data : number of points, types of sampling, etc... |
| 69 |
//----------------------------------------------------------------------- |
| 70 |
|
| 71 |
int nt = 7 ; // Number of points in theta |
| 72 |
int np = 8 ; // Number of points in phi |
| 73 |
int nz = 3 ; // Number of domains |
| 74 |
|
| 75 |
int* nr = new int[nz]; |
| 76 |
int* nt_tab = new int[nz]; |
| 77 |
int* np_tab = new int[nz]; |
| 78 |
double* bornes = new double[nz+1]; |
| 79 |
int* type_r = new int[nz]; |
| 80 |
|
| 81 |
for (int l=0; l<nz; l++) { |
| 82 |
nr[l] = 9 ; // Number of points in r |
| 83 |
np_tab[l] = np ; |
| 84 |
nt_tab[l] = nt ; |
| 85 |
} |
| 86 |
|
| 87 |
bornes[0] = 0. ; |
| 88 |
bornes[1] = 2. ; |
| 89 |
bornes[2] = 3.5 ; |
| 90 |
bornes[3] = __infinity ; |
| 91 |
|
| 92 |
type_r[0] = RARE ; |
| 93 |
type_r[1] = FIN ; |
| 94 |
type_r[2] = UNSURR ; |
| 95 |
|
| 96 |
int type_t = SYM ; |
| 97 |
|
| 98 |
int type_p = NONSYM ; |
| 99 |
|
| 100 |
//----------------------------------------------------------------------- |
| 101 |
// Construction of a multi-grid |
| 102 |
//----------------------------------------------------------------------- |
| 103 |
|
| 104 |
Mg3d mg(nz, nr, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 105 |
|
| 106 |
//---------------------------- |
| 107 |
// Construction of the Map_af |
| 108 |
//---------------------------- |
| 109 |
|
| 110 |
Map_af mp(mg, bornes) ; |
| 111 |
|
| 112 |
const Coord& r = mp.r ; |
| 113 |
const Coord& x = mp.x ; |
| 114 |
const Coord& y = mp.y ; |
| 115 |
const Coord& z = mp.z ; |
| 116 |
|
| 117 |
//----------------------------------------------------------------------- |
| 118 |
// Construction of a Cmp |
| 119 |
//----------------------------------------------------------------------- |
| 120 |
|
| 121 |
Cmp aa(mp) ; |
| 122 |
Cmp aa_ext(mp) ; |
| 123 |
|
| 124 |
aa = x*y*z*z + x*x ; // aa = x*y*z*z + x*x in all space |
| 125 |
aa.annule(nz-1) ; // aa = x*y*z*z + x*x in internal domains, |
| 126 |
// aa = 0 in extern. dom. |
| 127 |
|
| 128 |
aa_ext = 1 / (r*r) ; // aa_ext = 1/r^2 in all space |
| 129 |
aa_ext.annule(0, nz-2) ; // aa_ext = 0 in intern. dom., =1/r^2 in ext. dom. |
| 130 |
|
| 131 |
aa = aa + aa_ext ; // aa = x*y*z*z + x*x in internal domains, |
| 132 |
// aa = 1/r^2 in external domain |
| 133 |
|
| 134 |
aa.std_base_scal() ; // Sets the standard basis for spectral expansions |
| 135 |
|
| 136 |
cout << "Coef de aa : " << endl ; |
| 137 |
aa.affiche_seuil(cout) ; |
| 138 |
|
| 139 |
// Computation of Laplacian of a with zec_mult_r = 4 |
| 140 |
// ------------------------------------------------- |
| 141 |
|
| 142 |
Cmp lap = aa.laplacien() ; // lap = Delta(a) in internal domains |
| 143 |
// lap = r^4 Delta(a) in the external domain |
| 144 |
|
| 145 |
cout << "Coef of lap (zec_mult_r=4) : " << endl ; |
| 146 |
lap.affiche_seuil(cout) ; |
| 147 |
|
| 148 |
// Analytical expression for the Laplacian : |
| 149 |
Cmp lap_ana(mp) ; |
| 150 |
Cmp lap_ana_ext(mp) ; |
| 151 |
|
| 152 |
lap_ana = 2 + 2*x*y ; |
| 153 |
lap_ana.annule(nz-1) ; |
| 154 |
|
| 155 |
lap_ana_ext = 2 ; // 2/r^4 (dzpuis = 4) |
| 156 |
lap_ana_ext.annule(0, nz-2) ; |
| 157 |
|
| 158 |
lap_ana = lap_ana + lap_ana_ext ; |
| 159 |
(lap_ana.va).c->dzpuis = 4 ; |
| 160 |
lap_ana.set_dzpuis(4) ; |
| 161 |
lap_ana.std_base_scal() ; // Sets the standard base for spectral expansions |
| 162 |
|
| 163 |
cout << "Coef de lap_ana (dzpuis=4) : " << endl ; |
| 164 |
lap_ana.affiche_seuil(cout) ; |
| 165 |
|
| 166 |
cout << "diffrel lap <-> lap_ana : " << endl ; |
| 167 |
cout << diffrel(lap, lap_ana) << endl ; |
| 168 |
|
| 169 |
cout << "diffrelmax lap <-> lap_ana : " << endl ; |
| 170 |
cout << diffrelmax(lap, lap_ana) << endl ; |
| 171 |
|
| 172 |
|
| 173 |
// Computation of Laplacian of a with zec_mult_r = 2 |
| 174 |
// ------------------------------------------------- |
| 175 |
|
| 176 |
lap = aa.laplacien(2) ; // lap = Delta(a) in internal domains |
| 177 |
// lap = r^2 Delta(a) in the external domain |
| 178 |
|
| 179 |
cout << "Coef of lap (zec_mult_r=2) : " << endl ; |
| 180 |
lap.affiche_seuil(cout) ; |
| 181 |
|
| 182 |
// Analytical expression for the Laplacian : |
| 183 |
lap_ana = 2 + 2*x*y ; |
| 184 |
lap_ana.annule(nz-1) ; |
| 185 |
|
| 186 |
lap_ana_ext = 2/(r*r) ; // 2/r^4 (dzpuis = 2) |
| 187 |
lap_ana_ext.annule(0, nz-2) ; |
| 188 |
|
| 189 |
lap_ana = lap_ana + lap_ana_ext ; |
| 190 |
(lap_ana.va).c->dzpuis = 2 ; |
| 191 |
lap_ana.set_dzpuis(2) ; |
| 192 |
lap_ana.std_base_scal() ; // Sets the standard base for spectral expansions |
| 193 |
|
| 194 |
cout << "Coef de lap_ana (dzpuis=2) : " << endl ; |
| 195 |
lap_ana.affiche_seuil(cout) ; |
| 196 |
|
| 197 |
cout << "diffrel lap <-> lap_ana : " << endl ; |
| 198 |
cout << diffrel(lap, lap_ana) << endl ; |
| 199 |
|
| 200 |
cout << "diffrelmax lap <-> lap_ana : " << endl ; |
| 201 |
cout << diffrelmax(lap, lap_ana) << endl ; |
| 202 |
|
| 203 |
|
| 204 |
// Computation of Laplacian of a with zec_mult_r = 0 |
| 205 |
// ------------------------------------------------- |
| 206 |
|
| 207 |
lap = aa.laplacien(0) ; // lap = Delta(a) in internal domains |
| 208 |
// lap = r^0 Delta(a) in the external domain |
| 209 |
|
| 210 |
cout << "Coef of lap (zec_mult_r=0) : " << endl ; |
| 211 |
lap.affiche_seuil(cout) ; |
| 212 |
|
| 213 |
// Analytical expression for the Laplacian : |
| 214 |
lap_ana = 2 + 2*x*y ; |
| 215 |
lap_ana.annule(nz-1) ; |
| 216 |
|
| 217 |
lap_ana_ext = 2/pow(r, 4) ; // 2/r^4 (dzpuis = 0) |
| 218 |
lap_ana_ext.annule(0, nz-2) ; |
| 219 |
|
| 220 |
lap_ana = lap_ana + lap_ana_ext ; |
| 221 |
(lap_ana.va).c->dzpuis = 0 ; |
| 222 |
lap_ana.set_dzpuis(0) ; |
| 223 |
lap_ana.std_base_scal() ; // Sets the standard base for spectral expansions |
| 224 |
|
| 225 |
cout << "Coef de lap_ana (dzpuis=0) : " << endl ; |
| 226 |
lap_ana.affiche_seuil(cout) ; |
| 227 |
|
| 228 |
cout << "diffrel lap <-> lap_ana : " << endl ; |
| 229 |
cout << diffrel(lap, lap_ana) << endl ; |
| 230 |
|
| 231 |
cout << "diffrelmax lap <-> lap_ana : " << endl ; |
| 232 |
cout << diffrelmax(lap, lap_ana) << endl ; |
| 233 |
|
| 234 |
|
| 235 |
exit(-1) ; |
| 236 |
|
| 237 |
} |
| 238 |
|