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
|
/*
* Methods of class Base_val
*
* (see file base_val.h for documentation)
*
*/
/*
* Copyright (c) 1999-2000 Jean-Alain Marck
* Copyright (c) 1999-2001 Eric Gourgoulhon
* Copyright (c) 1999-2001 Philippe Grandclement
*
* 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 base_val_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_val/base_val.C,v 1.17 2014/10/13 08:52:38 j_novak Exp $" ;
/*
* $Id: base_val.C,v 1.17 2014/10/13 08:52:38 j_novak Exp $
* $Log: base_val.C,v $
* Revision 1.17 2014/10/13 08:52:38 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.16 2014/10/06 15:12:56 j_novak
* Modified #include directives to use c++ syntax.
*
* Revision 1.15 2013/01/11 08:20:11 j_novak
* New radial spectral bases with Legendre polynomials (R_LEG, R_LEGP, R_LEGI).
*
* Revision 1.14 2012/01/17 14:44:19 j_penner
* Modified phi variables to only use 16 integers in arrays
*
* Revision 1.13 2009/10/23 12:55:16 j_novak
* New base T_LEG_MI
*
* Revision 1.12 2009/10/08 16:20:13 j_novak
* Addition of new bases T_COS and T_SIN.
*
* Revision 1.11 2008/08/19 06:41:59 j_novak
* Minor modifications to avoid warnings with gcc 4.3. Most of them concern
* cast-type operations, and constant strings that must be defined as const char*
*
* Revision 1.10 2008/02/18 13:53:38 j_novak
* Removal of special indentation instructions.
*
* Revision 1.9 2007/12/11 15:28:09 jl_cornou
* Jacobi(0,2) polynomials partially implemented
*
* Revision 1.8 2004/12/17 13:35:01 m_forot
* Add the case T_LEG
*
* Revision 1.7 2004/11/04 15:19:02 e_gourgoulhon
* operator<< : added names R_CHEBPI_P, R_CHEBPI_I, T_COSSIN_C, T_COSSIN_S.
*
* Revision 1.6 2004/08/24 09:14:41 p_grandclement
* Addition of some new operators, like Poisson in 2d... It now requieres the
* GSL library to work.
*
* Also, the way a variable change is stored by a Param_elliptic is changed and
* no longer uses Change_var but rather 2 Scalars. The codes using that feature
* will requiere some modification. (It should concern only the ones about monopoles)
*
* Revision 1.5 2003/09/16 08:54:09 j_novak
* Addition of the T_LEG_II base (odd in theta, only for odd m) and the
* transformation functions to and from the T_SIN_P base.
*
* Revision 1.4 2002/11/13 15:05:59 j_novak
* Affichage de la base T_COS
*
* Revision 1.3 2002/10/16 14:36:30 j_novak
* Reorganization of #include instructions of standard C++, in order to
* use experimental version 3 of gcc.
*
* Revision 1.2 2001/12/04 21:27:52 e_gourgoulhon
*
* All writing/reading to a binary file are now performed according to
* the big endian convention, whatever the system is big endian or
* small endian, thanks to the functions fwrite_be and fread_be
*
* Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
* LORENE
*
* Revision 2.8 2000/09/28 10:20:19 eric
* Affichage: nouvelles bases T_LEG_IP et T_LEG_PI.
*
* Revision 2.7 2000/09/08 10:06:45 eric
* Ajout des methodes set_base_r, etc...
*
* Revision 2.6 1999/12/28 12:57:26 eric
* Reorganisation des headers.
*
* Revision 2.5 1999/10/12 10:02:51 eric
* Implementation de sauve().
* Modif de << : affichage du nom des bases et non plus de leur numero.
*
* Revision 2.4 1999/10/01 15:56:21 eric
* Depoussierage.
* Documentation.
*
* Revision 2.3 1999/09/13 14:57:06 phil
* ajout de l'operateur ==
*
* Revision 2.2 1999/03/02 15:22:23 eric
* Affichage des bases.
*
* Revision 2.1 1999/03/01 14:54:01 eric
* *** empty log message ***
*
* Revision 2.0 1999/02/22 15:19:20 hyc
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Source/Base_val/base_val.C,v 1.17 2014/10/13 08:52:38 j_novak Exp $
*
*/
// Headers C
#include <cstdio>
#include <cassert>
// Headers Lorene
#include "headcpp.h"
#include "type_parite.h"
#include "base_val.h"
#include "utilitaires.h"
//---------------//
// Constructeurs //
//---------------//
// Constructeur
namespace Lorene {
Base_val::Base_val(int n) : nzone(n) {
b = new int[nzone] ;
for (int i=0 ; i<nzone ; i++) { // Boucle sur les zones
b[i] = NONDEF ;
}
}
// Copie
Base_val::Base_val(const Base_val & bi) : nzone(bi.nzone) {
b = new int[nzone] ;
for (int i=0 ; i<nzone ; i++) { // Boucle sur les zones
b[i] = bi.b[i] ;
}
}
// From file
Base_val::Base_val(FILE* fd) {
fread_be(&nzone, sizeof(int), 1, fd) ; // nzone
b = new int[nzone] ;
fread_be(b, sizeof(int), nzone, fd) ; // b[]
}
//--------------//
// Destructeurs //
//--------------//
// Destructeur
Base_val::~Base_val() {
delete [] b ;
}
//-------------//
// Affectation //
//-------------//
void Base_val::set_base_r(int l, int base_r) {
assert( (l>=0) && (l<nzone) ) ;
int base_t = b[l] & MSQ_T ;
int base_p = b[l] & MSQ_P ;
b[l] = base_p | base_t | base_r ;
}
void Base_val::set_base_t(int base_t) {
for (int l=0; l<nzone; l++) {
int base_r = b[l] & MSQ_R ;
int base_p = b[l] & MSQ_P ;
b[l] = base_p | base_t | base_r ;
}
}
void Base_val::set_base_p(int base_p) {
for (int l=0; l<nzone; l++) {
int base_r = b[l] & MSQ_R ;
int base_t = b[l] & MSQ_T ;
b[l] = base_p | base_t | base_r ;
}
}
// From Base_val
void Base_val::operator=(const Base_val & bi) {
// Protection
assert(nzone == bi.nzone) ;
for (int i=0 ; i<nzone ; i++) { // Boucle sur les zones
b[i] = bi.b[i] ;
}
}
//------------//
// Sauvegarde //
//------------//
// Save in a file
void Base_val::sauve(FILE* fd) const {
fwrite_be(&nzone, sizeof(int), 1, fd) ; // nzone
fwrite_be(b, sizeof(int), nzone, fd) ; // b[]
}
//------------//
// Impression //
//------------//
// Operateurs <<
ostream& operator<<(ostream& o, const Base_val & bi) {
static bool premier_appel = true ;
static const char* nom_r[MAX_BASE] ;
static const char* nom_t[MAX_BASE] ;
static const char* nom_p[MAX_BASE_2] ;
if (premier_appel) { // First call initializations
premier_appel = false ;
for (int i=0; i<MAX_BASE; i++) {
nom_r[i] = "UNDEFINED" ;
nom_t[i] = "UNDEFINED" ;
if(i%2==0){
nom_p[i/2] = "UNDEFINED" ; // saves a loop
}
}
nom_r[R_CHEB >> TRA_R] = "R_CHEB " ;
nom_r[R_CHEBU >> TRA_R] = "R_CHEBU " ;
nom_r[R_CHEBP >> TRA_R] = "R_CHEBP " ;
nom_r[R_CHEBI >> TRA_R] = "R_CHEBI " ;
nom_r[R_CHEBPIM_P >> TRA_R] = "R_CHEBPIM_P" ;
nom_r[R_CHEBPIM_I >> TRA_R] = "R_CHEBPIM_I" ;
nom_r[R_CHEBPI_P >> TRA_R] = "R_CHEBPI_P " ;
nom_r[R_CHEBPI_I >> TRA_R] = "R_CHEBPI_I " ;
nom_r[R_LEG >> TRA_R] = "R_LEG " ;
nom_r[R_LEGP >> TRA_R] = "R_LEGP " ;
nom_r[R_LEGI >> TRA_R] = "R_LEGI " ;
nom_r[R_JACO02 >> TRA_R] = "R_JACO02 " ;
nom_t[T_COS >> TRA_T] = "T_COS " ;
nom_t[T_SIN >> TRA_T] = "T_SIN " ;
nom_t[T_COS_P >> TRA_T] = "T_COS_P " ;
nom_t[T_COS_I >> TRA_T] = "T_COS_I " ;
nom_t[T_SIN_P >> TRA_T] = "T_SIN_P " ;
nom_t[T_SIN_I >> TRA_T] = "T_SIN_I " ;
nom_t[T_COSSIN_CP >> TRA_T] = "T_COSSIN_CP" ;
nom_t[T_COSSIN_SI >> TRA_T] = "T_COSSIN_SI" ;
nom_t[T_COSSIN_SP >> TRA_T] = "T_COSSIN_SP" ;
nom_t[T_COSSIN_CI >> TRA_T] = "T_COSSIN_CI" ;
nom_t[T_COSSIN_C >> TRA_T] = "T_COSSIN_C " ;
nom_t[T_COSSIN_S >> TRA_T] = "T_COSSIN_S " ;
nom_t[T_LEG >> TRA_T] = "T_LEG " ;
nom_t[T_LEG_MP >> TRA_T] = "T_LEG_MP " ;
nom_t[T_LEG_MI >> TRA_T] = "T_LEG_MI " ;
nom_t[T_LEG_P >> TRA_T] = "T_LEG_P " ;
nom_t[T_LEG_PP >> TRA_T] = "T_LEG_PP " ;
nom_t[T_LEG_I >> TRA_T] = "T_LEG_I " ;
nom_t[T_LEG_IP >> TRA_T] = "T_LEG_IP " ;
nom_t[T_LEG_PI >> TRA_T] = "T_LEG_PI " ;
nom_t[T_LEG_II >> TRA_T] = "T_LEG_II " ;
nom_t[T_CL_COS_P >> TRA_T] = "T_CL_COS_P " ;
nom_t[T_CL_SIN_P >> TRA_T] = "T_CL_SIN_P " ;
nom_t[T_CL_COS_I >> TRA_T] = "T_CL_COS_I " ;
nom_t[T_CL_SIN_I >> TRA_T] = "T_CL_SIN_I " ;
nom_p[P_COSSIN >> TRA_P] = "P_COSSIN " ;
nom_p[P_COSSIN_P >> TRA_P] = "P_COSSIN_P " ;
nom_p[P_COSSIN_I >> TRA_P] = "P_COSSIN_I " ;
} // End of first call operations
// Intro - Nombre de zones
int nzone = bi.nzone ;
o << "Bases of spectral expansions: " ;
for (int l=0 ; l<nzone ; l++) {
int base_r = (bi.b[l] & MSQ_R) >> TRA_R ;
int base_t = (bi.b[l] & MSQ_T) >> TRA_T ;
int base_p = (bi.b[l] & MSQ_P) >> TRA_P ;
o << endl ;
o << "Domain #" << l << " : r: " << nom_r[base_r]
<< ", theta: " << nom_t[base_t]
<< ", phi: " << nom_p[base_p] ;
}
o << endl ;
//Termine
return o ;
}
//----------------------//
// Manipulation de base //
//----------------------//
void Base_val::set_base_nondef() {
for (int i=0 ; i<nzone ; i++) {
b[i] = NONDEF ;
}
}
//----------------------//
// operateur logique //
//----------------------//
bool Base_val::operator== (const Base_val& c2) const {
return (*b == *c2.b) ;
}
}
|