MeshKit  1.0
AssyGen.hpp
Go to the documentation of this file.
00001 //-----------------------------------C++-------------------------------------//
00002 // File: src/algs/meshkit/AssyGen.hpp
00003 //
00004 // Brief: AssyGen class definition:
00005 //        Creates reactor assembly geometry (ACIS or OCC format) and cubit mesh script as specified in a user defined input
00006 //         class, AssyGen
00007 //---------------------------------------------------------------------------//
00008 
00009 #ifndef MESHKIT_ASSYGEN_HPP
00010 #define MESHKIT_ASSYGEN_HPP
00011 
00012 #include <cassert>
00013 #include <string>
00014 #include <vector>
00015 #include <set>
00016 
00017 #include "meshkit/Types.hpp"
00018 #include "meshkit/Error.hpp"
00019 #include "meshkit/MeshScheme.hpp"
00020 #include "meshkit/ModelEnt.hpp"
00021 #include "meshkit/MKCore.hpp"
00022 #include "meshkit/SizingFunction.hpp"
00023 #include "meshkit/RegisterMeshOp.hpp"
00024 
00025 #include "meshkit/LocalSet.hpp"
00026 #include "meshkit/LocalTag.hpp"
00027 #include "meshkit/Matrix.hpp"
00028 
00029 #include "meshkit/iMesh.hpp"
00030 //#include "meshkit/iGeom.hpp"
00031 #include "iGeom.h"
00032 #include "MBCN.h"
00033 
00034 #include "meshkit/SimpleArray.hpp"
00035 
00036 #include "meshkit/vectortemplate.hpp"
00037 #include "meshkit/matrixtemplate.hpp"
00038 #include "meshkit/pincell.hpp"
00039 #include "meshkit/parser.hpp"
00040 #include "meshkit/clock.hpp"
00041 
00042 namespace MeshKit {
00043 
00044 #define DEFAULT_TEST_FILE  "assygen_default"
00045 #define TEST_FILE_NAME "assygen_default"
00046 
00047 //#define CHECK( STR ) if (err != iBase_SUCCESS) return Print_Error( STR, err, geom, __FILE__, __LINE__ )
00048 
00049   enum ErrorStates {PINCELLS, INVALIDINPUT, EMAT, EGEOMTYPE, EGEOMENGINE, ENEGATIVE, EALIAS, EPIN, EUNEQUAL};
00050 
00051   class MKCore;
00052 
00053   class AssyGen : public MeshScheme
00054   {
00055   public:
00056     /* \brief Constructor
00057      *
00058      * Create a new AssyGen instance
00059      * \param impl the iGeom instance handle for the Geom
00060      */
00061     AssyGen(MKCore *mk, const MEntVector &me_vec);
00062 
00063     /* \brief Destructor
00064      */
00065     virtual ~AssyGen();
00066 
00067     enum ErrorStates {PINCELLS, INVALIDINPUT, EMAT, EGEOMTYPE, EGEOMENGINE, ENEGATIVE, EALIAS, EPIN, EUNEQUAL};
00068 
00070     static const char* name();
00071 
00076     static bool can_mesh(iBase_EntityType dim);
00077 
00084     static bool can_mesh(ModelEnt *me);
00085 
00089     static const moab::EntityType* output_types();
00090 
00094     virtual const moab::EntityType* mesh_types_arr() const;
00095 
00099     virtual bool add_modelent(ModelEnt *model_ent);
00100 
00102     virtual void setup_this();
00103 
00105     virtual void execute_this();
00106 
00110     void PrepareIO (int argc, char *argv[], std::string TestDir);
00111 
00115     void ReadCommonInp ();
00116 
00120     void ReadInputPhase1 ();
00121 
00125     void ReadAndCreate ();
00126 
00130     void CreateAssyGenInputFiles();
00131 
00135     void Name_Faces( const std::string sMatName, const iBase_EntityHandle body,
00136                      iBase_TagHandle this_tag);
00137 
00141     void Center_Assm( char&);
00142 
00146     void Section_Assm ( char&, double&, const std::string);
00147 
00151     void Rotate_Assm ( char&, double&);
00152 
00156     void Move_Assm ( double&, double&, double&);
00157 
00161     void Create_HexAssm( std::string &);
00162 
00166     void Create_CartAssm( std::string &);
00167 
00171     void CreateOuterCovering();
00172 
00176     void Imprint_Merge (bool, bool);
00177 
00181     void Subtract_Pins ();
00182 
00186     void Create2DSurf();
00187 
00191     void ReadPinCellData( int i);
00192 
00196     void CreatePinCell_Intersect( int i, double dX,
00197                                   double dY, double dZ);
00198 
00202     void CreatePinCell( int i, double dX,
00203                         double dY, double dZ);
00204 
00208     void CreateCubitJournal();
00209 
00213     void ComputePinCentroid( int, CMatrix<std::string>, int, int,
00214                              double&, double&, double&);
00215 
00216   private:
00217     // iGeom Impl for calling geometry creation/manipulation operations
00218     iGeom *igeomImpl;
00219 
00220     // number of sides in the geometry
00221     int m_nSides;
00222 
00223     // file Input
00224     std::ifstream m_FileInput, m_FileCommon;
00225 
00226     // journal file Output
00227     std::ofstream m_FileOutput, m_SchemesFile, m_AssmInfo, m_PyCubGeomFile;
00228 
00229     // string for file names
00230     std::string m_szSmooth, m_szAssmInfo, m_szLogFile, m_szCommonFile, m_szFile, m_szInFile,
00231     m_szGeomFile, m_szGeomFile1, m_szJouFile, m_szSchFile, m_szPyCubGeom;
00232 
00233     // matrix for holding pincell arrangement
00234     CMatrix<std::string> m_Assembly;
00235 
00236     // matrix for holding verts coordinates used in tet-meshing
00237     CMatrix<double> m_dMTopSurfCoords;
00238 
00239     // vector for duct specification
00240     CMatrix<double> m_dMAssmPitch, m_dMAssmPitchX, m_dMAssmPitchY, m_dMXYAssm, m_dMZAssm;
00241 
00242     // vector for material names
00243     CVector<std::string> m_szAssmMat, m_szAssmMatAlias;
00244     CMatrix<std::string> m_szMMAlias;
00245 
00246     // vector holding a pincell
00247     CVector<CPincell> m_Pincell;
00248 
00249     CVector<double> m_dAxialSize, m_dBLMatBias;
00250 
00251     // string for geomtype, engine, meshtype
00252     std::string m_szEngine;
00253     std::string m_szGeomType;
00254     std::string m_szMeshType;
00255     std::string m_szSideset;
00256     std::vector<std::string> m_szDuctMats;
00257     // integers for vectors sizes, err etc
00258     int m_nAssemblyMat, m_nDimensions, m_nPincells , m_nAssmVol, m_nPin, m_nPinX, m_nPinY, err, m_nLineNumber, m_nPlanar,
00259       m_nNeumannSetId, m_nMaterialSetId, m_nDuct, m_nDuctNum, m_nJouFlag, m_nAssyGenInputFiles,  m_nTotalPincells;
00260 
00261     // doubles for pincell pitch, pi and mesh sizes resp.
00262     double m_dPitch, pi, m_dRadialSize, m_dTetMeshSize, m_dMergeTol, m_dZstart, m_dZend;
00263 
00264     // igeom related
00265     SimpleArray<iBase_EntityHandle> assms, in_pins;
00266     //iGeom_Instance geom;
00267     iBase_EntitySetHandle root_set;
00268 
00269 
00270     // error handlers
00271     void IOErrorHandler (ErrorStates) const;
00272     friend class CPincell;
00273 
00274     struct superblocks{
00275         int m_nSuperBlockId;
00276         std::string m_szSuperBlockAlias;
00277         int m_nNumSBContents;
00278         CVector<int> m_nSBContents;
00279     };
00280 
00281     int m_nSuperBlocks;
00282     CVector<superblocks> sb;
00283     int tmpSB;
00284 
00285     // parsing related
00286     std::string szInputString;
00287     std::string szComment;
00288     int MAXCHARS, MAXLINES;
00289 
00290     std::vector< std::vector<iBase_EntityHandle> > cp_inpins;
00291 
00292     CVector<std::string> m_szBLAssmMat;
00293     CVector<int> m_nListMatSet, m_nListNeuSet, m_nBLMatIntervals;
00294 
00295     int m_edgeInterval;
00296     int m_nStartpinid;
00297     std::string m_szInfo;
00298     std::string m_szMeshScheme;
00299     std::string pin_name;
00300     int m_nHblock;
00301     bool m_bCreateMatFiles;
00302     bool save_exodus, m_bmerge, m_bimprint;
00303     bool have_common;
00304     int com_run_count;
00305     int m_nBLAssemblyMat;
00306     std::string m_szInnerDuct;
00307   };
00308 
00309   inline const char* AssyGen::name()
00310   {
00311     return "AssyGen";
00312   }
00313 
00314   inline bool AssyGen::can_mesh(iBase_EntityType)
00315   {
00316     return false;
00317   }
00318 
00319   inline bool AssyGen::can_mesh(ModelEnt *)
00320   {
00321     return true;
00322   }
00323 
00324   inline const moab::EntityType* AssyGen::mesh_types_arr() const
00325   {
00326     return output_types();
00327   }
00328 
00329 } // namespace MeshKit
00330 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines