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
24char regularisation_C[] = "$Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.12 2014/10/13 08:53:01 j_novak Exp $" ;
25
26/*
27 * $Id: regularisation.C,v 1.12 2014/10/13 08:53:01 j_novak Exp $
28 * $Log: regularisation.C,v $
29 * Revision 1.12 2014/10/13 08:53:01 j_novak
30 * Lorene classes and functions now belong to the namespace Lorene.
31 *
32 * Revision 1.11 2014/10/06 15:13:11 j_novak
33 * Modified #include directives to use c++ syntax.
34 *
35 * Revision 1.10 2008/08/19 06:42:00 j_novak
36 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
37 * cast-type operations, and constant strings that must be defined as const char*
38 *
39 * Revision 1.9 2005/09/13 18:33:17 f_limousin
40 * New function vv_bound_cart_bin(double) for computing binaries with
41 * berlin condition for the shift vector.
42 * Suppress all the symy and asymy in the importations.
43 *
44 * Revision 1.8 2005/09/12 12:33:54 f_limousin
45 * Compilation Warning - Change of convention for the angular velocity
46 * Add Berlin boundary condition in the case of binary horizons.
47 *
48 * Revision 1.7 2005/05/12 14:48:07 f_limousin
49 * New boundary condition for the lapse : boundary_nn_lapl().
50 *
51 * Revision 1.6 2005/04/03 19:48:22 f_limousin
52 * Implementation of set_psi(psi_in). And minor changes to avoid warnings.
53 *
54 * Revision 1.5 2005/03/24 16:50:28 f_limousin
55 * Add parameters solve_shift and solve_psi in par_isol.d and in function
56 * init_dat(...). Implement Isolhor::kerr_perturb().
57 *
58 * Revision 1.4 2005/03/22 13:25:36 f_limousin
59 * Small changes. The angular velocity and A^{ij} are computed
60 * with a differnet sign.
61 *
62 * Revision 1.3 2005/03/10 10:19:42 f_limousin
63 * Add the regularisation of the shift in the case of a single black hole
64 * and lapse zero on the horizon.
65 *
66 * Revision 1.2 2005/03/06 17:05:33 f_limousin
67 * Change parameter omega to om, in order not to have warnings.
68 *
69 * Revision 1.1 2005/02/22 14:51:53 f_limousin
70 * First version
71 *
72 *
73 * $Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.12 2014/10/13 08:53:01 j_novak Exp $
74 *
75 */
76
77
78//Standard
79#include <cstdlib>
80#include <cmath>
81
82//Lorene
83#include "isol_hor.h"
84#include "nbr_spx.h"
85#include "tensor.h"
86
87namespace Lorene {
88double Isol_hor::regularisation (const Vector& shift_auto_temp,
89 const Vector& shift_comp_temp, double om) {
90
91 Vector shift_auto(shift_auto_temp) ;
92 shift_auto.change_triad(shift_auto.get_mp().get_bvect_cart()) ;
93 Vector shift_comp(shift_comp_temp) ;
94 shift_comp.change_triad(shift_comp.get_mp().get_bvect_cart()) ;
95 Vector shift_old (shift_auto) ;
96
97 double orientation = shift_auto.get_mp().get_rot_phi() ;
98 assert ((orientation==0) || (orientation == M_PI)) ;
99 double orientation_autre = shift_comp.get_mp().get_rot_phi() ;
100 assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
101
102 int alignes = (orientation == orientation_autre) ? 1 : -1 ;
103
104 int np = shift_auto.get_mp().get_mg()->get_np(1) ;
105 int nt = shift_auto.get_mp().get_mg()->get_nt(1) ;
106 int nr = shift_auto.get_mp().get_mg()->get_nr(1) ;
107
108 // Minimisation of the derivative of the shift on r
109 Vector shift_tot (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
110 shift_tot.set(1).import(alignes*shift_comp(1)) ;
111 shift_tot.set(2).import(alignes*shift_comp(2)) ;
112 shift_tot.set(3).import(shift_comp(3)) ;
113
114 shift_tot = shift_tot + shift_auto ;
115
116 double indic = (orientation == 0) ? 1 : -1 ;
117
118 Vector tbi (shift_tot) ;
119 if (om != 0) {
120 for (int i=1 ; i<=3 ; i++) {
121 tbi.set(i).set_spectral_va().coef_i() ;
123 }
124
125 tbi.set(1) = *shift_tot(1).get_spectral_va().c - indic *om * shift_tot.get_mp().ya ;
126 tbi.set(2) = *shift_tot(2).get_spectral_va().c + indic *om * shift_tot.get_mp().xa ;
127 tbi.std_spectral_base() ;
128 tbi.set(1).annule_domain(nz-1) ;
129 tbi.set(2).annule_domain(nz-1) ;
130 }
131
132 Vector derive_r (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
133 for (int i=1 ; i<=3 ; i++)
134 derive_r.set(i) = tbi(i).dsdr() ;
135
136
137 // We substract a function in order that Kij is regular
138
139 Valeur val_hor (shift_auto.get_mp().get_mg()) ;
140 Valeur fonction_radiale (shift_auto.get_mp().get_mg()) ;
141 Scalar enleve (shift_auto.get_mp()) ;
142
143 double erreur = 0 ;
144 for (int comp=1 ; comp<=3 ; comp++) {
145 val_hor.annule_hard() ;
146 for (int k=0 ; k<np ; k++)
147 for (int j=0 ; j<nt ; j++)
148 for (int i=0 ; i<nr ; i++)
149 val_hor.set(1, k, j, i) = derive_r(comp).
150 val_grid_point(1, k, j, 0) ;
151
152 double r_0 = shift_auto.get_mp().val_r (1, -1, 0, 0) ;
153 double r_1 = shift_auto.get_mp().val_r (1, 1, 0, 0) ;
154
155 fonction_radiale = pow(r_1-shift_auto.get_mp().r, 3.)*
156 (shift_auto.get_mp().r-r_0)/pow(r_1-r_0, 3.) ;
157 fonction_radiale.annule(0) ;
158 fonction_radiale.annule(2, nz-1) ;
159
160 enleve = fonction_radiale * val_hor ;
161 enleve.set_spectral_va().set_base (shift_auto(comp).
162 get_spectral_va().get_base()) ;
163
164 if (norme(enleve)(1) != 0)
165 shift_auto.set(comp) = shift_auto(comp) - enleve ;
166 if (norme(shift_auto(comp))(1) > 1e-5) {
167 Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
168 if (erreur < diff(1))
169 erreur = diff(1) ;
170 }
171 }
172
173 shift_auto.change_triad(shift_auto.get_mp().get_bvect_spher()) ;
174
175 double ttime = the_time[jtime] ;
176 beta_auto_evol.update(shift_auto, jtime, ttime) ;
177
178 return erreur ;
179}
180
181
182// Regularisation if only one black hole :
184
185 Vector shift (beta()) ;
186
188 // Vector B (without boost and rotation)
189 Vector tbi (shift) ;
190
191 for (int i=1 ; i<=3 ; i++) {
192 tbi.set(i).set_spectral_va().coef_i() ;
194 }
195
196 for (int i=1 ; i<=3 ; i++)
197 shift(i).get_spectral_va().coef_i() ;
198
199 tbi.set(1) = *shift(1).get_spectral_va().c - omega*mp.y - boost_x ;
200 tbi.set(2) = *shift(2).get_spectral_va().c + omega*mp.x ;
201 if (shift(3).get_etat() != ETATZERO)
202 tbi.set(3) = *shift(3).get_spectral_va().c - boost_z ;
203 else
204 tbi.set(3) = 0. ;
205 tbi.std_spectral_base() ;
206
207 // We only need values at the horizon
208 tbi.set(1).annule_domain(mp.get_mg()->get_nzone()-1) ;
209 tbi.set(2).annule_domain(mp.get_mg()->get_nzone()-1) ;
210
211 Vector derive_r (mp, CON, mp.get_bvect_cart()) ;
212 derive_r.set_etat_qcq() ;
213 for (int i=1 ; i<=3 ; i++)
214 derive_r.set(i) = tbi(i).dsdr() ;
215
216 Valeur val_hor (mp.get_mg()) ;
217 Valeur fonction_radiale (mp.get_mg()) ;
218 Scalar enleve (mp) ;
219
220 double erreur = 0 ;
221 int np = mp.get_mg()->get_np(1) ;
222 int nt = mp.get_mg()->get_nt(1) ;
223 int nr = mp.get_mg()->get_nr(1) ;
224
225 double r_0 = mp.val_r(1, -1, 0, 0) ;
226 double r_1 = mp.val_r(1, 1, 0, 0) ;
227
228 for (int comp=1 ; comp<=3 ; comp++) {
229 val_hor.annule_hard() ;
230 for (int k=0 ; k<np ; k++)
231 for (int j=0 ; j<nt ; j++)
232 for (int i=0 ; i<nr ; i++)
233 val_hor.set(1, k, j, i) = derive_r(comp).val_grid_point(1, k, j, 0) ;
234
235 fonction_radiale = pow(r_1-mp.r, 3.)* (mp.r-r_0)/pow(r_1-r_0, 3.) ;
236 fonction_radiale.annule(0) ;
237 fonction_radiale.annule(2, nz-1) ;
238
239 enleve = fonction_radiale*val_hor ;
240 enleve.set_spectral_va().base = shift(comp).get_spectral_va().base ;
241
242 Scalar copie (shift(comp)) ;
243 shift.set(comp) = shift(comp)-enleve ;
244 shift.std_spectral_base() ;
245
246 assert (shift(comp).check_dzpuis(0)) ;
247
248 // Intensity of the correction (if nonzero)
249 Tbl norm (norme(shift(comp))) ;
250 if (norm(1) > 1e-5) {
251 Tbl diff (diffrelmax (copie, shift(comp))) ;
252 if (erreur<diff(1))
253 erreur = diff(1) ;
254 }
255 }
256
258 beta_evol.update(shift, jtime, the_time[jtime]) ;
259
260 return erreur ;
261}
262}
virtual void update(const TyT &new_value, int j, double time_j)
Sets a new value at a given time step.
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
virtual double val_r(int l, double xi, double theta, double pphi) const
Returns the value of the radial coordinate r for a given in a given domain.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping,...
Definition map.h:791
Coord y
y coordinate centered on the grid
Definition map.h:727
Coord ya
Absolute y coordinate.
Definition map.h:731
Coord r
r coordinate centered on the grid
Definition map.h:718
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition map.h:783
Coord x
x coordinate centered on the grid
Definition map.h:726
double get_rot_phi() const
Returns the angle between the x –axis and X –axis.
Definition map.h:775
Coord xa
Absolute x coordinate.
Definition map.h:730
virtual double val_r(int l, double xi, double theta, double pphi) const =0
Returns the value of the radial coordinate r for a given in a given domain.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition map.h:765
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition grilles.h:462
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:457
int get_nzone() const
Returns the number of domains.
Definition grilles.h:448
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition grilles.h:452
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Valeur & set_spectral_va()
Returns va (read/write version)
Definition scalar.h:604
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:190
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:193
Evolution_std< Vector > beta_evol
Values at successive time steps of the shift vector .
Definition time_slice.h:219
Values and coefficients of a (real-value) function.
Definition valeur.h:287
void set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c ).
Definition valeur.C:701
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base )
Definition valeur.C:810
void annule(int l)
Sets the Valeur to zero in a given domain.
Definition valeur.C:744
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).
Definition valeur.h:363
void coef_i() const
Computes the physical value of *this.
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:305
void annule_hard()
Sets the Valeur to zero in a hard way.
Definition valeur.C:723
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:316
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:296
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition cmp_math.C:481
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition cmp_math.C:539
const Map & get_mp() const
Returns the mapping.
Definition tensor.h:861
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition tensor.h:866
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition tensor.C:666
virtual void set_etat_qcq()
Sets the logical state of all components to ETATQCQ (ordinary state).
Definition tensor.C:481
Lorene prototypes.
Definition app_hor.h:64