cgma
|
#include <MCNPInput.hpp>
Public Member Functions | |
SurfaceCard (InputDeck &deck, const token_list_t tokens) | |
int | getIdent () const |
void | print (std::ostream &s) const |
const DataRef< Transform > & | getTransform () const |
const std::string & | getMnemonic () const |
const std::vector< double > & | getArgs () const |
std::pair< Vector3d, double > | getPlaneParams () const |
std::vector< std::pair < Vector3d, double > > | getMacrobodyPlaneParams () const |
Protected Attributes | |
int | ident |
DataRef< Transform > * | coord_xform |
std::string | mnemonic |
std::vector< double > | args |
Definition at line 91 of file MCNPInput.hpp.
SurfaceCard::SurfaceCard | ( | InputDeck & | deck, |
const token_list_t | tokens | ||
) |
Definition at line 813 of file MCNPInput.cpp.
: Card(deck) { size_t idx = 0; std::string token1 = tokens.at(idx++); if(token1.find_first_of("*+") != token1.npos){ std::cerr << "Warning: no special handling for reflecting or white-boundary surfaces" << std::endl; token1[0] = ' '; } ident = makeint(token1); std::string token2 = tokens.at(idx++); if(token2.find_first_of("1234567890-") != 0){ //token2 is the mnemonic coord_xform = new NullRef<Transform>(); mnemonic = token2; } else{ // token2 is a coordinate transform identifier int tx_id = makeint(token2); if( tx_id == 0 ){ std::cerr << "I don't think 0 is a valid surface transformation ID, so I'm ignoring it." << std::endl; coord_xform = new NullRef<Transform>(); } else if ( tx_id < 0 ){ // abs(tx_id) is the ID of surface with respect to which this surface is periodic. std::cerr << "Warning: surface " << ident << " periodic, but this program has no special handling for periodic surfaces"; } else{ // tx_id is positive and nonzero coord_xform = new CardRef<Transform>( deck, DataCard::TR, makeint(token2) ); } mnemonic = tokens.at(idx++); } while( idx < tokens.size() ){ args.push_back( makedouble(tokens[idx++]) ); } }
const std::vector<double>& SurfaceCard::getArgs | ( | ) | const [inline] |
Definition at line 106 of file MCNPInput.hpp.
{ return args; }
int SurfaceCard::getIdent | ( | ) | const [inline] |
Definition at line 101 of file MCNPInput.hpp.
{ return ident; }
std::vector< std::pair< Vector3d, double > > SurfaceCard::getMacrobodyPlaneParams | ( | ) | const |
Definition at line 887 of file MCNPInput.cpp.
{ std::vector< std::pair< Vector3d, double> > ret; if( mnemonic == "box" ){ Vector3d corner( args ); const Vector3d v[3] = {Vector3d(args,3), Vector3d(args,6), Vector3d(args,9)}; // face order: v1 -v1 v2 -v2 v3 -v3 for( int i = 0; i < 3; ++i ){ Vector3d p = corner + v[i]; ret.push_back( std::make_pair( v[i].normalize(), v[i].projection( p ).length() ) ); ret.push_back( std::make_pair( -v[i].normalize(), v[i].projection( p ).length()-v[i].length() ) ); } } else if( mnemonic == "rpp" ){ Vector3d min( args.at(0), args.at(2), args.at(4) ); Vector3d max( args.at(1), args.at(3), args.at(5) ); for( int i = 0; i < 3; ++i ){ Vector3d v; v.v[i] = 1; ret.push_back( std::make_pair( v.normalize(), max.v[i] )); ret.push_back( std::make_pair(-v.normalize(), min.v[i] )); } } else if( mnemonic == "hex" || mnemonic == "rhp" ){ Vector3d vertex( args ), height( args,3 ), RV( args, 6 ), SV, TV; if( args.size() == 9 ){ SV = RV.rotate_about(height, 60); TV = RV.rotate_about(height, 120); } else{ SV = Vector3d( args, 9 ); TV = Vector3d( args, 12 ); } double len = RV.projection( vertex+RV ).length(); ret.push_back( std::make_pair( RV.normalize(), len ) ); ret.push_back( std::make_pair(-RV.normalize(), len - 2.0 * RV.length() )); len = SV.projection( vertex+SV ).length(); ret.push_back( std::make_pair( SV.normalize(), len ) ); ret.push_back( std::make_pair(-SV.normalize(), len - 2.0 * SV.length() )); len = TV.projection( vertex+TV ).length(); ret.push_back( std::make_pair( TV.normalize(), len ) ); ret.push_back( std::make_pair(-TV.normalize(), len - 2.0 * TV.length() )); len = height.projection( vertex+height ).length(); ret.push_back( std::make_pair( height.normalize(), len ) ); ret.push_back( std::make_pair(-height.normalize(), len - height.length() )); } else{ throw std::runtime_error("Tried to get macrobody plane normals of unsupported surface!" ); } return ret; }
const std::string& SurfaceCard::getMnemonic | ( | ) | const [inline] |
Definition at line 105 of file MCNPInput.hpp.
{ return mnemonic; }
std::pair< Vector3d, double > SurfaceCard::getPlaneParams | ( | ) | const |
Definition at line 869 of file MCNPInput.cpp.
{ if(mnemonic == "px"){ return std::make_pair(Vector3d(1,0,0), args[0]); } else if(mnemonic == "py"){ return std::make_pair(Vector3d(0,1,0), args[0]); } else if(mnemonic == "pz"){ return std::make_pair(Vector3d(0,0,1), args[0]); } else if(mnemonic == "p"){ return std::make_pair(Vector3d( args ), args[3]/Vector3d(args).length()); } else{ throw std::runtime_error("Tried to get plane normal of non-plane surface!"); } }
const DataRef< Transform > & SurfaceCard::getTransform | ( | ) | const |
Definition at line 856 of file MCNPInput.cpp.
{ return *coord_xform; }
void SurfaceCard::print | ( | std::ostream & | s | ) | const |
Definition at line 860 of file MCNPInput.cpp.
{ s << "Surface " << ident << " " << mnemonic << args; if( coord_xform->hasData() ){ // this ugly lookup returns the integer ID of the TR card s << " TR" << dynamic_cast<CardRef<Transform>*>(coord_xform)->getKey().second; } s << std::endl; }
std::vector<double> SurfaceCard::args [protected] |
Definition at line 96 of file MCNPInput.hpp.
DataRef<Transform>* SurfaceCard::coord_xform [protected] |
Definition at line 94 of file MCNPInput.hpp.
int SurfaceCard::ident [protected] |
Definition at line 93 of file MCNPInput.hpp.
std::string SurfaceCard::mnemonic [protected] |
Definition at line 95 of file MCNPInput.hpp.