fielddiagplot.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2011 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef FIELDDIAGPLOT_HPP
44 #define FIELDDIAGPLOT_HPP 1
45 
46 
47 #include "types.hpp"
48 #include "frame.hpp"
49 #include "xygraph.hpp"
50 #include "vec3d.hpp"
51 #include "geometry.hpp"
52 #include "scalarfield.hpp"
53 #include "vectorfield.hpp"
54 
55 
56 #define FIELDD_DIAG_NONE FIELD_NONE
57 #define FIELDD_DIAG_EPOT FIELD_EPOT
58 #define FIELDD_DIAG_SCHARGE FIELD_SCHARGE
59 #define FIELDD_DIAG_TRAJDENS FIELD_TRAJDENS
60 #define FIELDD_DIAG_EFIELD FIELD_EFIELD
61 #define FIELDD_DIAG_EFIELD_X FIELD_EFIELD_X
62 #define FIELDD_DIAG_EFIELD_Y FIELD_EFIELD_Y
63 #define FIELDD_DIAG_EFIELD_Z FIELD_EFIELD_Z
64 #define FIELDD_DIAG_BFIELD FIELD_BFIELD
65 #define FIELDD_DIAG_BFIELD_X FIELD_BFIELD_X
66 #define FIELDD_DIAG_BFIELD_Y FIELD_BFIELD_Y
67 #define FIELDD_DIAG_BFIELD_Z FIELD_BFIELD_Z
68 
69 
76 };
77 
78 
84 
85  Frame *_frame;
86 
87  const Geometry *_geom;
88  const ScalarField *_epot;
89  const ScalarField *_scharge;
90  const VectorField *_efield;
91  const VectorField *_bfield;
92 
93  size_t _N;
94  Vec3D _x1;
95  Vec3D _x2;
96 
97  field_diag_type_e _diag[2];
98  field_loc_type_e _loc[2];
99 
100  XYGraph *_graph[2];
101  LegendEntry *_legend[2];
102 
103  void build_data( std::vector<double> coord[4],
104  std::vector<double> fielddata[2] ) const;
105  std::string diagnostic_label( field_diag_type_e diag ) const;
106 
107 public:
108 
111  FieldDiagPlot( Frame *frame, const Geometry *geom );
112 
115  ~FieldDiagPlot();
116 
119  void set_epot( const ScalarField *epot ) {
120  _epot = epot;
121  }
122 
125  void set_efield( const VectorField *efield ) {
126  _efield = efield;
127  }
128 
131  void set_scharge( const ScalarField *scharge ) {
132  _scharge = scharge;
133  }
134 
137  void set_bfield( const VectorField *bfield ) {
138  _bfield = bfield;
139  }
140 
147  void set_coordinates( size_t N, const Vec3D &x1, const Vec3D &x2 ) {
148  _N = N;
149  _x1 = x1;
150  _x2 = x2;
151  }
152 
155  const Vec3D &start( void ) {
156  return( _x1 );
157  }
158 
161  const Vec3D &end( void ) {
162  return( _x2 );
163  }
164 
167  const size_t &N( void ) {
168  return( _N );
169  }
170 
178  void set_diagnostic( const field_diag_type_e diag[2], const field_loc_type_e loc[2] ) {
179  _diag[0] = diag[0];
180  _diag[1] = diag[1];
181  _loc[0] = loc[0];
182  _loc[1] = loc[1];
183  }
184 
188  return( _diag[i] );
189  }
190 
194  return( _loc[i] );
195  }
196 
199  void export_data( const std::string &filename ) const;
200 
203  void build_plot( void );
204 };
205 
206 
207 
208 #endif
209 
210 
211 
212 
213 
214