LORENE
map_radial_comp_xyz.C
1 /*
2  * Methods Map_radial::comp_x_from_spherical
3  * Map_radial::comp_y_from_spherical
4  * Map_radial::comp_z_from_spherical
5  *
6  */
7 
8 /*
9  * Copyright (c) 2000-2001 Eric Gourgoulhon
10  *
11  * This file is part of LORENE.
12  *
13  * LORENE is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * LORENE is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with LORENE; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  */
28 
29 
30 
31 
32 /*
33  * $Id: map_radial_comp_xyz.C,v 1.5 2016/12/05 16:17:58 j_novak Exp $
34  * $Log: map_radial_comp_xyz.C,v $
35  * Revision 1.5 2016/12/05 16:17:58 j_novak
36  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37  *
38  * Revision 1.4 2014/10/13 08:53:06 j_novak
39  * Lorene classes and functions now belong to the namespace Lorene.
40  *
41  * Revision 1.3 2014/10/06 15:13:13 j_novak
42  * Modified #include directives to use c++ syntax.
43  *
44  * Revision 1.2 2005/09/15 15:51:25 j_novak
45  * The "rotation" (change of triad) methods take now Scalars as default
46  * arguments.
47  *
48  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
49  * LORENE
50  *
51  * Revision 2.0 2000/09/11 15:56:22 eric
52  * *** empty log message ***
53  *
54  *
55  * $Header: /cvsroot/Lorene/C++/Source/Map/map_radial_comp_xyz.C,v 1.5 2016/12/05 16:17:58 j_novak Exp $
56  *
57  */
58 
59 // Headers C
60 #include <cassert>
61 
62 // Headers Lorene
63 #include "tensor.h"
64 #include "cmp.h"
65 
66 
67  //------------------------------------//
68  // X component //
69  //------------------------------------//
70 namespace Lorene {
71 void Map_radial::comp_x_from_spherical(const Cmp& v_r, const Cmp& v_theta,
72  const Cmp& v_phi, Cmp& v_x) const {
73  Scalar resu(v_x) ;
74  comp_x_from_spherical(Scalar(v_r), Scalar(v_theta), Scalar(v_phi),
75  resu ) ;
76  v_x = resu ;
77 }
78 
79 void Map_radial::comp_x_from_spherical(const Scalar& v_r, const Scalar& v_theta,
80  const Scalar& v_phi, Scalar& v_x) const {
81 
82 
83  // Protections
84  // -----------
85  assert(v_r.get_etat() != ETATNONDEF) ;
86  assert(v_theta.get_etat() != ETATNONDEF) ;
87  assert(v_phi.get_etat() != ETATNONDEF) ;
88 
89  assert(v_r.get_mp() == *this) ;
90  assert(v_theta.get_mp() == *this) ;
91  assert(v_phi.get_mp() == *this) ;
92 
93  int dzp ;
94  if ( v_r.dz_nonzero() ) {
95  dzp = v_r.get_dzpuis() ;
96  }
97  else{
98  if ( v_theta.dz_nonzero() ) {
99  dzp = v_theta.get_dzpuis() ;
100  }
101  else{
102  dzp = v_phi.get_dzpuis() ;
103  }
104  }
105 
106  assert( v_r.check_dzpuis(dzp) ) ;
107  assert( v_theta.check_dzpuis(dzp) ) ;
108  assert( v_phi.check_dzpuis(dzp) ) ;
109 
110  // Computation
111  // -----------
112  const Valeur& w_r = v_r.get_spectral_va() ;
113  const Valeur& w_t = v_theta.get_spectral_va() ;
114  const Valeur& w_p = v_phi.get_spectral_va() ;
115 
116  Valeur tmp = w_r.mult_st() + w_t.mult_ct() ;
117 
118  v_x = tmp.mult_cp() - w_p.mult_sp() ;
119 
120  v_x.set_dzpuis(dzp) ;
121 
122 }
123 
124 
125  //------------------------------------//
126  // Y component //
127  //------------------------------------//
128 
129 void Map_radial::comp_y_from_spherical(const Cmp& v_r, const Cmp& v_theta,
130  const Cmp& v_phi, Cmp& v_y) const {
131 
132  Scalar resu(v_y) ;
133  comp_y_from_spherical(Scalar(v_r), Scalar(v_theta), Scalar(v_phi),
134  resu ) ;
135  v_y = resu ;
136 }
137 
138 void Map_radial::comp_y_from_spherical(const Scalar& v_r, const Scalar& v_theta,
139  const Scalar& v_phi, Scalar& v_y) const {
140 
141 
142  // Protections
143  // -----------
144  assert(v_r.get_etat() != ETATNONDEF) ;
145  assert(v_theta.get_etat() != ETATNONDEF) ;
146  assert(v_phi.get_etat() != ETATNONDEF) ;
147 
148  assert(v_r.get_mp() == *this) ;
149  assert(v_theta.get_mp() == *this) ;
150  assert(v_phi.get_mp() == *this) ;
151 
152  int dzp ;
153  if ( v_r.dz_nonzero() ) {
154  dzp = v_r.get_dzpuis() ;
155  }
156  else{
157  if ( v_theta.dz_nonzero() ) {
158  dzp = v_theta.get_dzpuis() ;
159  }
160  else{
161  dzp = v_phi.get_dzpuis() ;
162  }
163  }
164 
165  assert( v_r.check_dzpuis(dzp) ) ;
166  assert( v_theta.check_dzpuis(dzp) ) ;
167  assert( v_phi.check_dzpuis(dzp) ) ;
168 
169  // Computation
170  // -----------
171  const Valeur& w_r = v_r.get_spectral_va() ;
172  const Valeur& w_t = v_theta.get_spectral_va() ;
173  const Valeur& w_p = v_phi.get_spectral_va() ;
174 
175  Valeur tmp = w_r.mult_st() + w_t.mult_ct() ;
176 
177  v_y = tmp.mult_sp() + w_p.mult_cp() ;
178 
179  v_y.set_dzpuis(dzp) ;
180 
181 }
182 
183  //------------------------------------//
184  // Z component //
185  //------------------------------------//
186 
187 void Map_radial::comp_z_from_spherical(const Cmp& v_r, const Cmp& v_theta,
188  Cmp& v_z) const {
189  Scalar resu = v_z ;
190  comp_z_from_spherical(Scalar(v_r), Scalar(v_theta), resu) ;
191  v_z = resu ;
192 
193 }
194 
195 void Map_radial::comp_z_from_spherical(const Scalar& v_r, const Scalar& v_theta,
196  Scalar& v_z) const {
197 
198 
199  // Protections
200  // -----------
201  assert(v_r.get_etat() != ETATNONDEF) ;
202  assert(v_theta.get_etat() != ETATNONDEF) ;
203 
204  assert(v_r.get_mp() == *this) ;
205  assert(v_theta.get_mp() == *this) ;
206 
207  int dzp ;
208  if ( v_r.dz_nonzero() ) {
209  dzp = v_r.get_dzpuis() ;
210  }
211  else{
212  dzp = v_theta.get_dzpuis() ;
213  }
214 
215  assert( v_r.check_dzpuis(dzp) ) ;
216  assert( v_theta.check_dzpuis(dzp) ) ;
217 
218  // Computation
219  // -----------
220  const Valeur& w_r = v_r.get_spectral_va() ;
221  const Valeur& w_t = v_theta.get_spectral_va() ;
222 
223  v_z = w_r.mult_ct() - w_t.mult_st() ;
224 
225  v_z.set_dzpuis(dzp) ;
226 
227 }
228 
229 
230 }
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
const Valeur & mult_sp() const
Returns applied to *this.
Lorene prototypes.
Definition: app_hor.h:67
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
virtual void comp_y_from_spherical(const Scalar &v_r, const Scalar &v_theta, const Scalar &v_phi, Scalar &v_y) const
Computes the Cartesian y component (with respect to bvect_cart ) of a vector given by its spherical c...
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition: scalar.h:560
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition: scalar.C:814
virtual void comp_z_from_spherical(const Scalar &v_r, const Scalar &v_theta, Scalar &v_z) const
Computes the Cartesian z component (with respect to bvect_cart ) of a vector given by its spherical c...
int get_dzpuis() const
Returns dzpuis.
Definition: scalar.h:563
const Valeur & mult_st() const
Returns applied to *this.
const Valeur & mult_cp() const
Returns applied to *this.
bool dz_nonzero() const
Returns true if the last domain is compactified and *this is not zero in this domain.
Definition: scalar.C:820
virtual void comp_x_from_spherical(const Scalar &v_r, const Scalar &v_theta, const Scalar &v_phi, Scalar &v_x) const
Computes the Cartesian x component (with respect to bvect_cart) of a vector given by its spherical co...
const Valeur & mult_ct() const
Returns applied to *this.
bool check_dzpuis(int dzi) const
Returns false if the last domain is compactified and *this is not zero in this domain and dzpuis is n...
Definition: scalar.C:879
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:874
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:607