LORENE
map_radial_comp_rtp.C
1 /*
2  * Copyright (c) 2000-2001 Philippe Grandclement
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 char map_radial_comp_rtp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_radial_comp_rtp.C,v 1.5 2014/10/13 08:53:06 j_novak Exp $" ;
24 
25 /*
26  * $Id: map_radial_comp_rtp.C,v 1.5 2014/10/13 08:53:06 j_novak Exp $
27  * $Log: map_radial_comp_rtp.C,v $
28  * Revision 1.5 2014/10/13 08:53:06 j_novak
29  * Lorene classes and functions now belong to the namespace Lorene.
30  *
31  * Revision 1.4 2014/10/06 15:13:13 j_novak
32  * Modified #include directives to use c++ syntax.
33  *
34  * Revision 1.3 2005/09/15 15:51:25 j_novak
35  * The "rotation" (change of triad) methods take now Scalars as default
36  * arguments.
37  *
38  * Revision 1.2 2003/06/20 14:46:17 f_limousin
39  * Les assert sur le mapping sont realise a partir du mapping meme et non a partir du pointeur sur ce mapping
40  *
41  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
42  * LORENE
43  *
44  * Revision 1.1 2000/09/19 15:25:50 phil
45  * Initial revision
46  *
47  *
48  * $Header: /cvsroot/Lorene/C++/Source/Map/map_radial_comp_rtp.C,v 1.5 2014/10/13 08:53:06 j_novak Exp $
49  *
50  */
51 
52 
53 // Headers C
54 #include <cassert>
55 
56 // Headers Lorene
57 #include "tensor.h"
58 #include "cmp.h"
59 
60 
61  //------------------------------------//
62  // r component //
63  //------------------------------------//
64 namespace Lorene {
65 void Map_radial::comp_r_from_cartesian(const Cmp& v_x, const Cmp& v_y,
66  const Cmp& v_z, Cmp& v_r) const {
67  Scalar resu = v_r ;
68  comp_r_from_cartesian(Scalar(v_x), Scalar(v_y), Scalar(v_z), resu) ;
69  v_r = resu ;
70 }
71 
72 void Map_radial::comp_r_from_cartesian(const Scalar& v_x, const Scalar& v_y,
73  const Scalar& v_z, Scalar& v_r) const {
74 
75 
76  // Protections
77  // -----------
78  assert(v_x.get_etat() != ETATNONDEF) ;
79  assert(v_y.get_etat() != ETATNONDEF) ;
80  assert(v_z.get_etat() != ETATNONDEF) ;
81 
82  assert(v_x.get_mp() == *this) ;
83  assert(v_y.get_mp() == *this) ;
84  assert(v_z.get_mp() == *this) ;
85 
86  int dzp ;
87  if ( v_x.dz_nonzero() ) {
88  dzp = v_x.get_dzpuis() ;
89  }
90  else{
91  if ( v_y.dz_nonzero() ) {
92  dzp = v_y.get_dzpuis() ;
93  }
94  else{
95  dzp = v_z.get_dzpuis() ;
96  }
97  }
98 
99  assert( v_x.check_dzpuis(dzp) ) ;
100  assert( v_y.check_dzpuis(dzp) ) ;
101  assert( v_z.check_dzpuis(dzp) ) ;
102 
103  // Computation
104  // -----------
105  const Valeur& w_x = v_x.get_spectral_va() ;
106  const Valeur& w_y = v_y.get_spectral_va() ;
107  const Valeur& w_z = v_z.get_spectral_va() ;
108 
109  Valeur tmp = w_x.mult_cp() + w_y.mult_sp() ;
110 
111  v_r = tmp.mult_st() + w_z.mult_ct() ;
112 
113  v_r.set_dzpuis(dzp) ;
114 
115 }
116 
117 
118  //------------------------------------//
119  // Theta component //
120  //------------------------------------//
121 void Map_radial::comp_t_from_cartesian(const Cmp& v_x, const Cmp& v_y,
122  const Cmp& v_z, Cmp& v_t) const {
123  Scalar resu = v_t ;
124  comp_t_from_cartesian( Scalar(v_x), Scalar(v_y), Scalar(v_z), resu ) ;
125  v_t = resu ;
126 }
127 
128 void Map_radial::comp_t_from_cartesian(const Scalar& v_x, const Scalar& v_y,
129  const Scalar& v_z, Scalar& v_t) const {
130 
131 
132  // Protections
133  // -----------
134  assert(v_x.get_etat() != ETATNONDEF) ;
135  assert(v_y.get_etat() != ETATNONDEF) ;
136  assert(v_z.get_etat() != ETATNONDEF) ;
137 
138  assert(v_x.get_mp() == *this) ;
139  assert(v_y.get_mp() == *this) ;
140  assert(v_z.get_mp() == *this) ;
141 
142  int dzp ;
143  if ( v_x.dz_nonzero() ) {
144  dzp = v_x.get_dzpuis() ;
145  }
146  else{
147  if ( v_y.dz_nonzero() ) {
148  dzp = v_y.get_dzpuis() ;
149  }
150  else{
151  dzp = v_z.get_dzpuis() ;
152  }
153  }
154 
155  assert( v_x.check_dzpuis(dzp) ) ;
156  assert( v_y.check_dzpuis(dzp) ) ;
157  assert( v_z.check_dzpuis(dzp) ) ;
158 
159  // Computation
160  // -----------
161  const Valeur& w_x = v_x.get_spectral_va() ;
162  const Valeur& w_y = v_y.get_spectral_va() ;
163  const Valeur& w_z = v_z.get_spectral_va() ;
164 
165  Valeur tmp = w_x.mult_cp() + w_y.mult_sp() ;
166 
167  v_t = tmp.mult_ct() - w_z.mult_st() ;
168 
169  v_t.set_dzpuis(dzp) ;
170 
171 }
172 
173  //------------------------------------//
174  // Phi component //
175  //------------------------------------//
176 void Map_radial::comp_p_from_cartesian(const Cmp& v_x, const Cmp& v_y,
177  Cmp& v_p) const {
178  Scalar resu = v_p ;
179  comp_p_from_cartesian(Scalar(v_x), Scalar(v_y), resu) ;
180  v_p = resu ;
181 }
182 
183 void Map_radial::comp_p_from_cartesian(const Scalar& v_x, const Scalar& v_y,
184  Scalar& v_p) const {
185 
186 
187  // Protections
188  // -----------
189  assert(v_x.get_etat() != ETATNONDEF) ;
190  assert(v_y.get_etat() != ETATNONDEF) ;
191 
192  assert(v_x.get_mp() == *this) ;
193  assert(v_y.get_mp() == *this) ;
194 
195  int dzp ;
196  if ( v_x.dz_nonzero() ) {
197  dzp = v_x.get_dzpuis() ;
198  }
199  else{
200  dzp = v_y.get_dzpuis() ;
201  }
202 
203  assert( v_x.check_dzpuis(dzp) ) ;
204  assert( v_y.check_dzpuis(dzp) ) ;
205 
206  // Computation
207  // -----------
208  const Valeur& w_x = v_x.get_spectral_va() ;
209  const Valeur& w_y = v_y.get_spectral_va() ;
210 
211  v_p = - w_x.mult_sp() + w_y.mult_cp() ;
212 
213  v_p.set_dzpuis(dzp) ;
214 
215 }
216 
217 
218 }
Lorene::Valeur::mult_cp
const Valeur & mult_cp() const
Returns applied to *this.
Definition: valeur_mult_cp.C:77
Lorene::Map_radial::comp_p_from_cartesian
virtual void comp_p_from_cartesian(const Scalar &v_x, const Scalar &v_y, Scalar &v_p) const
Computes the Spherical component (with respect to bvect_spher ) of a vector given by its cartesian c...
Definition: map_radial_comp_rtp.C:183
Lorene::Valeur
Values and coefficients of a (real-value) function.
Definition: valeur.h:287
Lorene::Valeur::mult_ct
const Valeur & mult_ct() const
Returns applied to *this.
Definition: valeur_mult_ct.C:98
Lorene
Lorene prototypes.
Definition: app_hor.h:64
Lorene::Map_radial::comp_t_from_cartesian
virtual void comp_t_from_cartesian(const Scalar &v_x, const Scalar &v_y, const Scalar &v_z, Scalar &v_t) const
Computes the Spherical component (with respect to bvect_spher ) of a vector given by its cartesian c...
Definition: map_radial_comp_rtp.C:128
Lorene::Scalar::check_dzpuis
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
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
Lorene::Tensor::get_mp
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:861
Lorene::Scalar::dz_nonzero
bool dz_nonzero() const
Returns true if the last domain is compactified and *this is not zero in this domain.
Definition: scalar.C:814
Lorene::Valeur::mult_sp
const Valeur & mult_sp() const
Returns applied to *this.
Definition: valeur_mult_sp.C:77
Lorene::Scalar::get_spectral_va
const Valeur & get_spectral_va() const
Returns va (read only version)
Definition: scalar.h:601
Lorene::Map_radial::comp_r_from_cartesian
virtual void comp_r_from_cartesian(const Scalar &v_x, const Scalar &v_y, const Scalar &v_z, Scalar &v_r) const
Computes the Spherical r component (with respect to bvect_spher ) of a vector given by its cartesian ...
Definition: map_radial_comp_rtp.C:72
Lorene::Valeur::mult_st
const Valeur & mult_st() const
Returns applied to *this.
Definition: valeur_mult_st.C:97
Lorene::Cmp
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
Definition: cmp.h:446
Lorene::Scalar::set_dzpuis
void set_dzpuis(int)
Modifies the dzpuis flag.
Definition: scalar.C:808
Lorene::Scalar::get_etat
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Definition: scalar.h:554
Lorene::Scalar::get_dzpuis
int get_dzpuis() const
Returns dzpuis.
Definition: scalar.h:557