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