LORENE
raccord_c1.C
1 /*
2  * Copyright (c) 2000-2001 Eric Gourgoulhon
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: raccord_c1.C,v 1.5 2016/12/05 16:18:11 j_novak Exp $
27  * $Log: raccord_c1.C,v $
28  * Revision 1.5 2016/12/05 16:18:11 j_novak
29  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
30  *
31  * Revision 1.4 2014/10/13 08:53:32 j_novak
32  * Lorene classes and functions now belong to the namespace Lorene.
33  *
34  * Revision 1.3 2010/01/26 16:47:40 e_gourgoulhon
35  * Added the Scalar version.
36  *
37  * Revision 1.2 2003/12/19 16:21:49 j_novak
38  * Shadow hunt
39  *
40  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
41  * LORENE
42  *
43  * Revision 2.0 2000/03/22 10:08:55 eric
44  * *** empty log message ***
45  *
46  *
47  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Utilities/raccord_c1.C,v 1.5 2016/12/05 16:18:11 j_novak Exp $
48  *
49  */
50 
51 // Headers Lorene
52 #include "cmp.h"
53 #include "scalar.h"
54 
55 namespace Lorene {
56 Cmp raccord_c1(const Cmp& uu, int l1) {
57 
58  const Map_radial* mpi = dynamic_cast<const Map_radial*>( uu.get_mp() ) ;
59 
60  if (mpi == 0x0) {
61  cout <<
62  "raccord_c1 : The mapping does not belong to the class Map_radial !"
63  << endl ;
64  abort() ;
65  }
66 
67  const Map_radial& mp = *mpi ;
68 
69  const Mg3d& mg = *(mp.get_mg()) ;
70 
71 #ifndef NDEBUG
72  int nz = mg.get_nzone() ;
73 #endif
74  assert(l1 > 0) ;
75  assert(l1 < nz-1) ;
76 
77  int l0 = l1 - 1 ; // index of left domain
78  int l2 = l1 + 1 ; // index of right domain
79 
80 
81  Mtbl dxdr = mp.dxdr ;
82  Mtbl r2 = mp.r * mp.r ;
83 
84  Cmp resu = uu ;
85 
86  Valeur& va = resu.va ;
87 
88  va.coef_i() ;
89  va.set_etat_c_qcq() ;
90 
91  va.c->set_etat_qcq() ;
92  va.c->t[l1]->set_etat_qcq() ;
93 
94  int np = mg.get_np(l1) ;
95  int nt = mg.get_nt(l1) ;
96  assert( mg.get_np(l0) == np ) ;
97  assert( mg.get_nt(l0) == nt ) ;
98  assert( mg.get_np(l2) == np ) ;
99  assert( mg.get_nt(l2) == nt ) ;
100 
101  int nr0 = mg.get_nr(l0) ;
102  int nr1 = mg.get_nr(l1) ;
103 
104  for (int k=0; k<np; k++) {
105  for (int j=0; j<nt; j++) {
106  double lam0 = uu(l0, k, j, nr0-1) ;
107  double lam1 = uu.dsdr()(l0, k, j, nr0-1) / dxdr(l1, k, j, 0) ;
108  double mu0 = uu(l2, k, j, 0) ;
109  double mu1 = uu.dsdr()(l2, k, j, 0) / dxdr(l1, k, j, nr1-1) ;
110 
111  if ( mg.get_type_r(l2) == UNSURR ) {
112  mu1 /= r2(l2, k, j, 0) ;
113  }
114 
115  double s0 = 0.25 * (mu0 + lam0) ;
116  double s1 = 0.25 * (mu1 + lam1) ;
117  double d0 = 0.25 * (mu0 - lam0) ;
118  double d1 = 0.25 * (mu1 - lam1) ;
119 
120  double a0 = 2. * s0 - d1 ;
121  double a1 = 3. * d0 - s1 ;
122  double a2 = d1 ;
123  double a3 = s1 - d0 ;
124 
125  for (int i=0; i<nr1; i++) {
126  double x = mg.get_grille3d(l1)->x[i] ;
127  va.set(l1, k, j, i) = a0 + x * ( a1 + x * ( a2 + x * a3 ) ) ;
128  }
129 
130  }
131  }
132 
133  return resu ;
134 
135 }
136 
137 /*
138  * Scalar version
139  */
140 Scalar raccord_c1(const Scalar& uu, int l1) {
141 
142  Cmp cuu(uu) ;
143  return Scalar( raccord_c1(cuu, l1) ) ;
144 
145 }
146 }
Lorene prototypes.
Definition: app_hor.h:67