| 1 |
/* |
| 2 |
* Test of the resolution of the vector Poisson equation for a given l |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2004 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_vpoisson_l_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/test_vpoisson_l.C,v 1.7 2014/10/13 08:54:02 j_novak Exp $" ; |
| 27 |
|
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_vpoisson_l.C,v 1.7 2014/10/13 08:54:02 j_novak Exp $ |
| 31 |
* $Log: test_vpoisson_l.C,v $ |
| 32 |
* Revision 1.7 2014/10/13 08:54:02 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.6 2005/04/06 14:38:41 j_novak |
| 36 |
* Added method 6: block inversion with spherical components |
| 37 |
* |
| 38 |
* Revision 1.5 2004/12/29 12:25:51 j_novak |
| 39 |
* non-symmetric grid in phi. |
| 40 |
* |
| 41 |
* Revision 1.4 2004/07/27 09:40:34 j_novak |
| 42 |
* test of method 5. |
| 43 |
* |
| 44 |
* Revision 1.3 2004/05/07 15:33:24 j_novak |
| 45 |
* Treated the case where all components are null. |
| 46 |
* |
| 47 |
* Revision 1.2 2004/03/26 17:05:24 j_novak |
| 48 |
* Added new method n.3 using Tenseur::poisson_vect_oohara |
| 49 |
* |
| 50 |
* Revision 1.1 2004/03/26 15:35:46 j_novak |
| 51 |
* More vector Poisson testing |
| 52 |
* |
| 53 |
* |
| 54 |
* $Header: /cvsroot/Lorene/Codes/Test/Poisson_vect/test_vpoisson_l.C,v 1.7 2014/10/13 08:54:02 j_novak Exp $ |
| 55 |
* |
| 56 |
*/ |
| 57 |
|
| 58 |
// Lorene headers |
| 59 |
#include "metric.h" |
| 60 |
#include "cmp.h" |
| 61 |
#include "nbr_spx.h" |
| 62 |
#include "utilitaires.h" |
| 63 |
#include "graphique.h" |
| 64 |
|
| 65 |
using namespace Lorene ; |
| 66 |
|
| 67 |
int main() { |
| 68 |
|
| 69 |
// Construction of a multi-grid (Mg3d) |
| 70 |
// ----------------------------------- |
| 71 |
|
| 72 |
const int nz = 3 ; // Number of domains |
| 73 |
int nr =33 ; // Number of collocation points in r in each domain |
| 74 |
int nt =9 ; // Number of collocation points in theta in each domain |
| 75 |
int np = 16 ; // Number of collocation points in phi in each domain |
| 76 |
int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane |
| 77 |
int symmetry_phi = NONSYM ; // no symmetry in phi |
| 78 |
|
| 79 |
int nbr[] = {nr, nr, nr}; |
| 80 |
int nbt[] = {nt, nt, nt} ; |
| 81 |
int nbp[] = {np, np, np} ; |
| 82 |
int tipe_r[] = {RARE, FIN, UNSURR} ; |
| 83 |
|
| 84 |
Mg3d mgrid(nz, nbr, tipe_r, nbt, symmetry_theta, nbp, symmetry_phi) ; |
| 85 |
|
| 86 |
// Construction of an affine mapping (Map_af) |
| 87 |
// ------------------------------------------ |
| 88 |
|
| 89 |
// Boundaries of each domains |
| 90 |
double r_limits[] = {0., 1.1, 2., __infinity} ; |
| 91 |
|
| 92 |
Map_af map(mgrid, r_limits) ; |
| 93 |
int nzm1 = nz - 1 ; |
| 94 |
|
| 95 |
|
| 96 |
// Construction of flat metrics |
| 97 |
// ---------------------------- |
| 98 |
|
| 99 |
const Metric_flat& mets = map.flat_met_spher() ; |
| 100 |
|
| 101 |
Scalar r(map) ; |
| 102 |
r = map.r ; |
| 103 |
Scalar xx(map) ; |
| 104 |
xx = map.x ; |
| 105 |
|
| 106 |
cout << "Entrer l: " << endl ; |
| 107 |
int lq; cin >> lq ; |
| 108 |
|
| 109 |
Scalar pot(map) ; |
| 110 |
pot = pow(xx,lq) / (1 + pow(r, 2*lq+2) ) ; |
| 111 |
pot.set_outer_boundary(nzm1,0.) ; |
| 112 |
pot.std_spectral_base() ; |
| 113 |
|
| 114 |
Vector sol(map, CON, map.get_bvect_cart()) ; |
| 115 |
sol.set(1) = pot.dsdy() ; |
| 116 |
sol.set(1).dec_dzpuis(2) ; |
| 117 |
sol.set(2) = 0 ; |
| 118 |
sol.set(3) = 0 ; |
| 119 |
|
| 120 |
sol.change_triad(map.get_bvect_spher()) ; |
| 121 |
|
| 122 |
Vector_divfree sol_df = sol.div_free(mets) ; |
| 123 |
|
| 124 |
Scalar poten = sol.potential(mets) ; |
| 125 |
|
| 126 |
Scalar diff = sol_df.divergence(mets) ; |
| 127 |
|
| 128 |
maxabs(diff, "Divergence de sol_df") ; |
| 129 |
|
| 130 |
double lambda = 1./3. ; |
| 131 |
|
| 132 |
Tensor grad = sol.derive_con(mets) ; |
| 133 |
Scalar div = sol.divergence(mets) ; |
| 134 |
|
| 135 |
Vector source = grad.divergence(mets) + lambda * div.derive_con(mets) ; |
| 136 |
|
| 137 |
source.inc_dzpuis() ; |
| 138 |
|
| 139 |
Vector_divfree sou_df = source.div_free(mets) ; |
| 140 |
|
| 141 |
Scalar pot_sou = source.potential(mets) ; |
| 142 |
|
| 143 |
diff = sou_df.divergence(mets) ; |
| 144 |
diff.dec_dzpuis() ; |
| 145 |
diff.dec_dzpuis(4) ; |
| 146 |
|
| 147 |
maxabs(diff, "Divergence de sou_df") ; |
| 148 |
|
| 149 |
Vector sol_num0 = source.poisson(lambda, 0) ; |
| 150 |
Vector sol_num1 = source.poisson(lambda, 1) ; |
| 151 |
Vector sol_num2 = source.poisson(lambda, 2) ; |
| 152 |
Vector sol_num3 = source.poisson(lambda, 3) ; |
| 153 |
Vector sol_num4 = source.poisson(lambda, 4) ; |
| 154 |
Vector sol_num5 = source.poisson(lambda, 5) ; |
| 155 |
Vector sol_num6 = source.poisson(lambda, 6) ; |
| 156 |
|
| 157 |
cout << endl ; |
| 158 |
|
| 159 |
cout << "==================================================" << endl ; |
| 160 |
cout << " --------- Erreur sur la solution --------- " << endl ; |
| 161 |
cout << "==================================================" << endl ; |
| 162 |
|
| 163 |
|
| 164 |
maxabs(sol_num0 - sol, "Methode 0 (Comp. spheriques)") ; |
| 165 |
maxabs(sol_num1 - sol, "Methode 1 (Comp. spheriques)") ; |
| 166 |
maxabs(sol_num2 - sol, "Methode 2 (Comp. cartesiennes)") ; |
| 167 |
maxabs(sol_num3 - sol, "Methode 3 (Comp. cartesiennes)") ; |
| 168 |
maxabs(sol_num4 - sol, "Methode 4 (Comp. spheriques)") ; |
| 169 |
maxabs(sol_num5 - sol, "Methode 5 (Comp. spheriques)") ; |
| 170 |
maxabs(sol_num6 - sol, "Methode 6 (Comp. spheriques)") ; |
| 171 |
|
| 172 |
|
| 173 |
return EXIT_SUCCESS ; |
| 174 |
} |