00001 00005 /* Copyright (c) 2005-2011 Taneli Kalvas. All rights reserved. 00006 * 00007 * You can redistribute this software and/or modify it under the terms 00008 * of the GNU General Public License as published by the Free Software 00009 * Foundation; either version 2 of the License, or (at your option) 00010 * any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this library (file "COPYING" included in the package); 00019 * if not, write to the Free Software Foundation, Inc., 51 Franklin 00020 * Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 * If you have questions about your rights to use or distribute this 00023 * software, please contact Berkeley Lab's Technology Transfer 00024 * Department at TTD@lbl.gov. Other questions, comments and bug 00025 * reports should be sent directly to the author via email at 00026 * taneli.kalvas@jyu.fi. 00027 * 00028 * NOTICE. This software was developed under partial funding from the 00029 * U.S. Department of Energy. As such, the U.S. Government has been 00030 * granted for itself and others acting on its behalf a paid-up, 00031 * nonexclusive, irrevocable, worldwide license in the Software to 00032 * reproduce, prepare derivative works, and perform publicly and 00033 * display publicly. Beginning five (5) years after the date 00034 * permission to assert copyright is obtained from the U.S. Department 00035 * of Energy, and subject to any subsequent five (5) year renewals, 00036 * the U.S. Government is granted for itself and others acting on its 00037 * behalf a paid-up, nonexclusive, irrevocable, worldwide license in 00038 * the Software to reproduce, prepare derivative works, distribute 00039 * copies to the public, perform publicly and display publicly, and to 00040 * permit others to do so. 00041 */ 00042 00043 #ifndef FIELDDIAGPLOT_HPP 00044 #define FIELDDIAGPLOT_HPP 1 00045 00046 00047 #include "types.hpp" 00048 #include "frame.hpp" 00049 #include "xygraph.hpp" 00050 #include "vec3d.hpp" 00051 #include "geometry.hpp" 00052 #include "scalarfield.hpp" 00053 #include "vectorfield.hpp" 00054 00055 00056 #define FIELDD_DIAG_NONE FIELD_NONE 00057 #define FIELDD_DIAG_EPOT FIELD_EPOT 00058 #define FIELDD_DIAG_SCHARGE FIELD_SCHARGE 00059 #define FIELDD_DIAG_TRAJDENS FIELD_TRAJDENS 00060 #define FIELDD_DIAG_EFIELD FIELD_EFIELD 00061 #define FIELDD_DIAG_EFIELD_X FIELD_EFIELD_X 00062 #define FIELDD_DIAG_EFIELD_Y FIELD_EFIELD_Y 00063 #define FIELDD_DIAG_EFIELD_Z FIELD_EFIELD_Z 00064 #define FIELDD_DIAG_BFIELD FIELD_BFIELD 00065 #define FIELDD_DIAG_BFIELD_X FIELD_BFIELD_X 00066 #define FIELDD_DIAG_BFIELD_Y FIELD_BFIELD_Y 00067 #define FIELDD_DIAG_BFIELD_Z FIELD_BFIELD_Z 00068 00069 00070 enum field_loc_type_e { 00071 FIELDD_LOC_NONE = 0, 00072 FIELDD_LOC_X, 00073 FIELDD_LOC_Y, 00074 FIELDD_LOC_Z, 00075 FIELDD_LOC_DIST 00076 }; 00077 00078 00083 class FieldDiagPlot { 00084 00085 Frame *_frame; 00086 00087 const Geometry *_geom; 00088 const ScalarField *_epot; 00089 const ScalarField *_scharge; 00090 const VectorField *_efield; 00091 const VectorField *_bfield; 00092 00093 size_t _N; 00094 Vec3D _x1; 00095 Vec3D _x2; 00096 00097 field_diag_type_e _diag[2]; 00098 field_loc_type_e _loc[2]; 00099 00100 XYGraph *_graph[2]; 00101 LegendEntry *_legend[2]; 00102 00103 void build_data( std::vector<double> coord[4], 00104 std::vector<double> fielddata[2] ) const; 00105 std::string diagnostic_label( field_diag_type_e diag ) const; 00106 00107 public: 00108 00111 FieldDiagPlot( Frame *frame, const Geometry *geom ); 00112 00115 ~FieldDiagPlot(); 00116 00119 void set_epot( const ScalarField *epot ) { 00120 _epot = epot; 00121 } 00122 00125 void set_efield( const VectorField *efield ) { 00126 _efield = efield; 00127 } 00128 00131 void set_scharge( const ScalarField *scharge ) { 00132 _scharge = scharge; 00133 } 00134 00137 void set_bfield( const VectorField *bfield ) { 00138 _bfield = bfield; 00139 } 00140 00147 void set_coordinates( size_t N, const Vec3D &x1, const Vec3D &x2 ) { 00148 _N = N; 00149 _x1 = x1; 00150 _x2 = x2; 00151 } 00152 00155 const Vec3D &start( void ) { 00156 return( _x1 ); 00157 } 00158 00161 const Vec3D &end( void ) { 00162 return( _x2 ); 00163 } 00164 00167 const size_t &N( void ) { 00168 return( _N ); 00169 } 00170 00178 void set_diagnostic( const field_diag_type_e diag[2], const field_loc_type_e loc[2] ) { 00179 _diag[0] = diag[0]; 00180 _diag[1] = diag[1]; 00181 _loc[0] = loc[0]; 00182 _loc[1] = loc[1]; 00183 } 00184 00187 const field_diag_type_e &get_diagnostic_type( int i ) { 00188 return( _diag[i] ); 00189 } 00190 00193 const field_loc_type_e &get_location_type( int i ) { 00194 return( _loc[i] ); 00195 } 00196 00199 void export_data( const std::string &filename ) const; 00200 00203 void build_plot( void ); 00204 }; 00205 00206 00207 00208 #endif 00209 00210 00211 00212 00213 00214