et_bin_bhns_extr_max.C

00001 /*
00002  *  Method of class Et_bin_bhns_extr to search the position of the maximum
00003  *   enthalpy
00004  *
00005  *    (see file et_bin_bhns_extr.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2004 Keisuke Taniguchi
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License version 2
00016  *   as published by the Free Software Foundation.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 char et_bin_bhns_extr_max_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_max.C,v 1.1 2004/11/30 20:50:24 k_taniguchi Exp $" ;
00030 
00031 /*
00032  * $Id: et_bin_bhns_extr_max.C,v 1.1 2004/11/30 20:50:24 k_taniguchi Exp $
00033  * $Log: et_bin_bhns_extr_max.C,v $
00034  * Revision 1.1  2004/11/30 20:50:24  k_taniguchi
00035  * *** empty log message ***
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_max.C,v 1.1 2004/11/30 20:50:24 k_taniguchi Exp $
00039  *
00040  */
00041 
00042 // C headers
00043 #include <math.h>
00044 
00045 // Lorene headers
00046 #include "et_bin_bhns_extr.h"
00047 //#include "utilitaires.h"
00048 
00049 void Et_bin_bhns_extr::ent_max_search(double& xx, double& yy) const {
00050 
00051     //------------------------------------------------------------------//
00052     //          Calculate the derivative of the enthalpy field          //
00053     //------------------------------------------------------------------//
00054 
00055     const Tenseur& dent = ent.gradient() ;
00056 
00057     double xxp = 0. ;  // Position of the x-coordinate, initialized to zero
00058     double yyp = 0. ;  // Position of the y-coordinate, initialized to zero
00059     double xtmp, ytmp ;
00060     int mm, nn ;       // Number of steps to the x and y directions
00061     double rr = 0. ;   // r coordinate, initialized to zero
00062     double pp = M_PI/2. ;    // phi coordinate, initialized to M_PI/2.
00063     double dval_x ;    // Direction of dent(0) (1 or -1)
00064     double dval_y ;    // Direction of dent(1) (1 or -1)
00065     double ss ;
00066 
00067     while ( fabs(dent(0).val_point(rr, M_PI/2., pp)) > 1.e-15 ||
00068         fabs(dent(1).val_point(rr, M_PI/2., pp)) > 5.e-15) {
00069 
00070         double dx = 1. ; // Step interval to the x-direction, initialized to 1
00071     double dy = 1. ; // Step interval to the y-direction, initialized to 1
00072     double diff_dent_x ;
00073     double diff_dent_y ;
00074 
00075     while ( dy > 1.e-15 ) {
00076 
00077         diff_dent_y = 1. ;
00078         nn = 0 ;
00079         dy = 0.1 * dy ;
00080 
00081         rr = sqrt( xxp*xxp + yyp*yyp ) ;
00082 
00083         if ( xxp == 0. ) {
00084             pp = M_PI/2. ;  // There is a possibility of (pp = 1.5*M_PI)
00085         }
00086         else {
00087             pp = acos( xxp / rr ) ;
00088         }
00089 
00090         dval_y = dent(1).val_point(rr, M_PI/2., pp) ;
00091 
00092         if ( dval_y > 0. ) {
00093             ss = 1. ;
00094         }
00095         else {
00096             ss = -1. ;
00097         }
00098 
00099         while( diff_dent_y > 1.e-15 ) {
00100 
00101             nn++ ;
00102         ytmp = yyp + ss * nn * dy ;
00103 
00104         rr = sqrt( xxp*xxp + ytmp*ytmp ) ;
00105 
00106         if ( xxp == 0. ) {
00107             if ( ss > 0. ) {
00108                 pp = M_PI/2. ;
00109             }
00110             else {
00111                 pp = 1.5*M_PI ;
00112             }
00113         }
00114         else {
00115             pp = acos( xxp / rr ) ;
00116         }
00117 
00118         diff_dent_y = ss * dent(1).val_point(rr, M_PI/2., pp) ;
00119 
00120         }
00121         yyp += ss * (nn - 1) * dy ;
00122 
00123     }
00124 
00125     while ( dx > 1.e-15 ) {
00126 
00127         diff_dent_x = 1. ;
00128         mm = 0 ;
00129         dx = 0.1 * dx ;
00130 
00131         rr = sqrt( xxp*xxp + yyp*yyp ) ;
00132 
00133         if ( xxp == 0. ) {
00134             pp = M_PI/2. ;  // There is a possibility of (pp = 1.5*M_PI)
00135         }
00136         else {
00137             pp = acos( xxp / rr ) ;
00138         }
00139 
00140         dval_x = dent(0).val_point(rr, M_PI/2., pp) ;
00141 
00142         if ( dval_x > 0. ) {
00143             ss = 1. ;
00144         }
00145         else {
00146             ss = -1. ;
00147         }
00148 
00149         while( diff_dent_x > 1.e-15 ) {
00150 
00151             mm++ ;
00152         xtmp = xxp + ss * mm * dx ;
00153 
00154         rr = sqrt( xtmp*xtmp + yyp*yyp ) ;
00155 
00156         if ( xtmp == 0. ) {
00157             if ( ss > 0. ) {
00158                 pp = M_PI/2. ;
00159             }
00160             else {
00161                 pp = 1.5*M_PI ;
00162             }
00163         }
00164         else {
00165             pp = acos( xtmp / rr ) ;
00166         }
00167 
00168         diff_dent_x = ss * dent(0).val_point(rr, M_PI/2., pp) ;
00169 
00170         }
00171         xxp += ss * (mm - 1) * dx ;
00172 
00173     }
00174     }
00175 
00176     xx = xxp ;
00177     yy = yyp ;
00178 
00179 }

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