1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // Copyright (c) 2016 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 // Vext.h 16 // 17 //////////////////////////////////////////////////////////////////////////////// 18 19 #ifndef VEXT_H 20 #define VEXT_H 21 22 #include<iostream> 23 #include<iomanip> 24 #include<sstream> 25 #include<stdlib.h> 26 27 #include "Sample.h" 28 #include "ExternalPotential.h" 29 30 class Vext : public Var 31 { 32 Sample *s; 33 34 public: 35 name(void)36 const char *name ( void ) const { return "vext"; }; 37 set(int argc,char ** argv)38 int set ( int argc, char **argv ) 39 { 40 if ( argc > 2 ) 41 { 42 if ( ui->onpe0() ) 43 cout << " vext takes only one value" << endl; 44 return 1; 45 } 46 47 if ( !strcmp(argv[1],"NULL") ) 48 { 49 // set vext NULL 50 delete s->vext; 51 s->vext = 0; 52 } 53 else 54 { 55 if ( s->vext ) 56 delete s->vext; 57 s->vext = new ExternalPotential(*s,argv[1]); 58 } 59 60 return 0; 61 } 62 print(void)63 string print (void) const 64 { 65 ostringstream st; 66 st.setf(ios::left,ios::adjustfield); 67 st << setw(10) << name() << " = "; 68 if ( s->vext ) 69 { 70 st.setf(ios::right,ios::adjustfield); 71 st << setw(10) << s->vext->filename(); 72 } 73 return st.str(); 74 } 75 Vext(Sample * sample)76 Vext(Sample *sample) : s(sample) {} 77 }; 78 #endif 79