LORENE
et_rot_diff_faitomeg.C
1 /*
2  * Functions Et_rot_diff::fait_omega_field
3  * Et_rot_diff::fait_prim_field
4  *
5  * (see file et_rot_diff.h for documentation).
6  *
7  */
8 
9 /*
10  * Copyright (c) 2001 Eric Gourgoulhon
11  *
12  * This file is part of LORENE.
13  *
14  * LORENE is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * LORENE is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with LORENE; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27  *
28  */
29 
30 
31 
32 
33 /*
34  * $Id: et_rot_diff_faitomeg.C,v 1.4 2016/12/05 16:17:53 j_novak Exp $
35  * $Log: et_rot_diff_faitomeg.C,v $
36  * Revision 1.4 2016/12/05 16:17:53 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.3 2014/10/13 08:52:57 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.2 2003/05/14 20:07:00 e_gourgoulhon
43  * Suppressed the outputs (cout)
44  *
45  * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
46  * LORENE
47  *
48  * Revision 1.3 2001/10/25 09:43:18 eric
49  * omega_min est determine dans l'etoile seulement (l<nzet).
50  *
51  * Revision 1.2 2001/10/25 09:21:29 eric
52  * Recherche de Omega dans un intervalle de 20% autour de la valeur precedente.
53  *
54  * Revision 1.1 2001/10/19 08:18:23 eric
55  * Initial revision
56  *
57  *
58  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_diff_faitomeg.C,v 1.4 2016/12/05 16:17:53 j_novak Exp $
59  *
60  */
61 
62 
63 // Headers Lorene
64 #include "et_rot_diff.h"
65 #include "utilitaires.h"
66 #include "param.h"
67 
68 namespace Lorene {
69 double et_rot_diff_fzero(double omeg, const Param& par) ;
70 
71 
72  //-----------------------------------//
73  // fait_omega_field //
74  //-----------------------------------//
75 
76 void Et_rot_diff::fait_omega_field(double omeg_min, double omeg_max,
77  double precis, int nitermax) {
78 
79  const Mg3d& mg = *(mp.get_mg()) ;
80  int nz = mg.get_nzone() ;
81  int nzm1 = nz - 1 ;
82 
83  // Computation of B^2 r^2 sin^2(theta):
84  // -----------------------------------
85 
86  Cmp brst2 = bbb() ;
87  brst2.annule(nzm1) ;
88  brst2.std_base_scal() ;
89  brst2.mult_rsint() ; // Multiplication by r sin(theta)
90  brst2 = brst2*brst2 ;
91 
92  Cmp nnn2 = nnn() * nnn() ;
93 
94  Param par ;
95  par.add_cmp(nnn2, 0) ;
96  par.add_cmp(brst2, 1) ;
97  par.add_cmp(nphi(), 2) ;
98 
99  int l, k, j, i ;
100  par.add_int(l, 0) ;
101  par.add_int(k, 1) ;
102  par.add_int(j, 2) ;
103  par.add_int(i, 3) ;
104 
105  par.add_etoile(*this) ;
106 
107  // Loop on the grid points
108  // -----------------------
109 
110  int niter ;
111 
112  bool prev_zero = (omega_field.get_etat() == ETATZERO) ;
113 
115 
116  // cout << "Et_rot_diff::fait_omega_field: niter : " << endl ;
117  for (l=0; l<nzet+1; l++) {
118  Tbl& tom = omega_field.set().set(l) ;
119  for (k=0; k<mg.get_np(l); k++) {
120  for (j=0; j<mg.get_nt(l); j++) {
121  for (i=0; i<mg.get_nr(l); i++) {
122 
123  double& omeg = tom.set(k, j, i) ;
124 
125  double omeg_min1, omeg_max1 ;
126  if ( prev_zero || omeg == double(0)) {
127  omeg_min1 = omeg_min ;
128  omeg_max1 = omeg_max ;
129  }
130  else{
131  omeg_min1 = 0.8 * omeg ;
132  omeg_max1 = 1.2 * omeg ;
133  }
134 
135  omeg = zerosec(et_rot_diff_fzero, par, omeg_min1,
136  omeg_max1, precis, nitermax, niter) ;
137 
138  // cout << " " << niter ;
139 
140  }
141  }
142  }
143  // cout << endl ;
144  }
145 
146  // omega_field is set to 0 far from the star:
147  // ---------------------------------------------------
148  for (l=nzet+1; l<nz; l++) {
149  omega_field.set().set(l) = 0 ;
150  }
151 
153 
154  // Min and Max of Omega
155  // --------------------
156 
157  omega_min = min( omega_field()(0) ) ;
158  for (l=1; l<nzet; l++) {
159  double xx = min( omega_field()(l) ) ;
160  omega_min = (xx < omega_min) ? xx : omega_min ;
161  }
162 
163  omega_max = max( max( omega_field() ) ) ;
164 
165  // Update of prim_field
166  // --------------------
167  fait_prim_field() ;
168 
169 }
170 
171  //-----------------------------------//
172  // et_rot_diff_fzero //
173  //-----------------------------------//
174 
175 double et_rot_diff_fzero(double omeg, const Param& par) {
176 
177  const Cmp& nnn2 = par.get_cmp(0) ;
178  const Cmp& brst2 = par.get_cmp(1) ;
179  const Cmp& nphi = par.get_cmp(2) ;
180  int l = par.get_int(0) ;
181  int k = par.get_int(1) ;
182  int j = par.get_int(2) ;
183  int i = par.get_int(3) ;
184 
185  const Et_rot_diff* et =
186  dynamic_cast<const Et_rot_diff*>(&par.get_etoile()) ;
187 
188  double fom = et->funct_omega(omeg) ;
189  double omnp = omeg - nphi(l, k, j, i) ;
190 
191  return fom - brst2(l, k, j, i) * omnp /
192  ( nnn2(l, k, j, i) - brst2(l, k, j, i) * omnp*omnp ) ;
193 
194 }
195 
196 
197  //-----------------------------------//
198  // fait_prim_field //
199  //-----------------------------------//
200 
201 
203 
204  const Mg3d& mg = *(mp.get_mg()) ;
205  int nz = mg.get_nzone() ;
206 
207  // Loop on the grid points in the vicinity of the star
208  // ---------------------------------------------------
209 
211 
212  for (int l=0; l<nzet+1; l++) {
213  Tbl& tprim = prim_field.set().set(l) ;
214  for (int k=0; k<mg.get_np(l); k++) {
215  for (int j=0; j<mg.get_nt(l); j++) {
216  for (int i=0; i<mg.get_nr(l); i++) {
217 
218  tprim.set(k, j, i) =
219  primfrot( omega_field()(l, k, j, i), par_frot ) ;
220 
221  }
222  }
223  }
224  }
225 
226  // prim_field is set to 0 far from the star:
227  // -----------------------------------------
228  for (int l=nzet+1; l<nz; l++) {
229  prim_field.set().set(l) = 0 ;
230  }
231 
233 
234 
235 }
236 }
const Etoile & get_etoile(int position=0) const
Returns the reference of a Etoile stored in the list.
Definition: param.C:1672
const Cmp & get_cmp(int position=0) const
Returns the reference of a Cmp stored in the list.
Definition: param.C:983
Tenseur prim_field
Field .
Definition: et_rot_diff.h:114
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
Definition: param.C:249
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
void annule(int l)
Sets the Cmp to zero in a given domain.
Definition: cmp.C:351
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Definition: tenseur.C:1186
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:777
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
Tenseur nnn
Total lapse function.
Definition: etoile.h:512
Tenseur nphi
Metric coefficient .
Definition: etoile.h:1513
double(* primfrot)(double, const Tbl &)
Primitive of the function , which vanishes at the stellar center.
Definition: et_rot_diff.h:96
void fait_omega_field(double omeg_min, double omeg_max, double precis, int nitermax)
Computes (member omega_field ).
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition: cmp_math.C:461
double funct_omega(double omeg) const
Evaluates , where F is the function defining the rotation profile.
Definition: et_rot_diff.C:318
double omega_max
Maximum value of .
Definition: et_rot_diff.h:111
double zerosec(double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter, bool abort=true)
Finding the zero a function.
Definition: zerosec.C:92
Class for differentially rotating stars.
Definition: et_rot_diff.h:73
void fait_prim_field()
Computes the member prim_field from omega_field .
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Definition: tenseur.C:840
const int & get_int(int position=0) const
Returns the reference of a int stored in the list.
Definition: param.C:295
void add_cmp(const Cmp &ti, int position=0)
Adds the address of a new Cmp to the list.
Definition: param.C:938
Tbl par_frot
Parameters of the function .
Definition: et_rot_diff.h:105
Parameter storage.
Definition: param.h:125
void mult_rsint()
Multiplication by .
Definition: cmp_r_manip.C:119
Map & mp
Mapping associated with the star.
Definition: etoile.h:432
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
int get_etat() const
Returns the logical state.
Definition: tenseur.h:710
Tenseur bbb
Metric factor B.
Definition: etoile.h:1507
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
Definition: cmp.C:647
void add_etoile(const Etoile &eti, int position=0)
Adds the address of a new Etoile to the list.
Definition: param.C:1627
int nzet
Number of domains of *mp occupied by the star.
Definition: etoile.h:435
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Multi-domain grid.
Definition: grilles.h:279
Tbl & set(int l)
Read/write of the value in a given domain.
Definition: cmp.h:724
void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
Definition: tenseur.C:673
Basic array class.
Definition: tbl.h:164
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
double omega_min
Minimum value of .
Definition: et_rot_diff.h:110
Tenseur omega_field
Field .
Definition: et_rot_diff.h:108