LORENE
regularisation.C
1/*
2 * Copyright (c) 2005 Francois Limousin
3 * Jose Luis Jaramillo
4 *
5 * This file is part of LORENE.
6 *
7 * LORENE is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * LORENE is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with LORENE; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23
24
25
26/*
27 * $Id: regularisation.C,v 1.13 2016/12/05 16:17:56 j_novak Exp $
28 * $Log: regularisation.C,v $
29 * Revision 1.13 2016/12/05 16:17:56 j_novak
30 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
31 *
32 * Revision 1.12 2014/10/13 08:53:01 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.11 2014/10/06 15:13:11 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.10 2008/08/19 06:42:00 j_novak
39 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
40 * cast-type operations, and constant strings that must be defined as const char*
41 *
42 * Revision 1.9 2005/09/13 18:33:17 f_limousin
43 * New function vv_bound_cart_bin(double) for computing binaries with
44 * berlin condition for the shift vector.
45 * Suppress all the symy and asymy in the importations.
46 *
47 * Revision 1.8 2005/09/12 12:33:54 f_limousin
48 * Compilation Warning - Change of convention for the angular velocity
49 * Add Berlin boundary condition in the case of binary horizons.
50 *
51 * Revision 1.7 2005/05/12 14:48:07 f_limousin
52 * New boundary condition for the lapse : boundary_nn_lapl().
53 *
54 * Revision 1.6 2005/04/03 19:48:22 f_limousin
55 * Implementation of set_psi(psi_in). And minor changes to avoid warnings.
56 *
57 * Revision 1.5 2005/03/24 16:50:28 f_limousin
58 * Add parameters solve_shift and solve_psi in par_isol.d and in function
59 * init_dat(...). Implement Isolhor::kerr_perturb().
60 *
61 * Revision 1.4 2005/03/22 13:25:36 f_limousin
62 * Small changes. The angular velocity and A^{ij} are computed
63 * with a differnet sign.
64 *
65 * Revision 1.3 2005/03/10 10:19:42 f_limousin
66 * Add the regularisation of the shift in the case of a single black hole
67 * and lapse zero on the horizon.
68 *
69 * Revision 1.2 2005/03/06 17:05:33 f_limousin
70 * Change parameter omega to om, in order not to have warnings.
71 *
72 * Revision 1.1 2005/02/22 14:51:53 f_limousin
73 * First version
74 *
75 *
76 * $Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.13 2016/12/05 16:17:56 j_novak Exp $
77 *
78 */
79
80
81//Standard
82#include <cstdlib>
83#include <cmath>
84
85//Lorene
86#include "isol_hor.h"
87#include "nbr_spx.h"
88#include "tensor.h"
89
90namespace Lorene {
91double Isol_hor::regularisation (const Vector& shift_auto_temp,
92 const Vector& shift_comp_temp, double om) {
93
94 Vector shift_auto(shift_auto_temp) ;
95 shift_auto.change_triad(shift_auto.get_mp().get_bvect_cart()) ;
96 Vector shift_comp(shift_comp_temp) ;
97 shift_comp.change_triad(shift_comp.get_mp().get_bvect_cart()) ;
98 Vector shift_old (shift_auto) ;
99
100 double orientation = shift_auto.get_mp().get_rot_phi() ;
101 assert ((orientation==0) || (orientation == M_PI)) ;
102 double orientation_autre = shift_comp.get_mp().get_rot_phi() ;
103 assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
104
105 int alignes = (orientation == orientation_autre) ? 1 : -1 ;
106
107 int np = shift_auto.get_mp().get_mg()->get_np(1) ;
108 int nt = shift_auto.get_mp().get_mg()->get_nt(1) ;
109 int nr = shift_auto.get_mp().get_mg()->get_nr(1) ;
110
111 // Minimisation of the derivative of the shift on r
112 Vector shift_tot (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
113 shift_tot.set(1).import(alignes*shift_comp(1)) ;
114 shift_tot.set(2).import(alignes*shift_comp(2)) ;
115 shift_tot.set(3).import(shift_comp(3)) ;
116
117 shift_tot = shift_tot + shift_auto ;
118
119 double indic = (orientation == 0) ? 1 : -1 ;
120
121 Vector tbi (shift_tot) ;
122 if (om != 0) {
123 for (int i=1 ; i<=3 ; i++) {
124 tbi.set(i).set_spectral_va().coef_i() ;
126 }
127
128 tbi.set(1) = *shift_tot(1).get_spectral_va().c - indic *om * shift_tot.get_mp().ya ;
129 tbi.set(2) = *shift_tot(2).get_spectral_va().c + indic *om * shift_tot.get_mp().xa ;
130 tbi.std_spectral_base() ;
131 tbi.set(1).annule_domain(nz-1) ;
132 tbi.set(2).annule_domain(nz-1) ;
133 }
134
135 Vector derive_r (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
136 for (int i=1 ; i<=3 ; i++)
137 derive_r.set(i) = tbi(i).dsdr() ;
138
139
140 // We substract a function in order that Kij is regular
141
142 Valeur val_hor (shift_auto.get_mp().get_mg()) ;
143 Valeur fonction_radiale (shift_auto.get_mp().get_mg()) ;
144 Scalar enleve (shift_auto.get_mp()) ;
145
146 double erreur = 0 ;
147 for (int comp=1 ; comp<=3 ; comp++) {
148 val_hor.annule_hard() ;
149 for (int k=0 ; k<np ; k++)
150 for (int j=0 ; j<nt ; j++)
151 for (int i=0 ; i<nr ; i++)
152 val_hor.set(1, k, j, i) = derive_r(comp).
153 val_grid_point(1, k, j, 0) ;
154
155 double r_0 = shift_auto.get_mp().val_r (1, -1, 0, 0) ;
156 double r_1 = shift_auto.get_mp().val_r (1, 1, 0, 0) ;
157
158 fonction_radiale = pow(r_1-shift_auto.get_mp().r, 3.)*
159 (shift_auto.get_mp().r-r_0)/pow(r_1-r_0, 3.) ;
160 fonction_radiale.annule(0) ;
161 fonction_radiale.annule(2, nz-1) ;
162
163 enleve = fonction_radiale * val_hor ;
164 enleve.set_spectral_va().set_base (shift_auto(comp).
165 get_spectral_va().get_base()) ;
166
167 if (norme(enleve)(1) != 0)
168 shift_auto.set(comp) = shift_auto(comp) - enleve ;
169 if (norme(shift_auto(comp))(1) > 1e-5) {
170 Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
171 if (erreur < diff(1))
172 erreur = diff(1) ;
173 }
174 }
175
176 shift_auto.change_triad(shift_auto.get_mp().get_bvect_spher()) ;
177
178 double ttime = the_time[jtime] ;
179 beta_auto_evol.update(shift_auto, jtime, ttime) ;
180
181 return erreur ;
182}
183
184
185// Regularisation if only one black hole :
187
188 Vector shift (beta()) ;
189
190 shift.change_triad(mp.get_bvect_cart()) ;
191 // Vector B (without boost and rotation)
192 Vector tbi (shift) ;
193
194 for (int i=1 ; i<=3 ; i++) {
195 tbi.set(i).set_spectral_va().coef_i() ;
197 }
198
199 for (int i=1 ; i<=3 ; i++)
200 shift(i).get_spectral_va().coef_i() ;
201
202 tbi.set(1) = *shift(1).get_spectral_va().c - omega*mp.y - boost_x ;
203 tbi.set(2) = *shift(2).get_spectral_va().c + omega*mp.x ;
204 if (shift(3).get_etat() != ETATZERO)
205 tbi.set(3) = *shift(3).get_spectral_va().c - boost_z ;
206 else
207 tbi.set(3) = 0. ;
208 tbi.std_spectral_base() ;
209
210 // We only need values at the horizon
211 tbi.set(1).annule_domain(mp.get_mg()->get_nzone()-1) ;
212 tbi.set(2).annule_domain(mp.get_mg()->get_nzone()-1) ;
213
214 Vector derive_r (mp, CON, mp.get_bvect_cart()) ;
215 derive_r.set_etat_qcq() ;
216 for (int i=1 ; i<=3 ; i++)
217 derive_r.set(i) = tbi(i).dsdr() ;
218
219 Valeur val_hor (mp.get_mg()) ;
220 Valeur fonction_radiale (mp.get_mg()) ;
221 Scalar enleve (mp) ;
222
223 double erreur = 0 ;
224 int np = mp.get_mg()->get_np(1) ;
225 int nt = mp.get_mg()->get_nt(1) ;
226 int nr = mp.get_mg()->get_nr(1) ;
227
228 double r_0 = mp.val_r(1, -1, 0, 0) ;
229 double r_1 = mp.val_r(1, 1, 0, 0) ;
230
231 for (int comp=1 ; comp<=3 ; comp++) {
232 val_hor.annule_hard() ;
233 for (int k=0 ; k<np ; k++)
234 for (int j=0 ; j<nt ; j++)
235 for (int i=0 ; i<nr ; i++)
236 val_hor.set(1, k, j, i) = derive_r(comp).val_grid_point(1, k, j, 0) ;
237
238 fonction_radiale = pow(r_1-mp.r, 3.)* (mp.r-r_0)/pow(r_1-r_0, 3.) ;
239 fonction_radiale.annule(0) ;
240 fonction_radiale.annule(2, nz-1) ;
241
242 enleve = fonction_radiale*val_hor ;
243 enleve.set_spectral_va().base = shift(comp).get_spectral_va().base ;
244
245 Scalar copie (shift(comp)) ;
246 shift.set(comp) = shift(comp)-enleve ;
247 shift.std_spectral_base() ;
248
249 assert (shift(comp).check_dzpuis(0)) ;
250
251 // Intensity of the correction (if nonzero)
252 Tbl norm (norme(shift(comp))) ;
253 if (norm(1) > 1e-5) {
254 Tbl diff (diffrelmax (copie, shift(comp))) ;
255 if (erreur<diff(1))
256 erreur = diff(1) ;
257 }
258 }
259
260 shift.change_triad(mp.get_bvect_spher()) ;
261 beta_evol.update(shift, jtime, the_time[jtime]) ;
262
263 return erreur ;
264}
265}
double regularise_one()
Corrects the shift in the innermost shell, so that it remains and that equals zero on the horizon.
double omega
Angular velocity in LORENE's units.
Definition isol_hor.h:269
int nz
Number of zones.
Definition isol_hor.h:263
Evolution_std< Vector > beta_auto_evol
Values at successive time steps of the shift function .
Definition isol_hor.h:301
double boost_z
Boost velocity in z-direction.
Definition isol_hor.h:275
Map_af & mp
Affine mapping.
Definition isol_hor.h:260
double regularisation(const Vector &shift_auto, const Vector &shift_comp, double ang_vel)
Corrects shift_auto in such a way that the total is equal to zero in the horizon,...
double boost_x
Boost velocity in x-direction.
Definition isol_hor.h:272
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:393
Valeur & set_spectral_va()
Returns va (read/write version).
Definition scalar.h:610
void import(const Scalar &ci)
Assignment to another Scalar defined on a different mapping.
Basic array class.
Definition tbl.h:161
int jtime
Time step index of the latest slice.
Definition time_slice.h:193
virtual const Vector & beta() const
shift vector at the current time step (jtime )
Evolution_std< double > the_time
Time label of each slice.
Definition time_slice.h:196
Evolution_std< Vector > beta_evol
Values at successive time steps of the shift vector .
Definition time_slice.h:222
Values and coefficients of a (real-value) function.
Definition valeur.h:297
void set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c ).
Definition valeur.C:704
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base ).
Definition valeur.C:813
void annule(int l)
Sets the Valeur to zero in a given domain.
Definition valeur.C:747
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).
Definition valeur.h:373
void coef_i() const
Computes the physical value of *this.
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:315
void annule_hard()
Sets the Valeur to zero in a hard way.
Definition valeur.C:726
Tensor field of valence 1.
Definition vector.h:188
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition vector.C:319
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Scalar & set(int)
Read/write access to a component.
Definition vector.C:299
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition cmp_math.C:484
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:351
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition cmp_math.C:542
const Map & get_mp() const
Returns the mapping.
Definition tensor.h:874
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition tensor.h:879
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition tensor.C:675
virtual void set_etat_qcq()
Sets the logical state of all components to ETATQCQ (ordinary state).
Definition tensor.C:490
Lorene prototypes.
Definition app_hor.h:67
Coord r
r coordinate centered on the grid
Definition map.h:730