| 1 |
/* |
| 2 |
* Code for testing the angular Poisson equation. |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2003-2005 Eric Gourgoulhon & Jerome Novak |
| 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 version 2 |
| 13 |
* as published by the Free Software Foundation. |
| 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 test_poisson_angu_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Tensor/test_poisson_angu.C,v 1.6 2014/10/13 08:54:03 j_novak Exp $" ; |
| 27 |
|
| 28 |
/* |
| 29 |
* $Id: test_poisson_angu.C,v 1.6 2014/10/13 08:54:03 j_novak Exp $ |
| 30 |
* $Log: test_poisson_angu.C,v $ |
| 31 |
* Revision 1.6 2014/10/13 08:54:03 j_novak |
| 32 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 33 |
* |
| 34 |
* Revision 1.5 2014/10/06 15:12:55 j_novak |
| 35 |
* Modified #include directives to use c++ syntax. |
| 36 |
* |
| 37 |
* Revision 1.4 2005/05/18 15:31:25 j_novak |
| 38 |
* *** empty log message *** |
| 39 |
* |
| 40 |
* Revision 1.3 2005/04/04 21:36:31 e_gourgoulhon |
| 41 |
* Method Scalar::poisson_angu takes now a parameter |
| 42 |
* lambda, for the generalized angular Poisson equation |
| 43 |
* Lap_ang u + lambda u = source. |
| 44 |
* Test passed for lambda = 1 and lambda = 10. |
| 45 |
* |
| 46 |
* Revision 1.2 2003/10/19 20:05:07 e_gourgoulhon |
| 47 |
* Change of the argument list of Scalar::spectral_display |
| 48 |
* (cout now default). |
| 49 |
* |
| 50 |
* Revision 1.1 2003/10/15 21:15:25 e_gourgoulhon |
| 51 |
* Test for Scalar::poisson_angu(). |
| 52 |
* |
| 53 |
* |
| 54 |
* |
| 55 |
* $Header: /cvsroot/Lorene/Codes/Test/Tensor/test_poisson_angu.C,v 1.6 2014/10/13 08:54:03 j_novak Exp $ |
| 56 |
* |
| 57 |
*/ |
| 58 |
|
| 59 |
// C++ headers |
| 60 |
#include "headcpp.h" |
| 61 |
|
| 62 |
// C headers |
| 63 |
#include <cstdlib> |
| 64 |
|
| 65 |
// Lorene headers |
| 66 |
#include "metric.h" |
| 67 |
#include "nbr_spx.h" |
| 68 |
#include "utilitaires.h" |
| 69 |
|
| 70 |
|
| 71 |
using namespace Lorene ; |
| 72 |
|
| 73 |
int main() { |
| 74 |
|
| 75 |
// Construction of a multi-grid (Mg3d) |
| 76 |
// ----------------------------------- |
| 77 |
|
| 78 |
int nz = 3 ; // Number of domains |
| 79 |
int nr = 5 ; // Number of collocation points in r in each domain |
| 80 |
int nt = 5 ; // Number of collocation points in theta in each domain |
| 81 |
int np = 12 ; // Number of collocation points in phi in each domain |
| 82 |
int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane |
| 83 |
int symmetry_phi = NONSYM ; // no symmetry in phi |
| 84 |
bool compact = true ; // external domain is compactified |
| 85 |
|
| 86 |
Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, compact) ; |
| 87 |
|
| 88 |
|
| 89 |
// Construction of an affine mapping (Map_af) |
| 90 |
// ------------------------------------------ |
| 91 |
|
| 92 |
// Boundaries of each domains |
| 93 |
double r_limits[] = {0., 1., 2., __infinity} ; |
| 94 |
assert( nz == 3 ) ; // since the above array described only 3 domains |
| 95 |
|
| 96 |
Map_af map(mgrid, r_limits) ; |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
cout << endl << |
| 101 |
"================ TEST FOR A SCALAR FIELD =================\n" ; |
| 102 |
|
| 103 |
|
| 104 |
// Construction of a scalar field (Scalar) |
| 105 |
// --------------------------------------- |
| 106 |
|
| 107 |
const Coord& x = map.x ; |
| 108 |
const Coord& y = map.y ; |
| 109 |
const Coord& z = map.z ; |
| 110 |
const Coord& r = map.r ; |
| 111 |
const Coord& sint = map.sint ; |
| 112 |
const Coord& sinp = map.sinp ; |
| 113 |
|
| 114 |
Scalar uu(map) ; |
| 115 |
Scalar tmp(map) ; |
| 116 |
|
| 117 |
uu = x + y + x*y + z*z*x - pow(z,4)*y*x ; |
| 118 |
tmp = sint * sinp / r ; |
| 119 |
uu.set_domain(nz-1) = tmp.domain(nz-1) ; // y/r^2 in the external domain |
| 120 |
|
| 121 |
uu.std_spectral_base() ; // sets the standard spectral basis for |
| 122 |
// expansion of a scalar field |
| 123 |
|
| 124 |
cout << "uu : " << uu << endl ; |
| 125 |
uu.spectral_display() ; |
| 126 |
arrete() ; |
| 127 |
|
| 128 |
double lambda = 2. ; |
| 129 |
|
| 130 |
Scalar lap = uu.lapang() ; |
| 131 |
|
| 132 |
lap.set_spectral_va().ylm_i() ; |
| 133 |
|
| 134 |
lap += lambda * uu ; |
| 135 |
|
| 136 |
cout << "lap : " << endl ; |
| 137 |
lap.spectral_display() ; |
| 138 |
arrete() ; |
| 139 |
|
| 140 |
|
| 141 |
Scalar uu1 = lap.poisson_angu(lambda) ; |
| 142 |
|
| 143 |
cout << "uu1 : " << endl ; |
| 144 |
uu1.spectral_display() ; |
| 145 |
arrete() ; |
| 146 |
|
| 147 |
Scalar diff = uu - uu1 ; |
| 148 |
diff.set_spectral_va().ylm() ; |
| 149 |
diff.spectral_display("Diff en Ylm: ", 1.e-14) ; |
| 150 |
|
| 151 |
cout << "Norm of diff: " << norme(diff) << endl ; |
| 152 |
|
| 153 |
return EXIT_SUCCESS ; |
| 154 |
} |