IBSimu  1.0.4
fielddiagplot.hpp
Go to the documentation of this file.
00001 
00005 /* Copyright (c) 2005-2010 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 "frame.hpp"
00048 #include "xygraph.hpp"
00049 #include "vec3d.hpp"
00050 #include "geometry.hpp"
00051 #include "scalarfield.hpp"
00052 #include "efield.hpp"
00053 #include "vectorfield.hpp"
00054 
00055 
00056 enum field_diag_type_e {
00057     FIELDD_DIAG_NONE = 0,
00058     FIELDD_DIAG_EPOT,
00059     FIELDD_DIAG_EFIELD,
00060     FIELDD_DIAG_EFIELD_X,
00061     FIELDD_DIAG_EFIELD_Y,
00062     FIELDD_DIAG_EFIELD_Z,
00063     FIELDD_DIAG_SCHARGE,
00064     FIELDD_DIAG_BFIELD,
00065     FIELDD_DIAG_BFIELD_X,
00066     FIELDD_DIAG_BFIELD_Y,
00067     FIELDD_DIAG_BFIELD_Z
00068 };
00069 
00070 
00071 enum field_loc_type_e {
00072     FIELDD_LOC_NONE = 0,
00073     FIELDD_LOC_X,
00074     FIELDD_LOC_Y,
00075     FIELDD_LOC_Z,
00076     FIELDD_LOC_DIST
00077 };
00078 
00079 
00084 class FieldDiagPlot {
00085 
00086     Frame              *_frame;
00087 
00088     const Geometry     *_geom;
00089     const ScalarField  *_epot;
00090     const Efield       *_efield;
00091     const ScalarField  *_scharge;
00092     const VectorField  *_bfield;
00093 
00094     size_t              _N;
00095     Vec3D               _x1;
00096     Vec3D               _x2;
00097 
00098     field_diag_type_e   _diag[2];
00099     field_loc_type_e    _loc[2];
00100 
00101     XYGraph            *_graph[2];
00102 
00103 
00104     void build_data( std::vector<double> coord[4], 
00105                      std::vector<double> fielddata[2] ) const;
00106     std::string diagnostic_label( field_diag_type_e diag ) const;
00107 
00108 public:
00109 
00112     FieldDiagPlot( Frame *frame, const Geometry *geom );
00113 
00116     ~FieldDiagPlot();
00117 
00120     void set_epot( const ScalarField *epot ) {
00121         _epot = epot;
00122     }
00123 
00126     void set_efield( const Efield *efield ) {
00127         _efield = efield;
00128     }
00129 
00132     void set_scharge( const ScalarField *scharge ) {
00133         _scharge = scharge;
00134     }
00135 
00138     void set_bfield( const VectorField *bfield ) {
00139         _bfield = bfield;
00140     }
00141 
00148     void set_coordinates( size_t N, const Vec3D &x1, const Vec3D &x2 ) {
00149         _N = N;
00150         _x1 = x1;
00151         _x2 = x2;
00152     }
00153 
00156     const Vec3D &start( void ) {
00157         return( _x1 );
00158     }
00159 
00162     const Vec3D &end( void ) {
00163         return( _x2 );
00164     }
00165 
00168     const size_t &N( void ) {
00169         return( _N );
00170     }
00171 
00179     void set_diagnostic( const field_diag_type_e diag[2], const field_loc_type_e loc[2] ) {
00180         _diag[0] = diag[0];
00181         _diag[1] = diag[1];
00182         _loc[0] = loc[0];
00183         _loc[1] = loc[1];
00184     }
00185 
00188     const field_diag_type_e &get_diagnostic_type( int i ) {
00189         return( _diag[i] );
00190     }
00191 
00194     const field_loc_type_e &get_location_type( int i ) {
00195         return( _loc[i] );
00196     }
00197 
00200     void export_data( const std::string &filename ) const;
00201 
00204     void build_plot( void );
00205 };
00206 
00207 
00208 
00209 #endif
00210 
00211 
00212 
00213 
00214