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 char map_radial_comp_xyz_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_radial_comp_xyz.C,v 1.4 2014/10/13 08:53:06 j_novak Exp $" ;
31 
32 /*
33  * $Id: map_radial_comp_xyz.C,v 1.4 2014/10/13 08:53:06 j_novak Exp $
34  * $Log: map_radial_comp_xyz.C,v $
35  * Revision 1.4 2014/10/13 08:53:06 j_novak
36  * Lorene classes and functions now belong to the namespace Lorene.
37  *
38  * Revision 1.3 2014/10/06 15:13:13 j_novak
39  * Modified #include directives to use c++ syntax.
40  *
41  * Revision 1.2 2005/09/15 15:51:25 j_novak
42  * The "rotation" (change of triad) methods take now Scalars as default
43  * arguments.
44  *
45  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
46  * LORENE
47  *
48  * Revision 2.0 2000/09/11 15:56:22 eric
49  * *** empty log message ***
50  *
51  *
52  * $Header: /cvsroot/Lorene/C++/Source/Map/map_radial_comp_xyz.C,v 1.4 2014/10/13 08:53:06 j_novak Exp $
53  *
54  */
55 
56 // Headers C
57 #include <cassert>
58 
59 // Headers Lorene
60 #include "tensor.h"
61 #include "cmp.h"
62 
63 
64  //------------------------------------//
65  // X component //
66  //------------------------------------//
67 namespace Lorene {
68 void Map_radial::comp_x_from_spherical(const Cmp& v_r, const Cmp& v_theta,
69  const Cmp& v_phi, Cmp& v_x) const {
70  Scalar resu(v_x) ;
71  comp_x_from_spherical(Scalar(v_r), Scalar(v_theta), Scalar(v_phi),
72  resu ) ;
73  v_x = resu ;
74 }
75 
76 void Map_radial::comp_x_from_spherical(const Scalar& v_r, const Scalar& v_theta,
77  const Scalar& v_phi, Scalar& v_x) const {
78 
79 
80  // Protections
81  // -----------
82  assert(v_r.get_etat() != ETATNONDEF) ;
83  assert(v_theta.get_etat() != ETATNONDEF) ;
84  assert(v_phi.get_etat() != ETATNONDEF) ;
85 
86  assert(v_r.get_mp() == *this) ;
87  assert(v_theta.get_mp() == *this) ;
88  assert(v_phi.get_mp() == *this) ;
89 
90  int dzp ;
91  if ( v_r.dz_nonzero() ) {
92  dzp = v_r.get_dzpuis() ;
93  }
94  else{
95  if ( v_theta.dz_nonzero() ) {
96  dzp = v_theta.get_dzpuis() ;
97  }
98  else{
99  dzp = v_phi.get_dzpuis() ;
100  }
101  }
102 
103  assert( v_r.check_dzpuis(dzp) ) ;
104  assert( v_theta.check_dzpuis(dzp) ) ;
105  assert( v_phi.check_dzpuis(dzp) ) ;
106 
107  // Computation
108  // -----------
109  const Valeur& w_r = v_r.get_spectral_va() ;
110  const Valeur& w_t = v_theta.get_spectral_va() ;
111  const Valeur& w_p = v_phi.get_spectral_va() ;
112 
113  Valeur tmp = w_r.mult_st() + w_t.mult_ct() ;
114 
115  v_x = tmp.mult_cp() - w_p.mult_sp() ;
116 
117  v_x.set_dzpuis(dzp) ;
118 
119 }
120 
121 
122  //------------------------------------//
123  // Y component //
124  //------------------------------------//
125 
126 void Map_radial::comp_y_from_spherical(const Cmp& v_r, const Cmp& v_theta,
127  const Cmp& v_phi, Cmp& v_y) const {
128 
129  Scalar resu(v_y) ;
130  comp_y_from_spherical(Scalar(v_r), Scalar(v_theta), Scalar(v_phi),
131  resu ) ;
132  v_y = resu ;
133 }
134 
135 void Map_radial::comp_y_from_spherical(const Scalar& v_r, const Scalar& v_theta,
136  const Scalar& v_phi, Scalar& v_y) const {
137 
138 
139  // Protections
140  // -----------
141  assert(v_r.get_etat() != ETATNONDEF) ;
142  assert(v_theta.get_etat() != ETATNONDEF) ;
143  assert(v_phi.get_etat() != ETATNONDEF) ;
144 
145  assert(v_r.get_mp() == *this) ;
146  assert(v_theta.get_mp() == *this) ;
147  assert(v_phi.get_mp() == *this) ;
148 
149  int dzp ;
150  if ( v_r.dz_nonzero() ) {
151  dzp = v_r.get_dzpuis() ;
152  }
153  else{
154  if ( v_theta.dz_nonzero() ) {
155  dzp = v_theta.get_dzpuis() ;
156  }
157  else{
158  dzp = v_phi.get_dzpuis() ;
159  }
160  }
161 
162  assert( v_r.check_dzpuis(dzp) ) ;
163  assert( v_theta.check_dzpuis(dzp) ) ;
164  assert( v_phi.check_dzpuis(dzp) ) ;
165 
166  // Computation
167  // -----------
168  const Valeur& w_r = v_r.get_spectral_va() ;
169  const Valeur& w_t = v_theta.get_spectral_va() ;
170  const Valeur& w_p = v_phi.get_spectral_va() ;
171 
172  Valeur tmp = w_r.mult_st() + w_t.mult_ct() ;
173 
174  v_y = tmp.mult_sp() + w_p.mult_cp() ;
175 
176  v_y.set_dzpuis(dzp) ;
177 
178 }
179 
180  //------------------------------------//
181  // Z component //
182  //------------------------------------//
183 
184 void Map_radial::comp_z_from_spherical(const Cmp& v_r, const Cmp& v_theta,
185  Cmp& v_z) const {
186  Scalar resu = v_z ;
187  comp_z_from_spherical(Scalar(v_r), Scalar(v_theta), resu) ;
188  v_z = resu ;
189 
190 }
191 
192 void Map_radial::comp_z_from_spherical(const Scalar& v_r, const Scalar& v_theta,
193  Scalar& v_z) const {
194 
195 
196  // Protections
197  // -----------
198  assert(v_r.get_etat() != ETATNONDEF) ;
199  assert(v_theta.get_etat() != ETATNONDEF) ;
200 
201  assert(v_r.get_mp() == *this) ;
202  assert(v_theta.get_mp() == *this) ;
203 
204  int dzp ;
205  if ( v_r.dz_nonzero() ) {
206  dzp = v_r.get_dzpuis() ;
207  }
208  else{
209  dzp = v_theta.get_dzpuis() ;
210  }
211 
212  assert( v_r.check_dzpuis(dzp) ) ;
213  assert( v_theta.check_dzpuis(dzp) ) ;
214 
215  // Computation
216  // -----------
217  const Valeur& w_r = v_r.get_spectral_va() ;
218  const Valeur& w_t = v_theta.get_spectral_va() ;
219 
220  v_z = w_r.mult_ct() - w_t.mult_st() ;
221 
222  v_z.set_dzpuis(dzp) ;
223 
224 }
225 
226 
227 }
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:64
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
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:287
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition: scalar.h:554
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition: scalar.C:808
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:557
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:814
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:873
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:861
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:601