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 char 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 
87 namespace Lorene {
88 double 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() ;
122  tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
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 
187  shift.change_triad(mp.get_bvect_cart()) ;
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() ;
193  tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
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 
257  shift.change_triad(mp.get_bvect_spher()) ;
258  beta_evol.update(shift, jtime, the_time[jtime]) ;
259 
260  return erreur ;
261 }
262 }
Lorene::Isol_hor::nz
int nz
Number of zones.
Definition: isol_hor.h:263
Lorene::Mg3d::get_np
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:462
Lorene::Valeur
Values and coefficients of a (real-value) function.
Definition: valeur.h:287
Lorene::Valeur::set_etat_c_qcq
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
Lorene::Time_slice::beta_evol
Evolution_std< Vector > beta_evol
Values at successive time steps of the shift vector .
Definition: time_slice.h:219
Lorene::Map::get_rot_phi
double get_rot_phi() const
Returns the angle between the x –axis and X –axis.
Definition: map.h:775
Lorene::Mg3d::get_nt
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:457
Lorene
Lorene prototypes.
Definition: app_hor.h:64
Lorene::Map::get_bvect_spher
const Base_vect_spher & get_bvect_spher() const
Returns the orthonormal vectorial basis associated with the coordinates of the mapping.
Definition: map.h:783
Lorene::Map::get_mg
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:765
Lorene::diffrelmax
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition: cmp_math.C:539
Lorene::Map::r
Coord r
r coordinate centered on the grid
Definition: map.h:718
Lorene::norme
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition: cmp_math.C:481
Lorene::Isol_hor::mp
Map_af & mp
Affine mapping.
Definition: isol_hor.h:260
Lorene::Valeur::annule
void annule(int l)
Sets the Valeur to zero in a given domain.
Definition: valeur.C:744
Lorene::Scalar::import
void import(const Scalar &ci)
Assignment to another Scalar defined on a different mapping.
Definition: scalar_import.C:68
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
Lorene::Tensor::get_mp
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:861
Lorene::Isol_hor::omega
double omega
Angular velocity in LORENE's units.
Definition: isol_hor.h:269
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:348
Lorene::Tensor::annule_domain
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition: tensor.C:666
Lorene::Map_af::val_r
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.
Definition: map_af_radius.C:96
Lorene::Isol_hor::beta_auto_evol
Evolution_std< Vector > beta_auto_evol
Values at successive time steps of the shift function .
Definition: isol_hor.h:301
Lorene::Vector::change_triad
virtual void change_triad(const Base_vect &)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Definition: vector_change_triad.C:75
Lorene::Scalar::set_spectral_va
Valeur & set_spectral_va()
Returns va (read/write version)
Definition: scalar.h:604
Lorene::Tensor::set_etat_qcq
virtual void set_etat_qcq()
Sets the logical state of all components to ETATQCQ (ordinary state).
Definition: tensor.C:481
Lorene::Isol_hor::regularisation
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,...
Definition: regularisation.C:88
Lorene::Vector::set
Scalar & set(int)
Read/write access to a component.
Definition: vector.C:296
Lorene::Valeur::annule_hard
void annule_hard()
Sets the Valeur to zero in a hard way.
Definition: valeur.C:723
Lorene::Isol_hor::boost_x
double boost_x
Boost velocity in x-direction.
Definition: isol_hor.h:272
Lorene::Tbl
Basic array class.
Definition: tbl.h:161
Lorene::Mg3d::get_nzone
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:448
Lorene::Mg3d::get_nr
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:452
Lorene::Time_slice::the_time
Evolution_std< double > the_time
Time label of each slice.
Definition: time_slice.h:193
Lorene::Valeur::set_base
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base )
Definition: valeur.C:810
Lorene::Map::get_bvect_cart
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
Lorene::Isol_hor::boost_z
double boost_z
Boost velocity in z-direction.
Definition: isol_hor.h:275
Lorene::Vector
Tensor field of valence 1.
Definition: vector.h:188
Lorene::Map::x
Coord x
x coordinate centered on the grid
Definition: map.h:726
Lorene::Map::xa
Coord xa
Absolute x coordinate.
Definition: map.h:730
Lorene::Tensor::get_triad
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tensor.h:866
Lorene::Isol_hor::regularise_one
double regularise_one()
Corrects the shift in the innermost shell, so that it remains and that equals zero on the horizon.
Definition: regularisation.C:183
Lorene::Time_slice::jtime
int jtime
Time step index of the latest slice.
Definition: time_slice.h:190
Lorene::Time_slice::beta
virtual const Vector & beta() const
shift vector at the current time step (jtime )
Definition: time_slice_access.C:87
Lorene::Valeur::coef_i
void coef_i() const
Computes the physical value of *this.
Definition: valeur_coef_i.C:140
Lorene::Valeur::base
Base_val base
Bases on which the spectral expansion is performed.
Definition: valeur.h:305
Lorene::Valeur::set
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).
Definition: valeur.h:363
Lorene::Map::y
Coord y
y coordinate centered on the grid
Definition: map.h:727
Lorene::Map::ya
Coord ya
Absolute y coordinate.
Definition: map.h:731
Lorene::Vector::std_spectral_base
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition: vector.C:316