MOAB: Mesh Oriented datABase
(version 5.2.1)
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 //---------------------------------------------------------------------- 00017 // Filename : ReadMCNP5.hpp 00018 // Purpose : Read a meshtal file created by MCNP5 into MOAB 00019 // Creator : Brandon Smith 00020 // Date : 07/2009 00021 //---------------------------------------------------------------------- 00022 00023 /** 00024 * Data structure of MCNP5 data created by this reader: 00025 * 00026 * each file_meshset contains 00027 * DATA_AND_TIME_TAG 00028 * TITLE_TAG 00029 * NPS_TAG 00030 * each tally_meshset contains 00031 * TALLY_NUMBER_TAG 00032 * TALLY_COMMENT_TAG 00033 * TALLY_PARTICLE_TAG 00034 * TALLY_COORD_SYS_TAG 00035 * each mesh element contains 00036 * TALLY_TAG 00037 * ERROR_TAG 00038 */ 00039 00040 #include "moab/Interface.hpp" 00041 #include "moab/ReaderIface.hpp" 00042 #include <iostream> 00043 #include <fstream> 00044 #include <sstream> 00045 #include <vector> 00046 00047 namespace moab 00048 { 00049 00050 class ReadUtilIface; 00051 00052 class ReadMCNP5 : public ReaderIface 00053 { 00054 00055 public: 00056 // factory method 00057 static ReaderIface* factory( Interface* ); 00058 00059 ErrorCode load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts, 00060 const SubsetList* subset_list = 0, const Tag* file_id_tag = 0 ); 00061 00062 ErrorCode read_tag_values( const char* file_name, const char* tag_name, const FileOptions& opts, 00063 std::vector< int >& tag_values_out, const SubsetList* subset_list = 0 ); 00064 00065 // constructor 00066 ReadMCNP5( Interface* impl = NULL ); 00067 00068 // destructor 00069 virtual ~ReadMCNP5(); 00070 00071 protected: 00072 private: 00073 // constants 00074 static const double PI; 00075 static const double C2PI; 00076 static const double CPI; 00077 00078 enum coordinate_system 00079 { 00080 NO_SYSTEM, 00081 CARTESIAN, 00082 CYLINDRICAL, 00083 SPHERICAL 00084 }; 00085 enum particle 00086 { 00087 NEUTRON, 00088 PHOTON, 00089 ELECTRON 00090 }; 00091 00092 // read mesh interface 00093 ReadUtilIface* readMeshIface; 00094 00095 // MOAB Interface 00096 Interface* MBI; 00097 00098 const Tag* fileIDTag; 00099 int nodeId, elemId; 00100 00101 // reads the meshtal file 00102 ErrorCode load_one_file( const char* fname, const EntityHandle* input_meshset, const FileOptions& options, 00103 const bool average ); 00104 00105 ErrorCode create_tags( Tag& date_and_time_tag, Tag& title_tag, Tag& nps_tag, Tag& tally_number_tag, 00106 Tag& tally_comment_tag, Tag& tally_particle_tag, Tag& tally_coord_sys_tag, Tag& tally_tag, 00107 Tag& error_tag ); 00108 00109 ErrorCode read_file_header( std::fstream& file, bool debug, char date_and_time[100], char title[100], 00110 unsigned long int& nps ); 00111 00112 ErrorCode set_header_tags( EntityHandle output_meshset, char date_and_time[100], char title[100], 00113 unsigned long int nps, Tag data_and_time_tag, Tag title_tag, Tag nps_tag ); 00114 00115 ErrorCode read_tally_header( std::fstream& file, bool debug, unsigned int& tally_number, char tally_comment[100], 00116 particle& tally_particle ); 00117 00118 ErrorCode get_tally_particle( std::string a, bool debug, particle& tally_particle ); 00119 00120 ErrorCode read_mesh_planes( std::fstream& file, bool debug, std::vector< double > planes[3], 00121 coordinate_system& coord_sys ); 00122 00123 ErrorCode get_mesh_plane( std::istringstream& ss, bool debug, std::vector< double >& plane ); 00124 00125 ErrorCode read_element_values_and_errors( std::fstream& file, bool debug, std::vector< double > planes[3], 00126 unsigned int n_chopped_x0_planes, unsigned int n_chopped_x2_planes, 00127 particle tally_particle, double values[], double errors[] ); 00128 00129 ErrorCode set_tally_tags( EntityHandle tally_meshset, unsigned int tally_number, char tally_comment[100], 00130 particle tally_particle, coordinate_system tally_coord_sys, Tag tally_number_tag, 00131 Tag tally_comment_tag, Tag tally_particle_tag, Tag tally_coord_sys_tag ); 00132 00133 ErrorCode create_vertices( std::vector< double > planes[3], bool debug, EntityHandle& start_vert, 00134 coordinate_system coord_sys, EntityHandle tally_meshset ); 00135 00136 ErrorCode create_elements( bool debug, std::vector< double > planes[3], unsigned int n_chopped_x0_planes, 00137 unsigned int n_chopped_x2_planes, EntityHandle start_vert, double values[], 00138 double errors[], Tag tally_tag, Tag error_tag, EntityHandle tally_meshset, 00139 coordinate_system tally_coord_sys ); 00140 00141 ErrorCode average_with_existing_tally( bool debug, unsigned long int& new_nps, unsigned long int nps, 00142 unsigned int tally_number, Tag tally_number_tag, Tag nps_tag, Tag tally_tag, 00143 Tag error_tag, double values[], double errors[], unsigned int n_elements ); 00144 00145 ErrorCode transform_point_to_cartesian( double* in, double* out, coordinate_system coord_sys ); 00146 00147 ErrorCode average_tally_values( const unsigned long int nps0, const unsigned long int nps1, double* values0, 00148 const double* values1, double* errors0, const double* errors1, 00149 const unsigned long int n_values ); 00150 }; 00151 00152 } // namespace moab