MeshKit  1.0
CoreGen.hpp
Go to the documentation of this file.
00001 //-----------------------------------C++-------------------------------------//
00002 // File: src/algs/meshkit/CoreGen.hpp
00003 //
00004 // Brief: CoreGen class definition:
00005 //        Creates reactor core model from input mesh files
00006 //         class, CoreGen
00007 //---------------------------------------------------------------------------//
00008 
00009 #ifndef MESHKIT_COREGEN_HPP
00010 #define MESHKIT_COREGEN_HPP
00011 
00012 
00013 #define STRINGIFY_(X) #X
00014 #define STRINGIFY(X) STRINGIFY_(X)
00015 #define COREGEN_DEFAULT_TEST_FILE  "CoreGen_default"
00016 #define CTEST_FILE_NAME "CoreGen_default"
00017 
00018 #include <cassert>
00019 #include <string>
00020 #include <vector>
00021 #include <set>
00022 
00023 #include "meshkit/Types.hpp"
00024 #include "meshkit/Error.hpp"
00025 #include "meshkit/MeshScheme.hpp"
00026 #include "meshkit/ModelEnt.hpp"
00027 #include "meshkit/MKCore.hpp"
00028 #include "meshkit/SizingFunction.hpp"
00029 #include "meshkit/RegisterMeshOp.hpp"
00030 
00031 #include "meshkit/LocalSet.hpp"
00032 #include "meshkit/LocalTag.hpp"
00033 #include "meshkit/Matrix.hpp"
00034 
00035 #include "meshkit/iMesh.hpp"
00036 #include "meshkit/iGeom.hpp"
00037 #include "MBCN.h"
00038 
00039 #include "meshkit/vectortemplate.hpp"
00040 #include "meshkit/matrixtemplate.hpp"
00041 #include "meshkit/parser.hpp"
00042 #include "meshkit/SimpleArray.hpp"
00043 #include "meshkit/clock.hpp"
00044 #include "meshkit/mstream.hpp"
00045 
00046 #ifdef HAVE_MOAB
00047 #include "iMesh_extensions.h"
00048 #include "MBiMesh.hpp"
00049 #include "MBInterface.hpp"
00050 #include "MBRange.hpp"
00051 #include "MBSkinner.hpp"
00052 #include "MBTagConventions.hpp"
00053 #include "moab/MergeMesh.hpp"
00054 #endif
00055 
00056 
00057 #ifdef USE_MPI
00058 #include "mpi.h"
00059 #include "iMeshP.h"
00060 #include "moab_mpi.h"
00061 #include "moab/ParallelMergeMesh.hpp"
00062 #include "moab/ParallelComm.hpp"
00063 #include "MBParallelConventions.h"
00064 #endif
00065 
00066 #include "meshkit/CopyGeom.hpp"
00067 #include "meshkit/CopyMesh.hpp"
00068 #include "meshkit/ExtrudeMesh.hpp"
00069 #include "meshkit/CESets.hpp"
00070 
00071 namespace MeshKit {
00072 
00073   class MKCore;
00074 
00075   class CoreGen : public MeshScheme
00076   {
00077   public:
00078     /* \brief Constructor
00079      *
00080      * Create a new CoreGen instance
00081      * \param impl the iGeom instance handle for the Geom
00082      */
00083     CoreGen(MKCore *mk, const MEntVector &me_vec);
00084 
00085     /* \brief Destructor
00086      */
00087     virtual ~CoreGen();
00088 
00090     static const char* name();
00091 
00096     static bool can_mesh(iBase_EntityType dim);
00097 
00104     static bool can_mesh(ModelEnt *me);
00105 
00109     static const moab::EntityType* output_types();
00110 
00114     virtual const moab::EntityType* mesh_types_arr() const;
00115 
00119     virtual bool add_modelent(ModelEnt *model_ent);
00120 
00122     virtual void setup_this();
00123 
00125     virtual void execute_this();
00126 
00127     enum ErrorStates {INVALIDINPUT, ENEGATIVE};
00128     int prepareIO (int argc, char *argv[], int nrank, int numprocs, std::string  TestDir);
00129     int load_meshes();
00130     int load_meshes_parallel(const int, int);
00131     int distribute_mesh(const int,  int);
00132     int load_geometries();
00133     int read_inputs_phase1 ();
00134     int read_inputs_phase2 ();
00135     int write_makefile ();
00136     int write_minfofile ();
00137     int find_assm(const int i, int &assm_index);
00138     void banner();
00139     int copymove(const int nrank, const int numprocs);
00140     int copymove_all(const int nrank, const int numprocs);
00141     int set_copymove_coords();
00142     int assign_gids();
00143     int assign_gids_parallel(const int nrank, const int numprocs);
00144     int save_mesh();
00145     int save_mesh(int rank);
00146     int save_mesh_parallel(const int nrank, const int numprocs);
00147     int save_geometry();
00148     int close();
00149     int close_parallel(const int nrank, const int numprocs);
00150     int extrude();
00151     int move_verts(iBase_EntitySetHandle set, const double *dx);
00152     int move_geoms(iBase_EntitySetHandle set, const double *dx);
00153     int create_neumannset();
00154 
00155     bool extrude_flag;
00156     bool mem_tflag;
00157     std::string prob_type, savefiles, info, minfo;
00158     std::vector<std::string> files, all_meshfiles, mk_files;
00159     std::vector<int> assm_meshfiles;
00160     std::vector< std::vector<int> > assm_location;
00161     std::vector<std::vector<int> > position_core;
00162     std::vector<int> meshfile_proc;
00163     std::vector<double> x_coord;
00164     std::vector<double> y_coord;
00165     bool nst_flag, nsb_flag, nss_flag;
00166     std::vector<std::string> core_alias;
00167     std::vector<double> nsx, nsy, nsc;
00168     int num_nsside;
00169 
00170   private:
00172     iGeom *igeom;
00173 
00175     iMesh *imesh;
00176 
00178     MBInterface *mb;
00179 
00180     std::vector <CopyMesh*> cm;
00181     std::vector <CopyGeom*> cg;
00182     ExtrudeMesh *em;
00183 
00184     iBase_EntitySetHandle root_set;
00185     std::vector<iBase_EntitySetHandle> assys;
00186     std::vector<int> assys_index;
00187     // declare variables read in the inputs
00188     int rank, procs, err;
00189     int UNITCELL_DUCT, ASSY_TYPES ;
00190     int nrings, nringsx, nringsy, pack_type, symm;
00191     double pitch, pitchx, pitchy;
00192     bool global_ids, back_mesh;
00193     std::string outfile, mesh_info;
00194     int nassys; // the number of mesh files
00195     int tot_assys; // total no. of assms forming core
00196     int set_DIM; // default is 3D
00197     double PII;
00198     double z_height;    // z_height for extruding surfaces mesh
00199     int z_divisions; // z_divisions for extruding surface mesh
00200     int nst_Id, nsb_Id;
00201     std::vector<int> nss_Id;
00202     std::string testdir;
00203 
00204     // file related
00205     std::ifstream file_input;    // File Input
00206     std::ofstream make_file, info_file, minfo_file;    // File Output
00207     std::string iname, ifile, mfile, geometry, back_meshfile, geom_engine, nsLoc, infofile, minfofile, logfilename;
00208     int linenumber;
00209     std::string card,geom_type, meshfile, mf_alias, temp_alias;
00210     std::vector<std::string> assm_alias;
00211     mstream logfile;
00212 
00213     // parsing related
00214     std::string input_string;
00215     std::string comment ;
00216     int MAXCHARS ;
00217 
00218     // merge related
00219     double merge_tol;
00220     int do_merge;
00221     int update_sets;
00222     iBase_TagHandle merge_tag;
00223 
00224     // MKUtils obj, assigning gid's etc.
00225     //  MKUtils *mu;
00226     // error handler
00227     void IOErrorHandler (ErrorStates) const;
00228     CClock Timer;
00229     std::string szDateTime;
00230     int run_flag;
00231     clock_t sTime;
00232 #ifdef USE_MPI
00233     moab::ParallelComm *pc;
00234 #endif
00235 
00236     // timing related variables
00237     double ctload, ctcopymove, ctmerge, ctextrude, ctns, ctgid, ctsave;
00238     clock_t tload, tcopymove, tmerge, textrude, tns, tgid, tsave;
00239 
00240     // more memory/time related variables
00241     int ld_t, ld_tload, ld_tcopymove, ld_tsave, ld_tgid, ld_tmerge, ld_tns;
00242     unsigned long mem1, mem2, mem3, mem4, mem5, mem6, mem7;
00243   };
00244 
00245   inline const char* CoreGen::name()
00246   {
00247     return "CoreGen";
00248   }
00249 
00250   inline bool CoreGen::can_mesh(iBase_EntityType)
00251   {
00252     return false;
00253   }
00254 
00255   inline bool CoreGen::can_mesh(ModelEnt *)
00256   {
00257     return true;
00258   }
00259 
00260   inline const moab::EntityType* CoreGen::mesh_types_arr() const
00261   {
00262     return output_types();
00263   }
00264 
00265 } // namespace MeshKit
00266 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines