File: get_operateur.C

package info (click to toggle)
lorene 0.0.0~cvs20161116%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, stretch
  • size: 26,444 kB
  • ctags: 13,953
  • sloc: cpp: 212,946; fortran: 21,645; makefile: 1,750; sh: 4
file content (573 lines) | stat: -rw-r--r-- 21,125 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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
/*
 *   Copyright (c) 2000-2001 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 as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   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 get_operateur_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/get_operateur.C,v 1.9 2014/10/13 08:53:28 j_novak Exp $" ;

/*
 * $Id: get_operateur.C,v 1.9 2014/10/13 08:53:28 j_novak Exp $
 * $Log: get_operateur.C,v $
 * Revision 1.9  2014/10/13 08:53:28  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.8  2014/10/06 15:16:08  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.7  2008/08/27 08:51:15  jl_cornou
 * Added Jacobi(0,2) polynomials
 *
 * Revision 1.6  2005/01/27 10:19:43  j_novak
 * Now using Diff operators to build the matrices.
 *
 * Revision 1.5  2003/06/18 08:45:27  j_novak
 * In class Mg3d: added the member get_radial, returning only a radial grid
 * For dAlembert solver: the way the coefficients of the operator are defined has been changed.
 *
 * Revision 1.4  2002/01/03 15:30:28  j_novak
 * Some comments modified.
 *
 * Revision 1.3  2002/01/03 13:18:41  j_novak
 * Optimization: the members set(i,j) and operator(i,j) of class Matrice are
 * now defined inline. Matrice is a friend class of Tbl.
 *
 * Revision 1.2  2002/01/02 14:07:57  j_novak
 * Dalembert equation is now solved in the shells. However, the number of
 * points in theta and phi must be the same in each domain. The solver is not
 * completely tested (beta version!).
 *
 * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
 * LORENE
 *
 * Revision 1.3  2001/10/29  10:55:28  novak
 * Error fixed for r^2 d^2/dr^2 operator
 *
 * Revision 1.2  2000/12/18 13:33:46  novak
 * *** empty log message ***
 *
 * Revision 1.1  2000/12/04 16:36:50  novak
 * Initial revision
 *
 *
 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/get_operateur.C,v 1.9 2014/10/13 08:53:28 j_novak Exp $
 *
 */

// Header C : 
#include <cmath>

// Headers Lorene :
#include "param.h"
#include "base_val.h"
#include "diff.h"
#include "proto.h"

/*************************************************************************
 *
 * Routine used by sol_dalembert, to compute the matrix of the operator
 * to be solved. The coefficients (Ci) are stored in par.get_tbl_mod(1->9)
 * The time-step is par.get_double(0). Other inputs are:
 * l: spherical harmonic number
 * alpha, beta: coefficients of the affine mapping (see map.h)
 * Outputs are: type_dal : type of the operator (see type_parite.h)
 *              operateur: matrix of the operator
 * 
 * The operator reads: 
 * 
 *  Indentity - 0.5*dt^2 [ (C1 + C3r^2) d^2/dr^2 + (C6/r + C5r) d/dr
 *                         (C9/r^2 + C7) Id ] 
 * 
 *************************************************************************/



		//-----------------------------------
		// Routine pour les cas non prevus --
		//-----------------------------------

namespace Lorene {
void _get_operateur_dal_pas_prevu(const Param& , const int&, int& , Matrice& )
{
    cout << "get_operateur_dal pas prevu..." << endl ;
    abort() ;
    exit(-1) ;
}


void _get_operateur_dal_r_cheb(const Param& par, const int& lz, 
int& type_dal, Matrice& operateur)
{
  int nr = operateur.get_dim(0) ;
  assert (nr == operateur.get_dim(1)) ;
  assert (par.get_n_double() > 0) ;
  assert (par.get_n_tbl_mod() > 0) ;
  assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
  assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;

  double dt = par.get_double(0) ;
  dt *= 0.5*dt ;

  // Copies the global coefficients to a local Tbl 
    Tbl coeff(10) ;
    coeff.set_etat_qcq() ;
    coeff.set(1) = (par.get_tbl_mod())(1,lz) ;
    coeff.set(2) = (par.get_tbl_mod())(2,lz) ;
    coeff.set(3) = (par.get_tbl_mod())(3,lz) ;
    coeff.set(4) = (par.get_tbl_mod())(4,lz) ;
    coeff.set(5) = (par.get_tbl_mod())(5,lz) ;
    coeff.set(6) = (par.get_tbl_mod())(6,lz) ;
    coeff.set(7) = (par.get_tbl_mod())(7,lz) ;
    coeff.set(8) = (par.get_tbl_mod())(8,lz) ;
    coeff.set(9) = (par.get_tbl_mod())(9,lz) ;
    double R1 = (par.get_tbl_mod())(10,lz) ;
    double R2 = (par.get_tbl_mod())(11,lz) ;

    double a00 = 0. ; double a01 = 0. ; double  a02 = 0. ; 
    double a10 = 0. ; double a11 = 0. ; double  a12 = 0. ; 
    double a13 = 0. ; double a20 = 0. ; double  a21 = 0. ; 
    double a22 = 0. ; double a23 = 0. ; double  a24 = 0. ; 

    bool dege = (fabs(coeff(9)) < 1.e-10) ;
     switch (dege) {
     case true:
      a00 = R1 - dt*(coeff(7)*R1 + coeff(8)) ;
      a01 = R2 - dt*R2*coeff(7) ;
      a02 = 0 ;
      a10 = -dt*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6))/R2 ;
      a11 = -dt*(coeff(4) + 2*R1*coeff(5)) ;
      a12 = -dt*R2*coeff(5) ;
      a13 = 0 ;
      a20 = -dt*R1/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
      a21 = -dt/R2*(coeff(1) + 2*R1*coeff(2) + 3*R1*R1*coeff(3)) ;
      a22 = -dt*(coeff(2) + 3*R1*coeff(3)) ;
      a23 = -dt*R2*coeff(3) ;
      a24 = 0 ;
      type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23))*nr*nr*nr 
 		   < 1.) ? O2DEGE_SMALL : O2DEGE_LARGE ) ;
       break ;
     case false:
      a00 = R1*R1 - dt*(coeff(7)*R1*R1 + coeff(8)*R1 + coeff(9)) ;
      a01 = 2*R1*R2 - dt*(2*R1*R2*coeff(7) + R2*coeff(8)) ;
      a02 = R2*R2*(1 - dt*coeff(7)) ;
      a10 = -dt*R1/R2*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6)) ;
      a11 = -dt*(2*R1*coeff(4) + 3*R1*R1*coeff(5) + coeff(6)) ;
      a12 = -dt*(R2*coeff(4) + 3*R1*R2*coeff(5)) ;
      a13 = -dt*R2*R2*coeff(5) ;
      a20 = -dt*(R1*R1)/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
      a21 = -dt*R1/R2*(2*coeff(1) + 3*R1*coeff(2) + 4*R1*R1*coeff(3)) ;
      a22 = -dt*(coeff(1) + 3*R1*coeff(2) + 6*R1*R1*coeff(3)) ;
      a23 = -dt*(R2*coeff(2) + 4*R1*R2*coeff(3)) ;
      a24 = -dt*R2*R2*coeff(3) ;
       type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23)+fabs(a24))
 		   *nr*nr*nr < 1.) ? O2NOND_SMALL : O2NOND_LARGE ) ;
       break ;
     }
    if (fabs(a00)<1.e-15) a00 = 0 ;
    if (fabs(a01)<1.e-15) a01 = 0 ;
    if (fabs(a02)<1.e-15) a02 = 0 ;
    if (fabs(a10)<1.e-15) a10 = 0 ;
    if (fabs(a11)<1.e-15) a11 = 0 ;
    if (fabs(a12)<1.e-15) a12 = 0 ;
    if (fabs(a13)<1.e-15) a13 = 0 ;
    if (fabs(a20)<1.e-15) a20 = 0 ;
    if (fabs(a21)<1.e-15) a21 = 0 ;
    if (fabs(a22)<1.e-15) a22 = 0 ;
    if (fabs(a23)<1.e-15) a23 = 0 ;
    if (fabs(a24)<1.e-15) a24 = 0 ;

    

    Diff_id id(R_CHEB, nr) ;
    if (fabs(a00)>1.e-15) {
	operateur = a00*id ;
    }
    else{
	operateur.set_etat_qcq() ;
	for (int i=0; i<nr; i++) 
	    for (int j=0; j<nr; j++)
		operateur.set(i,j) = 0. ;
    }
    Diff_mx op01(R_CHEB, nr) ; const Matrice& m01 = op01.get_matrice() ;
    Diff_mx2 op02(R_CHEB, nr) ; const Matrice& m02 = op02.get_matrice() ;
    Diff_dsdx op10(R_CHEB, nr) ; const Matrice& m10 = op10.get_matrice() ;
    Diff_xdsdx op11(R_CHEB, nr) ; const Matrice& m11 = op11.get_matrice() ;
    Diff_x2dsdx op12(R_CHEB, nr) ; const Matrice& m12 = op12.get_matrice() ;
    Diff_x3dsdx op13(R_CHEB, nr) ; const Matrice& m13 = op13.get_matrice() ;
    Diff_dsdx2 op20(R_CHEB, nr) ; const Matrice& m20 = op20.get_matrice() ;
    Diff_xdsdx2 op21(R_CHEB, nr) ; const Matrice& m21 = op21.get_matrice() ;
    Diff_x2dsdx2 op22(R_CHEB, nr) ; const Matrice& m22 = op22.get_matrice() ;
    Diff_x3dsdx2 op23(R_CHEB, nr) ; const Matrice& m23 = op23.get_matrice() ;
    Diff_x4dsdx2 op24(R_CHEB, nr) ; const Matrice& m24 = op24.get_matrice() ;

    for (int i=0; i<nr; i++) {
	int jmin = (i>3 ? i-3 : 0) ; 
	int jmax = (i<nr-9 ? i+10 : nr) ;
	for (int j=jmin ; j<jmax; j++) 
	    operateur.set(i,j) += a01*m01(i,j) + a02*m02(i,j) 
		+ a10*m10(i,j) + a11*m11(i,j) + a12*m12(i,j) 
		+ a13*m13(i,j) + a20*m20(i,j) + a21*m21(i,j)
		+ a22*m22(i,j) + a23*m23(i,j) + a24*m24(i,j) ;
	
    }
}

void _get_operateur_dal_r_chebp(const Param& par, const int& lzone, 
				int& type_dal, Matrice& operateur)
{
  assert(lzone == 0) ; // Nucleus!
  int nr = operateur.get_dim(0) ;
  assert (nr == operateur.get_dim(1)) ;
  assert (par.get_n_double() > 0) ;
  assert (par.get_n_tbl_mod() > 0) ;
  assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
  assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;

  double dt = par.get_double(0) ;
  dt *= 0.5*dt ;

  // Copies the global coefficients to a local Tbl and adds the -l(l+1) term
  Tbl coeff(7) ;
  coeff.set_etat_qcq() ;
  coeff.set(1) = (par.get_tbl_mod())(1,lzone) ;
  if (fabs(coeff(1))<1.e-15) coeff.set(1) = 0 ;
  coeff.set(2) = (par.get_tbl_mod())(3,lzone) ;
  if (fabs(coeff(2))<1.e-15) coeff.set(2) = 0 ;
  coeff.set(3) = (par.get_tbl_mod())(6,lzone) ;
  if (fabs(coeff(3))<1.e-15) coeff.set(3) = 0 ;
  coeff.set(4) = (par.get_tbl_mod())(5,lzone) ;
  if (fabs(coeff(4))<1.e-15) coeff.set(4) = 0 ;
  coeff.set(5) = (par.get_tbl_mod())(9,lzone) ;
  if (fabs(coeff(5))<1.e-15) coeff.set(5) = 0 ;
  coeff.set(6) = (par.get_tbl_mod())(7,lzone) ;
  if (fabs(coeff(6))<1.e-15) coeff.set(6) = 0 ;
  double alpha2 = (par.get_tbl_mod())(11,lzone)*(par.get_tbl_mod())(11,lzone) ;

  //***********************************************************************
  //                Definition of the type of operator
  // For each type and a fixed time-step, if the number of points (nr) is too
  // large, the round-off error makes the matrix ill-conditioned. So one has
  // to pass the last line of the matrix to the first place (see dal_inverse).
  // The linear combinations to put the matrix into a banded form also depend
  // on the type of operator.
  //***********************************************************************

  if (fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(5)) < 1.e-30) {
    // First order operator
    if (dt < 0.1/(fabs(coeff(3)) + fabs(coeff(4))*nr))
      type_dal = ORDRE1_SMALL ;
    else type_dal = ORDRE1_LARGE ;
  }
  else {
    // Second order degenerate (no 1/r^2 term)
    if (fabs(coeff(5)) < 1.e-24) {
      if (dt < 1./(fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
		   +fabs(coeff(4)))/nr/nr) type_dal = O2DEGE_SMALL ;
      else type_dal = O2DEGE_LARGE ;
    }
    else {
      // Second order non-degenerate (most general case)
      if (dt < 1./((fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
		    + fabs(coeff(4)) + fabs(coeff(5)))*nr*nr))
	type_dal = O2NOND_SMALL ;
      else type_dal = O2NOND_LARGE ;
    }
  }

  coeff.set(1) *= dt/alpha2 ;
  coeff.set(2) *= dt ;
  coeff.set(3) *= dt/alpha2 ;
  coeff.set(4) *= dt ;
  coeff.set(5) *= dt/alpha2 ;
  coeff.set(6) *= dt ;

  Diff_id id(R_CHEBP, nr) ;
  if (fabs(1-coeff(6))>1.e-15) {
      operateur = (1-coeff(6))*id ;
  }
  else{
      operateur.set_etat_qcq() ;
      for (int i=0; i<nr; i++) 
	  for (int j=0; j<nr; j++)
	      operateur.set(i,j) = 0. ;
  }
  Diff_sx2 op02(R_CHEBP, nr) ; const Matrice& m02 = op02.get_matrice() ;
  Diff_xdsdx op11(R_CHEBP, nr) ; const Matrice& m11 = op11.get_matrice() ;
  Diff_sxdsdx op12(R_CHEBP, nr) ; const Matrice& m12 = op12.get_matrice() ;
  Diff_dsdx2 op20(R_CHEBP, nr) ; const Matrice& m20 = op20.get_matrice() ;
  Diff_x2dsdx2 op22(R_CHEBP, nr) ; const Matrice& m22 = op22.get_matrice() ;

    for (int i=0; i<nr; i++) {
	int jmin = (i>3 ? i-3 : 0) ; 
	int jmax = (i<nr-9 ? i+10 : nr) ;
	for (int j=jmin ; j<jmax; j++) 
	    operateur.set(i,j) -= coeff(1)*m20(i,j) + coeff(2)*m22(i,j)
		+ coeff(3)*m12(i,j) + coeff(4)*m11(i,j) + coeff(5)*m02(i,j) ;
    }


}


void _get_operateur_dal_r_chebi(const Param& par, const int& lzone,
				int& type_dal, Matrice& operateur)
{
  assert(lzone == 0) ; // Nucleus!
  int nr = operateur.get_dim(0) ;
  assert (nr == operateur.get_dim(1)) ;
  assert (par.get_n_double() > 0) ;
  assert (par.get_n_tbl_mod() > 0) ;
  assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
  assert ((par.get_tbl_mod()).get_ndim() == 2 ) ;

  double dt = par.get_double(0) ;
  dt *= 0.5*dt ;

  // Copies the global coefficients to a local Tbl and adds the -l(l+1) term
  Tbl coeff(7) ;
  coeff.set_etat_qcq() ;
  coeff.set(1) = (par.get_tbl_mod())(1,lzone) ;
  if (fabs(coeff(1))<1.e-15) coeff.set(1) = 0 ;
  coeff.set(2) = (par.get_tbl_mod())(3,lzone) ;
  if (fabs(coeff(2))<1.e-15) coeff.set(2) = 0 ;
  coeff.set(3) = (par.get_tbl_mod())(6,lzone) ;
  if (fabs(coeff(3))<1.e-15) coeff.set(3) = 0 ;
  coeff.set(4) = (par.get_tbl_mod())(5,lzone) ;
  if (fabs(coeff(4))<1.e-15) coeff.set(4) = 0 ;
  coeff.set(5) = (par.get_tbl_mod())(9,lzone) ;
  if (fabs(coeff(5))<1.e-15) coeff.set(5) = 0 ;
  coeff.set(6) = (par.get_tbl_mod())(7,lzone) ;
  if (fabs(coeff(6))<1.e-15) coeff.set(6) = 0 ;
  double alpha2 = (par.get_tbl_mod())(11,lzone)*(par.get_tbl_mod())(11,lzone) ;

  //***********************************************************************
  //                Definition of the type of operator
  // For each type and a fixed time-step, if the number of points (nr) is too
  // large, the round-off error makes the matrix ill-conditioned. So one has
  // to pass the last line of the matrix to the first place (see dal_inverse).
  // The linear combinations to put the matrix into a banded form also depend
  // on the type of operator.
  //***********************************************************************

  if (fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3)) + 
      fabs(coeff(5)) < 1.e-30) {
    // First order operator
    if (dt < 0.1/(fabs(coeff(4))*nr))
      type_dal = ORDRE1_SMALL ;
    else type_dal = ORDRE1_LARGE ;
  }
  else {
    if (fabs(coeff(5)+coeff(3)) < 1.e-6) {
    // Second order degenerate (no 1/r^2 term)
      if (dt < 1./(fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
		   +fabs(coeff(4)))/nr/nr) type_dal = O2DEGE_SMALL ;
      else type_dal = O2DEGE_LARGE ;
    }
    else {
      // Second order non-degenerate (most general case)
      if (dt < 1./((fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
		    + fabs(coeff(4)) + fabs(coeff(5)))*nr*nr))
	type_dal = O2NOND_SMALL ;
      else type_dal = O2NOND_LARGE ;
    }
  }

  coeff.set(1) *= dt/alpha2 ;
  coeff.set(2) *= dt ;
  coeff.set(3) *= dt/alpha2 ;
  coeff.set(4) *= dt ;
  coeff.set(5) *= dt/alpha2 ;
  coeff.set(6) *= dt ;

  Diff_id id(R_CHEBP, nr) ;
  if (fabs(1-coeff(6))>1.e-15) {
      operateur = (1-coeff(6))*id ;
  }
  else{
      operateur.set_etat_qcq() ;
      for (int i=0; i<nr; i++) 
	  for (int j=0; j<nr; j++)
	      operateur.set(i,j) = 0. ;
  }
  Diff_sx2 op02(R_CHEBI, nr) ; const Matrice& m02 = op02.get_matrice() ;
  Diff_xdsdx op11(R_CHEBI, nr) ; const Matrice& m11 = op11.get_matrice() ;
  Diff_sxdsdx op12(R_CHEBI, nr) ; const Matrice& m12 = op12.get_matrice() ;
  Diff_dsdx2 op20(R_CHEBI, nr) ; const Matrice& m20 = op20.get_matrice() ;
  Diff_x2dsdx2 op22(R_CHEBI, nr) ; const Matrice& m22 = op22.get_matrice() ;

    for (int i=0; i<nr; i++) {
	int jmin = (i>3 ? i-3 : 0) ; 
	int jmax = (i<nr-9 ? i+10 : nr) ;
	for (int j=jmin ; j<jmax; j++) 
	    operateur.set(i,j) -= coeff(1)*m20(i,j) + coeff(2)*m22(i,j)
		+ coeff(3)*m12(i,j) + coeff(4)*m11(i,j) + coeff(5)*m02(i,j) ;
    }

}



void _get_operateur_dal_r_jaco02(const Param& par, const int& lz, 
int& type_dal, Matrice& operateur)
{
  int nr = operateur.get_dim(0) ;
  assert (nr == operateur.get_dim(1)) ;
  assert (par.get_n_double() > 0) ;
  assert (par.get_n_tbl_mod() > 0) ;
  assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
  assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;

  double dt = par.get_double(0) ;
  dt *= 0.5*dt ;

  // Copies the global coefficients to a local Tbl 
    Tbl coeff(10) ;
    coeff.set_etat_qcq() ;
    coeff.set(1) = (par.get_tbl_mod())(1,lz) ;
    coeff.set(2) = (par.get_tbl_mod())(2,lz) ;
    coeff.set(3) = (par.get_tbl_mod())(3,lz) ;
    coeff.set(4) = (par.get_tbl_mod())(4,lz) ;
    coeff.set(5) = (par.get_tbl_mod())(5,lz) ;
    coeff.set(6) = (par.get_tbl_mod())(6,lz) ;
    coeff.set(7) = (par.get_tbl_mod())(7,lz) ;
    coeff.set(8) = (par.get_tbl_mod())(8,lz) ;
    coeff.set(9) = (par.get_tbl_mod())(9,lz) ;
    double R1 = (par.get_tbl_mod())(10,lz) ;
    double R2 = (par.get_tbl_mod())(11,lz) ;

    double a00 = 0. ; double a01 = 0. ; double  a02 = 0. ; 
    double a10 = 0. ; double a11 = 0. ; double  a12 = 0. ; 
    double a13 = 0. ; double a20 = 0. ; double  a21 = 0. ; 
    double a22 = 0. ; double a23 = 0. ; double  a24 = 0. ; 

    bool dege = (fabs(coeff(9)) < 1.e-10) ;
     switch (dege) {
     case true:
      a00 = R1 - dt*(coeff(7)*R1 + coeff(8)) ;
      a01 = R2 - dt*R2*coeff(7) ;
      a02 = 0 ;
      a10 = -dt*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6))/R2 ;
      a11 = -dt*(coeff(4) + 2*R1*coeff(5)) ;
      a12 = -dt*R2*coeff(5) ;
      a13 = 0 ;
      a20 = -dt*R1/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
      a21 = -dt/R2*(coeff(1) + 2*R1*coeff(2) + 3*R1*R1*coeff(3)) ;
      a22 = -dt*(coeff(2) + 3*R1*coeff(3)) ;
      a23 = -dt*R2*coeff(3) ;
      a24 = 0 ;
      type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23))*nr*nr*nr 
 		   < 1.) ? O2DEGE_SMALL : O2DEGE_LARGE ) ;
       break ;
     case false:
      a00 = R1*R1 - dt*(coeff(7)*R1*R1 + coeff(8)*R1 + coeff(9)) ;
      a01 = 2*R1*R2 - dt*(2*R1*R2*coeff(7) + R2*coeff(8)) ;
      a02 = R2*R2*(1 - dt*coeff(7)) ;
      a10 = -dt*R1/R2*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6)) ;
      a11 = -dt*(2*R1*coeff(4) + 3*R1*R1*coeff(5) + coeff(6)) ;
      a12 = -dt*(R2*coeff(4) + 3*R1*R2*coeff(5)) ;
      a13 = -dt*R2*R2*coeff(5) ;
      a20 = -dt*(R1*R1)/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
      a21 = -dt*R1/R2*(2*coeff(1) + 3*R1*coeff(2) + 4*R1*R1*coeff(3)) ;
      a22 = -dt*(coeff(1) + 3*R1*coeff(2) + 6*R1*R1*coeff(3)) ;
      a23 = -dt*(R2*coeff(2) + 4*R1*R2*coeff(3)) ;
      a24 = -dt*R2*R2*coeff(3) ;
       type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23)+fabs(a24))
 		   *nr*nr*nr < 1.) ? O2NOND_SMALL : O2NOND_LARGE ) ;
       break ;
     }
    if (fabs(a00)<1.e-15) a00 = 0 ;
    if (fabs(a01)<1.e-15) a01 = 0 ;
    if (fabs(a02)<1.e-15) a02 = 0 ;
    if (fabs(a10)<1.e-15) a10 = 0 ;
    if (fabs(a11)<1.e-15) a11 = 0 ;
    if (fabs(a12)<1.e-15) a12 = 0 ;
    if (fabs(a13)<1.e-15) a13 = 0 ;
    if (fabs(a20)<1.e-15) a20 = 0 ;
    if (fabs(a21)<1.e-15) a21 = 0 ;
    if (fabs(a22)<1.e-15) a22 = 0 ;
    if (fabs(a23)<1.e-15) a23 = 0 ;
    if (fabs(a24)<1.e-15) a24 = 0 ;

    

    Diff_id id(R_JACO02, nr) ;
    if (fabs(a00)>1.e-15) {
	operateur = a00*id ;
    }
    else{
	operateur.set_etat_qcq() ;
	for (int i=0; i<nr; i++) 
	    for (int j=0; j<nr; j++)
		operateur.set(i,j) = 0. ;
    }
    Diff_mx op01(R_JACO02, nr) ; const Matrice& m01 = op01.get_matrice() ;
    Diff_mx2 op02(R_JACO02, nr) ; const Matrice& m02 = op02.get_matrice() ;
    Diff_dsdx op10(R_JACO02, nr) ; const Matrice& m10 = op10.get_matrice() ;
    Diff_xdsdx op11(R_JACO02, nr) ; const Matrice& m11 = op11.get_matrice() ;
    Diff_x2dsdx op12(R_JACO02, nr) ; const Matrice& m12 = op12.get_matrice() ;
    Diff_x3dsdx op13(R_JACO02, nr) ; const Matrice& m13 = op13.get_matrice() ;
    Diff_dsdx2 op20(R_JACO02, nr) ; const Matrice& m20 = op20.get_matrice() ;
    Diff_xdsdx2 op21(R_JACO02, nr) ; const Matrice& m21 = op21.get_matrice() ;
    Diff_x2dsdx2 op22(R_JACO02, nr) ; const Matrice& m22 = op22.get_matrice() ;
    Diff_x3dsdx2 op23(R_JACO02, nr) ; const Matrice& m23 = op23.get_matrice() ;
    Diff_x4dsdx2 op24(R_JACO02, nr) ; const Matrice& m24 = op24.get_matrice() ;

    for (int i=0; i<nr; i++) {
	int jmin = (i>3 ? i-3 : 0) ; 
	int jmax = (i<nr-9 ? i+10 : nr) ;
	for (int j=jmin ; j<jmax; j++) 
	    operateur.set(i,j) += a01*m01(i,j) + a02*m02(i,j) 
		+ a10*m10(i,j) + a11*m11(i,j) + a12*m12(i,j) 
		+ a13*m13(i,j) + a20*m20(i,j) + a21*m21(i,j)
		+ a22*m22(i,j) + a23*m23(i,j) + a24*m24(i,j) ;
	
    }
}




		 //--------------------------
		//- La routine a appeler  ---
	       //----------------------------
void get_operateur_dal(const Param& par, const int& lzone,
		       const int& base_r, int& type_dal, Matrice& operateur)
{

		// Routines de derivation
  static void (*get_operateur_dal[MAX_BASE])(const Param&,
					     const int&, int&, Matrice&) ;
  static int nap = 0 ;
  
  // Premier appel
  if (nap==0) {
    nap = 1 ;
    for (int i=0 ; i<MAX_BASE ; i++) 
      get_operateur_dal[i] = _get_operateur_dal_pas_prevu ;
    
    // Les routines existantes
    get_operateur_dal[R_CHEB >> TRA_R] = _get_operateur_dal_r_cheb ;
    get_operateur_dal[R_CHEBP >> TRA_R] = _get_operateur_dal_r_chebp ;
    get_operateur_dal[R_CHEBI >> TRA_R] = _get_operateur_dal_r_chebi ;
    get_operateur_dal[R_JACO02 >> TRA_R] = _get_operateur_dal_r_jaco02 ;
  }
  
  get_operateur_dal[base_r](par, lzone, type_dal, operateur) ;
}
}