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 #include "iMesh_extensions.h"
00047 #include "MBiMesh.hpp"
00048 #include "moab/Interface.hpp"
00049 #include "moab/Range.hpp"
00050 #include "moab/Skinner.hpp"
00051 #include "MBTagConventions.hpp"
00052 #include "moab/MergeMesh.hpp"
00053 
00054 
00055 #ifdef USE_MPI
00056 #include "mpi.h"
00057 #include "iMeshP.h"
00058 #include "moab_mpi.h"
00059 #include "moab/ParallelMergeMesh.hpp"
00060 #include "moab/ParallelComm.hpp"
00061 #include "MBParallelConventions.h"
00062 #endif
00063 
00064 #include "meshkit/CopyGeom.hpp"
00065 #include "meshkit/CopyMesh.hpp"
00066 #include "meshkit/ExtrudeMesh.hpp"
00067 #include "meshkit/CESets.hpp"
00068 
00069 namespace MeshKit {
00070 
00071   class MKCore;
00072 
00073   class CoreGen : public MeshScheme
00074   {
00075   public:
00076     /* \brief Constructor
00077      *
00078      * Create a new CoreGen instance
00079      * \param impl the iGeom instance handle for the Geom
00080      */
00081     CoreGen(MKCore *mk, const MEntVector &me_vec);
00082 
00083     /* \brief Destructor
00084      */
00085     virtual ~CoreGen();
00086 
00088     static const char* name();
00089 
00094     static bool can_mesh(iBase_EntityType dim);
00095 
00102     static bool can_mesh(ModelEnt *me);
00103 
00107     static const moab::EntityType* output_types();
00108 
00112     virtual const moab::EntityType* mesh_types_arr() const;
00113 
00117     virtual bool add_modelent(ModelEnt *model_ent);
00118 
00120     virtual void setup_this();
00121 
00123     virtual void execute_this();
00124 
00125     enum ErrorStates {INVALIDINPUT, ENEGATIVE};
00126     int prepareIO (int argc, char *argv[], int nrank, int numprocs, std::string  TestDir);
00127     int parse_assembly_names(CParser parse, int argc, char *argv[]);
00128     int load_meshes();
00129     int load_meshes_more_procs(const int, int);
00130     int load_meshes_parallel(const int, int);
00131     int distribute_mesh(const int,  int);
00132     int load_geometries();
00133     int read_inputs_phase1 (int argc, char *argv[]);
00134     int read_inputs_phase2 (int argc, char *argv[]);
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 save_mesh();
00143     int save_mesh(int rank);
00144 #ifdef USE_MPI
00145     int save_mesh_parallel(const int nrank, const int numprocs);
00146 #endif
00147     int save_geometry();
00148     int shift_mn_ids(iBase_EntitySetHandle orig_set, int index);
00149     int extrude();
00150     int move_verts(iBase_EntitySetHandle set, const double *dx);
00151     int move_geoms(iBase_EntitySetHandle set, const double *dx);
00152     int create_neumannset();
00153     int refine_coremodel();
00154     int load_and_compute_meshtogeom(iBase_EntitySetHandle set, std::string filenam);
00155 
00156     bool extrude_flag, umr_flag;
00157     bool compute_meshtogeom;
00158     std::vector <int> bsameas, deg;
00159     bool mem_tflag;
00160     std::string prob_type, savefiles, info, minfo, same_as, reloading_mf;
00161     std::vector<std::string> files, all_meshfiles, mk_files;
00162     std::vector<int> assm_meshfiles,  size_mf, times_loaded;
00163     std::vector<int> rank_load;
00164     std::vector<double> load_per_assm;
00165     std::vector< std::vector<int> > assm_location;
00166     std::vector<std::vector<int> > position_core;
00167     std::vector<int> meshfile_proc;
00168     std::vector<double> x_coord;
00169     std::vector<double> y_coord;
00170     bool nst_flag, nsb_flag, nss_flag, nssall_flag;
00171     std::vector<std::string> core_alias;
00172     std::vector<double> nsx, nsy, nsc;
00173     int num_nsside, ms_startid, ns_startid, nDegree;
00174 
00175   private:
00177     iGeom *igeom;
00178 
00180     iMesh *imesh;
00181 
00183     moab::Interface *mb;
00184 
00185     std::vector <CopyMesh*> cm;
00186     std::vector <CopyGeom*> cg;
00187     ExtrudeMesh *em;
00188 
00189     iBase_EntitySetHandle root_set;
00190     std::vector<iBase_EntitySetHandle> assys;
00191     std::vector<int> assys_index;
00192     // declare variables read in the inputs
00193     int rank, procs, err;
00194     int UNITCELL_DUCT, ASSY_TYPES ;
00195     int nrings, nringsx, nringsy, pack_type, symm;
00196     double pitch, pitchx, pitchy;
00197     bool global_ids, back_mesh, have_hex27;
00198     std::string outfile, mesh_info;
00199     int nassys; // the number of mesh files
00200     int tot_assys; // total no. of assms forming core
00201     int set_DIM; // default is 3D
00202     double PII;
00203     double z_height;    // z_height for extruding surfaces mesh
00204     int z_divisions; // z_divisions for extruding surface mesh
00205     int nst_Id, nsb_Id, nssall_Id;
00206     std::vector<int> nss_Id;
00207     std::string testdir;
00208 
00209     // file related
00210     std::ifstream file_input;    // File Input
00211     std::ofstream make_file, info_file, minfo_file;    // File Output
00212     std::string iname, ifile, mfile, geometry, back_meshfile, geom_engine, nsLoc, meshtogeomfile, infofile, minfofile, logfilename;
00213     int linenumber;
00214     std::string card,geom_type, meshfile, mf_alias, temp_alias, etype;
00215     std::vector<std::string> assm_alias;
00216     std::vector<int> all_ms_starts, all_ns_starts;
00217 
00218     mstream logfile, meshtogeom_file;
00219 
00220     // parsing related
00221     std::string input_string;
00222     std::string comment;
00223     int MAXCHARS ;
00224 
00225     // merge related
00226     double merge_tol;
00227     int do_merge;
00228     int update_sets;
00229     iBase_TagHandle merge_tag;
00230 
00231     // MKUtils obj, assigning gid's etc.
00232     //  MKUtils *mu;
00233     // error handler
00234     void IOErrorHandler (ErrorStates) const;
00235     CClock Timer;
00236     std::string szDateTime;
00237     int run_flag;
00238     clock_t sTime;
00239 #ifdef USE_MPI
00240     moab::ParallelComm *pc;
00241 #endif
00242 
00243     // timing related variables
00244     double ctload, ctcopymove, ctmerge, ctextrude, ctns, ctgid, ctsave;
00245     clock_t tload, tcopymove, tmerge, textrude, tns, tgid, tsave;
00246 
00247     // more memory/time related variables
00248     int ld_t, ld_tload, ld_tcopymove, ld_tsave, ld_tgid, ld_tmerge, ld_tns;
00249     unsigned long long mem1, mem2, mem3, mem4, mem5, mem6, mem7;
00250   };
00251 
00252   inline const char* CoreGen::name()
00253   {
00254     return "CoreGen";
00255   }
00256 
00257   inline bool CoreGen::can_mesh(iBase_EntityType)
00258   {
00259     return false;
00260   }
00261 
00262   inline bool CoreGen::can_mesh(ModelEnt *)
00263   {
00264     return true;
00265   }
00266 
00267   inline const moab::EntityType* CoreGen::mesh_types_arr() const
00268   {
00269     return output_types();
00270   }
00271 
00272 } // namespace MeshKit
00273 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines