1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2014 The Regents of the University of California 4 // 5 // This file is part of Qbox 6 // 7 // Qbox is distributed under the terms of the GNU General Public License 8 // as published by the Free Software Foundation, either version 2 of 9 // the License, or (at your option) any later version. 10 // See the file COPYING in the root directory of this distribution 11 // or <http://www.gnu.org/licenses/>. 12 // 13 //////////////////////////////////////////////////////////////////////////////// 14 // 15 // ForceTol.h 16 // 17 //////////////////////////////////////////////////////////////////////////////// 18 #ifndef FORCETOL_H 19 #define FORCETOL_H 20 21 #include<iostream> 22 #include<iomanip> 23 #include<sstream> 24 #include<stdlib.h> 25 26 #include "Sample.h" 27 28 class ForceTol : public Var 29 { 30 Sample *s; 31 32 public: 33 name(void)34 const char *name ( void ) const { return "force_tol"; }; 35 set(int argc,char ** argv)36 int set ( int argc, char **argv ) 37 { 38 if ( argc != 2 ) 39 { 40 if ( ui->onpe0() ) 41 cout << " force_tol takes only one value" << endl; 42 return 1; 43 } 44 45 double v = atof(argv[1]); 46 if ( v < 0.0 ) 47 { 48 if ( ui->onpe0() ) 49 cout << " force_tol must be non-negative" << endl; 50 return 1; 51 } 52 53 s->ctrl.force_tol = v; 54 return 0; 55 } 56 print(void)57 string print (void) const 58 { 59 ostringstream st; 60 st.setf(ios::left,ios::adjustfield); 61 st << setw(10) << name() << " = "; 62 st.setf(ios::right,ios::adjustfield); 63 st << setw(10) << s->ctrl.scf_tol; 64 return st.str(); 65 } 66 ForceTol(Sample * sample)67 ForceTol(Sample *sample) : s(sample) { s->ctrl.force_tol = 0.0; } 68 }; 69 #endif 70