| 1 |
/* |
| 2 |
* Main code for computing initial configuration |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2004-2005 Francois Limousin |
| 8 |
* Jose Luis Jaramillo |
| 9 |
* |
| 10 |
* This file is part of LORENE. |
| 11 |
* |
| 12 |
* LORENE is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License version 2 |
| 14 |
* as published by the Free Software Foundation. |
| 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 init_bh_C[] = "$Header: /cvsroot/Lorene/Codes/Bin_hor/init_bh.C,v 1.9 2014/10/13 08:53:53 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: init_bh.C,v 1.9 2014/10/13 08:53:53 j_novak Exp $ |
| 31 |
* $Log: init_bh.C,v $ |
| 32 |
* Revision 1.9 2014/10/13 08:53:53 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.8 2014/10/06 15:09:42 j_novak |
| 36 |
* Modified #include directives to use c++ syntax. |
| 37 |
* |
| 38 |
* Revision 1.7 2007/04/13 15:30:58 f_limousin |
| 39 |
* Lots of improvements, generalisation to an arbitrary state of |
| 40 |
* rotation, implementation of the spatial metric given by Samaya. |
| 41 |
* |
| 42 |
* Revision 1.6 2006/06/28 13:36:52 f_limousin |
| 43 |
* Convergence to a given irreductible mass |
| 44 |
* |
| 45 |
* Revision 1.5 2005/03/04 09:42:02 f_limousin |
| 46 |
* New construction of the object Bin_hor. |
| 47 |
* |
| 48 |
* Revision 1.4 2005/02/25 12:31:59 f_limousin |
| 49 |
* The boundary conditions for psi, N and beta are now parameters in |
| 50 |
* par_init.d and par_coal.d. |
| 51 |
* |
| 52 |
* Revision 1.3 2005/01/03 07:59:02 f_limousin |
| 53 |
* Drawings. |
| 54 |
* |
| 55 |
* Revision 1.2 2004/12/31 15:45:26 f_limousin |
| 56 |
* Change the parameters in par_init.d |
| 57 |
* |
| 58 |
* Revision 1.1 2004/12/29 18:00:20 f_limousin |
| 59 |
* First version |
| 60 |
* |
| 61 |
* |
| 62 |
* $Header: /cvsroot/Lorene/Codes/Bin_hor/init_bh.C,v 1.9 2014/10/13 08:53:53 j_novak Exp $ |
| 63 |
* |
| 64 |
*/ |
| 65 |
|
| 66 |
//standard |
| 67 |
#include <cstdlib> |
| 68 |
#include <cmath> |
| 69 |
|
| 70 |
// LORENE |
| 71 |
#include "type_parite.h" |
| 72 |
#include "nbr_spx.h" |
| 73 |
#include "proto.h" |
| 74 |
#include "coord.h" |
| 75 |
#include "tenseur.h" |
| 76 |
#include "tensor.h" |
| 77 |
#include "isol_hor.h" |
| 78 |
#include "utilitaires.h" |
| 79 |
#include "graphique.h" |
| 80 |
|
| 81 |
|
| 82 |
using namespace Lorene ; |
| 83 |
|
| 84 |
int main() { |
| 85 |
|
| 86 |
char blabla [120] ; |
| 87 |
ifstream param("par_init.d") ; |
| 88 |
|
| 89 |
double precis, relax, radius, separation, lim_nn ; |
| 90 |
int nz, nt, np, nr1, nrp1, bound_nn, bound_psi ; |
| 91 |
|
| 92 |
param.getline(blabla, 120) ; |
| 93 |
param.getline(blabla, 120) ; |
| 94 |
param >> separation ; param.getline(blabla, 120) ; |
| 95 |
param >> nz ; param.getline(blabla, 120) ; |
| 96 |
param >> nt; param.ignore(1000, '\n'); |
| 97 |
param >> np; param.ignore(1000, '\n'); |
| 98 |
param >> nr1; param.ignore(1000, '\n'); |
| 99 |
param >> nrp1; param.ignore(1000, '\n'); |
| 100 |
|
| 101 |
double* bornes = new double[nz+1] ; |
| 102 |
int* nr_tab = new int[nz]; |
| 103 |
int* nt_tab = new int[nz]; |
| 104 |
int* np_tab = new int[nz]; |
| 105 |
|
| 106 |
for (int l=0 ; l<nz ; l++){ |
| 107 |
if (l==1) nr_tab[1] = nr1 ; |
| 108 |
else nr_tab[l] = nrp1 ; |
| 109 |
np_tab[l] = np ; |
| 110 |
nt_tab[l] = nt ; |
| 111 |
param >> bornes[l] ; |
| 112 |
|
| 113 |
} |
| 114 |
radius = bornes[1] ; |
| 115 |
param.getline(blabla, 120) ; |
| 116 |
bornes[nz] = __infinity ; |
| 117 |
|
| 118 |
param >> precis ; param.getline(blabla, 120) ; |
| 119 |
param >> relax ; param.getline(blabla, 120) ; |
| 120 |
param >> bound_nn ; |
| 121 |
param >> lim_nn ; param.ignore(1000, '\n'); |
| 122 |
param >> bound_psi ; param.ignore(1000, '\n'); |
| 123 |
|
| 124 |
param.close() ; |
| 125 |
|
| 126 |
// Type of sampling in theta and phi : |
| 127 |
int type_t = SYM ; |
| 128 |
int type_p = NONSYM ; |
| 129 |
|
| 130 |
|
| 131 |
int* type_r = new int[nz] ; |
| 132 |
type_r[0] = RARE ; |
| 133 |
for (int l=1 ; l<nz-1 ; l++) |
| 134 |
type_r[l] = FIN ; |
| 135 |
type_r[nz-1] = UNSURR ; |
| 136 |
|
| 137 |
Mg3d grid (nz, nr_tab, type_r, nt_tab, type_t, np_tab, type_p) ; |
| 138 |
|
| 139 |
Map_af map_un (grid, bornes) ; |
| 140 |
Map_af map_deux (grid, bornes) ; |
| 141 |
|
| 142 |
map_un.set_ori (separation/2.,0, 0) ; |
| 143 |
map_deux.set_ori (-separation/2., 0, 0) ; |
| 144 |
map_deux.set_rot_phi (M_PI) ; |
| 145 |
|
| 146 |
Bin_hor bin (map_un, map_deux) ; |
| 147 |
bin.set_statiques(precis, relax, bound_nn, lim_nn, bound_psi) ; |
| 148 |
|
| 149 |
FILE* fich = fopen("static.d", "w") ; |
| 150 |
grid.sauve(fich) ; |
| 151 |
map_un.sauve(fich) ; |
| 152 |
map_deux.sauve(fich) ; |
| 153 |
bin.sauve(fich) ; |
| 154 |
fwrite_be(&bound_nn, sizeof(int), 1, fich) ; |
| 155 |
fwrite_be (&lim_nn, sizeof(double), 1, fich) ; |
| 156 |
fwrite_be(&bound_psi, sizeof(int), 1, fich) ; |
| 157 |
fclose(fich) ; |
| 158 |
|
| 159 |
// cout << bin << endl ; |
| 160 |
|
| 161 |
|
| 162 |
// Drawings |
| 163 |
const Coord& r = bin(1).get_mp().r ; // r field |
| 164 |
Mtbl usr = 1 / r ; |
| 165 |
Scalar unsr(bin(1).get_mp()) ; |
| 166 |
unsr = usr ; |
| 167 |
|
| 168 |
Scalar temp = 1. + unsr ; |
| 169 |
temp.std_spectral_base() ; |
| 170 |
/* |
| 171 |
des_profile(bin(1).nn(), 1.00001, 10, M_PI/2., 0., "bin(1).nn()") ; |
| 172 |
des_profile(bin(1).psi(), 1.00001, 10, M_PI/2., 0., "bin(1).psi()") ; |
| 173 |
des_profile(temp, 1.00001, 10, M_PI/2., 0., "psi ana()") ; |
| 174 |
des_profile(temp-bin(1).psi(), 1.00001, 10, M_PI/2., 0., "diff psi") ; |
| 175 |
*/ |
| 176 |
delete [] nr_tab ; |
| 177 |
delete [] nt_tab ; |
| 178 |
delete [] np_tab ; |
| 179 |
delete [] type_r ; |
| 180 |
delete [] bornes ; |
| 181 |
|
| 182 |
return 1 ; |
| 183 |
} |