scalar_pde.C

00001 /*
00002  * Methods of the class Scalar for various partial differential equations
00003  *
00004  *  See file scalar.h for documentation. 
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2003-2005 Eric Gourgoulhon & Jerome Novak
00009  *   Copyright (c) 2004 Philippe Grandclement
00010  *
00011  *   Copyright (c) 1999-2001 Eric Gourgoulhon (for preceding class Cmp)
00012  *   Copyright (c) 1999-2001 Philippe Grandclement (for preceding class Cmp)
00013  *   Copyright (c) 2000-2001 Jerome Novak (for preceding class Cmp)
00014  *
00015  *   This file is part of LORENE.
00016  *
00017  *   LORENE is free software; you can redistribute it and/or modify
00018  *   it under the terms of the GNU General Public License as published by
00019  *   the Free Software Foundation; either version 2 of the License, or
00020  *   (at your option) any later version.
00021  *
00022  *   LORENE is distributed in the hope that it will be useful,
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025  *   GNU General Public License for more details.
00026  *
00027  *   You should have received a copy of the GNU General Public License
00028  *   along with LORENE; if not, write to the Free Software
00029  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00030  *
00031  */
00032 
00033 
00034 char scalar_pde_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_pde.C,v 1.19 2007/05/06 10:48:15 p_grandclement Exp $" ;
00035 
00036 /*
00037  * $Id: scalar_pde.C,v 1.19 2007/05/06 10:48:15 p_grandclement Exp $
00038  * $Log: scalar_pde.C,v $
00039  * Revision 1.19  2007/05/06 10:48:15  p_grandclement
00040  * Modification of a few operators for the vorton project
00041  *
00042  * Revision 1.18  2007/01/16 15:10:00  n_vasset
00043  *  New function sol_elliptic_boundary, with Scalar on mono domain
00044  *  angular grid as boundary
00045  *
00046  * Revision 1.17  2005/11/30 11:09:09  p_grandclement
00047  * Changes for the Bin_ns_bh project
00048  *
00049  * Revision 1.16  2005/08/26 14:02:41  p_grandclement
00050  * Modification of the elliptic solver that matches with an oscillatory exterior solution
00051  * small correction in Poisson tau also...
00052  *
00053  * Revision 1.15  2005/08/25 12:14:10  p_grandclement
00054  * Addition of a new method to solve the scalar Poisson equation, based on a multi-domain Tau-method
00055  *
00056  * Revision 1.14  2005/06/09 08:00:10  f_limousin
00057  * Implement a new function sol_elliptic_boundary() and
00058  * Vector::poisson_boundary(...) which solve the vectorial poisson
00059  * equation (method 6) with an inner boundary condition.
00060  *
00061  * Revision 1.13  2005/04/04 21:34:44  e_gourgoulhon
00062  * Added argument lambda to method poisson_angu
00063  * to deal with the generalized angular Poisson equation:
00064  *     Lap_ang u + lambda u = source.
00065  *
00066  * Revision 1.12  2004/08/24 09:14:52  p_grandclement
00067  * Addition of some new operators, like Poisson in 2d... It now requieres the
00068  * GSL library to work.
00069  *
00070  * Also, the way a variable change is stored by a Param_elliptic is changed and
00071  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00072  * will requiere some modification. (It should concern only the ones about monopoles)
00073  *
00074  * Revision 1.11  2004/06/22 08:50:00  p_grandclement
00075  * Addition of everything needed for using the logarithmic mapping
00076  *
00077  * Revision 1.10  2004/05/25 14:30:48  f_limousin
00078  * Minor modif.
00079  *
00080  * Revision 1.9  2004/03/17 15:58:50  p_grandclement
00081  * Slight modification of sol_elliptic_no_zec
00082  *
00083  * Revision 1.8  2004/03/01 09:57:04  j_novak
00084  * the wave equation is solved with Scalars. It now accepts a grid with a
00085  * compactified external domain, which the solver ignores and where it copies
00086  * the values of the field from one time-step to the next.
00087  *
00088  * Revision 1.7  2004/02/11 09:47:46  p_grandclement
00089  * Addition of a new elliptic solver, matching with the homogeneous solution
00090  * at the outer shell and not solving in the external domain (more details
00091  * coming soon ; check your local Lorene dealer...)
00092  *
00093  * Revision 1.6  2004/01/28 16:59:14  p_grandclement
00094  * *** empty log message ***
00095  *
00096  * Revision 1.5  2004/01/28 16:46:24  p_grandclement
00097  * Addition of the sol_elliptic_fixe_der_zero stuff
00098  *
00099  * Revision 1.4  2004/01/14 10:11:51  f_limousin
00100  * Corrected bug in poisson with parameters.
00101  *
00102  * Revision 1.3  2003/12/11 14:48:51  p_grandclement
00103  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00104  *
00105  * Revision 1.2  2003/10/15 21:14:23  e_gourgoulhon
00106  * Added method poisson_angu().
00107  *
00108  * Revision 1.1  2003/09/25 08:06:56  e_gourgoulhon
00109  * First versions (use Cmp as intermediate quantities).
00110  *
00111  *
00112  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_pde.C,v 1.19 2007/05/06 10:48:15 p_grandclement Exp $
00113  *
00114  */
00115 
00116 // Header Lorene:
00117 #include "map.h"
00118 #include "scalar.h"
00119 #include "tensor.h"
00120 #include "param.h"
00121 #include "cmp.h"
00122 #include "param_elliptic.h"
00123 
00124   
00125             //-----------------------------------//
00126             //      Scalar Poisson equation      //
00127             //-----------------------------------//
00128 
00129 // Version without parameters
00130 // --------------------------
00131 
00132 Scalar Scalar::poisson() const {
00133     
00134     Param bidon ;
00135     Cmp csource(*this) ; 
00136     Cmp cresu(mp) ;     
00137     cresu = 0. ;
00138 
00139     mp->poisson(csource, bidon, cresu) ; 
00140 
00141     Scalar resu(cresu) ; 
00142     return resu ;          
00143 }
00144 
00145 // Version with parameters
00146 // -----------------------
00147 
00148 void Scalar::poisson(Param& par, Scalar& uu) const {
00149     
00150     Cmp csource(*this) ; 
00151     Cmp cuu(uu) ;     
00152 
00153     mp->poisson(csource, par, cuu) ;     
00154     
00155     uu = cuu ; 
00156 }
00157 
00158             //-----------------------------------------------//
00159             //      Scalar Poisson equation (TAU method)     //
00160             //----------------------------------------------//
00161         
00162         // without parameters
00163         // --------------------------
00164 
00165 Scalar Scalar::poisson_tau() const {
00166     
00167     Param bidon ;
00168     Cmp csource(*this) ; 
00169     Cmp cresu(mp) ;     
00170     cresu = 0. ;
00171 
00172     mp->poisson_tau(csource, bidon, cresu) ; 
00173 
00174     Scalar resu(cresu) ; 
00175     return resu ;          
00176 }
00177         
00178         // Version with parameters
00179         // -----------------------
00180 void Scalar::poisson_tau (Param& par, Scalar& uu) const {
00181     
00182     Cmp csource(*this) ; 
00183     Cmp cuu(uu) ;     
00184 
00185     mp->poisson_tau(csource, par, cuu) ;     
00186     
00187     uu = cuu ; 
00188 }
00189 
00190 
00191             //-----------------------------------//
00192             //      Angular Poisson equation     //
00193             //-----------------------------------//
00194 
00195 
00196 Scalar Scalar::poisson_angu(double lambda) const {
00197     
00198     Param bidon ;
00199 
00200     Scalar resu(*mp) ; 
00201     resu = 0. ;
00202         
00203     mp->poisson_angu(*this, bidon, resu, lambda) ; 
00204 
00205     return resu ;          
00206 }
00207 
00208 
00209             //-----------------------------------//
00210             //      Scalar d'Alembert equation   //
00211             //-----------------------------------//
00212 
00213 Scalar Scalar::avance_dalembert(Param& par, const Scalar& fjm1, 
00214     const Scalar& source) const {
00215 
00216   Scalar fjp1(*mp) ;
00217   
00218   mp->dalembert(par, fjp1, *this, fjm1, source) ;
00219     
00220   return fjp1 ;
00221 
00222 }
00223 
00224 
00225             //-----------------------------------//
00226             //      General elliptic equation    //
00227             //-----------------------------------//
00228 
00229 
00230 Scalar Scalar::sol_elliptic(Param_elliptic& ope_var) const {
00231 
00232   // Right now, only applicable with affine mapping or log one
00233   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00234   const Map_log* map_log = dynamic_cast <const Map_log*> (mp) ;
00235 
00236   if ((map_affine == 0x0) && (map_log == 0x0))  {
00237     cout << "sol_elliptic only defined for affine or log mapping" << endl ;
00238     abort() ;
00239   }
00240   
00241   Scalar res (*mp) ;
00242   res.set_etat_qcq() ;
00243   
00244   if (map_affine != 0x0)
00245     map_affine->sol_elliptic (ope_var, *this, res) ;
00246   else
00247     map_log->sol_elliptic (ope_var, *this, res) ;
00248 
00249   return (res) ;
00250 }
00251 
00252 Scalar Scalar::sol_elliptic_boundary(Param_elliptic& ope_var, const Mtbl_cf& bound,
00253 double fact_dir, double fact_neu) const {
00254 
00255   // Right now, only applicable with affine mapping or log one
00256   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00257   const Map_log* map_log = dynamic_cast <const Map_log*> (mp) ;
00258 
00259   if ((map_affine == 0x0) && (map_log == 0x0))  {
00260     cout << "sol_elliptic only defined for affine or log mapping" << endl ;
00261     abort() ;
00262   }
00263   
00264   Scalar res (*mp) ;
00265   res.set_etat_qcq() ;
00266   
00267   if (map_affine != 0x0)
00268     map_affine->sol_elliptic_boundary (ope_var, *this, res,  bound,
00269 fact_dir, fact_neu ) ;
00270   else
00271     map_log->sol_elliptic_boundary (ope_var, *this, res,  bound,
00272 fact_dir, fact_neu ) ;
00273 
00274   return (res) ;
00275 }
00276 
00277 
00278 Scalar Scalar::sol_elliptic_boundary(Param_elliptic& ope_var, const Scalar& bound,
00279 double fact_dir, double fact_neu) const {
00280 
00281   // Right now, only applicable with affine mapping or log one
00282   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00283   const Map_log* map_log = dynamic_cast <const Map_log*> (mp) ;
00284 
00285   if ((map_affine == 0x0) && (map_log == 0x0))  {
00286     cout << "sol_elliptic only defined for affine or log mapping" << endl ;
00287     abort() ;
00288   }
00289   
00290   Scalar res (*mp) ;
00291   res.set_etat_qcq() ;
00292   
00293   if (map_affine != 0x0)
00294     map_affine->sol_elliptic_boundary (ope_var, *this, res,  bound,
00295 fact_dir, fact_neu ) ;
00296   else
00297     map_log->sol_elliptic_boundary (ope_var, *this, res,  bound,
00298 fact_dir, fact_neu ) ;
00299 
00300   return (res) ;
00301 }
00302 
00303 
00304      
00305             //-----------------------------------//
00306             //      General elliptic equation    //
00307                     //             with no ZEC           //
00308             //-----------------------------------//
00309 
00310 Scalar Scalar::sol_elliptic_no_zec(Param_elliptic& ope_var, double val) const {
00311 
00312   // Right now, only applicable with affine mapping
00313   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00314   const Map_log* map_log = dynamic_cast <const Map_log*> (mp) ;
00315 
00316   if ((map_affine == 0x0) && (map_log == 0x0)) {
00317     cout << "sol_elliptic_no_zec only defined for affine or log mapping" << endl ;
00318     abort() ;
00319   }
00320   
00321   Scalar res (*mp) ;
00322   res.set_etat_qcq() ;
00323   
00324   if (map_affine != 0x0)
00325     map_affine->sol_elliptic_no_zec (ope_var, *this, res, val) ;
00326   else 
00327     map_log->sol_elliptic_no_zec (ope_var, *this, res, val) ;
00328 
00329   return (res) ;
00330 }       
00331  
00332                     //-----------------------------------//  
00333                     //      General elliptic equation    //
00334                     //             with no ZEC           //
00335             //-----------------------------------//
00336 
00337 Scalar Scalar::sol_elliptic_only_zec(Param_elliptic& ope_var, double val) const {
00338 
00339   // Right now, only applicable with affine mapping
00340   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00341 
00342   if (map_affine == 0x0) {
00343     cout << "sol_elliptic_no_zec only defined for affine or log mapping" << endl ;
00344     abort() ;
00345   }
00346   
00347   Scalar res (*mp) ;
00348   res.set_etat_qcq() ;
00349   
00350   map_affine->sol_elliptic_only_zec (ope_var, *this, res, val) ;
00351   return (res) ;
00352 }
00353                 //-----------------------------------//
00354             //      General elliptic equation    //
00355                     //         with no ZEC and a         //
00356                     //        matching with sin(r)/r     //
00357             //-----------------------------------//
00358 
00359 Scalar Scalar::sol_elliptic_sin_zec(Param_elliptic& ope_var, double* amplis, double* phases) 
00360   const {
00361 
00362   // Right now, only applicable with affine mapping
00363   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00364   
00365   if (map_affine == 0x0) {
00366     cout << "sol_elliptic_sin_zec only defined for affine mapping" << endl ;
00367     abort() ;
00368   }
00369   
00370   Scalar res (*mp) ;
00371   res.set_etat_qcq() ;
00372   
00373   map_affine->sol_elliptic_sin_zec (ope_var, *this, res, amplis, phases) ;
00374 
00375   return (res) ;
00376 }
00377             //-----------------------------------//
00378             //      General elliptic equation    //
00379                     //      fixing the radial derivative //
00380             //-----------------------------------//
00381 
00382 Scalar Scalar::sol_elliptic_fixe_der_zero (double valeur, 
00383                        Param_elliptic& ope_var) const {
00384 
00385   // Right now, only applicable with affine mapping
00386   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00387   
00388   if (map_affine == 0x0) {
00389     cout << "sol_elliptic_no_zec only defined for affine mapping" << endl ;
00390     abort() ;
00391   }
00392   
00393   Scalar res (*mp) ;
00394   res.set_etat_qcq() ;
00395   
00396   map_affine->sol_elliptic_fixe_der_zero (valeur, ope_var, *this, res) ;
00397 
00398   return (res) ;
00399 }
00400 
00401             //-----------------------------------//
00402             //     Two-dimensional Poisson eq.   //
00403             //-----------------------------------//
00404 
00405 Scalar Scalar::sol_elliptic_2d (Param_elliptic& ope_var) const {
00406 
00407   // Right now, only applicable with affine mapping
00408   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00409   
00410   if (map_affine == 0x0) {
00411     cout << "Poisson 2D only defined for affine mapping" << endl ;
00412     abort() ;
00413   }
00414   
00415   Scalar res (*mp) ;
00416   res.set_etat_qcq() ;
00417   
00418   map_affine->sol_elliptic_2d(ope_var, *this, res) ;
00419 
00420   return (res) ;
00421 }
00422             //-----------------------------------//
00423             //     Pseudo-1dimensional eq.   //
00424             //-----------------------------------//
00425 
00426 Scalar Scalar::sol_elliptic_pseudo_1d (Param_elliptic& ope_var) const {
00427 
00428   // Right now, only applicable with affine mapping
00429   const Map_af* map_affine = dynamic_cast <const Map_af*> (mp) ;
00430   
00431   if (map_affine == 0x0) {
00432     cout << "Pseudo_1d only defined for affine mapping" << endl ;
00433     abort() ;
00434   }
00435   
00436   Scalar res (*mp) ;
00437   res.set_etat_qcq() ;
00438   
00439   map_affine->sol_elliptic_pseudo_1d(ope_var, *this, res) ;
00440 
00441   return (res) ;
00442 }

Generated on Tue Feb 7 01:35:19 2012 for LORENE by  doxygen 1.4.6