Navigation

Main Page
Download
Support
Installation
Tutorial
Examples
Reference Manual
   Version 1.0.4
      Class Index
      File List
   Version 1.0.4dev
Publications


Hosted by Get Ion Beam Simulator at SourceForge.net. Fast, secure and Free Open Source software downloads

geometry.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 GEOMETRY_HPP
00044 #define GEOMETRY_HPP 1
00045 
00046 
00047 #include <stdint.h>
00048 #include <vector>
00049 #include <iostream>
00050 #include "file.hpp"
00051 #include "vec3d.hpp"
00052 #include "solid.hpp"
00053 #include "types.hpp"
00054 
00055 
00068 struct Bound 
00069 {
00070     bound_e         type;
00071     double          val;
00072 
00075     Bound( bound_e t, double v ) : type(t), val(v) {}
00076 
00079     Bound( std::istream &s ) {
00080         type = (bound_e)read_int32( s );
00081         val = read_double( s );
00082     }
00083 
00086     void save( std::ostream &fout ) const {
00087         write_int32( fout, type );
00088         write_double( fout, val );
00089     }
00090 };
00091 
00092 
00126 class Geometry 
00127 {
00128     geom_mode_e                _geom_mode; 
00129     Int3D                      _size;      
00130     Vec3D                      _origo;     
00131     Vec3D                      _max;       
00132     double                     _h;         
00134     int32_t                    _n;         
00135     std::vector<const Solid*>  _sdata;     
00136     std::vector<Bound>         _bound;     
00138     bool                       _built;     
00139     signed char               *_smesh;     
00141     int32_t                    _brktc;     
00146     bool vac_or_neu( int32_t i, int32_t j, int32_t k );
00147 
00148 public:
00149 
00155     Geometry( geom_mode_e geom_mode, Int3D size, Vec3D origo, double h );
00156 
00159     Geometry( std::istream &s );
00160 
00163     ~Geometry();
00164 
00167     geom_mode_e geom_mode( void ) const { return( _geom_mode ); }
00168 
00171     int32_t dim( void ) const;
00172 
00175     Int3D size( void ) const { return( _size ); }
00176 
00179     int32_t size( int i ) const { return( _size[i] ); }
00180    
00183     int32_t nodecount( void ) const { return( _size[0]*_size[1]*_size[2] ); }
00184 
00187     Vec3D origo( void ) const { return( _origo ); }
00188 
00191     double origo( int i ) const { return( _origo[i] ); }
00192 
00196     Vec3D max( void ) const { return( _max ); }
00197 
00201     double max( int i ) const { return( _max[i] ); }
00202 
00205     double h( void ) const { return( _h ); }
00206 
00216     void set_solid( int32_t n, const Solid *s );
00217 
00222     const Solid *get_solid( int32_t n ) const;
00223 
00239     void set_boundary( int32_t n, const Bound &b );
00240 
00243     Bound get_boundary( int32_t n ) const;
00244 
00247     std::vector<Bound> get_boundaries() const;
00248 
00262     void set_bracket_count( int32_t n );
00263 
00266     int32_t get_bracket_count( void ) const;
00267 
00274     int32_t inside( const Vec3D &x ) const;
00275 
00278     bool inside( int32_t n, const Vec3D &x ) const;
00279 
00289     double bracket_surface( int32_t n, const Vec3D &xin, const Vec3D &xout, Vec3D &xsurf ) const;
00290 
00293     bool built( void ) const { return( _built ); }
00294 
00298     void build_mesh( void );
00299 
00302     const signed char &mesh( int32_t i ) const { return( _smesh[i] ); }
00303 
00306     const signed char &mesh( int32_t i, int32_t j ) const {
00307         return( _smesh[i + j*_size[0]] ); 
00308     }
00309 
00312     const signed char &mesh( int32_t i, int32_t j, int32_t k ) const {
00313         return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00314     }
00315 
00318     signed char &mesh( int32_t i ) { return( _smesh[i] ); }
00319 
00322     signed char &mesh( int32_t i, int32_t j ) {
00323         return( _smesh[i + j*_size[0]] );
00324     }
00325 
00328     signed char &mesh( int32_t i, int32_t j, int32_t k ) {
00329         return( _smesh[i + j*_size[0] + k*_size[0]*_size[1]] );
00330     }
00331 
00335     signed char mesh_check( int32_t i, int32_t j, int32_t k ) const;
00336 
00339     void save( std::ostream &s ) const;
00340 
00343     void debug_print( void ) const;
00344 };
00345 
00346 
00347 #endif
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365 


Reference manual for Ion Beam Simulator 1.0.4
Generated by Doxygen 1.7.1 on Wed Apr 13 2011 23:25:31.