LORENE
regularise_shift.C
1/*
2 * Copyright (c) 2000-2001 Philippe Grandclement
3 *
4 * This file is part of LORENE.
5 *
6 * LORENE is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * LORENE is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with LORENE; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22
23
24
25/*
26 * $Id: regularise_shift.C,v 1.8 2016/12/05 16:17:45 j_novak Exp $
27 * $Log: regularise_shift.C,v $
28 * Revision 1.8 2016/12/05 16:17:45 j_novak
29 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30 *
31 * Revision 1.7 2014/10/13 08:52:41 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.6 2014/10/06 15:12:59 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.5 2006/04/27 09:12:32 p_grandclement
38 * First try at irrotational black holes
39 *
40 * Revision 1.4 2005/08/29 15:10:14 p_grandclement
41 * Addition of things needed :
42 * 1) For BBH with different masses
43 * 2) Provisory files for the mixted binaries (Bh and NS) : THIS IS NOT
44 * WORKING YET !!!
45 *
46 * Revision 1.3 2003/10/03 15:58:44 j_novak
47 * Cleaning of some headers
48 *
49 * Revision 1.2 2003/02/13 16:40:25 p_grandclement
50 * Addition of various things for the Bin_ns_bh project, non of them being
51 * completely tested
52 *
53 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
54 * LORENE
55 *
56 * Revision 2.6 2001/05/07 09:11:48 phil
57 * *** empty log message ***
58 *
59 * Revision 2.5 2001/01/29 14:30:48 phil
60 * ajout type rotation
61 *
62 * Revision 2.4 2000/11/02 10:18:05 phil
63 * modification du degre de l;a fonction\
64 * de correction. On passe de 2 a 3
65 *
66 * Revision 2.3 2000/10/31 10:04:28 phil
67 * correction importation
68 *
69 * Revision 2.2 2000/10/26 12:34:17 phil
70 * *** empty log message ***
71 *
72 * Revision 2.1 2000/10/26 12:31:55 phil
73 * correction orientation pour calcul du shift total
74 *
75 * Revision 2.0 2000/10/19 10:08:03 phil
76 * *** empty log message ***
77 *
78 *
79 * $Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/regularise_shift.C,v 1.8 2016/12/05 16:17:45 j_novak Exp $
80 *
81 */
82
83
84//Standard
85#include <cstdlib>
86#include <cmath>
87
88//Lorene
89#include "nbr_spx.h"
90#include "tenseur.h"
91
92namespace Lorene {
93double regle (Tenseur& shift_auto, const Tenseur& shift_comp, double omega, double omega_local) {
94
95 Tenseur 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 // Cas triades identiques
105 if (*shift_comp.get_triad() == *shift_auto.get_triad())
106 alignes = 1 ;
107
108 int nz = shift_auto.get_mp()->get_mg()->get_nzone() ;
109 int np = shift_auto.get_mp()->get_mg()->get_np(1) ;
110 int nt = shift_auto.get_mp()->get_mg()->get_nt(1) ;
111 int nr = shift_auto.get_mp()->get_mg()->get_nr(1) ;
112
113 // On minimise la valeur de la derivee de B sur R :
114 Tenseur shift_tot (*shift_auto.get_mp(), 1, CON, *shift_auto.get_triad()) ;
115 shift_tot.set_etat_qcq() ;
116 shift_tot.set(0).import_asymy (alignes*shift_comp(0)) ;
117 shift_tot.set(1).import_symy (alignes*shift_comp(1)) ;
118 shift_tot.set(2).import_asymy (shift_comp(2)) ;
119
120 shift_tot = shift_tot + shift_auto ;
121
122 double indic = (orientation == 0) ? 1 : -1 ;
123
124 Mtbl xa_mtbl (shift_tot.get_mp()->get_mg()) ;
125 xa_mtbl = shift_tot.get_mp()->xa ;
126 Mtbl ya_mtbl (shift_tot.get_mp()->get_mg()) ;
127 ya_mtbl = shift_tot.get_mp()->ya ;
128
129 Tenseur tbi (shift_tot) ;
130 if (omega != 0) {
131 for (int i=0 ; i<3 ; i++) {
132 tbi.set(i).va.coef_i() ;
133 tbi.set(i).va.set_etat_c_qcq() ;
134 }
135
136 tbi.set(0) = *shift_tot(0).va.c - indic *omega * ya_mtbl(0,0,0,0) - indic*omega_local* shift_tot.get_mp()->y ;
137 tbi.set(1) = *shift_tot(1).va.c + indic *omega * xa_mtbl(0,0,0,0) + indic*omega_local* shift_tot.get_mp()->x ;
138 tbi.set_std_base() ;
139 tbi.set(0).annule(nz-1) ;
140 tbi.set(1).annule(nz-1) ;
141 }
142
143 Tenseur derive_r (*shift_auto.get_mp(), 1, CON, *shift_auto.get_triad()) ;
144 derive_r.set_etat_qcq() ;
145 for (int i=0 ; i<3 ; i++) {
146 if (tbi(i).get_etat() != ETATZERO)
147 derive_r.set(i) = tbi(i).dsdr() ;
148 else
149 derive_r.set(i).set_etat_zero() ;
150 }
151
152 // On enleve un fonction pour rendre Kij regulier !
153
154 Valeur val_hor (shift_auto.get_mp()->get_mg()) ;
155 Valeur fonction_radiale (shift_auto.get_mp()->get_mg()) ;
156 Cmp enleve (shift_auto.get_mp()) ;
157
158 double erreur = 0 ;
159 for (int comp=0 ; comp<3 ; comp++)
160 {
161 val_hor.annule_hard() ; // Pour initialiser les tableaux
162 for (int k=0 ; k<np ; k++)
163 for (int j=0 ; j<nt ; j++)
164 for (int i=0 ; i<nr ; i++)
165 val_hor.set(1, k, j, i) = derive_r(comp) (1, k, j, 0) ;
166
167 double r_0 = shift_auto.get_mp()->val_r (1, -1, 0, 0) ;
168 double r_1 = shift_auto.get_mp()->val_r (1, 1, 0, 0) ;
169
170 fonction_radiale = pow(r_1-shift_auto.get_mp()->r, 3.)*
171 (shift_auto.get_mp()->r-r_0)/pow(r_1-r_0, 3.) ;
172 fonction_radiale.annule(0) ;
173 fonction_radiale.annule(2, nz-1) ;
174
175 enleve = fonction_radiale * val_hor ;
176 enleve.va.base = shift_auto(comp).va.base ;
177
178 if (norme(enleve)(1) != 0)
179 shift_auto.set(comp) = shift_auto(comp) - enleve ;
180 if (norme(shift_auto(comp))(1) > 1e-5) {
181 Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
182 if (erreur < diff(1))
183 erreur = diff(1) ;
184 }
185 }
186 return erreur ;
187}
188}
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition cmp.h:446
Multi-domain array.
Definition mtbl.h:118
Basic array class.
Definition tbl.h:161
Tensor handling *** DEPRECATED : use class Tensor instead ***.
Definition tenseur.h:304
Values and coefficients of a (real-value) function.
Definition valeur.h:297
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
Lorene prototypes.
Definition app_hor.h:67
Coord r
r coordinate centered on the grid
Definition map.h:730