LORENE
hot_strot_diff_cfc_faitomeg.C
1 /*
2  * Functions Hot_star_rot_diff_CFC::fait_omega_field
3  * Hot_star_rot_diff_CFC::fait_prim_field
4  *
5  * (see file hot_star_rot_diff_cfc.h for documentation).
6  *
7  */
8 
9 /*
10  * Copyright (c) 2025 Santiago Jaraba
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 // Lorene headers
31 #include "hot_star_rot_diff_cfc.h"
32 #include "utilitaires.h"
33 #include "param.h"
34 
35 namespace Lorene {
36  namespace {
37  const Hot_star_rot_diff_CFC* p_hotstar = nullptr;
38  }
39 
40  double strot_diff_fzero(double omeg, const Param& par) ;
41 
42  //-----------------------------------//
43  // fait_omega_field //
44  //-----------------------------------//
45 
46  void Hot_star_rot_diff_CFC::fait_omega_field(double omeg_min, double omeg_max,
47  double precis, int nitermax) {
48 
49  const Mg3d& mg = *(mp.get_mg()) ;
50  int nz = mg.get_nzone() ;
51  int nzm1 = nz - 1 ;
52 
53  // Computation of auxiliary quantities:
54  // -----------------------------------
55 
56  Scalar nnn2 = nn * nn ;
57  Scalar rsint(mp) ;
58  rsint = 1 ;
59  rsint.annule_domain(nzm1) ;
60  rsint.std_spectral_base() ;
61  rsint.mult_rsint() ;
62 
63  Param par ;
64  par.add_scalar(nnn2, 0) ;
65  par.add_scalar(psi4, 1) ;
66  par.add_scalar(beta(3), 2) ;
67  par.add_scalar(rsint, 3) ;
68 
69  int l, k, j, i ;
70  par.add_int(l, 0) ;
71  par.add_int(k, 1) ;
72  par.add_int(j, 2) ;
73  par.add_int(i, 3) ;
74 
75  // par.add_star(*this) ;
76  p_hotstar = this ;
77 
78  // Loop on the grid points
79  // -----------------------
80 
81  int niter ;
82 
83  bool prev_zero = (omega_field.get_etat() == ETATZERO) ;
84 
86 
87  for (l=0; l<nzet+1; l++) {
88  Tbl& tom = omega_field.set_domain(l) ;
89  for (k=0; k<mg.get_np(l); k++) {
90  for (j=0; j<mg.get_nt(l); j++) {
91  for (i=0; i<mg.get_nr(l); i++) {
92 
93  double& omeg = tom.set(k, j, i) ;
94 
95  double omeg_min1, omeg_max1 ;
96  if ( prev_zero || omeg == double(0)) {
97  omeg_min1 = omeg_min ;
98  omeg_max1 = omeg_max ;
99  }
100  else{
101  omeg_min1 = 0.8 * omeg ;
102  omeg_max1 = 1.2 * omeg ;
103  }
104 
105  omeg = zerosec(strot_diff_fzero, par, omeg_min1,
106  omeg_max1, precis, nitermax, niter) ;
107 
108  }
109  }
110  }
111  }
112 
113  p_hotstar = nullptr ;
114 
115  // omega_field is set to 0 far from the star:
116  // ---------------------------------------------------
117  for (l=nzet+1; l<nz; l++) {
118  omega_field.set_domain(l) = 0 ;
119  }
120 
122 
123  // Min and Max of Omega
124  // --------------------
125 
126  omega_min = min( omega_field.domain(0) ) ;
127  for (l=1; l<nzet; l++) {
128  double xx = min( omega_field.domain(l) ) ;
129  omega_min = (xx < omega_min) ? xx : omega_min ;
130  }
131 
132  omega_max = max( max( omega_field ) ) ;
133 
134  // Update of prim_field
135  // --------------------
136  fait_prim_field() ;
137 
138 }
139 
140 
141  //----------------------------------------//
142  // strot_diff_fzero //
143  //----------------------------------------//
144 
145 double strot_diff_fzero(double omeg, const Param& par) {
146 
147  const Scalar& nnn2 = par.get_scalar(0) ;
148  const Scalar& p4 = par.get_scalar(1) ;
149  const Scalar& beta_phi = par.get_scalar(2) ;
150  const Scalar& rsint = par.get_scalar(3) ;
151  int l = par.get_int(0) ;
152  int k = par.get_int(1) ;
153  int j = par.get_int(2) ;
154  int i = par.get_int(3) ;
155 
156  //const Hot_star_rot_diff_CFC* star =
157  // dynamic_cast<const Hot_star_rot_diff_CFC*>(&par.get_star()) ;
158 
159  double omnp = omeg*rsint.val_grid_point(l, k, j, i) + beta_phi.val_grid_point(l, k, j, i) ;
160  double fom = p4.val_grid_point(l, k, j, i)*rsint.val_grid_point(l, k, j, i) * omnp /
161  ( nnn2.val_grid_point(l, k, j, i) -
162  p4.val_grid_point(l, k, j, i) * omnp * omnp ) ;
163 
164  // cout << omeg << " " << omeg - star->omega_funct(fom) << endl ;
165 
166  return omeg - p_hotstar->omega_funct(fom) ;
167 
168 }
169 
170 
171  //-----------------------------------//
172  // fait_prim_field //
173  //-----------------------------------//
174 
175 
177 
178  const Mg3d& mg = *(mp.get_mg()) ;
179  int nz = mg.get_nzone() ;
180  int nzm1 = nz - 1 ;
181 
182  Scalar rsint(mp) ;
183  rsint = 1 ;
184  rsint.annule_domain(nzm1) ;
185  rsint.std_spectral_base() ;
186  rsint.mult_rsint() ;
187 
188  Scalar nnn2 = nn * nn ;
189 
190  // Loop on the grid points in the vicinity of the star
191  // ---------------------------------------------------
192 
194 
195  for (int l=0; l<nzet+1; l++) {
196  Tbl& tprim = prim_field.set_domain(l) ;
197  for (int k=0; k<mg.get_np(l); k++) {
198  for (int j=0; j<mg.get_nt(l); j++) {
199  for (int i=0; i<mg.get_nr(l); i++) {
200  double omnp = omega_field.val_grid_point(l, k, j, i)*rsint.val_grid_point(l, k, j, i)
201  + beta(3).val_grid_point(l, k, j, i) ;
202 
203  double F = psi4.val_grid_point(l, k, j, i)*rsint.val_grid_point(l, k, j, i) * omnp /
204  ( nnn2.val_grid_point(l, k, j, i) -
205  psi4.val_grid_point(l, k, j, i) * omnp * omnp ) ;
206 
207  tprim.set(k, j, i) =
208  primfrot( F, par_frot ) ;
209 
210  }
211  }
212  }
213  }
214 
215  // prim_field is set to 0 far from the star:
216  // -----------------------------------------
217  for (int l=nzet+1; l<nz; l++) {
218  prim_field.set_domain(l) = 0 ;
219  }
220 
222 
223 
224 }
225 
226 }
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition: tensor.C:676
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:481
const Tbl & domain(int l) const
Read-only of the value in a given domain.
Definition: scalar.h:640
Lorene prototypes.
Definition: app_hor.h:67
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Definition: map.h:791
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:402
Tbl par_frot
Parameters of the function .
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Definition: scalar.C:790
virtual void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
Definition: scalar.C:371
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition: scalar.h:569
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition: cmp_math.C:461
Scalar nn
Lapse function N .
Definition: hot_star.h:130
Tbl & set_domain(int l)
Read/write of the value in a given domain.
Definition: scalar.h:630
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
double val_grid_point(int l, int k, int j, int i) const
Returns the value of the field at a specified grid point.
Definition: scalar.h:652
const Scalar & get_scalar(int position=0) const
Returns the reference of a Scalar stored in the list.
Definition: param.C:1396
int nzet
Number of domains of *mp occupied by the star.
Definition: hot_star.h:84
const int & get_int(int position=0) const
Returns the reference of a int stored in the list.
Definition: param.C:295
Parameter storage.
Definition: param.h:125
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:467
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
Map & mp
Mapping associated with the star.
Definition: hot_star.h:81
Scalar psi4
Conformal factor .
void mult_rsint()
Multiplication by everywhere; dzpuis is not changed.
double(* primfrot)(double, const Tbl &)
Primitive of the function , which vanishes at the stellar center.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:471
Multi-domain grid.
Definition: grilles.h:276
void add_scalar(const Scalar &ti, int position=0)
Adds the address of a new Scalar to the list.
Definition: param.C:1351
void fait_omega_field(double omeg_min, double omeg_max, double precis, int nitermax)
Computes (member omega_field ).
double omega_max
Maximum value of .
void fait_prim_field()
Computes the member prim_field from omega_field .
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:476
double omega_min
Minimum value of .
Vector beta
Shift vector.
Definition: hot_star.h:133