Debian Codegraph @

Codes/Test/Map/test_map_af_primr.C

raw
1 /*
2 * Test program for the radial primitive computation with a Map_af mapping
3 *
4 */
5
6 /*
7 * Copyright (c) 2004 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_primr_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Map/test_map_af_primr.C,v 1.3 2014/10/13 08:54:01 j_novak Exp $" ;
28
29 /*
30 * $Id: test_map_af_primr.C,v 1.3 2014/10/13 08:54:01 j_novak Exp $
31 * $Log: test_map_af_primr.C,v $
32 * Revision 1.3 2014/10/13 08:54:01 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.2 2014/10/06 15:12:53 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.1 2004/06/14 15:29:12 e_gourgoulhon
39 * First version
40 *
41 *
42 * $Header: /cvsroot/Lorene/Codes/Test/Map/test_map_af_primr.C,v 1.3 2014/10/13 08:54:01 j_novak Exp $
43 *
44 */
45
46 // headers C++
47 #include "headcpp.h"
48
49 // headers C
50 #include <cstdlib>
51 #include <cmath>
52
53 // headers Lorene
54 #include "tensor.h"
55 #include "nbr_spx.h"
56 #include "graphique.h"
57 #include "utilitaires.h"
58
59 //******************************************************************************
60
61 using namespace Lorene ;
62
63 int main(){
64
65 // Setup of a multi-domain grid (Lorene class Mg3d)
66 // ------------------------------------------------
67
68 int nz = 4 ; // Number of domains
69 int nzm1 = nz-1 ;
70 int nr = 17 ; // Number of collocation points in r in each domain
71 int nt = 5 ; // Number of collocation points in theta in each domain
72 int np = 8 ; // Number of collocation points in phi in each domain
73 int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane
74 int symmetry_phi = SYM ; // no symmetry in phi
75 bool compact = true ; // external domain is compactified
76
77 // Multi-domain grid construction:
78 Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, compact) ;
79
80 cout << mgrid << endl ;
81
82
83 // Setup of an affine mapping : grid --> physical space (Lorene class Map_af)
84 // --------------------------------------------------------------------------
85
86 // radial boundaries of each domain:
87 double r_limits[] = {0., 1.5, 2., 3., __infinity} ;
88 assert( nz == 4 ) ; // since the above array described only 3 domains
89
90 Map_af map(mgrid, r_limits) ; // Mapping construction
91
92 cout << map << endl ;
93
94 // Denomination of various coordinates associated with the mapping
95 // ---------------------------------------------------------------
96
97 const Coord& r = map.r ; // r field
98 // const Coord& th = map.tet ; // theta field
99 // const Coord& phi = map.phi ; // phi field
100 const Coord& x = map.x ; // x field
101 const Coord& y = map.y ; // y field
102 const Coord& z = map.z ; // z field
103
104
105 //-----------------------------------------------------------------------
106 // Construction of a scalar field
107 //-----------------------------------------------------------------------
108
109 Scalar tmp(map) ;
110 tmp = r*r ;
111 tmp.annule_domain(nzm1) ;
112 tmp.std_spectral_base() ;
113
114 double rced = map.val_r(nz-2, 1., 0., 0.) ;
115 double ray_des = 2. * rced ; // outermost radius for plots
116
117 Scalar prim_ana(map) ;
118
119 prim_ana = r*( 1- x*x + z*z + x*y) ;
120 // prim_ana = r*r*r ;
121 Mtbl aux(mgrid) ;
122 aux = pow(rced,4) / r ;
123 prim_ana.set_domain(nzm1) = aux(nzm1) ;
124
125 prim_ana.set_spectral_base( tmp.dsdr().get_spectral_va().get_base() ) ;
126
127 des_meridian(prim_ana, 0., ray_des, "prim_ana", 9) ;
128
129 Scalar uu = prim_ana.dsdr() ;
130
131 uu.spectral_display("uu") ; // prints the spectral expansions
132
133 Scalar uu_des = uu ;
134 uu_des.dec_dzpuis(2) ;
135 des_meridian(uu_des, 0., ray_des, "U", 10) ;
136
137 Scalar prim = uu.primr() ;
138 prim.spectral_display("Primitive") ; // prints the spectral expansions
139
140 des_meridian(prim, 0., ray_des, "Primitive", 11) ;
141
142 maxabs(prim - prim_ana, "Absolute error prim - prim_ana") ;
143
144 maxabs(prim.dsdr() - uu, "Absolute error d/dr prim - uu") ;
145
146 arrete() ;
147
148 return EXIT_SUCCESS ;
149
150 }
151