et_bin_bhns_extr_phi.C

00001 /*
00002  *  Method of class Et_bin_bhns_extr to search the position of the longest
00003  *   radius from the position of the maximum enthalpy
00004  *  The code returns the position of "phi" only because "xi=1" and
00005  *   "theta=pi/2".
00006  *
00007  *    (see file et_bin_bhns_extr.h for documentation).
00008  *
00009  */
00010 
00011 /*
00012  *   Copyright (c) 2004 Keisuke Taniguchi
00013  *
00014  *   This file is part of LORENE.
00015  *
00016  *   LORENE is free software; you can redistribute it and/or modify
00017  *   it under the terms of the GNU General Public License version 2
00018  *   as published by the Free Software Foundation.
00019  *
00020  *   LORENE is distributed in the hope that it will be useful,
00021  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *   GNU General Public License for more details.
00024  *
00025  *   You should have received a copy of the GNU General Public License
00026  *   along with LORENE; if not, write to the Free Software
00027  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028  *
00029  */
00030 
00031 char et_bin_bhns_extr_phi_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_phi.C,v 1.1 2004/11/30 20:50:48 k_taniguchi Exp $" ;
00032 
00033 /*
00034  * $Id: et_bin_bhns_extr_phi.C,v 1.1 2004/11/30 20:50:48 k_taniguchi Exp $
00035  * $Log: et_bin_bhns_extr_phi.C,v $
00036  * Revision 1.1  2004/11/30 20:50:48  k_taniguchi
00037  * *** empty log message ***
00038  *
00039  *
00040  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_phi.C,v 1.1 2004/11/30 20:50:48 k_taniguchi Exp $
00041  *
00042  */
00043 
00044 // C headers
00045 #include <math.h>
00046 
00047 // Lorene headers
00048 #include "et_bin_bhns_extr.h"
00049 #include "utilitaires.h"
00050 
00051 double Et_bin_bhns_extr::phi_longest_rad(double x_max, double y_max) const {
00052 
00053     //----------------------------------------------------------------//
00054     //          Construct the surface function S(theta, phi)          //
00055     //----------------------------------------------------------------//
00056 
00057     // The following is required to access functions of Map_et
00058     Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
00059 
00060     const Valeur& ff0 = mp_et.get_ff() ;
00061     const Valeur& gg0 = mp_et.get_gg() ;
00062 
00063     Valeur fff = ff0 ;
00064     Valeur ggg = gg0 ;
00065     Valeur dff = fff.dsdp() ;
00066     Valeur dgg = ggg.dsdp() ;
00067 
00068     double ppp = M_PI/2. ; // Initial position of the phi-coordinate
00069     double ptmp ;
00070     int mm ;          // Number of steps to the phi-direction
00071     double dp = 1. ;  // Step interval to the phi-direction, initialized to 1
00072     double diff ;
00073     double diff_prev ;
00074     double ss ;
00075 
00076     while ( dp > 1.e-15 ) {
00077 
00078         diff = 1. ;
00079     mm = 0 ;
00080     dp = 0.1 * dp ;
00081 
00082     diff_prev = ( dff.val_point(0,1.,M_PI/2.,ppp)
00083               + dgg.val_point(0,1.,M_PI/2.,ppp) )
00084       * ( 1. + ff0.val_point(0,1.,M_PI/2.,ppp)
00085           + gg0.val_point(0,1.,M_PI/2.,ppp)
00086           - x_max * cos(ppp) - y_max * sin(ppp) )
00087       - ( 1. + ff0.val_point(0,1.,M_PI/2.,ppp)
00088           + gg0.val_point(0,1.,M_PI/2.,ppp) )
00089       * ( - x_max * sin(ppp) + y_max * cos(ppp) ) ;
00090 
00091     if ( diff_prev > 0. ) {
00092         ss = 1. ;
00093     }
00094     else {
00095         ss = -1. ;
00096     }
00097 
00098     while ( diff > 1.e-15 ) {
00099 
00100         mm++ ;
00101         ptmp = ppp + mm * dp ;
00102 
00103         diff = ss * ( ( dff.val_point(0,1.,M_PI/2.,ptmp)
00104                 + dgg.val_point(0,1.,M_PI/2.,ptmp) )
00105               * ( 1. + ff0.val_point(0,1.,M_PI/2.,ptmp)
00106                   + gg0.val_point(0,1.,M_PI/2.,ptmp)
00107                   - x_max * cos(ptmp) - y_max * sin(ptmp) )
00108               - ( 1. + ff0.val_point(0,1.,M_PI/2.,ptmp)
00109                   + gg0.val_point(0,1.,M_PI/2.,ptmp) )
00110               * ( - x_max * sin(ptmp) + y_max * cos(ptmp) ) ) ;
00111 
00112     }
00113     ppp += ss * (mm - 1) * dp ;
00114 
00115     }
00116 
00117     return ppp ;
00118 
00119 }

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