File: tslice_conf_init.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,472 kB
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (350 lines) | stat: -rw-r--r-- 12,817 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*
 *  Method of class Time_slice_conf to compute valid initial data
 *
 *    (see file time_slice.h for documentation).
 *
 */

/*
 *   Copyright (c) 2004  Eric Gourgoulhon & Jerome Novak
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2
 *   as published by the Free Software Foundation.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

char tslice_conf_init_C[] = "$Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_conf_init.C,v 1.13 2014/10/13 08:53:48 j_novak Exp $" ;

/*
 * $Id: tslice_conf_init.C,v 1.13 2014/10/13 08:53:48 j_novak Exp $
 * $Log: tslice_conf_init.C,v $
 * Revision 1.13  2014/10/13 08:53:48  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.12  2014/10/06 15:13:22  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.11  2010/10/20 07:58:09  j_novak
 * Better implementation of the explicit time-integration. Not fully-tested yet.
 *
 * Revision 1.10  2008/12/04 18:22:49  j_novak
 * Enhancement of the dzpuis treatment + various bug fixes.
 *
 * Revision 1.9  2008/12/02 15:02:22  j_novak
 * Implementation of the new constrained formalism, following Cordero et al. 2009
 * paper. The evolution eqs. are solved as a first-order system. Not tested yet!
 *
 * Revision 1.8  2004/05/17 19:53:13  e_gourgoulhon
 * Added arguments graph_device and  method_poisson_vect.
 *
 * Revision 1.7  2004/05/12 15:24:20  e_gourgoulhon
 * Reorganized the #include 's, taking into account that
 * time_slice.h contains now an #include "metric.h".
 *
 * Revision 1.6  2004/05/10 09:12:01  e_gourgoulhon
 * Added a call to del_deriv() at the end.
 *
 * Revision 1.5  2004/05/03 14:48:48  e_gourgoulhon
 * Treatment of special cases nn_jp1.etat = ETATUN and psi_jp1.etat = ETATUN.
 *
 * Revision 1.4  2004/04/29 17:10:36  e_gourgoulhon
 * Added argument pdt and update of depth slices at the end,
 * taking into account the known time derivatives.
 *
 * Revision 1.3  2004/04/08 16:45:11  e_gourgoulhon
 * Use of new methods set_*.
 *
 * Revision 1.2  2004/04/07 07:58:21  e_gourgoulhon
 * Constructor as Minkowski slice: added call to std_spectral_base()
 * after setting the lapse to 1.
 *
 * Revision 1.1  2004/04/05 21:25:37  e_gourgoulhon
 * First version.
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Time_slice/tslice_conf_init.C,v 1.13 2014/10/13 08:53:48 j_novak Exp $
 *
 */

// C headers
#include <cassert>

// Lorene headers
#include "time_slice.h"
#include "unites.h"
#include "graphique.h"
#include "utilitaires.h"

namespace Lorene {
void Time_slice_conf::initial_data_cts(const Sym_tensor& uu, 
                const Scalar& trk_in, const Scalar& trk_point, 
                double pdt, double precis, int method_poisson_vect,
                const char* graph_device, const Scalar* p_ener_dens, 
                const Vector* p_mom_dens, const Scalar* p_trace_stress) {

    using namespace Unites ;

    // Verifications
    // -------------
    double tr_uu = max(maxabs(uu.trace(tgam()), "trace tgam_{ij} u^{ij}")) ; 
    if (tr_uu > 1.e-7) {
        cerr << 
        "Time_slice_conf::initial_data_cts : the trace of u^{ij} with respect\n"
        << "  to the conformal metric tgam_{ij} is not zero !\n" 
        << "  error = " << tr_uu << endl ; 
        abort() ; 
    }

    assert(trk_in.check_dzpuis(2)) ; 
    assert(trk_point.check_dzpuis(4)) ; 

    // Initialisations
    // ---------------
    double ttime = the_time[jtime] ; 
         
    trk_evol.update(trk_in, jtime, ttime) ; 

    // Reset of quantities depending on K:
    k_dd_evol.downdate(jtime) ; 
    k_uu_evol.downdate(jtime) ; 
   
    set_hata(psi4()*psi()*psi()* uu / (2.* nn()) ) ; 

    const Map& map = uu.get_mp() ; 
    const Base_vect& triad = *(uu.get_triad()) ;
    
    // For graphical outputs:
    int ngraph0 = 10 ;  // index of the first graphic device to be used
    int nz = map.get_mg()->get_nzone() ; 
    double ray_des = 1.25 * map.val_r(nz-2, 1., 0., 0.) ; // outermost radius
                                                          // for plots

    Scalar ener_dens(map) ; 
    if (p_ener_dens != 0x0) ener_dens = *(p_ener_dens) ; 
    else ener_dens.set_etat_zero() ; 
    
    Vector mom_dens(map, CON, triad) ; 
    if (p_mom_dens != 0x0) mom_dens = *(p_mom_dens) ; 
    else mom_dens.set_etat_zero() ; 
    
    Scalar trace_stress(map) ; 
    if (p_trace_stress != 0x0) trace_stress = *(p_trace_stress) ; 
    else trace_stress.set_etat_zero() ; 
    
    Scalar tmp(map) ; 
    Scalar source_psi(map) ; 
    Scalar source_nn(map) ; 
    Vector source_beta(map, CON, triad) ; 
    
    // Iteration
    // ---------
    int imax = 100 ; 
    for (int i=0; i<imax; i++) {
    
        //===============================================
        //  Computations of sources 
        //===============================================
    
        const Vector& dpsi = psi().derive_cov(ff) ;       // D_i Psi
        const Vector& dln_psi = ln_psi().derive_cov(ff) ; // D_i ln(Psi)
        const Vector& dnn = nn().derive_cov(ff) ;         // D_i N
        
        Sym_tensor taa = aa().up_down(tgam()) ;         
        Scalar aa_quad = contract(taa, 0, 1, aa(), 0, 1) ; 

        // Source for Psi 
        // --------------
        tmp = 0.125* psi() * tgam().ricci_scal() 
                - contract(hh(), 0, 1, dpsi.derive_cov(ff), 0, 1 ) ;
        tmp.inc_dzpuis() ; // dzpuis : 3 -> 4

        tmp -= contract(hdirac(), 0, dpsi, 0) ;  
                
        source_psi = tmp - psi()*psi4()* ( 0.5*qpig* ener_dens 
                        + 0.125* aa_quad 
                       - 8.33333333333333e-2* trk()*trk() ) ;  
                               
        // Source for N 
        // ------------
        
        source_nn = psi4()*( nn()*( qpig* (ener_dens + trace_stress) + aa_quad
                                    - 0.3333333333333333* trk()*trk() )
                             - trk_point ) 
                    - 2.* contract(dln_psi, 0, nn().derive_con(tgam()), 0)  
                    - contract(hdirac(), 0, dnn, 0) ; 
        
        tmp = psi4()* contract(beta(), 0, trk().derive_cov(ff), 0)
                - contract( hh(), 0, 1, dnn.derive_cov(ff), 0, 1 ) ;
        
        tmp.inc_dzpuis() ; // dzpuis: 3 -> 4
        
        source_nn += tmp ;


        // Source for beta 
        // ---------------

        source_beta = 2.* contract(aa(), 1, 
                                   dnn - 6.*nn() * dln_psi, 0) ;
                
        source_beta += 2.* nn() * ( 2.*qpig* psi4() * mom_dens 
            + 0.66666666666666666* trk().derive_con(tgam()) 
            - contract(tgam().connect().get_delta(), 1, 2, 
                                  aa(), 0, 1) ) ;
            
        Vector vtmp = contract(hh(), 0, 1, 
                           beta().derive_cov(ff).derive_cov(ff), 1, 2)
                + 0.3333333333333333*
                  contract(hh(), 1, beta().divergence(ff).derive_cov(ff), 0) 
                - hdirac().derive_lie(beta()) 
                + uu.divergence(ff) ; 
        vtmp.inc_dzpuis() ; // dzpuis: 3 -> 4
                    
        source_beta -= vtmp ; 
        
        source_beta += 0.66666666666666666* beta().divergence(ff) * hdirac() ;
        

        //=============================================
        // Resolution of elliptic equations
        //=============================================
        
        // Resolution of the Poisson equation for Psi
        // ------------------------------------------
        
        Scalar psi_jp1 = source_psi.poisson() + 1. ; 

        if (psi_jp1.get_etat() == ETATUN) psi_jp1.std_spectral_base() ; 

        // Test:
        maxabs(psi_jp1.laplacian() - source_psi,
                "Absolute error in the resolution of the equation for Psi") ;  

        des_meridian(psi_jp1, 0., ray_des, "Psi", ngraph0, graph_device) ; 

        // Resolution of the Poisson equation for the lapse
        // ------------------------------------------------
        
        Scalar nn_jp1 = source_nn.poisson() + 1. ; 

        if (nn_jp1.get_etat() == ETATUN) nn_jp1.std_spectral_base() ; 

        // Test:
        maxabs(nn_jp1.laplacian() - source_nn,
                "Absolute error in the resolution of the equation for N") ;  

        des_meridian(nn_jp1, 0., ray_des, "N", ngraph0+1, graph_device) ; 
        
        // Resolution of the vector Poisson equation for the shift
        //---------------------------------------------------------
        
        Vector beta_jp1 = source_beta.poisson(0.3333333333333333, ff, 
                                              method_poisson_vect) ; 
        
        des_meridian(beta_jp1(1), 0., ray_des, "\\gb\\ur\\d", ngraph0+2, 
                     graph_device) ; 
        des_meridian(beta_jp1(2), 0., ray_des, "\\gb\\u\\gh\\d", ngraph0+3, 
                     graph_device) ; 
        des_meridian(beta_jp1(3), 0., ray_des, "\\gb\\u\\gf\\d", ngraph0+4, 
                     graph_device) ; 
        
        // Test:
        Vector test_beta = (beta_jp1.derive_con(ff)).divergence(ff)
            +  0.3333333333333333 * (beta_jp1.divergence(ff)).derive_con(ff) ;
        test_beta.inc_dzpuis() ;  
        maxabs(test_beta - source_beta,
                "Absolute error in the resolution for beta") ; 

        //===========================================
        //      Convergence control
        //===========================================
    
        double diff_psi = max( diffrel(psi(), psi_jp1) ) ; 
        double diff_nn = max( diffrel(nn(), nn_jp1) ) ; 
        double diff_beta = max( diffrel(beta(), beta_jp1) ) ; 
        
        cout << "step = " << i << " :  diff_psi = " << diff_psi 
             << "  diff_nn = " << diff_nn
             << "  diff_beta = " << diff_beta << endl ; 
        if ( (diff_psi < precis) && (diff_nn < precis) && (diff_beta < precis) )
            break ; 

        //=============================================
        //      Updates for next step 
        //=============================================

        set_psi_del_npsi(psi_jp1) ; 
     
        n_evol.update(nn_jp1, jtime, ttime) ; 

        beta_evol.update(beta_jp1, jtime, ttime) ; 

        // New value of A^{ij}:
        Sym_tensor aa_jp1 = ( beta().ope_killing_conf(tgam()) + uu ) 
                                / (2.* nn()) ; 
        
        set_hata( aa_jp1 / (psi4()*psi()*psi()) ) ; 

    }
    
    //==================================================================
    // End of iteration 
    //===================================================================

    npsi_evol.update( n_evol[jtime]*psi_evol[jtime], jtime, ttime ) ;
    A_hata() ;
    B_hata() ;

    // Push forward in time to enable the computation of time derivatives
    // ------------------------------------------------------------------
    
    double ttime1 = ttime ; 
    int jtime1 = jtime ; 
    for (int j=1; j < depth; j++) {
        jtime1++ ; 
        ttime1 += pdt ; 
        psi_evol.update(psi_evol[jtime], jtime1, ttime1) ;  
        npsi_evol.update(npsi_evol[jtime], jtime1, ttime1) ;  
        n_evol.update(n_evol[jtime], jtime1, ttime1) ;  
        beta_evol.update(beta_evol[jtime], jtime1, ttime1) ;  
        hh_evol.update(hh_evol[jtime], jtime1, ttime1) ;
        hata_evol.update(hata_evol[jtime], jtime1, ttime1) ;
	A_hata_evol.update(A_hata_evol[jtime], jtime1, ttime1) ;
	B_hata_evol.update(B_hata_evol[jtime], jtime1, ttime1) ;
        trk_evol.update(trk_evol[jtime], jtime1, ttime1) ;
        the_time.update(ttime1, jtime1, ttime1) ;         
    } 
    jtime += depth - 1 ; 
    
    // Taking into account the time derivative of h^{ij} and K : 
    // ---------------------------------------------------------
    Sym_tensor uu0 = uu ; 
    uu0.dec_dzpuis(2) ; // dzpuis: 2 --> 0
    
    for (int j=1; j < depth; j++) {
        hh_evol.update(hh_evol[jtime] - j*pdt* uu0, 
                       jtime-j, the_time[jtime-j]) ;
                       
        trk_evol.update(trk_evol[jtime] - j*pdt* trk_point, 
                       jtime-j, the_time[jtime-j]) ;
                       
    } 
    
    // Reset of derived quantities (at the new time step jtime)
    // ---------------------------
    del_deriv() ; 
    
} 
}