LCOV - code coverage report
Current view: top level - algs/CoreGen - CoreGen.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 3 1435 0.2 %
Date: 2020-07-01 15:24:36 Functions: 3 32 9.4 %
Branches: 2 4096 0.1 %

           Branch data     Line data    Source code
       1                 :            : #include "meshkit/CoreGen.hpp"
       2                 :            : #include "moab/verdict/VerdictWrapper.hpp"
       3                 :            : #include "moab/NestedRefine.hpp"
       4                 :            : 
       5                 :            : #define ERROR(a) {if (iBase_SUCCESS != err) std::cerr << a << std::endl;}
       6                 :            : #define ERRORR(a,b) {if (iBase_SUCCESS != err) {std::cerr << a << std::endl; return b;}}
       7                 :            : namespace MeshKit
       8                 :            : {
       9                 :            :   // static registration of this  mesh scheme
      10                 :            :   moab::EntityType CoreGen_tps[] = { moab::MBVERTEX,
      11                 :            :                                      moab::MBEDGE,
      12                 :            :                                      moab::MBTRI,
      13                 :            :                                      moab::MBHEX,
      14                 :            :                                      moab::MBMAXTYPE};
      15                 :         40 :   const moab::EntityType* CoreGen::output_types()
      16                 :         40 :   { return CoreGen_tps; }
      17                 :            : 
      18                 :          0 :   CoreGen::CoreGen( MKCore *mk, const MEntVector &me_vec)
      19                 :            :     : MeshScheme( mk, me_vec),
      20 [ #  # ][ #  # ]:          0 :       igeom(mk->igeom_instance()), imesh(mk->imesh_instance()),
      21 [ #  # ][ #  # ]:          0 :       mb (mk->moab_instance())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      22                 :            :   {
      23                 :          0 :     err = 0;
      24                 :          0 :     run_flag = 1;
      25                 :          0 :     UNITCELL_DUCT = 0;
      26                 :          0 :     ASSY_TYPES = 1;
      27                 :          0 :     pack_type = 1;
      28                 :          0 :     symm = 1;
      29                 :          0 :     z_height = 1;
      30                 :          0 :     z_divisions = 2;
      31                 :          0 :     set_DIM = 3; // default is 3D
      32                 :          0 :     PII = acos(-1.0);
      33         [ #  # ]:          0 :     comment = "!";
      34                 :          0 :     MAXCHARS = 2000;
      35                 :          0 :     compute_meshtogeom = false;
      36                 :          0 :     extrude_flag = false;
      37                 :          0 :     mem_tflag = false;
      38                 :          0 :     global_ids = true;
      39                 :          0 :     merge_tol = 1.0e-4;
      40                 :          0 :     do_merge = 1;
      41                 :          0 :     update_sets = 0;
      42                 :          0 :     merge_tag = NULL;
      43                 :          0 :     nst_flag = false;
      44                 :          0 :     nsb_flag = false;
      45                 :          0 :     nss_flag = false;
      46                 :          0 :     nssall_flag = false;
      47                 :          0 :     have_hex27 = false;
      48                 :          0 :     umr_flag = false;
      49                 :          0 :     nst_Id = 9997;
      50                 :          0 :     nsb_Id = 9998;
      51         [ #  # ]:          0 :     prob_type = "mesh";
      52         [ #  # ]:          0 :     savefiles = "one";
      53                 :          0 :     num_nsside = 0;
      54                 :          0 :     linenumber = 0;
      55         [ #  # ]:          0 :     info = "off";
      56         [ #  # ]:          0 :     minfo = "off";
      57                 :          0 :     nringsx = 0;
      58                 :          0 :     nringsy = 0;
      59                 :          0 :     nDegree = 0;
      60                 :            : 
      61                 :            :     // initialize more memory/time related variables
      62                 :          0 :     ctload = 0, ctcopymove = 0, ctmerge = 0, ctextrude = 0, ctns = 0, ctgid = 0, ctsave = 0;
      63                 :          0 :     tload = 0, tcopymove = 0, tmerge = 0, textrude = 0, tns = 0, tgid = 0, tsave = 0;
      64                 :          0 :     ld_t = 0, ld_tload = 0, ld_tcopymove = 0, ld_tsave = 0, ld_tgid = 0, ld_tmerge = 0, ld_tns = 0;
      65                 :          0 :     mem1 = 0, mem2 = 0, mem3 = 0, mem4 = 0, mem5 = 0, mem6 = 0, mem7 = 0;
      66                 :            : 
      67                 :            : 
      68                 :          0 :   }
      69                 :            : 
      70                 :          0 :   CoreGen::~CoreGen()
      71         [ #  # ]:          0 :   {}
      72                 :            : 
      73                 :          0 :   bool CoreGen::add_modelent(ModelEnt *model_ent)
      74                 :            :   {
      75                 :          0 :     return MeshOp::add_modelent(model_ent);
      76                 :            :   }
      77                 :            : 
      78                 :          0 :   void CoreGen::setup_this()
      79                 :            :   {
      80         [ #  # ]:          0 :     if(rank == 0)
      81                 :          0 :       logfile << "Setting-up in CoreGen meshop.." << std::endl;
      82         [ #  # ]:          0 :     if(run_flag != 0){
      83                 :          0 :         double ctload = 0;
      84                 :          0 :         clock_t tload = 0;
      85         [ #  # ]:          0 :         CClock ld_time;
      86                 :          0 :         int ld_t = 0, ld_tload = 0;
      87                 :          0 :         unsigned long long mem1 = 0;
      88 [ #  # ][ #  # ]:          0 :         if (prob_type == "mesh") {
      89         [ #  # ]:          0 :             if (procs == 1) {
      90         [ #  # ]:          0 :                 err = load_meshes();
      91 [ #  # ][ #  # ]:          0 :                 if(err !=0) {logfile << "load meshes failed!" << std::endl; exit(1);}
                 [ #  # ]
      92                 :            :               }
      93                 :            :             else {
      94                 :            : #ifdef USE_MPI
      95                 :            :                 if(procs < (int) files.size()){
      96                 :            :                     err = load_meshes_parallel(rank, procs);
      97                 :            :                     if(err !=0) {logfile << "failed to load meshes in parallel!" << std::endl; exit(1);}
      98                 :            :                   }
      99                 :            :                 else{
     100                 :            :                     // if there are more procs than files distribute the copy/move work on each proc
     101                 :            :                     err = distribute_mesh(rank, procs);
     102                 :            :                     if(err !=0) {logfile << "distribute meshes failed!" << std::endl; exit(1);}
     103                 :            : 
     104                 :            :                     MPI_Barrier(MPI_COMM_WORLD);
     105                 :            : 
     106                 :            :                     err = load_meshes_more_procs(rank, procs);
     107                 :            :                     if(err !=0) {logfile << "load m meshes failed!" << std::endl; exit(1);}
     108                 :            :                   }
     109                 :            :                 //Get a pcomm object
     110                 :            :                 pc = new moab::ParallelComm(mk_core()->moab_instance(), MPI_COMM_WORLD, &err);
     111                 :            : #endif
     112                 :            :               }
     113                 :            : 
     114 [ #  # ][ #  # ]:          0 :             mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem1);
                 [ #  # ]
     115         [ #  # ]:          0 :             ld_tload = ld_time.DiffTime();
     116                 :          0 :             tload = clock();
     117                 :          0 :             ctload = (double) (tload - sTime)/(60*CLOCKS_PER_SEC);
     118                 :            : 
     119 [ #  # ][ #  # ]:          0 :             if (mem_tflag == true && rank == 0) {
     120 [ #  # ][ #  # ]:          0 :                 logfile << "\n" << " Clock time taken to load mesh files = " << ld_tload
                 [ #  # ]
     121 [ #  # ][ #  # ]:          0 :                         << " seconds" << std::endl;
     122 [ #  # ][ #  # ]:          0 :                 logfile << " CPU time = " << ctload << " mins" << std::endl;
         [ #  # ][ #  # ]
     123 [ #  # ][ #  # ]:          0 :                 logfile << " Memory used: " << mem1/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     124                 :            :               }
     125                 :            :           }
     126                 :            : 
     127                 :            :         /*********************************************/
     128                 :            :         // load geometry files
     129                 :            :         /*********************************************/
     130 [ #  # ][ #  # ]:          0 :         else if (prob_type == "geometry" && procs == 1) {
         [ #  # ][ #  # ]
     131         [ #  # ]:          0 :             err = load_geometries();
     132 [ #  # ][ #  # ]:          0 :             if(err !=0) {logfile << "load geometry failed!" << std::endl; exit(1);}
                 [ #  # ]
     133                 :            :           }
     134 [ #  # ][ #  # ]:          0 :         else if(prob_type == "geometry" && procs > 1){
         [ #  # ][ #  # ]
     135 [ #  # ][ #  # ]:          0 :             logfile << " Parallel mode not supported for problem-type: Geometry " << std::endl;
     136                 :          0 :             exit(1);
     137                 :            :           }
     138                 :            : 
     139                 :            :         /*********************************************/
     140                 :            :         // copy move
     141                 :            :         /*********************************************/
     142         [ #  # ]:          0 :         CClock ld_cm;
     143         [ #  # ]:          0 :         err = copymove(rank, procs);
     144 [ #  # ][ #  # ]:          0 :         if (prob_type == "mesh"){
     145 [ #  # ][ #  # ]:          0 :             mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem2);
                 [ #  # ]
     146         [ #  # ]:          0 :             ld_tcopymove = ld_cm.DiffTime();
     147                 :          0 :             tcopymove = clock();
     148                 :          0 :             ctcopymove = (double) (tcopymove - tload)/(60*CLOCKS_PER_SEC);
     149                 :            : 
     150 [ #  # ][ #  # ]:          0 :             if (mem_tflag == true && (strcmp(prob_type.c_str(), "mesh") == 0) && rank == 0) {
         [ #  # ][ #  # ]
     151 [ #  # ][ #  # ]:          0 :                 logfile << "\n" << " Clock time taken to copy/move mesh files = " << ld_tcopymove
                 [ #  # ]
     152 [ #  # ][ #  # ]:          0 :                         << " seconds" << std::endl;
     153 [ #  # ][ #  # ]:          0 :                 logfile << " CPU time = " << ctcopymove << " mins" << std::endl;
         [ #  # ][ #  # ]
     154 [ #  # ][ #  # ]:          0 :                 logfile << " Memory used: " << mem2/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     155                 :            :               }
     156                 :            :           }
     157                 :            : 
     158         [ #  # ]:          0 :         for (unsigned int i = 0; i < assys.size(); i++) {
     159 [ #  # ][ #  # ]:          0 :             if(prob_type =="mesh")
     160 [ #  # ][ #  # ]:          0 :               cm[i]->setup_called(true);
     161 [ #  # ][ #  # ]:          0 :             if(prob_type =="geometry")
     162 [ #  # ][ #  # ]:          0 :               cg[i]->setup_called(true);
     163                 :            :           }
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :         if (prob_type == "mesh") {
     166                 :            :             /*********************************************/
     167                 :            :             // merge
     168                 :            :             /*********************************************/
     169         [ #  # ]:          0 :             CClock ld_mm;
     170         [ #  # ]:          0 :             if (procs == 1){
     171                 :            :                 // merge mesh now
     172                 :            :                 //std::vector<iBase_EntityHandle> ents;
     173         [ #  # ]:          0 :                 moab::Range ents;
     174                 :            :                 //int dim = imesh->getGeometricDimension();
     175         [ #  # ]:          0 :                 mb->get_entities_by_dimension(0, set_DIM, ents);
     176 [ #  # ][ #  # ]:          0 :                 logfile << " Merging nodes.."<< std::endl;
     177         [ #  # ]:          0 :                 moab::MergeMesh mm(mb);
     178         [ #  # ]:          0 :                 moab::ErrorCode err = mm.merge_entities(ents, merge_tol, true);
     179         [ #  # ]:          0 :                 if (moab::MB_SUCCESS != err) {
     180 [ #  # ][ #  # ]:          0 :                     std::cerr << "Error in MergeMesh during merging entities" << std::endl;
     181                 :          0 :                     exit(2);
     182                 :          0 :                   }
     183                 :            :               }
     184         [ #  # ]:          0 :             else if(procs > 1){
     185         [ #  # ]:          0 :                 if (rank == 0) {
     186 [ #  # ][ #  # ]:          0 :                     logfile << "Merging nodes in parallel. " << std::endl;
     187                 :            :                   }
     188                 :            : 
     189                 :            : #ifdef USE_MPI
     190                 :            :                 //Call the resolve parallel function
     191                 :            :                 moab::ParallelMergeMesh pm(pc, merge_tol);
     192                 :            :                 err = pm.merge();
     193                 :            :                 if (err != moab::MB_SUCCESS) {
     194                 :            :                     std::cerr << "Merge Failed" << std::endl;
     195                 :            :                     //MPI_Abort(MPI_COMM_WORLD, 1);
     196                 :            :                   }
     197                 :            : #endif
     198                 :            :               }
     199 [ #  # ][ #  # ]:          0 :             mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem3);
                 [ #  # ]
     200         [ #  # ]:          0 :             ld_tmerge = ld_mm.DiffTime();
     201                 :          0 :             tmerge = clock();
     202                 :          0 :             ctmerge = (double) (tmerge - tcopymove)/(60*CLOCKS_PER_SEC);
     203                 :            : 
     204 [ #  # ][ #  # ]:          0 :             if (mem_tflag == true && rank == 0 ) {
     205 [ #  # ][ #  # ]:          0 :                 logfile << "\n" << " Clock time taken to merge nodes = " << ld_tmerge
                 [ #  # ]
     206 [ #  # ][ #  # ]:          0 :                         << " seconds" << std::endl;
     207 [ #  # ][ #  # ]:          0 :                 logfile << " CPU time = " << ctmerge << " mins" << std::endl;
         [ #  # ][ #  # ]
     208 [ #  # ][ #  # ]:          0 :                 logfile << " Memory used: " << mem3/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     209                 :            :               }
     210                 :            : #ifdef USE_MPI
     211                 :            :             MPI_Barrier(MPI_COMM_WORLD);
     212                 :            : #endif
     213                 :            :             /*********************************************/
     214                 :            :             // extrude
     215                 :            :             /*********************************************/
     216         [ #  # ]:          0 :             if(procs == 1){
     217         [ #  # ]:          0 :                 if (extrude_flag == true) {
     218         [ #  # ]:          0 :                     CClock ld_em;
     219         [ #  # ]:          0 :                     err = extrude();
     220 [ #  # ][ #  # ]:          0 :                     if(err !=0) {logfile << "extrusion failed!" << std::endl; exit(1);}
                 [ #  # ]
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :                     mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem4);
                 [ #  # ]
     223         [ #  # ]:          0 :                     ld_t = ld_em.DiffTime();
     224                 :          0 :                     textrude = clock();
     225                 :          0 :                     ctextrude = (double) (textrude - tmerge)/(60*CLOCKS_PER_SEC);
     226                 :            : 
     227 [ #  # ][ #  # ]:          0 :                     if (mem_tflag == true && rank == 0) {
     228 [ #  # ][ #  # ]:          0 :                         logfile << "\n" << " Clock time taken to extrude = " << ld_t
                 [ #  # ]
     229 [ #  # ][ #  # ]:          0 :                                 << " seconds" << std::endl;
     230 [ #  # ][ #  # ]:          0 :                         logfile << " CPU time = " << ctextrude << " mins" << std::endl;
         [ #  # ][ #  # ]
     231 [ #  # ][ #  # ]:          0 :                         logfile << " Memory used: " << mem4/1e6 << " Mb\n For rank 0\n"
                 [ #  # ]
     232         [ #  # ]:          0 :                                 << std::endl;
     233                 :          0 :                       }
     234                 :            :                   }
     235                 :            :               }
     236         [ #  # ]:          0 :             if(extrude_flag == true)
     237         [ #  # ]:          0 :               em->setup_called(true);
     238                 :            : #ifdef USE_MPI
     239                 :            :             MPI_Barrier(MPI_COMM_WORLD);
     240                 :            : #endif
     241                 :          0 :           }
     242                 :            :       }
     243                 :          0 :   }
     244                 :            : 
     245                 :            : 
     246                 :          0 :   void CoreGen::execute_this()
     247                 :            :   {
     248         [ #  # ]:          0 :     if(rank == 0)
     249                 :          0 :       logfile << "Executing in CoreGen meshop.." << std::endl;
     250                 :            : 
     251 [ #  # ][ #  # ]:          0 :     if(run_flag != 0 && prob_type != "geometry"){
                 [ #  # ]
     252         [ #  # ]:          0 :         for (unsigned int i = 0; i < assys.size(); i++) {
     253 [ #  # ][ #  # ]:          0 :             cm[i]->execute_called(true);
     254                 :            :           }
     255         [ #  # ]:          0 :         if(extrude_flag == true)
     256         [ #  # ]:          0 :           em->execute_called(true);
     257                 :            :         /*********************************************/
     258                 :            :         // assign gids
     259                 :            :         /*********************************************/
     260         [ #  # ]:          0 :         CClock ld_gid;
     261 [ #  # ][ #  # ]:          0 :         mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem5);
                 [ #  # ]
     262         [ #  # ]:          0 :         ld_tgid = ld_gid.DiffTime();
     263                 :          0 :         tgid = clock();
     264                 :          0 :         ctgid = (double) (tgid-tmerge)/(60*CLOCKS_PER_SEC);
     265                 :            : 
     266 [ #  # ][ #  # ]:          0 :         if (mem_tflag == true && rank == 0) {
     267 [ #  # ][ #  # ]:          0 :             logfile << "\n" << " Clock time taken to assign gids = " << ld_tgid
                 [ #  # ]
     268 [ #  # ][ #  # ]:          0 :                     << " seconds" << std::endl;
     269 [ #  # ][ #  # ]:          0 :             logfile << " CPU time = " << ctgid << " mins" << std::endl;
         [ #  # ][ #  # ]
     270 [ #  # ][ #  # ]:          0 :             logfile << " Memory used: " << mem5/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     271                 :            :           }
     272                 :            :         /*********************************************/
     273                 :            :         // create neumann sets on the core model
     274                 :            :         /*********************************************/
     275 [ #  # ][ #  # ]:          0 :         if((nss_flag == true || nsb_flag == true
     276 [ #  # ][ #  # ]:          0 :             || nst_flag == true) && procs == 1){
     277         [ #  # ]:          0 :             CClock ld_ns;
     278         [ #  # ]:          0 :             err = create_neumannset();
     279 [ #  # ][ #  # ]:          0 :             if(err !=0) {logfile << "create NeumannSet failed!" << std::endl; exit(1);}
                 [ #  # ]
     280                 :            : 
     281 [ #  # ][ #  # ]:          0 :             mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem6);
                 [ #  # ]
     282         [ #  # ]:          0 :             ld_tns = ld_ns.DiffTime();
     283                 :          0 :             tns = clock();
     284                 :          0 :             ctns = (double) (tns-tgid)/(60*CLOCKS_PER_SEC);
     285 [ #  # ][ #  # ]:          0 :             if (mem_tflag == true && rank == 0) {
     286 [ #  # ][ #  # ]:          0 :                 logfile << "\n" << " Clock time taken to create neumann sets = " << ld_tns
                 [ #  # ]
     287 [ #  # ][ #  # ]:          0 :                         << " seconds" << std::endl;
     288 [ #  # ][ #  # ]:          0 :                 logfile << " CPU time = " << ctns << " mins" << std::endl;
         [ #  # ][ #  # ]
     289 [ #  # ][ #  # ]:          0 :                 logfile << " Memory used: " << mem6/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     290                 :          0 :               }
     291                 :            :           }
     292                 :          0 :         if(umr_flag == true){
     293                 :            : #ifdef USE_MPI
     294                 :            :             err = refine_coremodel();
     295                 :            : #endif
     296                 :          0 :           }
     297                 :            :       }
     298         [ #  # ]:          0 :     if (prob_type == "mesh") {
     299                 :            :         /*********************************************/
     300                 :            :         // save
     301                 :            :         /*********************************************/
     302         [ #  # ]:          0 :         CClock ld_sv;
     303         [ #  # ]:          0 :         if (procs == 1) {
     304         [ #  # ]:          0 :             err = save_mesh();
     305 [ #  # ][ #  # ]:          0 :             if(err !=0) {logfile << "save mesh failed!" << std::endl; exit(1);}
                 [ #  # ]
     306                 :            :           } else {
     307 [ #  # ][ #  # ]:          0 :             if(savefiles != "one" && (savefiles == "multiple" || savefiles == "both")){
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     308         [ #  # ]:          0 :                 err = save_mesh(rank); // uncomment to save the meshes with each proc
     309 [ #  # ][ #  # ]:          0 :                 if(err !=0) {logfile << "save mesh failed!" << std::endl; exit(1);}
                 [ #  # ]
     310                 :            :               }
     311         [ #  # ]:          0 :             if(savefiles != "multiple"){
     312                 :            : #ifdef USE_MPI
     313                 :            :                 double write_time = MPI_Wtime();
     314                 :            :                 err = save_mesh_parallel(rank, procs);
     315                 :            :                 if(err !=0) {logfile << "save parallel mesh failed!" << std::endl; exit(1);}
     316                 :            :                 write_time = MPI_Wtime() - write_time;
     317                 :            :                 if (rank == 0)
     318                 :            :                   logfile << "Parallel write time = " << write_time/60.0 << " mins" << std::endl;
     319                 :            : #endif
     320                 :            :               }
     321                 :            :           }
     322                 :            : 
     323 [ #  # ][ #  # ]:          0 :         mk_core()->moab_instance()->estimated_memory_use(0, 0, 0, &mem7);
                 [ #  # ]
     324         [ #  # ]:          0 :         ld_tsave = ld_sv.DiffTime();
     325                 :          0 :         tsave = clock();
     326                 :          0 :         ctsave = (double) (tsave - tgid)/(60*CLOCKS_PER_SEC);
     327                 :            : 
     328 [ #  # ][ #  # ]:          0 :         if (mem_tflag == true && rank == 0 ) {
     329 [ #  # ][ #  # ]:          0 :             logfile << "\n" << " Clock time taken to save = " << ld_tsave << " seconds"
         [ #  # ][ #  # ]
     330         [ #  # ]:          0 :                     << std::endl;
     331 [ #  # ][ #  # ]:          0 :             logfile << " CPU time = " << ctsave << " mins" << std::endl;
         [ #  # ][ #  # ]
     332 [ #  # ][ #  # ]:          0 :             logfile << " Memory used: " << mem7/1e6 << " Mb\n For rank 0\n" << std::endl;
         [ #  # ][ #  # ]
     333                 :          0 :           }
     334                 :            :       }
     335                 :            :     /*********************************************/
     336                 :            :     // geometry operations
     337                 :            :     /*********************************************/
     338         [ #  # ]:          0 :     else if (prob_type == "geometry") {
     339                 :          0 :         err = save_geometry();
     340         [ #  # ]:          0 :         if(err !=0) {logfile << "save geometry failed!" << std::endl; exit(1);}
     341                 :            :       }
     342                 :            : 
     343                 :            :     /*********************************************/
     344                 :            :     // print memory and timing if using mpi
     345                 :            :     /*********************************************/
     346                 :          0 :     mem1/=1e6;
     347                 :          0 :     mem2/=1e6;
     348                 :          0 :     mem3/=1e6;
     349                 :          0 :     mem5/=1e6;
     350                 :          0 :     mem7/=1e6;
     351                 :            : 
     352                 :            : #ifdef USE_MPI
     353                 :            :     unsigned long max_mem7 = 1.0;
     354                 :            :     MPI_Reduce( &mem7, &max_mem7, 1, MPI_UNSIGNED_LONG, MPI_MAX, 0, MPI_COMM_WORLD);
     355                 :            : #endif
     356                 :            : 
     357                 :            : #ifdef USE_MPI
     358                 :            :     if (mem_tflag == true) {
     359                 :            : 
     360                 :            :         unsigned long max_mem1 = 1.0, max_mem2 = 1.0, max_mem3 = 1.0, max_mem5 = 1.0;
     361                 :            : 
     362                 :            :         MPI_Reduce( &mem1, &max_mem1, 1, MPI_UNSIGNED_LONG, MPI_MAX, 0, MPI_COMM_WORLD);
     363                 :            :         MPI_Reduce( &mem2, &max_mem2, 1, MPI_UNSIGNED_LONG, MPI_MAX, 0, MPI_COMM_WORLD);
     364                 :            :         MPI_Reduce( &mem3, &max_mem3, 1, MPI_UNSIGNED_LONG, MPI_MAX, 0, MPI_COMM_WORLD);
     365                 :            :         MPI_Reduce( &mem5, &max_mem5, 1, MPI_UNSIGNED_LONG, MPI_MAX, 0, MPI_COMM_WORLD);
     366                 :            : 
     367                 :            :         double max_ctload = -1.0, max_ctcopymove = -1.0, max_ctgid = -1.0, max_ctsave = -1.0, max_ctmerge = -1.0;
     368                 :            :         MPI_Reduce( &ctload, &max_ctload, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
     369                 :            :         MPI_Reduce( &ctcopymove, &max_ctcopymove, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
     370                 :            :         MPI_Reduce( &ctmerge, &max_ctmerge, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
     371                 :            :         MPI_Reduce( &ctgid, &max_ctgid, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
     372                 :            :         MPI_Reduce( &ctsave, &max_ctsave, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
     373                 :            : 
     374                 :            :         int max_tload = -1.0, max_tcopymove = -1.0, max_tgid = -1.0, max_tsave = -1.0, max_tmerge = -1.0;
     375                 :            :         MPI_Reduce( &ld_tload, &max_tload, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
     376                 :            :         MPI_Reduce( &ld_tcopymove, &max_tcopymove, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
     377                 :            :         MPI_Reduce( &ld_tmerge, &max_tmerge, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
     378                 :            :         MPI_Reduce( &ld_tgid, &max_tgid, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
     379                 :            :         MPI_Reduce( &ld_tsave, &max_tsave, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
     380                 :            : 
     381                 :            :         if(rank == 0 && procs > 1){
     382                 :            :             logfile << "\nMAXIMUM TIME TAKEN OVER ALL PROCS\nCLOCK TIME:-";
     383                 :            :             logfile << "\n**r = " << rank<< " Time taken to load mesh files = " << max_tload
     384                 :            :                     << " secs" << std::endl;
     385                 :            :             logfile << "***r = : " << rank<< " Memory used: " << max_mem1 << " Mb" << std::endl;
     386                 :            : 
     387                 :            :             // copymove
     388                 :            :             logfile << "\n**r = " << rank<< " Time taken to copy/move mesh files = " << max_tcopymove
     389                 :            :                     << " secs" << std::endl;
     390                 :            :             logfile << "***r = " << rank<< " Memory used: " << max_mem2 << " Mb" << std::endl;
     391                 :            : 
     392                 :            :             // merge
     393                 :            :             logfile << "\n**r = " << rank<< " Time taken to merge nodes = " << max_tmerge
     394                 :            :                     << " secs" << std::endl;
     395                 :            :             logfile << "***r = " << rank<< " Memory used: " << max_mem3 << " kb" << std::endl;
     396                 :            : 
     397                 :            :             // assign gid
     398                 :            :             logfile << "\n**r = " << rank<< " Time taken to assign gids = " << max_tgid
     399                 :            :                     << " secs" << std::endl;
     400                 :            :             logfile << "*** r = " << rank<< " Memory used: " << max_mem5 << " Mb" << std::endl;
     401                 :            : 
     402                 :            :             // save
     403                 :            :             logfile << "\n**r = " << rank<< " Time taken to save = " <<  max_tsave << " secs"
     404                 :            :                     << std::endl;
     405                 :            :             logfile << "***r = " << rank<< " Memory used: " << max_mem7 << " Mb" << std::endl;
     406                 :            : 
     407                 :            :             // cpu times
     408                 :            :             logfile << "\n CPU TIME:-\n" << " r = " << rank<< " Time taken to load mesh files = " << ctload
     409                 :            :                     << " mins" << std::endl;
     410                 :            : 
     411                 :            :             logfile << " r = " << rank << " Time taken to copy/move files = " << ctcopymove
     412                 :            :                     << " mins" << std::endl;
     413                 :            : 
     414                 :            :             logfile << " r = " << rank << " Time taken to merge = " << ctmerge
     415                 :            :                     << " mins" << std::endl;
     416                 :            : 
     417                 :            :             logfile << " r = " << rank <<  " Time taken to assign gids = " << ctgid
     418                 :            :                     << " mins" << std::endl;
     419                 :            : 
     420                 :            :             logfile  << " r = " << rank << " Time taken to save mesh = " << ctsave
     421                 :            :                      << " mins" << std::endl;
     422                 :            :           }
     423                 :            :       }
     424                 :            : #endif
     425                 :            : 
     426         [ #  # ]:          0 :     if (rank == 0) {
     427                 :          0 :         Timer.GetDateTime(szDateTime);
     428                 :          0 :         logfile << "\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"  << std::endl;
     429 [ #  # ][ #  # ]:          0 :         logfile << "Ending at : " << szDateTime;
     430                 :          0 :         logfile << "Elapsed wall clock time: " << Timer.DiffTime()
     431                 :          0 :                 << " seconds or " << (Timer.DiffTime()) / 60.0 << " mins\n";
     432                 :            : 
     433                 :          0 :         logfile << "Total CPU time used: " <<  (double) (clock() - sTime)/(CLOCKS_PER_SEC) << " seconds or " <<
     434                 :          0 :                    (double) (clock() - sTime)/(60*CLOCKS_PER_SEC)
     435                 :          0 :                 << " mins" << std::endl;
     436                 :            : #ifdef USE_MPI
     437                 :            :         logfile << "Maximum memory used by a processor: " << max_mem7 <<  " Mb" << std::endl;
     438                 :            : #endif
     439         [ #  # ]:          0 :         if(procs == 1)
     440                 :          0 :           logfile << "Maximum memory used: " << mem7 <<  " Mb" << std::endl;
     441                 :          0 :           logfile << "Total processors used =  " << procs << std::endl;
     442                 :          0 :           logfile << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n"  << std::endl;
     443                 :            : 
     444                 :            :       }
     445                 :          0 :   }
     446                 :            : #ifdef USE_MPI
     447                 :            :   int CoreGen::save_mesh_parallel(const int nrank, const int numprocs)
     448                 :            :   // -------------------------------------------------------------------------------------------
     449                 :            :   // Function: resolve shared entitie and save mesh file in parallel (hdf5 only)
     450                 :            :   // Input:    none
     451                 :            :   // Output:   none
     452                 :            :   // -------------------------------------------------------------------------------------------
     453                 :            :   {
     454                 :            :     // start saving mesh in parallel
     455                 :            :     if (nrank == 0) {
     456                 :            :         logfile << "Saving mesh file in parallel, starting to cleanup sets " << std::endl;
     457                 :            :     }
     458                 :            : 
     459                 :            :    // handle sets before saving - delete all unnessary sets - this would save a lot of save time
     460                 :            :     moab::Tag mattag;
     461                 :            :     mb->tag_get_handle( "MATERIAL_SET", 1, MB_TYPE_INTEGER, mattag );
     462                 :            :     moab::Range matsets, this_mat_ents;
     463                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mattag, 0, 1, matsets );
     464                 :            :     moab::Range::iterator m_it;
     465                 :            :     moab::EntityHandle old_mat_set, new_mat_set;
     466                 :            : 
     467                 :            :     for(m_it = matsets.begin(); m_it != matsets.end(); m_it++){
     468                 :            :         this_mat_ents.clear();
     469                 :            :         old_mat_set = *m_it;
     470                 :            :         mb->get_entities_by_dimension(old_mat_set, set_DIM, this_mat_ents, true);
     471                 :            :         int material_id;
     472                 :            :         mb->tag_get_data(mattag, &old_mat_set, 1, &material_id);
     473                 :            :         // create a new material set, fill with ents (directly) and set id tag
     474                 :            :         mb->create_meshset(MESHSET_SET, new_mat_set);
     475                 :            :         mb->add_entities(new_mat_set, this_mat_ents);
     476                 :            :         mb->tag_set_data(mattag, &new_mat_set, 1, &material_id);
     477                 :            :         mb->delete_entities(&old_mat_set, 1);
     478                 :            :       }
     479                 :            : 
     480                 :            :     if (nrank == 0) {
     481                 :            :         logfile << "Done dealing with material sets " << std::endl;
     482                 :            :     }
     483                 :            : 
     484                 :            :     moab::Tag nstag;
     485                 :            :     mb->tag_get_handle( "NEUMANN_SET", 1, MB_TYPE_INTEGER, nstag );
     486                 :            :     moab::Range nssets, this_neu_ents;
     487                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &nstag, 0, 1, nssets );
     488                 :            :     moab::Range::iterator n_it;
     489                 :            :     moab::EntityHandle old_neu_set, new_neu_set;
     490                 :            : 
     491                 :            :     for(n_it = nssets.begin(); n_it != nssets.end(); n_it++){
     492                 :            :         this_neu_ents.clear();
     493                 :            :         old_neu_set = *n_it;
     494                 :            :         mb->get_entities_by_dimension(old_neu_set, (set_DIM-1), this_neu_ents, true);
     495                 :            :         int neumann_id;
     496                 :            :         mb->tag_get_data(nstag, &old_mat_set, 1, &neumann_id);
     497                 :            :         // create a new neumann set, fill with ents (directly) and set id tag
     498                 :            :         mb->create_meshset(MESHSET_SET, new_neu_set);
     499                 :            :         mb->add_entities(new_neu_set, this_neu_ents);
     500                 :            :         mb->tag_set_data(nstag, &new_neu_set, 1, &neumann_id);
     501                 :            :         mb->delete_entities(&old_neu_set, 1);
     502                 :            :       }
     503                 :            : 
     504                 :            : 
     505                 :            :     moab::Tag drtag;
     506                 :            :     mb->tag_get_handle( "DIRICHLET_SET", 1, MB_TYPE_INTEGER, drtag );
     507                 :            :     moab::Range drsets, this_dir_ents;
     508                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &drtag, 0, 1, drsets );
     509                 :            :     moab::Range::iterator d_it;
     510                 :            :     moab::EntityHandle old_dir_set, new_dir_set;
     511                 :            : 
     512                 :            :     for(d_it = drsets.begin(); d_it != drsets.end(); d_it++){
     513                 :            :         this_dir_ents.clear();
     514                 :            :         old_dir_set = *n_it;
     515                 :            :         mb->get_entities_by_dimension(old_dir_set, 0, this_dir_ents, true);
     516                 :            :         int dirichlet_id;
     517                 :            :         mb->tag_get_data(drtag, &old_dir_set, 1, &dirichlet_id);
     518                 :            :         // create a new neumann set, fill with ents (directly) and set id tag
     519                 :            :         mb->create_meshset(MESHSET_SET, new_dir_set);
     520                 :            :         mb->add_entities(new_dir_set, this_dir_ents);
     521                 :            :         mb->tag_set_data(drtag, &new_dir_set, 1, &dirichlet_id);
     522                 :            :         mb->delete_entities(&old_dir_set, 1);
     523                 :            :       }
     524                 :            : 
     525                 :            : 
     526                 :            :     if (nrank == 0) {
     527                 :            :         logfile << "Done dealing with all ms ns and ds" << std::endl;
     528                 :            :     }
     529                 :            : 
     530                 :            : 
     531                 :            :     // Deleting GEOM_DIMENSION tags and others?
     532                 :            :     moab::Range all_sets;
     533                 :            :     moab::EntityHandle curr_set;
     534                 :            :     mb->get_entities_by_type(0, MBENTITYSET, all_sets);
     535                 :            :     moab::Range::iterator all_it;
     536                 :            :     moab::Tag gdtag;
     537                 :            :     mb->tag_get_handle( "GEOM_DIMENSION", 1, MB_TYPE_INTEGER, gdtag );
     538                 :            : 
     539                 :            :     for(all_it = all_sets.begin(); all_it != all_sets.end(); all_it++){
     540                 :            :         curr_set = *all_it;
     541                 :            :         int temp_gid = -1;
     542                 :            :         mb->tag_get_data(gdtag, &curr_set, 1, &temp_gid);
     543                 :            :         if(temp_gid != -1){
     544                 :            :             mb->delete_entities(&curr_set, 1);
     545                 :            :           }
     546                 :            :       }
     547                 :            : 
     548                 :            :     MPI_Barrier(MPI_COMM_WORLD);
     549                 :            : 
     550                 :            :     if (nrank == 0) {
     551                 :            :         logfile << "Done deleting gd sets, now starting to resolve shared ents " << std::endl;
     552                 :            :     }
     553                 :            : 
     554                 :            : 
     555                 :            :     // resolve shared sets to create only on MATERIAL_SET
     556                 :            :     matsets.clear();
     557                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mattag, 0, 1, matsets );
     558                 :            :     if(matsets.size() > 0)
     559                 :            :         pc->resolve_shared_sets( matsets, mattag );
     560                 :            : 
     561                 :            :      if (nrank == 0) {
     562                 :            :         logfile << matsets.size() << "Done resolving material ents " << std::endl;
     563                 :            :     }
     564                 :            : 
     565                 :            :     /*// resolve
     566                 :            :     nssets.clear();
     567                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &nstag, 0, 1, nssets );
     568                 :            :      if(nssets.size() > 0)
     569                 :            :         pc->resolve_shared_sets( nssets, nstag );
     570                 :            : */
     571                 :            :     // resolve
     572                 :            :     drsets.clear();
     573                 :            :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &drtag, 0, 1, drsets );
     574                 :            :      if(drsets.size() > 0)
     575                 :            :         pc->resolve_shared_sets( drsets, drtag );
     576                 :            : 
     577                 :            :     // need this barrier before setting pp tag
     578                 :            : //      MPI_Barrier(MPI_COMM_WORLD);
     579                 :            : 
     580                 :            : 
     581                 :            :     // Done with deleting recursive sets now create pp tags and save
     582                 :            :     if (nrank == 0) {
     583                 :            :         logfile << "setting PARALLEL_PARTITION  tag" << std::endl;
     584                 :            :         logfile << "Saving mesh file in parallel. " << std::endl;
     585                 :            :     }
     586                 :            :     moab::Range entities;
     587                 :            :     moab::EntityHandle meshsetp;
     588                 :            :     mb->get_entities_by_type(0, MBHEX, entities);
     589                 :            : 
     590                 :            :     mb->create_meshset(MESHSET_SET, meshsetp);
     591                 :            :     mb->add_entities(meshsetp, entities);
     592                 :            : 
     593                 :            :     moab::Tag pp_tag;
     594                 :            : 
     595                 :            :     mb->tag_get_handle( "PARALLEL_PARTITION", 1, MB_TYPE_INTEGER, pp_tag, MB_TAG_SPARSE|MB_TAG_CREAT);
     596                 :            :     mb->tag_set_data(pp_tag, &meshsetp, 1, &nrank);
     597                 :            : 
     598                 :            : 
     599                 :            :    //MPI_Barrier(MPI_COMM_WORLD);
     600                 :            : 
     601                 :            : 
     602                 :            :    // flag specified in input file
     603                 :            :     if(have_hex27 == true){
     604                 :            :         moab::Range entities;
     605                 :            :         moab::EntityHandle meshset;
     606                 :            :         mb->get_entities_by_type(0, MBHEX, entities);
     607                 :            :         mb->create_meshset(MESHSET_SET, meshset);
     608                 :            :         mb->add_entities(meshset, entities);
     609                 :            :         // Add nodes along mid- edge, face and region
     610                 :            :         mb->convert_entities(meshset, true, true, true);
     611                 :            :       }
     612                 :            : /*
     613                 :            :     moab::Range out_sets;
     614                 :            :     out_sets.merge(matsets);
     615                 :            :     out_sets.merge(nssets);
     616                 :            :     out_sets.merge(drsets);
     617                 :            :     out_sets.insert(meshsetp);
     618                 :            : */
     619                 :            : 
     620                 :            :     MPI_Barrier(MPI_COMM_WORLD);
     621                 :            :     if (nrank == 0) {
     622                 :            :         logfile << "Before saving mesh file in parallel. " << std::endl;
     623                 :            :     }
     624                 :            : 
     625                 :            :     MPI_Barrier(MPI_COMM_WORLD);
     626                 :            : 
     627                 :            :     moab::ErrorCode rval = mb->write_file(outfile.c_str() , 0,"PARALLEL=WRITE_PART;CPUTIME;"/*DEBUG_IO=2;", out_sets*/);
     628                 :            :     if(rval != moab::MB_SUCCESS) {
     629                 :            :         std::cerr<<"Writing output file failed Code:";
     630                 :            :         std::string foo = ""; mb->get_last_error(foo);
     631                 :            :         std::cerr<<"File Error: "<<foo<<std::endl;
     632                 :            :         return 1;
     633                 :            :       }
     634                 :            :     if (nrank == 0) {
     635                 :            :         logfile << "Done saving mesh file: " << outfile << std::endl;
     636                 :            :       }
     637                 :            :     return iBase_SUCCESS;
     638                 :            :   }
     639                 :            : #endif
     640                 :          0 :   int CoreGen::save_mesh(int nrank) {
     641                 :            :     // ---------------------------------------------------------------------------
     642                 :            :     // Function: save mesh serially from each rank
     643                 :            :     // Input:    none
     644                 :            :     // Output:   none
     645                 :            :     // ---------------------------------------------------------------------------
     646                 :            : 
     647                 :            :       // set parallel partition tag
     648         [ #  # ]:          0 :     moab::Range entities;
     649                 :            :     moab::EntityHandle meshset;
     650         [ #  # ]:          0 :     mb->get_entities_by_type(0, MBHEX, entities);
     651                 :            : 
     652         [ #  # ]:          0 :     mb->create_meshset(MESHSET_SET, meshset);
     653         [ #  # ]:          0 :     mb->add_entities(meshset, entities);
     654                 :            : 
     655                 :            :     moab::Tag pp_tag;
     656                 :            : 
     657         [ #  # ]:          0 :     mb->tag_get_handle( "PARALLEL_PARTITION", 1, MB_TYPE_INTEGER, pp_tag, MB_TAG_SPARSE|MB_TAG_CREAT);
     658 [ #  # ][ #  # ]:          0 :     logfile << "setting PARALLEL_PARTITION  tag" << std::endl;
     659         [ #  # ]:          0 :     mb->tag_set_data(pp_tag, &meshset, 1, &nrank);
     660                 :            : 
     661                 :            : 
     662         [ #  # ]:          0 :       if(have_hex27 == true){
     663         [ #  # ]:          0 :         moab::Range entities;
     664                 :            :         moab::EntityHandle meshset;
     665         [ #  # ]:          0 :         mb->get_entities_by_type(0, MBHEX, entities);
     666                 :            : 
     667         [ #  # ]:          0 :         mb->create_meshset(MESHSET_SET, meshset);
     668         [ #  # ]:          0 :         mb->add_entities(meshset, entities);
     669         [ #  # ]:          0 :         mb->convert_entities(meshset, true, true, true);
     670                 :            :       }
     671                 :            :     // export proc- nrank mesh
     672         [ #  # ]:          0 :     std::ostringstream os;
     673         [ #  # ]:          0 :     std::string fname;
     674         [ #  # ]:          0 :     fname = iname;
     675 [ #  # ][ #  # ]:          0 :     os << fname << nrank << ".h5m";
                 [ #  # ]
     676 [ #  # ][ #  # ]:          0 :     fname = os.str();
     677 [ #  # ][ #  # ]:          0 :     iMesh_save(imesh->instance(), root_set, fname.c_str(), NULL, &err, strlen(fname.c_str()), 0);
     678 [ #  # ][ #  # ]:          0 :     ERRORR("Trouble writing output mesh.", err);
                 [ #  # ]
     679 [ #  # ][ #  # ]:          0 :     logfile << "Saved mesh file: " << fname.c_str() << std::endl;
                 [ #  # ]
     680                 :            : 
     681                 :          0 :     return iBase_SUCCESS;
     682                 :            :   }
     683                 :            : 
     684                 :          0 :   int CoreGen::save_mesh() {
     685                 :            :     // ---------------------------------------------------------------------------
     686                 :            :     // Function: save mesh serially
     687                 :            :     // Input:    none
     688                 :            :     // Output:   none
     689                 :            :     // ---------------------------------------------------------------------------
     690                 :            :     // export
     691         [ #  # ]:          0 :     if(have_hex27 == true){
     692         [ #  # ]:          0 :         moab::Range entities;
     693                 :            :         moab::EntityHandle meshset;
     694         [ #  # ]:          0 :         mb->get_entities_by_type(0, MBHEX, entities);
     695                 :            : 
     696         [ #  # ]:          0 :         mb->create_meshset(MESHSET_SET, meshset);
     697         [ #  # ]:          0 :         mb->add_entities(meshset, entities);
     698         [ #  # ]:          0 :         mb->convert_entities(meshset, true, true, true);
     699                 :            :       }
     700                 :            : 
     701                 :          0 :     mb->write_mesh(outfile.c_str());
     702                 :          0 :     logfile << "Saved mesh file: " << outfile.c_str() << std::endl;
     703                 :            : 
     704                 :          0 :     return iBase_SUCCESS;
     705                 :            :   }
     706                 :            : 
     707                 :            : 
     708                 :          0 :   int CoreGen::save_geometry() {
     709                 :            :     // ---------------------------------------------------------------------------
     710                 :            :     // Function: save geometry serially
     711                 :            :     // Input:    none
     712                 :            :     // Output:   none
     713                 :            :     // ---------------------------------------------------------------------------
     714                 :            : /*    double dTol = 1e-3;
     715                 :            : 
     716                 :            :     // getting all entities for merge and imprint
     717                 :            :     SimpleArray<iBase_EntityHandle> entities_merge, entities_imprint;
     718                 :            :     iGeom_getEntities(igeom->instance(), root_set, iBase_REGION,
     719                 :            :                       ARRAY_INOUT(entities_merge), &err );
     720                 :            :     ERRORR("Trouble writing output geometry.", err);
     721                 :            : 
     722                 :            :     // merge and imprint before save
     723                 :            :     logfile << "Merging.." << std::endl;
     724                 :            :     iGeom_mergeEnts(igeom->instance(), ARRAY_IN(entities_merge), dTol, &err);
     725                 :            :     ERRORR("Trouble writing output geometry.", err);
     726                 :            : 
     727                 :            :     iGeom_getEntities( igeom->instance(), root_set, iBase_REGION, ARRAY_INOUT(entities_imprint),&err );
     728                 :            :     ERRORR("Trouble writing output geometry.", err);
     729                 :            : 
     730                 :            :     // logfile << "Imprinting.." << std::endl;
     731                 :            :     // iGeom_imprintEnts(igeom->instance(), ARRAY_IN(entities_imprint),&err);
     732                 :            :     // ERRORR("Trouble writing output geometry.", err);
     733                 :            :     // export
     734                 :            :     logfile << "Saving geometry file: " <<  outfile << std::endl;
     735                 :            : */
     736                 :            :     iGeom_save(igeom->instance(), outfile.c_str(), NULL, &err,
     737                 :          0 :                strlen(outfile.c_str()), 0);
     738         [ #  # ]:          0 :     ERRORR("Trouble writing output geometry.", err);
     739                 :          0 :     logfile << "Saved geometry file: "<< outfile.c_str() <<std::endl;
     740                 :            : 
     741                 :          0 :     return iBase_SUCCESS;
     742                 :            :   }
     743                 :            : 
     744                 :          0 :   int CoreGen::distribute_mesh(const int nrank, int numprocs)
     745                 :            :   // -------------------------------------------------------------------------------------------
     746                 :            :   // Function: merge the nodes within a set tolerance in the model
     747                 :            :   // Input:    none
     748                 :            :   // Output:   none
     749                 :            :   // -------------------------------------------------------------------------------------------
     750                 :            :   {
     751                 :          0 :     int nback = files.size() - nassys;
     752         [ #  # ]:          0 :     if(nrank < ((int) core_alias.size() + nback)){
     753         [ #  # ]:          0 :         if(numprocs > (int) core_alias.size()){
     754                 :          0 :             numprocs =  core_alias.size() + nback;
     755                 :            :           }
     756                 :            : 
     757         [ #  # ]:          0 :         rank_load.resize(numprocs);
     758                 :          0 :         int extra_procs = numprocs - files.size();
     759 [ #  # ][ #  # ]:          0 :         if(numprocs >= (int) files.size() && numprocs <= (tot_assys + nback)){
                 [ #  # ]
     760                 :            :             // again fill assm_meshfiles
     761         [ #  # ]:          0 :             for(int p=0; p<nassys; p++){
     762         [ #  # ]:          0 :                 assm_meshfiles[p]=0;
     763         [ #  # ]:          0 :                 load_per_assm[p]=0;
     764                 :            :               }
     765         [ #  # ]:          0 :             for(int p=0; p<tot_assys; p++){
     766         [ #  # ]:          0 :                 for(int q=0; q<nassys; q++){
     767 [ #  # ][ #  # ]:          0 :                     if(strcmp(core_alias[p].c_str(), assm_alias[q].c_str()) ==0) {
                 [ #  # ]
     768         [ #  # ]:          0 :                         assm_meshfiles[q]+=1;
     769         [ #  # ]:          0 :                         load_per_assm[q]+=1;
     770                 :            :                       }
     771                 :            :                   }
     772                 :            :               }
     773         [ #  # ]:          0 :             if(nrank == 0){
     774 [ #  # ][ #  # ]:          0 :                 logfile << " assm_meshfiles" << std::endl;
     775         [ #  # ]:          0 :                 for(int p=0; p<nassys; p++){
     776 [ #  # ][ #  # ]:          0 :                     logfile << assm_meshfiles[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     777                 :            :                   }
     778 [ #  # ][ #  # ]:          0 :                 logfile << " load per assm" << std::endl;
     779         [ #  # ]:          0 :                 for(int p=0; p<nassys; p++){
     780 [ #  # ][ #  # ]:          0 :                     logfile << load_per_assm[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     781                 :            :                   }
     782                 :            :               }
     783                 :            :             //distribute
     784         [ #  # ]:          0 :             for(int i=0; i<  (int)files.size(); i++){
     785         [ #  # ]:          0 :                 rank_load[i] = i;
     786         [ #  # ]:          0 :                 if(i< nassys)
     787         [ #  # ]:          0 :                   times_loaded[i]+=1;
     788                 :            :               }
     789                 :            : 
     790                 :          0 :             double temp = 0;
     791                 :          0 :             int assm_load = - 1;
     792                 :          0 :             int e= 0;
     793                 :            :             // compute the rank, mf vector for extra procs
     794         [ #  # ]:          0 :             while(e < extra_procs){
     795         [ #  # ]:          0 :                 for(int i = 0; i < nassys; i++){
     796 [ #  # ][ #  # ]:          0 :                     if (load_per_assm[i] > temp ){
     797                 :            :                     //if (load_per_assm[i] > temp){
     798         [ #  # ]:          0 :                         temp = load_per_assm[i];
     799                 :          0 :                         assm_load = i;
     800                 :            :                       }
     801         [ #  # ]:          0 :                     else if (assm_load == -1){
     802 [ #  # ][ #  # ]:          0 :                         logfile << "No assemblies mesh files used in core" << std::endl;
     803                 :          0 :                         exit(0);
     804                 :            :                       }
     805                 :            :                   }
     806                 :            :                 //assm_meshfiles[assm_load]-=1;
     807         [ #  # ]:          0 :                 times_loaded[assm_load]+=1;
     808 [ #  # ][ #  # ]:          0 :                  load_per_assm[assm_load] = (double)assm_meshfiles[assm_load]/(double)times_loaded[assm_load];
                 [ #  # ]
     809                 :            : 
     810         [ #  # ]:          0 :                  if(nrank == 0)
     811 [ #  # ][ #  # ]:          0 :                   logfile << assm_load <<": - assembly has a Current Load: " << load_per_assm[assm_load] << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     812                 :          0 :                 int temp_rank = files.size()+ e;
     813         [ #  # ]:          0 :                 rank_load[temp_rank] = assm_load;
     814                 :          0 :                 e++;
     815                 :          0 :                 temp = 0;
     816                 :            :               }
     817                 :            :           }
     818                 :            :         else{
     819 [ #  # ][ #  # ]:          0 :             logfile << "Warning: #procs <= #assys in core, some processor will be idle" << std::endl;
     820                 :            :           }
     821         [ #  # ]:          0 :         if(nrank == 0){
     822 [ #  # ][ #  # ]:          0 :             logfile << "Times loaded 1 " << std::endl;
     823         [ #  # ]:          0 :             for(int p=0; p<nassys; p++){
     824 [ #  # ][ #  # ]:          0 :                 logfile << times_loaded[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     825                 :            :               }
     826                 :            : 
     827                 :            :           }
     828                 :            :        // times_loaded.resize(nassys);
     829         [ #  # ]:          0 :         std::vector<std::vector<int> > meshfiles_rank (files.size());
     830         [ #  # ]:          0 :         for(int i=0; i < (int) files.size(); i++){
     831         [ #  # ]:          0 :             for(int j=0; j < (int) rank_load.size(); j++){
     832 [ #  # ][ #  # ]:          0 :                 if(rank_load[j]==i){
     833 [ #  # ][ #  # ]:          0 :                     meshfiles_rank[i].push_back(j);
     834                 :            :                     // already done above times_loaded[i]+=1;
     835                 :            :                   }
     836                 :            :               }
     837                 :            :           }
     838                 :            : 
     839         [ #  # ]:          0 :         position_core.resize(numprocs);
     840                 :            : 
     841         [ #  # ]:          0 :         for(int i=0; i < (int) files.size(); i++){
     842                 :          0 :             int k = 0;
     843         [ #  # ]:          0 :             if(i < (nassys) ){
     844 [ #  # ][ #  # ]:          0 :                 for(int j=0; j < (int) assm_location[i].size(); j++){
     845 [ #  # ][ #  # ]:          0 :                     if (k >= (int) meshfiles_rank[i].size()){
     846                 :          0 :                         k = 0;
     847                 :            :                       }
     848 [ #  # ][ #  # ]:          0 :                     int p = meshfiles_rank[i][k];
     849 [ #  # ][ #  # ]:          0 :                     int q = assm_location[i][j];
     850 [ #  # ][ #  # ]:          0 :                     position_core[p].push_back(q);
     851                 :            : 
     852                 :          0 :                     ++k;
     853                 :            :                   }
     854                 :            :               }
     855                 :            :             else{
     856                 :            :                 // this is background mesh set it -2, no meshfile to copy/move
     857 [ #  # ][ #  # ]:          0 :                 position_core[i].push_back(-2);
     858                 :            :               }
     859                 :            :           }
     860         [ #  # ]:          0 :         if(nrank == 0){
     861 [ #  # ][ #  # ]:          0 :             logfile << "Times loaded 1 After" << std::endl;
     862         [ #  # ]:          0 :             for(int p=0; p<nassys; p++){
     863 [ #  # ][ #  # ]:          0 :                 logfile << times_loaded[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     864                 :            :               }
     865                 :            : 
     866                 :            :           }
     867         [ #  # ]:          0 :         if(nrank == 0){
     868 [ #  # ][ #  # ]:          0 :             logfile << "FINAL scheme 1 assm_meshfiles" << std::endl;
     869         [ #  # ]:          0 :             for(int p=0; p<nassys; p++){
     870 [ #  # ][ #  # ]:          0 :                 logfile << assm_meshfiles[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     871                 :            :               }
     872 [ #  # ][ #  # ]:          0 :             logfile << "FINAL scheme 1 load per assm" << std::endl;
     873         [ #  # ]:          0 :             for(int p=0; p<nassys; p++){
     874 [ #  # ][ #  # ]:          0 :                 logfile << load_per_assm[p] << " : " << p << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     875                 :            :               }
     876                 :            :           }
     877         [ #  # ]:          0 :         if(nrank == 0){
     878 [ #  # ][ #  # ]:          0 :             logfile << " copy/move task distribution " << std::endl;
     879         [ #  # ]:          0 :             for(int i =0; i< numprocs; i++){
     880 [ #  # ][ #  # ]:          0 :                 logfile << "rank: " << i <<  " positions : ";
                 [ #  # ]
     881 [ #  # ][ #  # ]:          0 :                 for(int j=0; j< (int) position_core[i].size(); j++){
     882 [ #  # ][ #  # ]:          0 :                     logfile << (int) position_core[i][j] << " ";
         [ #  # ][ #  # ]
     883                 :            :                   }
     884 [ #  # ][ #  # ]:          0 :                 logfile << "\n" << std::endl;
     885                 :            :               }
     886                 :          0 :           }
     887                 :            :       }
     888                 :          0 :     return 0;
     889                 :            :   }
     890                 :            : 
     891                 :            : 
     892                 :          0 :   int CoreGen::load_meshes_more_procs(const int nrank, int numprocs)
     893                 :            :   // ---------------------------------------------------------------------------
     894                 :            :   // Function: loads all the meshes and initializes copymesh object
     895                 :            :   // Input:    none
     896                 :            :   // Output:   none
     897                 :            :   // ---------------------------------------------------------------------------
     898                 :            :   {
     899 [ #  # ][ #  # ]:          0 :     iMesh_getRootSet(imesh->instance(), &root_set, &err);
     900 [ #  # ][ #  # ]:          0 :     ERRORR("Couldn't get the root set", err);
                 [ #  # ]
     901                 :            : 
     902         [ #  # ]:          0 :     int temp_index = rank_load[nrank];
     903                 :            : 
     904                 :            :     iBase_EntitySetHandle orig_set;
     905 [ #  # ][ #  # ]:          0 :     iMesh_createEntSet(imesh->instance(), 0, &orig_set, &err);
     906 [ #  # ][ #  # ]:          0 :     ERRORR("Couldn't create file set.", err);
                 [ #  # ]
     907                 :            : 
     908                 :            :     // load this file
     909 [ #  # ][ #  # ]:          0 :     iMesh_load(imesh->instance(), orig_set, files[temp_index].c_str(), NULL, &err, strlen(files[temp_index].c_str()), 0);
         [ #  # ][ #  # ]
     910 [ #  # ][ #  # ]:          0 :     ERRORR("Couldn't read mesh file.", err);
                 [ #  # ]
     911 [ #  # ][ #  # ]:          0 :     logfile << "Loaded mesh file " << temp_index << " in processor: " << nrank << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     912                 :            : 
     913 [ #  # ][ #  # ]:          0 :     if(bsameas[temp_index] == 0 && temp_index < nassys){
         [ #  # ][ #  # ]
     914 [ #  # ][ #  # ]:          0 :         if(all_ms_starts[temp_index] != -1 && all_ns_starts[temp_index] !=-1){
         [ #  # ][ #  # ]
                 [ #  # ]
     915 [ #  # ][ #  # ]:          0 :             if(!shift_mn_ids(orig_set, temp_index))
     916 [ #  # ][ #  # ]:          0 :               ERRORR("Couldn't shift material and neumann set id's.", 1);
                 [ #  # ]
     917                 :            :           }
     918                 :            :       }
     919                 :            : 
     920         [ #  # ]:          0 :     assys.push_back(orig_set);
     921         [ #  # ]:          0 :     assys_index.push_back(temp_index);
     922                 :            : 
     923                 :            :     // create cm instances for each mesh file
     924         [ #  # ]:          0 :     cm.resize(assys.size());
     925         [ #  # ]:          0 :     for (unsigned int i = 0; i < assys.size(); i++) {
     926                 :            :         ModelEnt *me;
     927                 :          0 :         me = NULL;
     928 [ #  # ][ #  # ]:          0 :         me = new ModelEnt(mk_core(), iBase_EntitySetHandle(0), /*igeom instance*/0, (moab::EntityHandle)orig_set, 0);
                 [ #  # ]
     929         [ #  # ]:          0 :         MEntVector assm_set;
     930         [ #  # ]:          0 :         assm_set.push_back(me);
     931 [ #  # ][ #  # ]:          0 :         cm[i] = (CopyMesh*) mk_core()->construct_meshop("CopyMesh", assm_set);
         [ #  # ][ #  # ]
     932 [ #  # ][ #  # ]:          0 :         cm[i]->set_name("copy_move_mesh");
                 [ #  # ]
     933                 :          0 :       }
     934                 :          0 :     return iBase_SUCCESS;
     935                 :            :   }
     936                 :            : 
     937                 :            : 
     938                 :            : 
     939                 :          0 :   int CoreGen::load_meshes_parallel(const int nrank, int numprocs)
     940                 :            :   // ---------------------------------------------------------------------------
     941                 :            :   // Function: loads all the meshes and initializes copymesh object
     942                 :            :   // Input:    none
     943                 :            :   // Output:   none
     944                 :            :   // ---------------------------------------------------------------------------
     945                 :            :   {
     946                 :          0 :     int nback = files.size() - nassys;
     947                 :          0 :     cm.resize(files.size());
     948                 :            : 
     949                 :          0 :     iMesh_getRootSet(imesh->instance(), &root_set, &err);
     950         [ #  # ]:          0 :     ERRORR("Couldn't get the root set", err);
     951         [ #  # ]:          0 :     if(nrank < ((int) core_alias.size() + nback)){
     952         [ #  # ]:          0 :         if(numprocs > (int) core_alias.size()){
     953                 :          0 :             numprocs =  core_alias.size() + nback;
     954                 :            :           }
     955                 :            : 
     956                 :            : #ifdef USE_MPI
     957                 :            :         if(numprocs > ((int) core_alias.size() + nback)){
     958                 :            :             logfile << "Warning: #procs <= #assys in core, some processor will be idle" << std::endl;
     959                 :            :           }
     960                 :            : 
     961                 :            :         iBase_EntitySetHandle orig_set;
     962                 :            :         int temp_index;
     963                 :            :         int extra_procs = numprocs - files.size();
     964                 :            :         std::vector<int> rank_load;
     965                 :            :         for(int i = 0; i< (int) files.size(); i++){
     966                 :            :             temp_index = numprocs*i + nrank;
     967                 :            :             if(temp_index >= (int) files.size()){
     968                 :            :                 if (nrank >= (int) files.size() && nrank <= (tot_assys + nback)){
     969                 :            :                     int temp = 1;
     970                 :            :                     int p = extra_procs;
     971                 :            :                     // compute the rank, mf vector for extra procs
     972                 :            :                     while(p !=0){
     973                 :            :                         int assm_load = - 1;
     974                 :            :                         for(int i = 0; i < nassys; i++){
     975                 :            :                             if ((int) assm_meshfiles[i] > temp){
     976                 :            :                                 temp = assm_meshfiles[i];
     977                 :            :                                 assm_load = i;
     978                 :            :                               }
     979                 :            :                           }
     980                 :            :                         if (assm_load == -1){
     981                 :            :                             continue;
     982                 :            :                             logfile << "Warning: #procs <= #assys in core, some processor will be idle" << std::endl;
     983                 :            :                           }
     984                 :            :                         assm_meshfiles[assm_load]-=1;
     985                 :            :                         rank_load.push_back(assm_load);
     986                 :            :                         --p;
     987                 :            :                         temp = 1;
     988                 :            :                       }
     989                 :            : 
     990                 :            :                     temp_index = nrank - files.size();
     991                 :            :                     iMesh_createEntSet(imesh->instance(), 0, &orig_set, &err);
     992                 :            :                     ERRORR("Couldn't create file set.", err);
     993                 :            : 
     994                 :            :                     if(!compute_meshtogeom){
     995                 :            :                         // load this file
     996                 :            :                         iMesh_load(imesh->instance(), orig_set, files[rank_load[temp_index]].c_str(), NULL, &err, strlen(files[rank_load[temp_index]].c_str()), 0);
     997                 :            :                         ERRORR("Couldn't read mesh file.", err);
     998                 :            :                       }
     999                 :            :                     else{
    1000                 :            :                         load_and_compute_meshtogeom(orig_set, files[rank_load[temp_index]]);
    1001                 :            :                       }
    1002                 :            :                     logfile << "Loaded mesh file " << rank_load[temp_index] << " in processor: " << nrank << std::endl;
    1003                 :            : 
    1004                 :            :                     ModelEnt *me;
    1005                 :            :                     me = NULL;
    1006                 :            :                     me = new ModelEnt(mk_core(), iBase_EntitySetHandle(0), /*igeom instance*/0, (moab::EntityHandle)orig_set, 0);
    1007                 :            :                     MEntVector assm_set;
    1008                 :            :                     assm_set.push_back(me);
    1009                 :            :                     cm[i] = (CopyMesh*) mk_core()->construct_meshop("CopyMesh", assm_set);
    1010                 :            :                     cm[i]->set_name("copy_move_mesh");
    1011                 :            : 
    1012                 :            :                     assys.push_back(orig_set);
    1013                 :            :                     assys_index.push_back(rank_load[temp_index]);
    1014                 :            :                     break;
    1015                 :            :                   }
    1016                 :            :               }
    1017                 :            :             else{
    1018                 :            :                 iMesh_createEntSet(imesh->instance(), 0, &orig_set, &err);
    1019                 :            :                 ERRORR("Couldn't create file set.", err);
    1020                 :            : 
    1021                 :            :                 if(!compute_meshtogeom){
    1022                 :            :                     // load this file
    1023                 :            :                     iMesh_load(imesh->instance(), orig_set, files[temp_index].c_str(), NULL, &err, strlen(files[temp_index].c_str()), 0);
    1024                 :            :                     ERRORR("Couldn't read mesh file.", err);
    1025                 :            :                   }
    1026                 :            :                 else{
    1027                 :            :                     load_and_compute_meshtogeom(orig_set, files[temp_index]);
    1028                 :            :                   }\
    1029                 :            :                 logfile << "Loaded mesh file " << temp_index << " in processor: " << nrank << std::endl;
    1030                 :            : 
    1031                 :            :                 ModelEnt *me;
    1032                 :            :                 me = NULL;
    1033                 :            :                 me = new ModelEnt(mk_core(), iBase_EntitySetHandle(0), /*igeom instance*/0, (moab::EntityHandle)orig_set, 0);
    1034                 :            :                 MEntVector assm_set;
    1035                 :            :                 assm_set.push_back(me);
    1036                 :            :                 cm[i] = (CopyMesh*) mk_core()->construct_meshop("CopyMesh", assm_set);
    1037                 :            :                 cm[i]->set_name("copy_move_mesh");
    1038                 :            : 
    1039                 :            :                 assys.push_back(orig_set);
    1040                 :            :                 assys_index.push_back(temp_index);
    1041                 :            :               }
    1042                 :            :           }
    1043                 :            : #endif
    1044                 :            :       }
    1045                 :          0 :     return iBase_SUCCESS;
    1046                 :            :   }
    1047                 :            : 
    1048                 :          0 :   int CoreGen::load_meshes()
    1049                 :            :   // ---------------------------------------------------------------------------
    1050                 :            :   // Function: loads all the meshes and initializes copymesh and merge mesh objects
    1051                 :            :   // Input:    none
    1052                 :            :   // Output:   none
    1053                 :            :   // ---------------------------------------------------------------------------
    1054                 :            :   {
    1055                 :            :     // create cm instances for each mesh file
    1056         [ #  # ]:          0 :     cm.resize(files.size());
    1057                 :            :     iBase_EntitySetHandle orig_set;
    1058                 :            :     // loop reading all mesh files
    1059         [ #  # ]:          0 :     for (unsigned int i = 0; i < files.size(); i++) {
    1060 [ #  # ][ #  # ]:          0 :         iMesh_createEntSet(imesh->instance(), 0, &orig_set, &err);
    1061 [ #  # ][ #  # ]:          0 :         ERRORR("Couldn't create file set.", err);
                 [ #  # ]
    1062 [ #  # ][ #  # ]:          0 :         logfile << "Loading File: " << files[i].c_str() << std::endl;
         [ #  # ][ #  # ]
    1063         [ #  # ]:          0 :         if(!compute_meshtogeom){
    1064 [ #  # ][ #  # ]:          0 :             iMesh_load(imesh->instance(), orig_set, files[i].c_str(), NULL, &err, strlen(files[i].c_str()), 0);
         [ #  # ][ #  # ]
    1065 [ #  # ][ #  # ]:          0 :             ERRORR("Couldn't read mesh file.", err);
                 [ #  # ]
    1066 [ #  # ][ #  # ]:          0 :             mk_core()->populate_model_ents(0,0,0);
    1067                 :            :           }
    1068                 :            :         else{
    1069 [ #  # ][ #  # ]:          0 :             load_and_compute_meshtogeom(orig_set, files[i]);
                 [ #  # ]
    1070                 :            :           }
    1071                 :            :         ModelEnt *me;
    1072                 :          0 :         me = NULL;
    1073 [ #  # ][ #  # ]:          0 :         me = new ModelEnt(mk_core(), iBase_EntitySetHandle(0), /*igeom instance*/0, (moab::EntityHandle)orig_set, 0);
                 [ #  # ]
    1074         [ #  # ]:          0 :         MEntVector assm_set;
    1075                 :            :         //assm_set.clear();
    1076         [ #  # ]:          0 :         assm_set.push_back(me);
    1077 [ #  # ][ #  # ]:          0 :         cm[i] = (CopyMesh*) mk_core()->construct_meshop("CopyMesh", assm_set);
         [ #  # ][ #  # ]
    1078 [ #  # ][ #  # ]:          0 :         cm[i]->set_name("copy_move_mesh");
                 [ #  # ]
    1079 [ #  # ][ #  # ]:          0 :         cm[i]->copy_sets().add_set(orig_set);
                 [ #  # ]
    1080                 :            : 
    1081                 :            :         //resize this else code will break
    1082                 :            :         //check if we've loaded the same mesh file and need to shift the Material and Neumann set start id's
    1083 [ #  # ][ #  # ]:          0 :         if(bsameas[i] == 0 && (int) i < nassys){
         [ #  # ][ #  # ]
    1084 [ #  # ][ #  # ]:          0 :             if(all_ms_starts[i] != -1 && all_ns_starts[i] !=-1){
         [ #  # ][ #  # ]
                 [ #  # ]
    1085 [ #  # ][ #  # ]:          0 :                 if(!shift_mn_ids(orig_set, i))
    1086 [ #  # ][ #  # ]:          0 :                   ERRORR("Couldn't shift material and neumann set id's.", 1);
                 [ #  # ]
    1087                 :            :               }
    1088                 :            :           }
    1089                 :            : 
    1090         [ #  # ]:          0 :         assys.push_back(orig_set);
    1091 [ #  # ][ #  # ]:          0 :         assys_index.push_back(i);
    1092                 :          0 :       }
    1093 [ #  # ][ #  # ]:          0 :     logfile << "Loaded mesh files." << std::endl;
    1094                 :            : 
    1095                 :          0 :     return iBase_SUCCESS;
    1096                 :            :   }
    1097                 :            : 
    1098                 :          0 :   int CoreGen::load_and_compute_meshtogeom(iBase_EntitySetHandle orig_set, std::string filename)
    1099                 :            :   // ---------------------------------------------------------------------------
    1100                 :            :   // Function: loads all the meshes and initializes copymesh and merge mesh objects
    1101                 :            :   // Input:    none
    1102                 :            :   // Output:   none
    1103                 :            :   // ---------------------------------------------------------------------------
    1104                 :            :   {
    1105                 :          0 :     bool isCub = false;
    1106         [ #  # ]:          0 :     std::string ext;
    1107                 :            :     std::string::size_type idx;
    1108                 :          0 :     idx = filename.rfind('.');
    1109         [ #  # ]:          0 :     if(idx != std::string::npos)
    1110                 :            :       {
    1111 [ #  # ][ #  # ]:          0 :         ext = filename.substr(idx+1);
    1112                 :            :       }
    1113                 :            :     else
    1114                 :            :       {
    1115                 :            :         // No extension found
    1116                 :            :       }
    1117 [ #  # ][ #  # ]:          0 :     if(ext == "cub") isCub = true;
    1118                 :            : 
    1119         [ #  # ]:          0 :     if(isCub){
    1120 [ #  # ][ #  # ]:          0 :         mk_core()->igeom_instance()->deleteAll();
                 [ #  # ]
    1121                 :            : 
    1122                 :            :         iGeom_load(igeom->instance(), filename.c_str(), NULL, &err,
    1123 [ #  # ][ #  # ]:          0 :                    strlen(filename.c_str()), 0);
    1124 [ #  # ][ #  # ]:          0 :         iMesh_load(imesh->instance(), orig_set, filename.c_str(), NULL, &err, strlen(filename.c_str()), 0);
    1125 [ #  # ][ #  # ]:          0 :         ERRORR("Couldn't read mesh file.", err);
                 [ #  # ]
    1126                 :            :         // populate model eneities here so we can call irel function from MeshKit
    1127                 :            : 
    1128 [ #  # ][ #  # ]:          0 :         mk_core()->irel_pair()->inferAllRelations();
                 [ #  # ]
    1129 [ #  # ][ #  # ]:          0 :         mk_core()->populate_model_ents(0,0,0);
    1130                 :            : 
    1131                 :            : 
    1132                 :            :         // now calculate geometric and mesh volume
    1133         [ #  # ]:          0 :         VerdictWrapper vw(mb);
    1134                 :            :         // Get all the materials in this mesh file
    1135                 :            :         moab::Tag mattag, gidtag;
    1136         [ #  # ]:          0 :         moab::Range matsets;
    1137         [ #  # ]:          0 :         mb->tag_get_handle("MATERIAL_SET", 1, MB_TYPE_INTEGER, mattag);
    1138         [ #  # ]:          0 :         mb->tag_get_handle("GLOBAL_ID", 1, MB_TYPE_INTEGER, gidtag);
    1139         [ #  # ]:          0 :         mb->get_entities_by_type_and_tag((moab::EntityHandle) orig_set, MBENTITYSET, &mattag, 0, 1, matsets );
    1140                 :            : 
    1141                 :          0 :         double mtot = 0.0, volume = 0.0;
    1142                 :            :         //loop thru all the materials
    1143         [ #  # ]:          0 :         moab::Range::iterator set_it;
    1144 [ #  # ][ #  # ]:          0 :         for (set_it = matsets.begin(); set_it != matsets.end(); set_it++)  {
         [ #  # ][ #  # ]
                 [ #  # ]
    1145         [ #  # ]:          0 :             moab::EntityHandle this_set = *set_it;
    1146                 :            : 
    1147                 :            :             // get the id for this set
    1148                 :            :             int material_id;
    1149         [ #  # ]:          0 :             mb->tag_get_data(mattag, &this_set, 1, &material_id);
    1150                 :            :             // add up the geometric volume for these geometric volumes
    1151                 :            :             // get the entity sets there must be one entity set for each volume
    1152         [ #  # ]:          0 :             std::vector<moab::EntityHandle> geomsets_for_gid;
    1153                 :          0 :             geomsets_for_gid.clear();
    1154         [ #  # ]:          0 :             mb->get_entities_by_type(this_set, MBENTITYSET, geomsets_for_gid);
    1155                 :            : 
    1156         [ #  # ]:          0 :             for(unsigned int volid = 0; volid < geomsets_for_gid.size(); volid++){
    1157                 :            :                 // get the gid of this volume
    1158                 :          0 :                 int my_geom_id = 0;
    1159 [ #  # ][ #  # ]:          0 :                 mb->tag_get_data(gidtag, &geomsets_for_gid[volid], 1, &my_geom_id);
    1160                 :          0 :                 iBase_EntityHandle ent2=NULL;
    1161 [ #  # ][ #  # ]:          0 :                 mk_core()->irel_pair()->getSetEntRelation((iBase_EntitySetHandle) geomsets_for_gid[volid], 1, ent2);
         [ #  # ][ #  # ]
    1162                 :          0 :                 double myvol = 0.0;
    1163         [ #  # ]:          0 :                 if(ent2 != NULL){
    1164 [ #  # ][ #  # ]:          0 :                     mk_core()->igeom_instance()->measure(&ent2,1,&myvol);
                 [ #  # ]
    1165                 :          0 :                     volume+=myvol;
    1166                 :            :                   }
    1167                 :            :               }
    1168         [ #  # ]:          0 :             if(volume == 0){
    1169 [ #  # ][ #  # ]:          0 :                 logfile << "Trying to compute MESHTOGEOM, but volume obtained is zero." << std::endl;
    1170 [ #  # ][ #  # ]:          0 :                 logfile << "Geometry engine must match file type. Aborting." << std::endl;
    1171                 :            :                 // exit(0); don't abort, continue to run. MESHTOGEOM won't be computed rest should still work.
    1172                 :            :               }
    1173                 :            : 
    1174         [ #  # ]:          0 :             std::vector<moab::EntityHandle> elems;
    1175         [ #  # ]:          0 :             mb->get_entities_by_dimension(this_set, 3, elems, true);
    1176                 :            :             // get all the elements in this material
    1177                 :          0 :             double mvol_temp = 0.0;
    1178         [ #  # ]:          0 :             for(unsigned int i=0; i<elems.size();i++){
    1179                 :          0 :                 mvol_temp = 0.0;
    1180 [ #  # ][ #  # ]:          0 :                 vw.quality_measure(elems[i], moab::MB_VOLUME, mvol_temp);
    1181                 :          0 :                 mtot+=mvol_temp;
    1182                 :            :               }
    1183                 :            : 
    1184                 :          0 :             double meshtogeom = mtot/volume;
    1185 [ #  # ][ #  # ]:          0 :             meshtogeom_file << material_id << " "<<  meshtogeom << std::endl;
         [ #  # ][ #  # ]
    1186 [ #  # ][ #  # ]:          0 :             logfile << material_id << " " << meshtogeom << std::endl;
         [ #  # ][ #  # ]
    1187                 :            :             moab::Tag mtog_tag;
    1188                 :            :             // now set the meshtogeom tag on this set
    1189                 :            :             mb->tag_get_handle( "MESHTOGEOM", 1, MB_TYPE_DOUBLE,
    1190         [ #  # ]:          0 :                                 mtog_tag, MB_TAG_SPARSE|MB_TAG_CREAT );
    1191 [ #  # ][ #  # ]:          0 :             mb->tag_set_data(mtog_tag, &(*set_it), 1, &meshtogeom);
    1192                 :            : 
    1193                 :          0 :             elems.clear();
    1194                 :          0 :             mtot = 0.0;
    1195                 :          0 :             volume = 0.0;
    1196                 :          0 :           }
    1197                 :            :         //
    1198                 :            :       }
    1199                 :            :     else{
    1200 [ #  # ][ #  # ]:          0 :         logfile << "Trying to load a file that doesn't have geometry: Aborting" << std::endl;
    1201 [ #  # ][ #  # ]:          0 :         logfile << "Try loading a .cub file." << std::endl;
    1202                 :            :        // exit(0); don't abort, continue to run. MESHTOGEOM won't be computed rest should still work.
    1203                 :            :     }
    1204                 :          0 :     return iBase_SUCCESS;
    1205                 :            :   }
    1206                 :            : 
    1207                 :          0 :   int CoreGen::load_geometries()
    1208                 :            :   // ---------------------------------------------------------------------------
    1209                 :            :   // Function: loads all the meshes and initializes copymesh and merge mesh objects
    1210                 :            :   // Input:    none
    1211                 :            :   // Output:   none
    1212                 :            :   // ---------------------------------------------------------------------------
    1213                 :            :   {
    1214 [ #  # ][ #  # ]:          0 :     logfile << "\n--Loading geometry files." << std::endl;
    1215                 :            : 
    1216 [ #  # ][ #  # ]:          0 :     iGeom_getRootSet(igeom->instance(), &root_set, &err);
    1217 [ #  # ][ #  # ]:          0 :     ERRORR("Couldn't get the root set", err);
                 [ #  # ]
    1218                 :            : 
    1219                 :            :     // create cm instances for each mesh file
    1220         [ #  # ]:          0 :     cg.resize(files.size());
    1221                 :            : 
    1222                 :            :     iBase_EntitySetHandle orig_set, temp_set, temp_set1;
    1223                 :            : 
    1224 [ #  # ][ #  # ]:          0 :     iGeom_createEntSet(igeom->instance(), 0, &temp_set1, &err);
    1225 [ #  # ][ #  # ]:          0 :     ERRORR( "Problem creating entity set.",err );
                 [ #  # ]
    1226                 :            : 
    1227         [ #  # ]:          0 :     MEntVector vols_old;
    1228                 :            :     // loop reading all igeom->instance() files
    1229         [ #  # ]:          0 :     for (unsigned int i = 0; i < files.size(); i++) {
    1230 [ #  # ][ #  # ]:          0 :         iGeom_createEntSet(igeom->instance(), 0, &orig_set, &err);
    1231 [ #  # ][ #  # ]:          0 :         ERRORR( "Problem creating entity set.", err);
                 [ #  # ]
    1232                 :            : 
    1233 [ #  # ][ #  # ]:          0 :         iGeom_createEntSet(igeom->instance(), 0, &temp_set, &err);
    1234 [ #  # ][ #  # ]:          0 :         ERRORR( "Problem creating entity set.",err );
                 [ #  # ]
    1235                 :            : 
    1236         [ #  # ]:          0 :         iGeom_load(igeom->instance(), files[i].c_str(), NULL, &err,
    1237 [ #  # ][ #  # ]:          0 :                    strlen(files[i].c_str()), 0);
                 [ #  # ]
    1238 [ #  # ][ #  # ]:          0 :         ERRORR("Couldn't read geometry file.", err);
                 [ #  # ]
    1239 [ #  # ][ #  # ]:          0 :         mk_core()->populate_model_ents(0,-1,-1);
    1240                 :            : 
    1241                 :          0 :         iBase_EntityHandle *entities = NULL;
    1242                 :          0 :         int entities_ehsize = 0, entities_ehallocated = 0;
    1243                 :            : 
    1244                 :            :         iGeom_getEntities(igeom->instance(), root_set, iBase_REGION, &entities,
    1245 [ #  # ][ #  # ]:          0 :                           &entities_ehsize, &entities_ehallocated, &err);
    1246 [ #  # ][ #  # ]:          0 :         ERRORR( "Problem getting entities." , err);
                 [ #  # ]
    1247                 :            : 
    1248                 :            :         // add the entity
    1249         [ #  # ]:          0 :         for (int j = 0; j < entities_ehsize; j++) {
    1250 [ #  # ][ #  # ]:          0 :             iGeom_addEntToSet(igeom->instance(), entities[j], temp_set, &err);
    1251 [ #  # ][ #  # ]:          0 :             ERRORR( "Problem adding to set.", err );
                 [ #  # ]
    1252                 :            :           }
    1253                 :            : 
    1254 [ #  # ][ #  # ]:          0 :         iGeom_subtract(igeom->instance(), temp_set, temp_set1, &orig_set, &err);
    1255 [ #  # ][ #  # ]:          0 :         ERRORR( "Unable to subtract entity sets.", err );
                 [ #  # ]
    1256                 :            : 
    1257         [ #  # ]:          0 :         MEntVector vols;
    1258 [ #  # ][ #  # ]:          0 :         mk_core()->get_entities_by_dimension(3, vols);
    1259         [ #  # ]:          0 :         MEntVector vols1;// = vols - vols_old;
    1260                 :            : 
    1261 [ #  # ][ #  # ]:          0 :         std::set_difference(vols.begin(), vols.end(), vols_old.begin(), vols_old.end(), std::inserter(vols1, vols1.begin()));
    1262                 :            : 
    1263 [ #  # ][ #  # ]:          0 :         cg[i] = (CopyGeom*) mk_core()->construct_meshop("CopyGeom", vols1);
         [ #  # ][ #  # ]
    1264 [ #  # ][ #  # ]:          0 :         cg[i]->set_name("copy_move_geom");
                 [ #  # ]
    1265                 :            : 
    1266         [ #  # ]:          0 :         assys.push_back(orig_set);
    1267                 :            : 
    1268         [ #  # ]:          0 :         assys_index.push_back(i);
    1269                 :            : 
    1270                 :            :         // store this set for subtraction with next entity set
    1271                 :          0 :         temp_set1 = temp_set;
    1272         [ #  # ]:          0 :         vols_old = vols;
    1273                 :          0 :       }
    1274 [ #  # ][ #  # ]:          0 :     logfile << "\n--Loaded geometry files.\n" << std::endl;
    1275                 :            : 
    1276                 :          0 :     return iBase_SUCCESS;
    1277                 :            :   }
    1278                 :            : 
    1279                 :          0 :   int CoreGen::shift_mn_ids(iBase_EntitySetHandle orig_set, int number)
    1280                 :            :   // ---------------------------------------------------------------------------
    1281                 :            :   // Function: loads all the meshes and initializes copymesh and merge mesh objects
    1282                 :            :   // Input:    none
    1283                 :            :   // Output:   none
    1284                 :            :   // ---------------------------------------------------------------------------
    1285                 :            :   {
    1286 [ #  # ][ #  # ]:          0 :     logfile << "Swapping MS and NS ids for " << number << std::endl;
                 [ #  # ]
    1287                 :            :     // get all the material sets in this assembly
    1288                 :            :     moab::Tag mattag, neutag;
    1289         [ #  # ]:          0 :     mb->tag_get_handle( "MATERIAL_SET", 1, MB_TYPE_INTEGER, mattag );
    1290         [ #  # ]:          0 :     mb->tag_get_handle( "NEUMANN_SET", 1, MB_TYPE_INTEGER, neutag );
    1291                 :            : 
    1292                 :          0 :     int rval = 0;
    1293 [ #  # ][ #  # ]:          0 :     moab::Range matsets, neusets;
    1294                 :            : 
    1295         [ #  # ]:          0 :     mb->get_entities_by_type_and_tag( (moab::EntityHandle)orig_set, MBENTITYSET, &mattag, 0, 1, matsets );
    1296         [ #  # ]:          0 :     mb->get_entities_by_type_and_tag( (moab::EntityHandle)orig_set, MBENTITYSET, &neutag, 0, 1, neusets );
    1297                 :            : 
    1298                 :          0 :     int i = 0;
    1299         [ #  # ]:          0 :     moab::Range::iterator set_it;
    1300 [ #  # ][ #  # ]:          0 :     for (set_it = matsets.begin(); set_it != matsets.end(); set_it++)  {
         [ #  # ][ #  # ]
                 [ #  # ]
    1301         [ #  # ]:          0 :         moab::EntityHandle this_set = *set_it;
    1302                 :            : 
    1303                 :            :         // get the id for this set
    1304                 :            :         int set_id;
    1305         [ #  # ]:          0 :         rval = mb->tag_get_data(mattag, &this_set, 1, &set_id);
    1306         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1307         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1308 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1309 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1310                 :          0 :             return 1;
    1311                 :            :           }
    1312                 :            : 
    1313                 :            :         // set the new id for this set
    1314         [ #  # ]:          0 :         int new_id = all_ms_starts[number] + i;
    1315         [ #  # ]:          0 :         rval = mb->tag_set_data(mattag, &this_set, 1, &new_id);
    1316         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1317         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1318 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1319 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1320                 :          0 :             return 1;
    1321                 :            :           }
    1322                 :          0 :         ++i;
    1323                 :            :       }
    1324                 :            : 
    1325                 :          0 :     int j = 0;
    1326 [ #  # ][ #  # ]:          0 :     for (set_it = neusets.begin(); set_it != neusets.end(); set_it++)  {
         [ #  # ][ #  # ]
                 [ #  # ]
    1327         [ #  # ]:          0 :         moab::EntityHandle this_set = *set_it;
    1328                 :            : 
    1329                 :            :         // get the id for this set
    1330                 :            :         int set_id;
    1331         [ #  # ]:          0 :         rval = mb->tag_get_data(neutag, &this_set, 1, &set_id);
    1332         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1333         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1334 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1335 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1336                 :          0 :             return 1;
    1337                 :            :           }
    1338                 :            : 
    1339                 :            :         // set the new id for this set
    1340         [ #  # ]:          0 :         int new_id = all_ns_starts[number] + j;
    1341         [ #  # ]:          0 :         rval = mb->tag_set_data(neutag, &this_set, 1, &new_id);
    1342         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1343         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1344 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1345 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1346                 :          0 :             return 1;
    1347                 :            :           }
    1348                 :          0 :         ++j;
    1349                 :            :       }
    1350                 :          0 :     return 0;
    1351                 :            :   }
    1352                 :            : 
    1353                 :          0 :   int CoreGen::move_verts(iBase_EntitySetHandle set, const double *dx)
    1354                 :            :   // ---------------------------------------------------------------------------
    1355                 :            :   // Function: Change the coordinates for moving the assembly to its first loc.
    1356                 :            :   // Input:    none
    1357                 :            :   // Output:   none
    1358                 :            :   // ---------------------------------------------------------------------------
    1359                 :            :   {
    1360                 :            : 
    1361                 :          0 :     int verts_ents_alloc = 0, verts_ents_size = 0;
    1362                 :          0 :     iBase_EntityHandle *verts_ents = NULL;
    1363                 :            : 
    1364                 :            :     iMesh_getEntities(imesh->instance(), set, iBase_VERTEX, iMesh_ALL_TOPOLOGIES,
    1365 [ #  # ][ #  # ]:          0 :                       &verts_ents, &verts_ents_alloc, &verts_ents_size, &err);
    1366 [ #  # ][ #  # ]:          0 :     ERRORR("Failed to get any entities from original set.", iBase_FAILURE);
                 [ #  # ]
    1367                 :            : 
    1368                 :          0 :     double *coords = 0;
    1369                 :          0 :     int coords_alloc = 0, coords_size = 0;
    1370                 :            : 
    1371                 :            :     iMesh_getVtxArrCoords(imesh->instance(), verts_ents, verts_ents_size, iBase_INTERLEAVED,
    1372 [ #  # ][ #  # ]:          0 :                           &coords, &coords_alloc, &coords_size, &err);
    1373 [ #  # ][ #  # ]:          0 :     ERRORR("Failed to get vtx coords from set.", iBase_FAILURE);
                 [ #  # ]
    1374                 :            : 
    1375         [ #  # ]:          0 :     for (int i = 0; i < verts_ents_size; i++) {
    1376                 :          0 :         coords[3 * i] += dx[0];
    1377                 :          0 :         coords[3 * i + 1] += dx[1];
    1378                 :          0 :         coords[3 * i + 2] += dx[2];
    1379                 :            :       }
    1380                 :            : 
    1381                 :            :     iMesh_setVtxArrCoords(imesh->instance(), verts_ents, verts_ents_size, iBase_INTERLEAVED,
    1382 [ #  # ][ #  # ]:          0 :                           coords, coords_size, &err);
    1383 [ #  # ][ #  # ]:          0 :     ERRORR("Failed to set vtx coords.", iBase_FAILURE);
                 [ #  # ]
    1384                 :            : 
    1385                 :          0 :     return iBase_SUCCESS;
    1386                 :            :   }
    1387                 :            : 
    1388                 :          0 :   int CoreGen::move_geoms(iBase_EntitySetHandle set, const double *dx)
    1389                 :            :   // ---------------------------------------------------------------------------
    1390                 :            :   // Function: Change the coordinates for moving the assembly to its first loc.
    1391                 :            :   // Input:    none
    1392                 :            :   // Output:   none
    1393                 :            :   // ---------------------------------------------------------------------------
    1394                 :            :   {
    1395                 :          0 :     int entities_ehsize = 0, entities_ehallocated = 0;
    1396                 :          0 :     iBase_EntityHandle *entities = NULL;
    1397                 :            : 
    1398                 :            :     iGeom_getEntities(igeom->instance(), set, iBase_ALL_TYPES, &entities, &entities_ehsize,
    1399 [ #  # ][ #  # ]:          0 :                       &entities_ehallocated, &err);
    1400 [ #  # ][ #  # ]:          0 :     ERRORR("Failed to get entities from set.", iBase_FAILURE);
                 [ #  # ]
    1401                 :            : 
    1402         [ #  # ]:          0 :     for (int i = 0; i < entities_ehsize; i++) {
    1403 [ #  # ][ #  # ]:          0 :         iGeom_moveEnt(igeom->instance(), entities[i], dx[0], dx[1], dx[2], &err);
    1404 [ #  # ][ #  # ]:          0 :         ERRORR("Failed to move geometries.", iBase_FAILURE);
                 [ #  # ]
    1405                 :            :       }
    1406                 :          0 :     return iBase_SUCCESS;
    1407                 :            :   }
    1408                 :            : 
    1409                 :          0 :   int CoreGen::extrude() {
    1410                 :            :     // ---------------------------------------------------------------------------
    1411                 :            :     // Function: extrude 2D surface core
    1412                 :            :     // Input:    none
    1413                 :            :     // Output:   none
    1414                 :            :     // ---------------------------------------------------------------------------
    1415                 :            :     // extrude if this is a surface mesh
    1416 [ #  # ][ #  # ]:          0 :     if (set_DIM == 2 && extrude_flag == true) { // if surface geometry and extrude
    1417 [ #  # ][ #  # ]:          0 :         logfile << "Extruding surface mesh." << std::endl;
    1418                 :            :         //get entities for extrusion
    1419                 :          0 :         iBase_EntityHandle *ents = NULL;
    1420                 :          0 :         int ents_alloc = 0, ents_size;
    1421                 :            :         iMesh_getEntities(imesh->instance(), root_set, iBase_FACE, iMesh_ALL_TOPOLOGIES,
    1422 [ #  # ][ #  # ]:          0 :                           &ents, &ents_alloc, &ents_size, &err);
    1423 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting face mesh.", err);
                 [ #  # ]
    1424                 :            : 
    1425                 :            :         // add entities for extrusion to a set
    1426                 :            :         iBase_EntitySetHandle set;
    1427 [ #  # ][ #  # ]:          0 :         iMesh_createEntSet(imesh->instance(), false, &set, &err);
    1428 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting face mesh.", err);
                 [ #  # ]
    1429                 :            : 
    1430 [ #  # ][ #  # ]:          0 :         iMesh_addEntArrToSet(imesh->instance(), ents, ents_size, set, &err);
    1431 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting face mesh.", err);
                 [ #  # ]
    1432                 :            : 
    1433                 :            :         ModelEnt me(mk_core(), iBase_EntitySetHandle(0), /*igeom instance*/0,
    1434 [ #  # ][ #  # ]:          0 :                     (moab::EntityHandle)set);
    1435 [ #  # ][ #  # ]:          0 :         MEntVector selection;
    1436         [ #  # ]:          0 :         selection.push_back(&me);
    1437                 :            : 
    1438                 :            :         // This tag needs to be set to the newly created extrude sets
    1439                 :          0 :         const char *tag_g1 = "GEOM_DIMENSION";
    1440                 :            :         iBase_TagHandle gtag;
    1441 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), tag_g1, &gtag, &err, 14);
    1442 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting geom dimension set.", err);
                 [ #  # ]
    1443                 :            : 
    1444                 :            :         // This tag needs to be set to the newly created extrude sets
    1445                 :          0 :         const char *tag_m1 = "MATERIAL_SET";
    1446                 :            :         iBase_TagHandle mtag;
    1447 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), tag_m1, &mtag, &err, 12);
    1448 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting material set.", err);
                 [ #  # ]
    1449                 :            : 
    1450                 :            :         // This tag needs to be set to the newly created extrude sets
    1451                 :          0 :         const char *tag_n1 = "NEUMANN_SET";
    1452                 :            :         iBase_TagHandle ntag;
    1453 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), tag_n1, &ntag, &err, 11);
    1454 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting neumann set.", err);
                 [ #  # ]
    1455                 :            : 
    1456                 :            : 
    1457                 :          0 :         double v[] = { 0, 0, z_height };
    1458                 :          0 :         int steps = z_divisions;
    1459 [ #  # ][ #  # ]:          0 :         em = (ExtrudeMesh*) mk_core()->construct_meshop("ExtrudeMesh", selection);
                 [ #  # ]
    1460 [ #  # ][ #  # ]:          0 :         em->set_transform(Extrude::Translate(v, steps));
                 [ #  # ]
    1461         [ #  # ]:          0 :         em->copy_faces(true);
    1462                 :            : 
    1463                 :            : 
    1464 [ #  # ][ #  # ]:          0 :         SimpleArray<iBase_EntitySetHandle> msets;
    1465                 :            :         iMesh_getEntSetsByTagsRec(imesh->instance(), root_set, &mtag, NULL, 1, 0,
    1466 [ #  # ][ #  # ]:          0 :                                   ARRAY_INOUT(msets), &err);
         [ #  # ][ #  # ]
                 [ #  # ]
    1467 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1468                 :            : 
    1469 [ #  # ][ #  # ]:          0 :         for (int i = 0; i < msets.size(); i++) {
    1470 [ #  # ][ #  # ]:          0 :             em->extrude_sets().add_set((iMesh::EntitySetHandle)msets[i]);
                 [ #  # ]
    1471                 :            :           }
    1472                 :            : 
    1473                 :            :         // some entity tag types are always copy or expand
    1474 [ #  # ][ #  # ]:          0 :         em->extrude_sets().add_tag("MATERIAL_SET");
                 [ #  # ]
    1475                 :            : 
    1476                 :            :         // run
    1477         [ #  # ]:          0 :         em->setup_this();
    1478         [ #  # ]:          0 :         em->execute_this();
    1479                 :            : 
    1480 [ #  # ][ #  # ]:          0 :         iMesh_destroyEntSet(imesh->instance(), set, &err);
    1481 [ #  # ][ #  # ]:          0 :         ERRORR("Error in destroying ent set of faces after extrusion is done.", err);
                 [ #  # ]
    1482                 :            : 
    1483         [ #  # ]:          0 :         msets.clear();
    1484                 :            :         iMesh_getEntSetsByTagsRec(imesh->instance(), root_set, &mtag, NULL, 1, 0,
    1485 [ #  # ][ #  # ]:          0 :                                   ARRAY_INOUT(msets), &err);
         [ #  # ][ #  # ]
                 [ #  # ]
    1486 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1487                 :            :         // now delete all the 2D material sets:
    1488 [ #  # ][ #  # ]:          0 :         for (int i = 0; i < msets.size(); i++) {
    1489                 :          0 :             int num =0;
    1490 [ #  # ][ #  # ]:          0 :             iMesh_getNumOfType(imesh->instance(), msets[i], iBase_REGION, &num, &err);
                 [ #  # ]
    1491 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting num entities.", err);
                 [ #  # ]
    1492         [ #  # ]:          0 :             if(num == 0){ // material sets with quads
    1493 [ #  # ][ #  # ]:          0 :                 iMesh_destroyEntSet(imesh->instance(), msets[i], &err);
                 [ #  # ]
    1494 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble destroying set.", err);
                 [ #  # ]
    1495                 :            :               }
    1496                 :            :           }
    1497                 :            : 
    1498                 :            : 
    1499                 :            :         // Step 2: get all max. value of neumann sets, then, for newly created NS set a new value and GD =2 tag.
    1500                 :            : 
    1501                 :          0 :         iBase_EntityHandle *ents1 = NULL;
    1502                 :          0 :         int ents_alloc1 = 0, ents_size1 = 0;
    1503                 :            : 
    1504 [ #  # ][ #  # ]:          0 :         SimpleArray<iBase_EntitySetHandle> nsets;
    1505                 :            :         iMesh_getEntSetsByTagsRec(imesh->instance(), root_set, &ntag, NULL,
    1506 [ #  # ][ #  # ]:          0 :                                   1, 0, ARRAY_INOUT(nsets), &err);
         [ #  # ][ #  # ]
                 [ #  # ]
    1507 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1508                 :            : 
    1509                 :          0 :         int max_nset_value = 0;
    1510 [ #  # ][ #  # ]:          0 :         for (int i = 0; i < nsets.size(); i++) {
    1511                 :            :             int nvalue;
    1512 [ #  # ][ #  # ]:          0 :             iMesh_getEntSetIntData(imesh->instance(), nsets[i], ntag, &nvalue, &err);
                 [ #  # ]
    1513 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1514         [ #  # ]:          0 :             if (nvalue > max_nset_value)
    1515                 :          0 :               max_nset_value = nvalue;
    1516                 :            :           }
    1517                 :            : 
    1518 [ #  # ][ #  # ]:          0 :         for (int i = 0; i < nsets.size(); i++) {
                 [ #  # ]
    1519                 :            : 
    1520         [ #  # ]:          0 :             iMesh_getEntities(imesh->instance(), nsets[i],
    1521                 :            :                               iBase_FACE, iMesh_ALL_TOPOLOGIES,
    1522 [ #  # ][ #  # ]:          0 :                               &ents1, &ents_alloc1, &ents_size1, &err);
    1523 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting face mesh.", err);
                 [ #  # ]
    1524                 :            : 
    1525         [ #  # ]:          0 :             if(ents_size1 > 0) {
    1526                 :            :                 // set GEOM_DIMENSION tag = 2 and renumber the neumann set
    1527                 :          0 :                 const int gd = 2;
    1528                 :          0 :                 const int nvalue = max_nset_value + i;
    1529                 :            : 
    1530 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData(imesh->instance(), nsets[i], ntag, nvalue, &err);
                 [ #  # ]
    1531 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1532                 :            : 
    1533 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData(imesh->instance(),nsets[i], gtag, gd, &err);
                 [ #  # ]
    1534 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting entity set.", err);
                 [ #  # ]
    1535                 :            :               }
    1536                 :          0 :             ents_alloc1 = 0;
    1537                 :          0 :             ents_size1 = 0;
    1538                 :          0 :             *ents1 = NULL;
    1539                 :          0 :           }
    1540                 :            :       }
    1541                 :          0 :     return iBase_SUCCESS;
    1542                 :            :   }
    1543                 :            : 
    1544                 :          0 :   int CoreGen::refine_coremodel(){
    1545                 :            : 
    1546                 :            : #ifdef USE_MPI
    1547                 :            :     std::cout<<"REFINEMENT BLOCK"<<std::endl;
    1548                 :            :     /*********************************************/
    1549                 :            :     // refine the mesh
    1550                 :            :     /*********************************************/
    1551                 :            :     int num_levels = deg.size();
    1552                 :            :     moab::NestedRefine uref(dynamic_cast<Core*>(mb), pc, 0);
    1553                 :            :     std::vector<moab::EntityHandle> lsets;
    1554                 :            : 
    1555                 :            :     std::cout<<"Starting hierarchy generation"<<std::endl;
    1556                 :            : 
    1557                 :            :     uref.generate_mesh_hierarchy(num_levels, &deg[0], lsets);
    1558                 :            :     uref.update_special_tags(num_levels, lsets[num_levels]);
    1559                 :            :     std::cout<<"Finished hierarchy generation in "<<uref.timeall.tm_total<<"  secs"<<std::endl;
    1560                 :            : 
    1561                 :            :     std::cout<<"Time taken for refinement "<<uref.timeall.tm_refine<<"  secs"<<std::endl;
    1562                 :            :     std::cout<<"Time taken for resolving shared interface "<<uref.timeall.tm_resolve<<"  secs"<<std::endl;
    1563                 :            : 
    1564                 :            :     moab::Range all_ents, ents[4];
    1565                 :            :     for (int l=0; l<num_levels; l++)
    1566                 :            :       {
    1567                 :            :         all_ents.clear();
    1568                 :            :         ents[0].clear(); ents[1].clear(); ents[2].clear(); ents[3].clear();
    1569                 :            :         mb->get_entities_by_handle(lsets[l+1], all_ents); //MB_CHK_ERR(error);
    1570                 :            : 
    1571                 :            :         for (int k=0; k<4; k++)
    1572                 :            :           ents[k] = all_ents.subset_by_dimension(k);
    1573                 :            : 
    1574                 :            :         std::cout<<"Mesh size for level "<<l+1<<"  :: nverts = "<<ents[0].size()<<", nedges = "<<ents[1].size()<<", nfaces = "<<ents[2].size()<<", ncells = "<<ents[3].size()<<std::endl;
    1575                 :            :       }
    1576                 :            : #endif
    1577                 :          0 :     return 0;
    1578                 :            :   }
    1579                 :            : 
    1580                 :          0 :   int CoreGen::create_neumannset() {
    1581                 :            :     // ---------------------------------------------------------------------------
    1582                 :            :     // Function: create Neumann set on the whole core
    1583                 :            :     // Input:    none
    1584                 :            :     // Output:   none
    1585                 :            :     // ---------------------------------------------------------------------------
    1586 [ #  # ][ #  # ]:          0 :     if (nss_flag == true || nsb_flag == true || nst_flag == true || nssall_flag == true) {
         [ #  # ][ #  # ]
    1587 [ #  # ][ #  # ]:          0 :         logfile << "Creating NeumannSet." << std::endl;
    1588                 :            : 
    1589         [ #  # ]:          0 :         if (extrude_flag == true)
    1590                 :          0 :           set_DIM = 3;
    1591                 :            : 
    1592                 :          0 :         int err = 0, z_flag = 0, i, ents_alloc = 0, ents_size;
    1593                 :          0 :         double z1 = 0.0;
    1594                 :            :         iBase_TagHandle ntag1, gtag1, nametag1;
    1595                 :          0 :         iBase_EntityHandle *ents = NULL;
    1596                 :          0 :         iBase_EntitySetHandle set = NULL, set_z1 = NULL, set_z2 = NULL;
    1597         [ #  # ]:          0 :         std::vector<iBase_EntitySetHandle> set_side;
    1598                 :            : 
    1599                 :            :         //get entities for skinner
    1600         [ #  # ]:          0 :         if(set_DIM ==2) { // if surface geometry specified
    1601                 :            :             iMesh_getEntities(imesh->instance(), root_set,
    1602                 :            :                               iBase_FACE, iMesh_ALL_TOPOLOGIES,
    1603 [ #  # ][ #  # ]:          0 :                               &ents, &ents_alloc, &ents_size, &err);
    1604                 :            :           }
    1605                 :            :         else {
    1606                 :            :             iMesh_getEntities(imesh->instance(), root_set,
    1607                 :            :                               iBase_REGION, iMesh_ALL_TOPOLOGIES,
    1608 [ #  # ][ #  # ]:          0 :                               &ents, &ents_alloc, &ents_size, &err);
    1609                 :            :           }
    1610 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting entities for specifying neumannsets via skinner.", err);
                 [ #  # ]
    1611                 :            : 
    1612                 :            :         // assign a name to the tag
    1613                 :          0 :         const char *ch_name1 = "NAME";
    1614                 :            :         // get tag handle
    1615                 :          0 :         const char *tag_neumann1 = "NEUMANN_SET";
    1616                 :          0 :         const char *global_id1 = "GLOBAL_ID";
    1617                 :            : 
    1618 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), tag_neumann1, &ntag1, &err, 12);
    1619 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1620                 :            : 
    1621 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), global_id1, &gtag1, &err, 9);
    1622 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1623                 :            : 
    1624 [ #  # ][ #  # ]:          0 :         iMesh_getTagHandle(imesh->instance(), ch_name1, &nametag1, &err, 4);
    1625 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1626                 :            : 
    1627 [ #  # ][ #  # ]:          0 :         iMesh_createEntSet(imesh->instance(),0, &set, &err); // for all other sides
    1628 [ #  # ][ #  # ]:          0 :         ERRORR("Trouble creating set handle.", err);
                 [ #  # ]
    1629                 :            : 
    1630         [ #  # ]:          0 :         if (set_DIM == 3) { // sets for collecting top and bottom surface
    1631 [ #  # ][ #  # ]:          0 :             iMesh_createEntSet(imesh->instance(),0, &set_z1, &err);
    1632 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble creating set handle.", err);
                 [ #  # ]
    1633                 :            : 
    1634 [ #  # ][ #  # ]:          0 :             iMesh_createEntSet(imesh->instance(),0, &set_z2, &err);
    1635 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble creating set handle.", err);
                 [ #  # ]
    1636                 :            : 
    1637         [ #  # ]:          0 :             set_side.resize(num_nsside);
    1638         [ #  # ]:          0 :             for(int i=0; i<num_nsside; i++){
    1639 [ #  # ][ #  # ]:          0 :                 iMesh_createEntSet(imesh->instance(),0, &set_side[i], &err);
                 [ #  # ]
    1640 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble creating set handle.", err);
                 [ #  # ]
    1641                 :            :               }
    1642                 :            :           }
    1643                 :            : 
    1644 [ #  # ][ #  # ]:          0 :         moab::Range tmp_elems;
    1645         [ #  # ]:          0 :         tmp_elems.insert((EntityHandle*)ents, (moab::EntityHandle*)ents + ents_size);
    1646                 :            : 
    1647                 :            :         // get the skin of the entities
    1648 [ #  # ][ #  # ]:          0 :         moab::Skinner skinner(mb);
    1649 [ #  # ][ #  # ]:          0 :         moab::Range skin_range;
    1650                 :            :         moab::ErrorCode result;
    1651         [ #  # ]:          0 :         moab::Range::iterator rit;
    1652                 :            : 
    1653         [ #  # ]:          0 :         result = skinner.find_skin(0, tmp_elems, set_DIM-1, skin_range);
    1654         [ #  # ]:          0 :         if (MB_SUCCESS != result) return result;
    1655                 :            : 
    1656 [ #  # ][ #  # ]:          0 :         for (rit = skin_range.begin(), i = 0; rit != skin_range.end(); rit++, i++) {
         [ #  # ][ #  # ]
                 [ #  # ]
    1657         [ #  # ]:          0 :             if(set_DIM == 3) { // filter top and bottom
    1658                 :          0 :                 int num_vertex=0, size_vertex =0;
    1659                 :          0 :                 iBase_EntityHandle *vertex = NULL;
    1660         [ #  # ]:          0 :                 iMesh_getEntAdj(imesh->instance(), (iBase_EntityHandle)(*rit), iBase_VERTEX, &vertex,
    1661 [ #  # ][ #  # ]:          0 :                                 &num_vertex, &size_vertex, &err);
    1662 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1663                 :            : 
    1664                 :          0 :                 double *coords = NULL;
    1665                 :          0 :                 int coords_alloc = 0, coords_size=0;
    1666                 :            :                 iMesh_getVtxArrCoords(imesh->instance(), vertex, size_vertex, iBase_INTERLEAVED,
    1667 [ #  # ][ #  # ]:          0 :                                       &coords, &coords_alloc, &coords_size, &err);
    1668 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1669                 :          0 :                 double ztemp = coords[2];
    1670                 :          0 :                 int flag = 0;
    1671         [ #  # ]:          0 :                 for (int p=1; p<num_vertex; p++) {
    1672                 :          0 :                     double z1 = coords[3*p+2];
    1673         [ #  # ]:          0 :                     if( fabs(ztemp-z1) >= merge_tol) {
    1674                 :          0 :                         flag = 1;
    1675                 :          0 :                         continue;
    1676                 :            :                       }
    1677                 :            :                   }
    1678         [ #  # ]:          0 :                 if(flag == 0) { // this is top or bottom surface
    1679         [ #  # ]:          0 :                     if (z_flag == 0) { // store z-coord this is the first call
    1680                 :          0 :                         z_flag = 1;
    1681                 :          0 :                         z1 = ztemp;
    1682                 :            :                       }
    1683         [ #  # ]:          0 :                     if( fabs(ztemp-z1) <= merge_tol) {
    1684 [ #  # ][ #  # ]:          0 :                         iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), set_z1, &err);
                 [ #  # ]
    1685 [ #  # ][ #  # ]:          0 :                         ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1686                 :            :                       }
    1687                 :            :                     else {
    1688 [ #  # ][ #  # ]:          0 :                         iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), set_z2, &err);
                 [ #  # ]
    1689 [ #  # ][ #  # ]:          0 :                         ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1690                 :            :                       }
    1691                 :            :                   }
    1692         [ #  # ]:          0 :                 else if (flag == 1) { // add the faces that are not top or bottom surface
    1693                 :            :                     // filter the sidesets based on their x and y coords
    1694                 :            : 
    1695         [ #  # ]:          0 :                     for(int k=0; k<num_nsside; k++){
    1696 [ #  # ][ #  # ]:          0 :                         if ( fabs((coords[0])*nsx[k] + (coords[1])*nsy[k] + nsc[k]) <= merge_tol
         [ #  # ][ #  # ]
    1697 [ #  # ][ #  # ]:          0 :                              && fabs((coords[3])*nsx[k] + (coords[4])*nsy[k] + nsc[k]) <= merge_tol
         [ #  # ][ #  # ]
    1698 [ #  # ][ #  # ]:          0 :                              && fabs((coords[6])*nsx[k] + (coords[7])*nsy[k] + nsc[k]) <= merge_tol) {
         [ #  # ][ #  # ]
                 [ #  # ]
    1699 [ #  # ][ #  # ]:          0 :                             iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), (iBase_EntitySetHandle) set_side[k], &err);
         [ #  # ][ #  # ]
    1700 [ #  # ][ #  # ]:          0 :                             ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1701                 :          0 :                             continue;
    1702                 :            :                           }
    1703                 :            :                         else{ // outside the specified
    1704 [ #  # ][ #  # ]:          0 :                             iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), set, &err);
                 [ #  # ]
    1705 [ #  # ][ #  # ]:          0 :                             ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1706                 :          0 :                             continue;
    1707                 :            :                           }
    1708                 :            :                       }
    1709         [ #  # ]:          0 :                     if(num_nsside == 0){
    1710 [ #  # ][ #  # ]:          0 :                         iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), set, &err);
                 [ #  # ]
    1711 [ #  # ][ #  # ]:          0 :                         ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1712                 :            :                       }
    1713                 :            : 
    1714                 :            :                   }
    1715                 :            :               }
    1716         [ #  # ]:          0 :             else if(set_DIM == 2) { // edges add all for sideset
    1717 [ #  # ][ #  # ]:          0 :                 iMesh_addEntToSet(imesh->instance(), (iBase_EntityHandle)(*rit), set, &err);
                 [ #  # ]
    1718 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting number of entities after merge.", err);
                 [ #  # ]
    1719                 :            :               }
    1720                 :            :           }
    1721                 :            : 
    1722         [ #  # ]:          0 :         if (set_DIM == 3) {
    1723 [ #  # ][ #  # ]:          0 :             if (nst_flag == true || nsb_flag == true) {
    1724                 :            : 
    1725 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData( imesh->instance(), set_z1, ntag1, nst_Id, &err);
    1726 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1727                 :            : 
    1728 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData( imesh->instance(), set_z1, gtag1, nst_Id, &err);
    1729 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1730                 :            : 
    1731         [ #  # ]:          0 :                 std::string name1 = "core_top_ss";
    1732 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetData( imesh->instance(), set_z1, nametag1, name1.c_str(), 11, &err);
    1733 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1734                 :            : 
    1735 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData( imesh->instance(), set_z2, ntag1, nsb_Id, &err);
    1736 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1737                 :            : 
    1738 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetIntData( imesh->instance(), set_z2, gtag1, nsb_Id, &err);
    1739 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1740                 :            : 
    1741 [ #  # ][ #  # ]:          0 :                 std::string name2 = "core_bottom_ss";
    1742 [ #  # ][ #  # ]:          0 :                 iMesh_setEntSetData( imesh->instance(), set_z2, nametag1, name2.c_str(), 14, &err);
    1743 [ #  # ][ #  # ]:          0 :                 ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1744                 :            : 
    1745 [ #  # ][ #  # ]:          0 :                 for(int j=0; j<num_nsside; j++){
    1746 [ #  # ][ #  # ]:          0 :                     iMesh_setEntSetIntData( imesh->instance(), set_side[j], ntag1, nss_Id[j], &err);
         [ #  # ][ #  # ]
    1747 [ #  # ][ #  # ]:          0 :                     ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1748                 :            : 
    1749 [ #  # ][ #  # ]:          0 :                     iMesh_setEntSetIntData( imesh->instance(), set_side[j], gtag1, nss_Id[j], &err);
         [ #  # ][ #  # ]
    1750 [ #  # ][ #  # ]:          0 :                     ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1751                 :            : 
    1752 [ #  # ][ #  # ]:          0 :                     std::stringstream ss;
    1753         [ #  # ]:          0 :                     ss << j;
    1754 [ #  # ][ #  # ]:          0 :                     std::string name3 = "side" + ss.str();
                 [ #  # ]
    1755 [ #  # ][ #  # ]:          0 :                     iMesh_setEntSetData( imesh->instance(), set_side[j], nametag1, name3.c_str(), 8, &err);
                 [ #  # ]
    1756 [ #  # ][ #  # ]:          0 :                     ERRORR("Trouble getting handle.", err);
         [ #  # ][ #  # ]
    1757                 :          0 :                   }
    1758                 :            :               }
    1759                 :            :           }
    1760                 :            :         // same for both 2D and 3D models
    1761         [ #  # ]:          0 :         if (nssall_flag == true) {
    1762 [ #  # ][ #  # ]:          0 :             iMesh_setEntSetIntData( imesh->instance(), set, ntag1, nssall_Id, &err);
    1763 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting handle.", err);
         [ #  # ][ #  # ]
    1764                 :            : 
    1765 [ #  # ][ #  # ]:          0 :             iMesh_setEntSetIntData( imesh->instance(), set, gtag1, nssall_Id, &err);
    1766 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting handle.", err);
                 [ #  # ]
    1767                 :            : 
    1768         [ #  # ]:          0 :             std::string name = "all_sides";
    1769 [ #  # ][ #  # ]:          0 :             iMesh_setEntSetData( imesh->instance(), set, nametag1, name.c_str(), 9, &err);
    1770 [ #  # ][ #  # ]:          0 :             ERRORR("Trouble getting handle.", err);
         [ #  # ][ #  # ]
    1771                 :          0 :           }
    1772                 :            :       }
    1773                 :          0 :     return iBase_SUCCESS;
    1774                 :            :   }
    1775                 :            : 
    1776                 :          0 :   void CoreGen::IOErrorHandler (ErrorStates ECode) const
    1777                 :            :   // ---------------------------------------------------------------------------
    1778                 :            :   // Function: displays error messages related to input file parsing data
    1779                 :            :   // Input:    error code
    1780                 :            :   // Output:   none
    1781                 :            :   // ---------------------------------------------------------------------------
    1782                 :            :   {
    1783                 :          0 :     std::cerr << '\n';
    1784         [ #  # ]:          0 :     if (ECode == INVALIDINPUT) // invalid input
    1785                 :          0 :       std::cerr << "Invalid input.";
    1786         [ #  # ]:          0 :     else if (ECode == ENEGATIVE) // invalid input
    1787                 :          0 :       std::cerr << "Unexpected negative value.";
    1788                 :            :     else
    1789                 :          0 :       std::cerr << "Unknown error ...?";
    1790                 :            : 
    1791                 :          0 :     std::cerr << '\n' << "Error reading input file, line : " << linenumber;
    1792                 :          0 :     std::cerr << std::endl;
    1793                 :          0 :     exit (1);
    1794                 :            :   }
    1795                 :            : 
    1796                 :          0 :   int CoreGen::write_minfofile()
    1797                 :            :   // ---------------------------------------------------------------------------
    1798                 :            :   // Function: write the spreadsheet mesh info file based on inputs read from mesh & input file
    1799                 :            :   // Input:    none
    1800                 :            :   // Output:   none
    1801                 :            :   // ---------------------------------------------------------------------------
    1802                 :            :   {
    1803 [ #  # ][ #  # ]:          0 :     logfile << "Writing mesh info file indicating elements and pin number" << std::endl;
    1804                 :            : 
    1805                 :            :     moab::Tag ntag;
    1806         [ #  # ]:          0 :     mb->tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, ntag);
    1807                 :            :     moab::Tag mattag;
    1808         [ #  # ]:          0 :     mb->tag_get_handle( "MATERIAL_SET", 1, MB_TYPE_INTEGER, mattag );
    1809                 :          0 :     int rval = 0;
    1810         [ #  # ]:          0 :     moab::Range matsets;
    1811         [ #  # ]:          0 :     std::vector <EntityHandle> set_ents;
    1812                 :            : 
    1813         [ #  # ]:          0 :     mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &mattag, 0, 1, matsets );
    1814                 :            : 
    1815         [ #  # ]:          0 :     moab::Range::iterator set_it;
    1816 [ #  # ][ #  # ]:          0 :     for (set_it = matsets.begin(); set_it != matsets.end(); set_it++)  {
         [ #  # ][ #  # ]
                 [ #  # ]
    1817         [ #  # ]:          0 :         moab::EntityHandle this_set = *set_it;
    1818                 :            : 
    1819                 :            :         // get the id for this set
    1820                 :            :         int set_id;
    1821         [ #  # ]:          0 :         rval = mb->tag_get_data(mattag, &this_set, 1, &set_id);
    1822         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1823         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1824 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1825 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1826                 :          0 :             return 1;
    1827                 :            :           }
    1828                 :            :         char name[NAME_TAG_SIZE];
    1829         [ #  # ]:          0 :         rval = mb->tag_get_data(ntag, &this_set, 1, &name);
    1830         [ #  # ]:          0 :         if(rval != moab::MB_SUCCESS) {
    1831         [ #  # ]:          0 :             std::cerr<<"getting tag data failed Code:";
    1832 [ #  # ][ #  # ]:          0 :             std::string foo = ""; mb->get_last_error(foo);
    1833 [ #  # ][ #  # ]:          0 :             std::cerr<<"File Error: "<<foo<<std::endl;
                 [ #  # ]
    1834                 :          0 :             return 1;
    1835                 :            :           }
    1836                 :            :         // check for the special block _xp created in AssyGen stage
    1837                 :            :         // now print out elements for each pin on the mesh info file
    1838 [ #  # ][ #  # ]:          0 :         if(name[0]=='_' && name[1]=='x' && name[2] == 'p'){
                 [ #  # ]
    1839                 :            : 
    1840                 :            :             // get the entities in the set, recursively
    1841         [ #  # ]:          0 :             rval = mb->get_entities_by_dimension(this_set, 3, set_ents, true);
    1842                 :            : 
    1843 [ #  # ][ #  # ]:          0 :             logfile << "Block: " << set_id << " has "
                 [ #  # ]
    1844 [ #  # ][ #  # ]:          0 :                     << set_ents.size() << " entities. Name = " << name;
                 [ #  # ]
    1845                 :            : 
    1846                 :            :             // loop thro' all the elements in all the sets
    1847         [ #  # ]:          0 :             for (int i=0;i<int(set_ents.size());i++){
    1848                 :            : 
    1849         [ #  # ]:          0 :                 std::vector<EntityHandle> conn;
    1850         [ #  # ]:          0 :                 EntityHandle handle = set_ents[i];
    1851                 :            : 
    1852                 :            :                 // get the connectivity of this element
    1853         [ #  # ]:          0 :                 rval = mb->get_connectivity(&handle, 1, conn);
    1854                 :            :                 double coords[3];
    1855                 :          0 :                 double x_sum = 0.0, y_sum = 0.0, z_sum = 0.0;
    1856         [ #  # ]:          0 :                 for (int j = 0; j<int(conn.size()); ++j){
    1857 [ #  # ][ #  # ]:          0 :                     rval = mb->get_coords(&conn[j], 1, coords);
    1858                 :          0 :                     x_sum+=coords[0];
    1859                 :          0 :                     y_sum+=coords[1];
    1860                 :          0 :                     z_sum+=coords[2];
    1861                 :            :                   }
    1862                 :          0 :                 int p = 3;
    1863         [ #  # ]:          0 :                 while(name[p]!='\0'){
    1864         [ #  # ]:          0 :                     minfo_file << name[p];
    1865                 :          0 :                     ++p;
    1866                 :            :                   }
    1867 [ #  # ][ #  # ]:          0 :                 minfo_file << " \t" << x_sum/conn.size() << " \t" << y_sum/conn.size() << " \t" <<  z_sum/conn.size() <<  std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1868                 :          0 :               }
    1869 [ #  # ][ #  # ]:          0 :             logfile << ". Deleting block " << set_id << std::endl;
                 [ #  # ]
    1870         [ #  # ]:          0 :             mb->delete_entities(&this_set, 1);
    1871                 :          0 :             set_ents.clear();
    1872                 :            :           }
    1873                 :            : 
    1874                 :            :       }
    1875                 :          0 :     return 0;
    1876                 :            :   }
    1877                 :            : 
    1878                 :            : 
    1879                 :          0 :   int CoreGen::prepareIO(int argc, char *argv[], int nrank, int nprocs, std::string  TestDir)
    1880                 :            :   // -----------------------------------------------------------------------------------
    1881                 :            :   // Function: Obtains file names and opens input/output files and then read/write them
    1882                 :            :   // Input:    command line arguments
    1883                 :            :   // Output:   none
    1884                 :            :   // -----------------------------------------------------------------------------------
    1885                 :            :   {
    1886                 :            :     // set rank and total number of processors
    1887                 :          0 :     rank = nrank;
    1888                 :          0 :     procs = nprocs;
    1889                 :          0 :     sTime = clock();
    1890                 :          0 :     testdir = TestDir;
    1891         [ #  # ]:          0 :     if (argc > 1) {
    1892 [ #  # ][ #  # ]:          0 :         if (argv[1][0] == '-' && argv[1][1] == 'm') {
    1893                 :            :             // set to zero, when run_flag = 1, program runs and does copy, move, merge, extrude, assign gids, save and close
    1894                 :          0 :             run_flag = 0;
    1895                 :            :           }
    1896                 :            :       }
    1897                 :            : 
    1898                 :          0 :     bool bDone = false;
    1899         [ #  # ]:          0 :     do {
    1900         [ #  # ]:          0 :         if (2 == argc) {
    1901 [ #  # ][ #  # ]:          0 :             if (argv[1][0] == '-' && nrank == 0) {
    1902         [ #  # ]:          0 :                 if (argv[1][1] == 'h') {
    1903                 :          0 :                     logfile << "Usage: coregen [-t -m -h] <coregen input file>"
    1904                 :          0 :                             << std::endl;
    1905                 :          0 :                     logfile << "        -t print timing and memory usage info in each step"
    1906                 :          0 :                             << std::endl;
    1907                 :          0 :                     logfile << "        -m create makefile only" << std::endl;
    1908                 :          0 :                     logfile << "        -h print help" << std::endl;
    1909                 :          0 :                     logfile << "\nInstruction on writing coregen input file can be found at: "
    1910                 :          0 :                             << std::endl;
    1911                 :          0 :                     logfile << "        http://press3.mcs.anl.gov/sigma/meshkit/rgg/coregen-input-file-keyword-definitions/"
    1912                 :          0 :                             << std::endl;
    1913                 :          0 :                     exit(0);
    1914                 :            :                   }
    1915                 :            :               }
    1916                 :            : 
    1917                 :          0 :             iname = argv[1];
    1918         [ #  # ]:          0 :             ifile = iname + ".inp";
    1919         [ #  # ]:          0 :             outfile = iname + ".h5m";
    1920         [ #  # ]:          0 :             mfile = iname + ".makefile";
    1921         [ #  # ]:          0 :             meshtogeomfile = "meshtogeom." + iname;
    1922         [ #  # ]:          0 :             infofile = iname + "_info.csv";
    1923         [ #  # ]:          0 :             minfofile = iname + "_mesh_info.csv";
    1924         [ #  # ]:          0 :             logfilename = iname + ".log";
    1925         [ #  # ]:          0 :           } else if (3 == argc) {
    1926                 :          0 :             int i = 1;// will loop through arguments, and process them
    1927         [ #  # ]:          0 :             for (i = 1; i < argc - 1; i++) {
    1928         [ #  # ]:          0 :                 if (argv[i][0] == '-') {
    1929   [ #  #  #  # ]:          0 :                     switch (argv[i][1]) {
    1930                 :            :                       case 'm': {
    1931         [ #  # ]:          0 :                           if (nrank == 0) {
    1932                 :          0 :                               logfile << "Creating Make/Info file Only" << std::endl;
    1933                 :            :                             }
    1934                 :            :                           // only makefile creation specified
    1935                 :          0 :                           iname = argv[2];
    1936         [ #  # ]:          0 :                           ifile = iname + ".inp";
    1937         [ #  # ]:          0 :                           outfile = iname + ".h5m";
    1938         [ #  # ]:          0 :                           mfile = iname + ".makefile";
    1939         [ #  # ]:          0 :                           meshtogeomfile = "meshtogeom." + iname;
    1940         [ #  # ]:          0 :                           infofile = iname + "_info.csv";
    1941         [ #  # ]:          0 :                           minfofile = iname + "_mesh_info.csv";
    1942         [ #  # ]:          0 :                           logfilename = iname + ".log";
    1943                 :          0 :                           break;
    1944                 :            :                         }
    1945                 :            :                       case 't': {
    1946                 :          0 :                           mem_tflag = true;
    1947                 :          0 :                           iname = argv[2];
    1948         [ #  # ]:          0 :                           ifile = iname + ".inp";
    1949         [ #  # ]:          0 :                           outfile = iname + ".h5m";
    1950         [ #  # ]:          0 :                           mfile = iname + ".makefile";
    1951         [ #  # ]:          0 :                           meshtogeomfile = "meshtogeom." + iname;
    1952         [ #  # ]:          0 :                           infofile = iname + "_info.csv";
    1953         [ #  # ]:          0 :                           minfofile = iname + "_mesh_info.csv";
    1954         [ #  # ]:          0 :                           logfilename = iname + ".log";
    1955                 :          0 :                           break;
    1956                 :            :                         }
    1957                 :            :                       case 'h': {
    1958         [ #  # ]:          0 :                           if (nrank == 0) {
    1959                 :          0 :                               logfile << "Usage: coregen [-t -m -h] <coregen input file>"
    1960                 :          0 :                                       << std::endl;
    1961                 :          0 :                               logfile << "        -t print timing and memory usage info in each step"
    1962                 :          0 :                                       << std::endl;
    1963                 :          0 :                               logfile << "        -m create makefile only"
    1964                 :          0 :                                       << std::endl;
    1965                 :          0 :                               logfile << "        -h print help" << std::endl;
    1966                 :          0 :                               logfile << "\nInstruction on writing coregen input file can also be found at: "
    1967                 :          0 :                                       << std::endl;
    1968                 :          0 :                               logfile << "        http://press3.mcs.anl.gov/sigma/meshkit/rgg/coregen-input-file-keyword-definitions/"
    1969                 :          0 :                                       << std::endl;
    1970                 :          0 :                               exit(0);
    1971                 :            :                               break;
    1972                 :            :                             }
    1973                 :            :                         }
    1974                 :            :                       }
    1975                 :            :                   }
    1976                 :            :               }
    1977                 :            :           } else { //default case
    1978         [ #  # ]:          0 :             if (nrank == 0) {
    1979 [ #  # ][ #  # ]:          0 :                 logfile << "Usage: " << argv[0]
    1980 [ #  # ][ #  # ]:          0 :                         << " <input file> WITHOUT EXTENSION" << std::endl;
    1981                 :            :               }
    1982 [ #  # ][ #  # ]:          0 :             iname = TestDir + "/" + COREGEN_DEFAULT_TEST_FILE;
                 [ #  # ]
    1983 [ #  # ][ #  # ]:          0 :             ifile = iname + ".inp";
    1984         [ #  # ]:          0 :             std::string temp = CTEST_FILE_NAME;
    1985 [ #  # ][ #  # ]:          0 :             outfile = temp + ".h5m";
    1986 [ #  # ][ #  # ]:          0 :             mfile = temp + ".makefile";
    1987 [ #  # ][ #  # ]:          0 :             meshtogeomfile = "meshtogeom." + temp;
    1988 [ #  # ][ #  # ]:          0 :             infofile = temp + "_info.csv";
    1989 [ #  # ][ #  # ]:          0 :             minfofile = temp + "_mesh_info.csv";
    1990 [ #  # ][ #  # ]:          0 :             logfilename = temp + ".log";
    1991                 :            :           }
    1992                 :            : 
    1993                 :            :         // open the file
    1994                 :          0 :         file_input.open(ifile.c_str(), std::ios::in);
    1995                 :          0 :         logfile.coss.open(logfilename.c_str(), std::ios::out);
    1996                 :            : 
    1997                 :            :         /*********************************************/
    1998                 :            :         // Print banner on logfile and std out
    1999                 :            :         /*********************************************/
    2000         [ #  # ]:          0 :         if (rank == 0) {
    2001                 :          0 :             banner();
    2002                 :          0 :             Timer.GetDateTime(szDateTime);
    2003 [ #  # ][ #  # ]:          0 :             logfile << "\nStarting out at : " << szDateTime << "\n";
                 [ #  # ]
    2004                 :            :           }
    2005                 :            : 
    2006         [ #  # ]:          0 :         if (!file_input) {
    2007         [ #  # ]:          0 :             if (nrank == 0) {
    2008                 :          0 :                 logfile << "Default case input file located here: <MeshKit/data>" << std::endl;
    2009                 :          0 :                 logfile << "Usage: coregen [-t -m -h] <coregen input file>"
    2010                 :          0 :                         << std::endl;
    2011                 :          0 :                 logfile << "        -t print timing and memory usage info in each step"
    2012                 :          0 :                         << std::endl;
    2013                 :          0 :                 logfile << "        -m create makefile only" << std::endl;
    2014                 :          0 :                 logfile << "        -h print help" << std::endl;
    2015                 :          0 :                 logfile << "\nInstruction on writing coregen input file can be found at: "
    2016                 :          0 :                         << std::endl;
    2017                 :          0 :                 logfile << "        http://press3.mcs.anl.gov/sigma/meshkit/rgg/coregen-input-file-keyword-definitions/"
    2018                 :          0 :                         << std::endl;
    2019                 :          0 :                 logfile << "ERROR - Invalid INPUT FILE specified. Hint: input file name must be specified without extension" << std::endl;
    2020                 :            : 
    2021                 :            :               }
    2022                 :          0 :             file_input.clear();
    2023                 :          0 :             exit(1);
    2024                 :            :           } else
    2025                 :          0 :           bDone = true; // file opened successfully
    2026                 :          0 :       } while (!bDone);
    2027                 :            : 
    2028                 :            :     // open Makefile-rgg
    2029         [ #  # ]:          0 :     do {
    2030                 :          0 :         make_file.open(mfile.c_str(), std::ios::out);
    2031         [ #  # ]:          0 :         if (!make_file) {
    2032         [ #  # ]:          0 :             if (nrank == 0) {
    2033                 :          0 :                 logfile << "Unable to open makefile for writing" << std::endl;
    2034                 :            :               }
    2035                 :          0 :             make_file.clear();
    2036                 :            :           } else
    2037                 :          0 :           bDone = true; // file opened successfully
    2038                 :          0 :       } while (!bDone);
    2039                 :            : 
    2040         [ #  # ]:          0 :     if (nrank == 0) {
    2041 [ #  # ][ #  # ]:          0 :         logfile << "\nEntered input file name: " << ifile << std::endl;
                 [ #  # ]
    2042                 :            :       }
    2043                 :            : 
    2044                 :            :     // now call the functions to read and write
    2045                 :          0 :     err = read_inputs_phase1(argc, argv);
    2046         [ #  # ]:          0 :     ERRORR("Failed to read inputs in phase1.", 1);
    2047                 :            : 
    2048                 :          0 :     err = read_inputs_phase2(argc, argv);
    2049         [ #  # ]:          0 :     ERRORR("Failed to read inputs in phase2.", 1);
    2050                 :            : 
    2051                 :            :     // open meshtogeomfile
    2052         [ #  # ]:          0 :     if(compute_meshtogeom){
    2053                 :          0 :         meshtogeom_file.coss.open(meshtogeomfile.c_str(), std::ios::out);
    2054 [ #  # ][ #  # ]:          0 :         logfile << "Created meshtogeom file: " << meshtogeomfile << std::endl;
                 [ #  # ]
    2055                 :            :     }
    2056                 :            :     // open info file
    2057 [ #  # ][ #  # ]:          0 :     if(strcmp(info.c_str(),"on") == 0 && nrank == 0){
                 [ #  # ]
    2058         [ #  # ]:          0 :         do {
    2059                 :          0 :             info_file.open(infofile.c_str(), std::ios::out);
    2060         [ #  # ]:          0 :             if (!info_file) {
    2061         [ #  # ]:          0 :                 if (nrank == 0) {
    2062                 :          0 :                     logfile << "Unable to open makefile for writing" << std::endl;
    2063                 :            :                   }
    2064                 :          0 :                 info_file.clear();
    2065                 :            :               } else
    2066                 :          0 :               bDone = true; // file opened successfully
    2067 [ #  # ][ #  # ]:          0 :             logfile << "Created core info file: " << infofile << std::endl;
                 [ #  # ]
    2068                 :          0 :           } while (!bDone);
    2069                 :            : 
    2070                 :          0 :         info_file << "assm index"  << " \t" << "assm number" << " \t" << "dX" << " \t" << "dY" << " \t" << "dZ"  << " \t" << "rank" << std::endl;
    2071                 :            :       }
    2072                 :            : 
    2073                 :            :     // open mesh info file
    2074 [ #  # ][ #  # ]:          0 :     if(strcmp(minfo.c_str(),"on") == 0 && nrank == 0){
                 [ #  # ]
    2075         [ #  # ]:          0 :         do {
    2076                 :          0 :             minfo_file.open(minfofile.c_str(), std::ios::out);
    2077         [ #  # ]:          0 :             if (!info_file) {
    2078         [ #  # ]:          0 :                 if (nrank == 0) {
    2079                 :          0 :                     logfile << "Unable to open minfofile for writing" << std::endl;
    2080                 :            :                   }
    2081                 :          0 :                 minfo_file.clear();
    2082                 :            :               } else
    2083                 :          0 :               bDone = true; // file opened successfully
    2084 [ #  # ][ #  # ]:          0 :             logfile << "Created mesh details info file: " << minfofile << std::endl;
                 [ #  # ]
    2085                 :          0 :           } while (!bDone);
    2086                 :          0 :         minfo_file << "pin_number"  << " \t" << "x_centroid" << " \t" << "y_centroid" << " \t" << "z_centroid" << std::endl;
    2087                 :            :       }
    2088         [ #  # ]:          0 :     if (nrank == 0) {
    2089                 :          0 :         err = write_makefile();
    2090         [ #  # ]:          0 :         ERRORR("Failed to write a makefile.", 1);
    2091                 :            :       }
    2092                 :          0 :     return 0;
    2093                 :            :   }
    2094                 :            : 
    2095                 :            : 
    2096                 :          0 :   int CoreGen::read_inputs_phase1(int argc, char *argv[]) {
    2097                 :            :     // ---------------------------------------------------------------------------
    2098                 :            :     // Function: Reads the dimension and symmetry of the problem
    2099                 :            :     // Input:    none
    2100                 :            :     // Output:   none
    2101                 :            :     // ---------------------------------------------------------------------------
    2102         [ #  # ]:          0 :     CParser parse;
    2103                 :            :     for (;;) {
    2104         [ #  # ]:          0 :         if (!parse.ReadNextLine(file_input, linenumber, input_string, MAXCHARS,
    2105         [ #  # ]:          0 :                                 comment))
    2106 [ #  # ][ #  # ]:          0 :           ERRORR("Reading input file failed",1);
                 [ #  # ]
    2107                 :            :         //    logfile << input_string << std::endl;
    2108 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 11) == "problemtype") {
                 [ #  # ]
    2109         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2110 [ #  # ][ #  # ]:          0 :             formatString >> card >> prob_type;
    2111         [ #  # ]:          0 :             if(((strcmp (prob_type.c_str(), "geometry") != 0)
    2112 [ #  # ][ #  # ]:          0 :                 && (strcmp (prob_type.c_str(), "mesh") != 0)) || formatString.fail())
         [ #  # ][ #  # ]
    2113         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2114         [ #  # ]:          0 :             if ((strcmp(prob_type.c_str(), "geometry") == 0)) {
    2115         [ #  # ]:          0 :                 prob_type = "geometry";
    2116                 :          0 :               }
    2117                 :            :           }
    2118 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 8) == "geometry" && input_string.substr(0, 12) != "geometrytype") {
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
    2119         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2120 [ #  # ][ #  # ]:          0 :             formatString >> card >> geometry;
    2121         [ #  # ]:          0 :             if(((strcmp (geometry.c_str(), "volume") != 0)
    2122 [ #  # ][ #  # ]:          0 :                 && (strcmp (geometry.c_str(), "surface") != 0)) || formatString.fail())
         [ #  # ][ #  # ]
    2123         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2124         [ #  # ]:          0 :             if ((strcmp(geometry.c_str(), "surface") == 0)) {
    2125                 :          0 :                 set_DIM = 2;
    2126                 :          0 :               }
    2127                 :            :           }
    2128                 :            : 
    2129                 :            :         // igeom->instance() engine
    2130 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 10) == "geomengine") {
                 [ #  # ]
    2131         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2132 [ #  # ][ #  # ]:          0 :             formatString >> card >> geom_engine;
    2133         [ #  # ]:          0 :             if(((strcmp (geom_engine.c_str(), "acis") != 0)
    2134 [ #  # ][ #  # ]:          0 :                 && (strcmp (geom_engine.c_str(), "occ") != 0)) || formatString.fail())
         [ #  # ][ #  # ]
    2135         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2136                 :            :           }
    2137                 :            : 
    2138                 :            :         // symmetry
    2139 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 8) == "symmetry") {
                 [ #  # ]
    2140         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2141 [ #  # ][ #  # ]:          0 :             formatString >> card >> symm;
    2142 [ #  # ][ #  # ]:          0 :             if((symm !=1 && symm !=6 && symm !=12) || formatString.fail())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2143         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2144                 :            :           }
    2145                 :            :         // element type
    2146 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 11) == "elementtype") {
                 [ #  # ]
    2147         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2148 [ #  # ][ #  # ]:          0 :             formatString >> card >> etype;
    2149 [ #  # ][ #  # ]:          0 :             if(etype == "hex27")
    2150                 :          0 :                 have_hex27 = true;
    2151 [ #  # ][ #  # ]:          0 :             else if (etype == "hex8")
    2152                 :          0 :                 have_hex27 = false;
    2153                 :            :             else
    2154         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2155                 :            :           }
    2156                 :            :         // UMR parameters
    2157 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 3) == "umr") {
                 [ #  # ]
    2158                 :          0 :             umr_flag = true;
    2159                 :          0 :             int temp_deg = 0;
    2160         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2161 [ #  # ][ #  # ]:          0 :             formatString >> card >> nDegree;
    2162         [ #  # ]:          0 :             for(int i=1; i<=nDegree;i++){
    2163         [ #  # ]:          0 :                 formatString >> temp_deg;
    2164         [ #  # ]:          0 :                 deg.push_back(temp_deg);
    2165                 :            :               }
    2166 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2167         [ #  # ]:          0 :                 IOErrorHandler (INVALIDINPUT);
    2168                 :            :           }
    2169                 :            :         // merge tolerance
    2170 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 14) == "mergetolerance") {
                 [ #  # ]
    2171         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2172 [ #  # ][ #  # ]:          0 :             formatString >> card >> merge_tol;
    2173 [ #  # ][ #  # ]:          0 :             if(merge_tol < 0 || formatString.fail())
         [ #  # ][ #  # ]
    2174         [ #  # ]:          0 :               IOErrorHandler (ENEGATIVE);
    2175                 :            :           }
    2176                 :            : 
    2177                 :            :         // save onefile for each proc (multiple) flag
    2178 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 12) == "saveparallel") {
                 [ #  # ]
    2179         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2180 [ #  # ][ #  # ]:          0 :             formatString >> card >> savefiles;
    2181 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2182         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2183                 :            :           }
    2184                 :            :         // info flag
    2185 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 4) == "info") {
                 [ #  # ]
    2186         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2187 [ #  # ][ #  # ]:          0 :             formatString >> card >> info;
    2188 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2189         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2190                 :            :           }
    2191                 :            :         // info flag
    2192 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 8) == "meshinfo") {
                 [ #  # ]
    2193         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2194 [ #  # ][ #  # ]:          0 :             formatString >> card >> minfo;
    2195 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2196         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2197                 :            :           }
    2198                 :            :         // neumannset card
    2199 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 10) == "neumannset") {
                 [ #  # ]
    2200         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2201 [ #  # ][ #  # ]:          0 :             std::string nsLoc = "", temp1, temp2, temp3;
         [ #  # ][ #  # ]
    2202                 :            :             double x, y, c;
    2203                 :          0 :             int nsId = 0;
    2204 [ #  # ][ #  # ]:          0 :             formatString >> card >> nsLoc >> nsId;
                 [ #  # ]
    2205 [ #  # ][ #  # ]:          0 :             if(nsId < 0 || formatString.fail())
         [ #  # ][ #  # ]
    2206         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2207         [ #  # ]:          0 :             if ((strcmp(nsLoc.c_str(), "top") == 0)) {
    2208                 :          0 :                 nst_flag = true;
    2209                 :          0 :                 nst_Id = nsId;
    2210         [ #  # ]:          0 :               } else if ((strcmp(nsLoc.c_str(), "bot") == 0)) {
    2211                 :          0 :                 nsb_flag = true;
    2212                 :          0 :                 nsb_Id = nsId;
    2213         [ #  # ]:          0 :               } else if ((strcmp(nsLoc.c_str(), "sideall") == 0)) {
    2214                 :          0 :                 nssall_flag = true;
    2215                 :          0 :                 nssall_Id = nsId;
    2216         [ #  # ]:          0 :               } else if ((strcmp(nsLoc.c_str(), "side") == 0)) {
    2217         [ #  # ]:          0 :                 nss_Id.push_back(nsId);
    2218                 :            :                 // we are reading the equation of a straight line ax + by + c = 0
    2219 [ #  # ][ #  # ]:          0 :                 formatString >> temp1 >> x >> temp2 >> y >> temp3 >> c;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2220 [ #  # ][ #  # ]:          0 :                 if(formatString.fail())
    2221         [ #  # ]:          0 :                   IOErrorHandler (INVALIDINPUT);
    2222         [ #  # ]:          0 :                 nsx.push_back(x);
    2223         [ #  # ]:          0 :                 nsy.push_back(y);
    2224         [ #  # ]:          0 :                 nsc.push_back(c);
    2225                 :            : 
    2226                 :          0 :                 ++num_nsside;
    2227                 :          0 :                 nss_flag = true;
    2228                 :            :               } else {
    2229 [ #  # ][ #  # ]:          0 :                 logfile << "Invalid Neumann set specification" << std::endl;
    2230                 :          0 :               }
    2231                 :            :           }
    2232                 :            : 
    2233                 :            :         // breaking condition
    2234 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 3) == "end") {
                 [ #  # ]
    2235         [ #  # ]:          0 :             std::istringstream formatstring(input_string);
    2236                 :          0 :             break;
    2237                 :            :           }
    2238                 :          0 :       }
    2239                 :          0 :     return iBase_SUCCESS;
    2240                 :            :   }
    2241                 :            : 
    2242                 :          0 :   int CoreGen::read_inputs_phase2(int argc, char *argv[])
    2243                 :            :   // ---------------------------------------------------------------------------
    2244                 :            :   // Function: read all the inputs
    2245                 :            :   // Input:    command line arguments
    2246                 :            :   // Output:   none
    2247                 :            :   // ---------------------------------------------------------------------------
    2248                 :            :   {
    2249                 :            :     //Rewind the input file
    2250         [ #  # ]:          0 :     file_input.clear(std::ios_base::goodbit);
    2251         [ #  # ]:          0 :     file_input.seekg(0L, std::ios::beg);
    2252                 :          0 :     linenumber = 0;
    2253                 :            : 
    2254         [ #  # ]:          0 :     CParser parse;
    2255                 :            :     for (;;) {
    2256         [ #  # ]:          0 :         if (!parse.ReadNextLine(file_input, linenumber, input_string, MAXCHARS,
    2257         [ #  # ]:          0 :                                 comment))
    2258 [ #  # ][ #  # ]:          0 :           ERRORR("Reading input file failed",1);
                 [ #  # ]
    2259                 :            : 
    2260 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 12) == "geometrytype" ) {
                 [ #  # ]
    2261         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2262 [ #  # ][ #  # ]:          0 :             formatString >> card >> geom_type;
    2263 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2264         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2265                 :            : 
    2266 [ #  # ][ #  # ]:          0 :             if(geom_type.substr(0,3) == "hex"){ // for all hex type assemblies read the pitch and mesh files names
                 [ #  # ]
    2267                 :          0 :                 bool reading_assemblies = false;
    2268         [ #  # ]:          0 :                 do{
    2269         [ #  # ]:          0 :                     if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2270         [ #  # ]:          0 :                                             MAXCHARS, comment))
    2271 [ #  # ][ #  # ]:          0 :                       ERRORR("Reading input file failed",1);
                 [ #  # ]
    2272         [ #  # ]:          0 :                     std::istringstream formatString(input_string);
    2273 [ #  # ][ #  # ]:          0 :                     if (input_string.substr(0, 10) == "assemblies"){
                 [ #  # ]
    2274 [ #  # ][ #  # ]:          0 :                         formatString >> card >> nassys >> pitch;
                 [ #  # ]
    2275 [ #  # ][ #  # ]:          0 :                         if(nassys < 0 || formatString.fail())
         [ #  # ][ #  # ]
    2276         [ #  # ]:          0 :                           IOErrorHandler (INVALIDINPUT);
    2277                 :            : 
    2278                 :            :                         // reading file and alias names
    2279 [ #  # ][ #  # ]:          0 :                         if(!parse_assembly_names(parse, argc, argv))
    2280 [ #  # ][ #  # ]:          0 :                           ERRORR("error parsing names of assemblies",1);
                 [ #  # ]
    2281         [ #  # ]:          0 :                         reading_assemblies = true;
    2282                 :          0 :                       }
    2283                 :          0 :                   } while (reading_assemblies == false) ;
    2284                 :            :               }
    2285                 :            :             // read lattice info for all assemblies, also assemblies for rect assemblies.
    2286 [ #  # ][ #  # ]:          0 :             if (geom_type == "hexvertex" && symm == 6) {
         [ #  # ][ #  # ]
    2287                 :            : 
    2288                 :            :                 // reading lattice
    2289                 :          0 :                 bool reading_lattice = false;
    2290         [ #  # ]:          0 :                 do{
    2291         [ #  # ]:          0 :                     if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2292         [ #  # ]:          0 :                                             MAXCHARS, comment))
    2293 [ #  # ][ #  # ]:          0 :                       ERRORR("Reading input file failed",1);
                 [ #  # ]
    2294         [ #  # ]:          0 :                     std::istringstream formatString1(input_string);
    2295 [ #  # ][ #  # ]:          0 :                     if (input_string.substr(0,7) == "lattice"){
                 [ #  # ]
    2296                 :          0 :                         reading_lattice = true;
    2297 [ #  # ][ #  # ]:          0 :                         formatString1 >> card >> nrings;
    2298 [ #  # ][ #  # ]:          0 :                         if(nrings < 0 || formatString1.fail())
         [ #  # ][ #  # ]
    2299         [ #  # ]:          0 :                           IOErrorHandler (INVALIDINPUT);
    2300         [ #  # ]:          0 :                         if (nrings % 2 == 0)
    2301                 :          0 :                           tot_assys = (nrings * (nrings)) / 2;
    2302                 :            :                         else
    2303                 :          0 :                           tot_assys = ((nrings * (nrings - 1)) / 2)
    2304                 :          0 :                               + (nrings + 1) / 2;
    2305                 :          0 :                       }
    2306                 :          0 :                   } while (reading_lattice == false) ;
    2307                 :            : 
    2308                 :            :                 // now reading the arrangement
    2309         [ #  # ]:          0 :                 if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2310         [ #  # ]:          0 :                                         MAXCHARS, comment))
    2311 [ #  # ][ #  # ]:          0 :                   ERRORR("Reading input file failed",1);
                 [ #  # ]
    2312         [ #  # ]:          0 :                 std::istringstream formatString2(input_string);
    2313         [ #  # ]:          0 :                 for (int i = 1; i <= tot_assys; i++) {
    2314         [ #  # ]:          0 :                     formatString2 >> temp_alias;
    2315 [ #  # ][ #  # ]:          0 :                     if(formatString2.fail())
    2316         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
    2317         [ #  # ]:          0 :                     core_alias.push_back(temp_alias);
    2318                 :          0 :                   }
    2319                 :            :               }
    2320                 :            : 
    2321 [ #  # ][ #  # ]:          0 :             else if (geom_type == "rectangular" && symm == 1) {
         [ #  # ][ #  # ]
    2322                 :            : 
    2323                 :          0 :                     bool reading_assemblies = false;
    2324         [ #  # ]:          0 :                     do{
    2325         [ #  # ]:          0 :                         if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2326         [ #  # ]:          0 :                                                 MAXCHARS, comment))
    2327 [ #  # ][ #  # ]:          0 :                           ERRORR("Reading input file failed",1);
                 [ #  # ]
    2328         [ #  # ]:          0 :                         std::istringstream formatString(input_string);
    2329 [ #  # ][ #  # ]:          0 :                         if (input_string.substr(0, 10) == "assemblies"){
                 [ #  # ]
    2330 [ #  # ][ #  # ]:          0 :                             formatString >> card >> nassys >> pitchx >> pitchy;
         [ #  # ][ #  # ]
    2331 [ #  # ][ #  # ]:          0 :                             if(nassys < 0 || pitchx < 0 || pitchy< 0 || formatString.fail())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2332         [ #  # ]:          0 :                               IOErrorHandler (INVALIDINPUT);
    2333                 :            : 
    2334                 :            :                             // reading file and alias names
    2335 [ #  # ][ #  # ]:          0 :                             if(!parse_assembly_names(parse, argc, argv))
    2336 [ #  # ][ #  # ]:          0 :                               ERRORR("error parsing names of assemblies",1);
                 [ #  # ]
    2337         [ #  # ]:          0 :                             reading_assemblies = true;
    2338                 :          0 :                           }
    2339                 :          0 :                       } while (reading_assemblies == false) ;
    2340                 :            : 
    2341                 :            :                     // reading lattice
    2342                 :          0 :                     bool reading_lattice = false;
    2343         [ #  # ]:          0 :                     do{
    2344         [ #  # ]:          0 :                         if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2345         [ #  # ]:          0 :                                                 MAXCHARS, comment))
    2346 [ #  # ][ #  # ]:          0 :                           ERRORR("Reading input file failed",1);
                 [ #  # ]
    2347         [ #  # ]:          0 :                         std::istringstream formatString1(input_string);
    2348 [ #  # ][ #  # ]:          0 :                         if (input_string.substr(0,7) == "lattice"){
                 [ #  # ]
    2349                 :          0 :                             reading_lattice = true;
    2350 [ #  # ][ #  # ]:          0 :                             formatString1 >> card >> nringsx >> nringsy;
                 [ #  # ]
    2351 [ #  # ][ #  # ]:          0 :                             if(nringsx <= 0 || nringsy <= 0 || formatString1.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    2352         [ #  # ]:          0 :                               IOErrorHandler (INVALIDINPUT);
    2353                 :          0 :                             tot_assys = nringsx * nringsy;
    2354                 :          0 :                           }
    2355                 :          0 :                       } while (reading_lattice == false) ;
    2356                 :            : 
    2357                 :            :                 // now reading the arrangement
    2358         [ #  # ]:          0 :                 if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2359         [ #  # ]:          0 :                                         MAXCHARS, comment))
    2360 [ #  # ][ #  # ]:          0 :                   ERRORR("Reading input file failed",1);
                 [ #  # ]
    2361         [ #  # ]:          0 :                 std::istringstream formatString2(input_string);
    2362         [ #  # ]:          0 :                 for (int i = 1; i <= tot_assys; i++) {
    2363         [ #  # ]:          0 :                     formatString2 >> temp_alias;
    2364 [ #  # ][ #  # ]:          0 :                     if(formatString2.fail())
    2365         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
    2366         [ #  # ]:          0 :                     core_alias.push_back(temp_alias);
    2367                 :          0 :                   }
    2368                 :            :               }
    2369                 :            : 
    2370 [ #  # ][ #  # ]:          0 :             else if (geom_type == "hexflat" && symm == 6) {
         [ #  # ][ #  # ]
    2371                 :            : 
    2372                 :            :                 // reading lattice
    2373                 :          0 :                 bool reading_lattice = false;
    2374         [ #  # ]:          0 :                 do{
    2375         [ #  # ]:          0 :                     if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2376         [ #  # ]:          0 :                                             MAXCHARS, comment))
    2377 [ #  # ][ #  # ]:          0 :                       ERRORR("Reading input file failed",1);
                 [ #  # ]
    2378         [ #  # ]:          0 :                     std::istringstream formatString1(input_string);
    2379 [ #  # ][ #  # ]:          0 :                     if (input_string.substr(0,7) == "lattice"){
                 [ #  # ]
    2380                 :          0 :                         reading_lattice = true;
    2381 [ #  # ][ #  # ]:          0 :                         formatString1 >> card >> nrings;
    2382 [ #  # ][ #  # ]:          0 :                         if(nrings < 0 || formatString1.fail())
         [ #  # ][ #  # ]
    2383         [ #  # ]:          0 :                           IOErrorHandler (INVALIDINPUT);
    2384                 :          0 :                         tot_assys = (nrings * (nrings + 1)) / 2;
    2385                 :          0 :                       }
    2386                 :          0 :                   } while (reading_lattice == false) ;
    2387                 :            : 
    2388                 :            : 
    2389                 :            :                 // now reading the arrangement
    2390         [ #  # ]:          0 :                 if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2391         [ #  # ]:          0 :                                         MAXCHARS, comment))
    2392 [ #  # ][ #  # ]:          0 :                   ERRORR("Reading input file failed",1);
                 [ #  # ]
    2393         [ #  # ]:          0 :                 std::istringstream formatString2(input_string);
    2394         [ #  # ]:          0 :                 for (int i = 1; i <= tot_assys; i++) {
    2395         [ #  # ]:          0 :                     formatString2 >> temp_alias;
    2396 [ #  # ][ #  # ]:          0 :                     if(formatString2.fail())
    2397         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
    2398         [ #  # ]:          0 :                     core_alias.push_back(temp_alias);
    2399                 :          0 :                   }
    2400                 :            :               }
    2401                 :            : 
    2402 [ #  # ][ #  # ]:          0 :             else if (geom_type == "hexflat" && symm == 1) {
         [ #  # ][ #  # ]
    2403                 :            :                 // reading lattice
    2404                 :          0 :                 bool reading_lattice = false;
    2405         [ #  # ]:          0 :                 do{
    2406         [ #  # ]:          0 :                     if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2407         [ #  # ]:          0 :                                             MAXCHARS, comment))
    2408 [ #  # ][ #  # ]:          0 :                       ERRORR("Reading input file failed",1);
                 [ #  # ]
    2409         [ #  # ]:          0 :                     std::istringstream formatString1(input_string);
    2410 [ #  # ][ #  # ]:          0 :                     if (input_string.substr(0,7) == "lattice"){
                 [ #  # ]
    2411                 :          0 :                         reading_lattice = true;
    2412 [ #  # ][ #  # ]:          0 :                         formatString1 >> card >> nrings;
    2413 [ #  # ][ #  # ]:          0 :                         if(nrings < 0 || formatString1.fail())
         [ #  # ][ #  # ]
    2414         [ #  # ]:          0 :                           IOErrorHandler (INVALIDINPUT);
    2415                 :          0 :                         tot_assys = 3 * (nrings * (nrings - 1)) + 1;
    2416                 :          0 :                       }
    2417                 :          0 :                   } while (reading_lattice == false) ;
    2418                 :            : 
    2419                 :            :                 // now reading the arrangement
    2420         [ #  # ]:          0 :                 if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2421         [ #  # ]:          0 :                                         MAXCHARS, comment))
    2422 [ #  # ][ #  # ]:          0 :                   ERRORR("Reading input file failed",1);
                 [ #  # ]
    2423         [ #  # ]:          0 :                 std::istringstream formatString2(input_string);
    2424         [ #  # ]:          0 :                 for (int i = 1; i <= tot_assys; i++) {
    2425         [ #  # ]:          0 :                     formatString2 >> temp_alias;
    2426 [ #  # ][ #  # ]:          0 :                     if(formatString2.fail())
    2427         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
    2428         [ #  # ]:          0 :                     core_alias.push_back(temp_alias);
    2429                 :          0 :                   }
    2430                 :            :               }
    2431                 :            : 
    2432 [ #  # ][ #  # ]:          0 :             else if (geom_type == "hexflat" && symm == 12) {
         [ #  # ][ #  # ]
    2433                 :            :                 // reading lattice
    2434                 :          0 :                 bool reading_lattice = false;
    2435         [ #  # ]:          0 :                 do{
    2436         [ #  # ]:          0 :                     if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2437         [ #  # ]:          0 :                                             MAXCHARS, comment))
    2438 [ #  # ][ #  # ]:          0 :                       ERRORR("Reading input file failed",1);
                 [ #  # ]
    2439         [ #  # ]:          0 :                     std::istringstream formatString1(input_string);
    2440 [ #  # ][ #  # ]:          0 :                     if (input_string.substr(0,7) == "lattice"){
                 [ #  # ]
    2441                 :          0 :                         reading_lattice = true;
    2442 [ #  # ][ #  # ]:          0 :                         formatString1 >> card >> nrings;
    2443 [ #  # ][ #  # ]:          0 :                         if(nrings < 0 || formatString.fail())
         [ #  # ][ #  # ]
    2444         [ #  # ]:          0 :                           IOErrorHandler (INVALIDINPUT);
    2445         [ #  # ]:          0 :                         if (nrings % 2 == 0)
    2446                 :          0 :                           tot_assys = (nrings * (nrings + 2)) / 4;
    2447                 :            :                         else
    2448                 :          0 :                           tot_assys = ((nrings + 1) * (nrings + 1)) / 4;
    2449                 :          0 :                       }
    2450                 :          0 :                   } while (reading_lattice == false) ;
    2451                 :            : 
    2452                 :            :                 // now reading the arrangement
    2453         [ #  # ]:          0 :                 if (!parse.ReadNextLine(file_input, linenumber, input_string,
    2454         [ #  # ]:          0 :                                         MAXCHARS, comment))
    2455 [ #  # ][ #  # ]:          0 :                   ERRORR("Reading input file failed",1);
                 [ #  # ]
    2456         [ #  # ]:          0 :                 std::istringstream formatString2(input_string);
    2457         [ #  # ]:          0 :                 for (int i = 1; i <= tot_assys; i++) {
    2458         [ #  # ]:          0 :                     formatString2 >> temp_alias;
    2459 [ #  # ][ #  # ]:          0 :                     if(formatString2.fail())
    2460         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
    2461         [ #  # ]:          0 :                     core_alias.push_back(temp_alias);
    2462                 :          0 :                   }
    2463                 :            :               }
    2464                 :            : 
    2465                 :            :             else {
    2466 [ #  # ][ #  # ]:          0 :                 ERRORR("Invalid geometry type",1);
         [ #  # ][ #  # ]
    2467                 :          0 :               }
    2468                 :            :           }
    2469                 :            :         // background mesh
    2470 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 10) == "background") {
                 [ #  # ]
    2471         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2472 [ #  # ][ #  # ]:          0 :             formatString >> card >> back_meshfile;
    2473 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2474         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2475                 :            : 
    2476         [ #  # ]:          0 :             all_meshfiles.push_back(back_meshfile);
    2477                 :            : 
    2478 [ #  # ][ #  # ]:          0 :             if (iname == COREGEN_DEFAULT_TEST_FILE){
    2479 [ #  # ][ #  # ]:          0 :                 back_meshfile = testdir + back_meshfile;
    2480                 :            :               }
    2481         [ #  # ]:          0 :             files.push_back(back_meshfile);
    2482                 :          0 :             back_mesh = true;
    2483                 :            :           }
    2484                 :            :         // z-height and z-divisions
    2485 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 7) == "extrude") {
                 [ #  # ]
    2486                 :          0 :             extrude_flag = true;
    2487         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2488 [ #  # ][ #  # ]:          0 :             formatString >> card >> z_height >> z_divisions;
                 [ #  # ]
    2489 [ #  # ][ #  # ]:          0 :             if(z_divisions < 0 || formatString.fail())
         [ #  # ][ #  # ]
    2490         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2491                 :            :           }
    2492                 :            :         // if keyword MESHTOGEOM is specified set tags on material sets and write a meshtogeom.txt file with #material id and #meshtogeom ratio
    2493 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 10) == "meshtogeom") {
                 [ #  # ]
    2494                 :          0 :             compute_meshtogeom = true;
    2495                 :            :           }
    2496                 :            :         // OutputFileName
    2497 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 14) == "outputfilename") {
                 [ #  # ]
    2498         [ #  # ]:          0 :             std::istringstream formatString(input_string);
    2499 [ #  # ][ #  # ]:          0 :             formatString >> card >> outfile;
    2500 [ #  # ][ #  # ]:          0 :             if(formatString.fail())
    2501         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2502                 :            :           }
    2503                 :            : 
    2504                 :            :         // breaking condition
    2505 [ #  # ][ #  # ]:          0 :         if (input_string.substr(0, 3) == "end") {
                 [ #  # ]
    2506         [ #  # ]:          0 :             std::istringstream formatstring(input_string);
    2507                 :          0 :             break;
    2508                 :            :           }
    2509                 :          0 :       }
    2510                 :            :     // set some variables
    2511         [ #  # ]:          0 :     assm_meshfiles.resize(nassys);
    2512         [ #  # ]:          0 :     load_per_assm.resize(nassys);
    2513         [ #  # ]:          0 :     size_mf.resize(nassys);
    2514         [ #  # ]:          0 :     times_loaded.resize(nassys);
    2515         [ #  # ]:          0 :     assm_location.resize(nassys);
    2516         [ #  # ]:          0 :     bsameas.resize(nassys);
    2517                 :            : 
    2518         [ #  # ]:          0 :     for(int i = 0; i < tot_assys; i++){
    2519         [ #  # ]:          0 :         for (int j = 0; j < nassys; j++){
    2520 [ #  # ][ #  # ]:          0 :             if (strcmp(core_alias[i].c_str(), assm_alias[j].c_str()) == 0) {
                 [ #  # ]
    2521         [ #  # ]:          0 :                 assm_meshfiles[j]+=1;
    2522 [ #  # ][ #  # ]:          0 :                 assm_location[j].push_back(i);
    2523                 :          0 :                 break;
    2524                 :            :               }
    2525                 :            :           }
    2526                 :            :       }
    2527                 :          0 :     return iBase_SUCCESS;
    2528                 :            :   }
    2529                 :            : 
    2530                 :          0 :   int CoreGen::parse_assembly_names(CParser parse, int argc, char *argv[] )
    2531                 :            :   // ---------------------------------------------------------------------------
    2532                 :            :   // Function: Reads all the assemblies from CoreGen input file
    2533                 :            :   // Input:    none
    2534                 :            :   // Output:   none
    2535                 :            :   // ---------------------------------------------------------------------------
    2536                 :            :   {
    2537                 :            : 
    2538                 :            :     // reading file and alias names
    2539         [ #  # ]:          0 :     for (int i = 1; i <= nassys; i++) {
    2540         [ #  # ]:          0 :         if (!parse.ReadNextLine(file_input, linenumber,
    2541         [ #  # ]:          0 :                                 input_string, MAXCHARS, comment, false))
    2542 [ #  # ][ #  # ]:          0 :           ERRORR("Reading input file failed",1);
                 [ #  # ]
    2543         [ #  # ]:          0 :         std::istringstream formatString(input_string);
    2544 [ #  # ][ #  # ]:          0 :         formatString >> meshfile >> mf_alias >> same_as >> reloading_mf >> ms_startid >> ns_startid;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2545                 :            :         // we don't check for formatting since same_as and parameters after it may not be present.
    2546                 :            :         // variable gets populated correctly in the file
    2547                 :            : 
    2548                 :            :         // if meshfile variable is a path then only convert the filename to lower case
    2549                 :          0 :         unsigned pos = 0;
    2550         [ #  # ]:          0 :         pos = meshfile.find_last_of("/\\");
    2551 [ #  # ][ #  # ]:          0 :         if (pos > 0 && pos < meshfile.length()){
                 [ #  # ]
    2552 [ #  # ][ #  # ]:          0 :             std::string filename = "", path="";
    2553 [ #  # ][ #  # ]:          0 :             path = meshfile.substr(0,pos);
    2554 [ #  # ][ #  # ]:          0 :             filename = meshfile.substr(pos+1);
    2555         [ #  # ]:          0 :             std::transform(filename.begin(), filename.end(), filename.begin(), ::tolower);
    2556 [ #  # ][ #  # ]:          0 :             meshfile = path+"/"+ filename;
                 [ #  # ]
    2557                 :            :           }
    2558                 :            :         else{
    2559         [ #  # ]:          0 :             std::transform(meshfile.begin(), meshfile.end(), meshfile.begin(), ::tolower);
    2560                 :            :           }
    2561                 :            :         // also convert the alias and reloading_mf name to lower case, since we've changed the actual reading.
    2562         [ #  # ]:          0 :         std::transform(mf_alias.begin(), mf_alias.end(), mf_alias.begin(), ::tolower);
    2563         [ #  # ]:          0 :         std::transform(reloading_mf.begin(), reloading_mf.end(), reloading_mf.begin(), ::tolower);
    2564                 :            : 
    2565 [ #  # ][ #  # ]:          0 :         if (same_as == "same_as")
    2566         [ #  # ]:          0 :           bsameas.push_back(0);
    2567                 :            :         else
    2568         [ #  # ]:          0 :           bsameas.push_back(1);
    2569 [ #  # ][ #  # ]:          0 :         if(bsameas[i-1] == 1){
    2570         [ #  # ]:          0 :             all_meshfiles.push_back(meshfile);
    2571         [ #  # ]:          0 :             if (argc == 1){
    2572 [ #  # ][ #  # ]:          0 :                 meshfile = testdir + "/" + meshfile;
                 [ #  # ]
    2573                 :            :               }
    2574         [ #  # ]:          0 :             files.push_back(meshfile);
    2575         [ #  # ]:          0 :             assm_alias.push_back(mf_alias);
    2576         [ #  # ]:          0 :             all_ms_starts.push_back(-1);
    2577         [ #  # ]:          0 :             all_ns_starts.push_back(-1);
    2578                 :            :           }
    2579                 :            :         else{
    2580         [ #  # ]:          0 :             all_meshfiles.push_back(reloading_mf);
    2581 [ #  # ][ #  # ]:          0 :             if (iname == COREGEN_DEFAULT_TEST_FILE){
    2582 [ #  # ][ #  # ]:          0 :                 meshfile = testdir + reloading_mf;
    2583                 :            :               }
    2584         [ #  # ]:          0 :             files.push_back(reloading_mf);
    2585         [ #  # ]:          0 :             assm_alias.push_back(mf_alias);
    2586         [ #  # ]:          0 :             all_ms_starts.push_back(ms_startid);
    2587         [ #  # ]:          0 :             all_ns_starts.push_back(ns_startid);
    2588                 :            :           }
    2589                 :            :         //  bsameas = false;
    2590                 :          0 :       }
    2591                 :          0 :     return 0;
    2592                 :            :   }
    2593                 :            : 
    2594                 :          0 :   int CoreGen::find_assm(const int i, int &assm_index)
    2595                 :            :   // ---------------------------------------------------------------------------
    2596                 :            :   // Function: find the assembly index (0 to n) for n assemblies for core alias i
    2597                 :            :   // Input:    none
    2598                 :            :   // Output:   none
    2599                 :            :   // ---------------------------------------------------------------------------
    2600                 :            :   {
    2601                 :          0 :     int flag = 0;
    2602         [ #  # ]:          0 :     for (int j = 0; j < nassys; j++)
    2603         [ #  # ]:          0 :       if (strcmp(core_alias[i].c_str(), assm_alias[j].c_str()) == 0) {
    2604                 :          0 :           assm_index = j;
    2605                 :          0 :           flag = 1;
    2606                 :          0 :           break;
    2607                 :            :         }
    2608         [ #  # ]:          0 :     if (flag == 0)//nothing found return -1 or no assembly
    2609                 :          0 :       assm_index = -1;
    2610                 :          0 :     return iBase_SUCCESS;
    2611                 :            :   }
    2612                 :            : 
    2613                 :          0 :   int CoreGen::write_makefile()
    2614                 :            :   // ---------------------------------------------------------------------------
    2615                 :            :   // Function: write the makefile based on inputs read from input file
    2616                 :            :   // Input:    none
    2617                 :            :   // Output:   none
    2618                 :            :   // ---------------------------------------------------------------------------
    2619                 :            :   {
    2620         [ #  # ]:          0 :     std::string name;
    2621 [ #  # ][ #  # ]:          0 :     std::vector<std::string> f_no_ext, f_sat, f_inp, f_jou, f_injou, f_py;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2622 [ #  # ][ #  # ]:          0 :     make_file << "##" << std::endl;
    2623                 :            :     make_file
    2624         [ #  # ]:          0 :         << "## This makefile is automatically generated by coregen program"
    2625         [ #  # ]:          0 :         << std::endl;
    2626 [ #  # ][ #  # ]:          0 :     make_file << "##" << std::endl;
    2627         [ #  # ]:          0 :     make_file << "## Check your coregen, assygen and cubit location"
    2628         [ #  # ]:          0 :               << std::endl;
    2629 [ #  # ][ #  # ]:          0 :     make_file << "##" << std::endl;
    2630 [ #  # ][ #  # ]:          0 :     make_file << "include ../../common.mk\n" << std::endl;
    2631                 :            :     
    2632 [ #  # ][ #  # ]:          0 :     make_file << "\nCUBIT = trelis -nographics\n" << std::endl;
    2633 [ #  # ][ #  # ]:          0 :     make_file << "COREGEN = $(MESHKIT_DIR)/bin/coregen\n" << std::endl;
    2634 [ #  # ][ #  # ]:          0 :     make_file << "ASSYGEN = $(MESHKIT_DIR)/bin/assygen\n" << std::endl;
    2635                 :            : 
    2636                 :            :     // remove the ./ if run from the current working TestDirectory
    2637         [ #  # ]:          0 :     make_file << "MESH_FILES = ";
    2638         [ #  # ]:          0 :     std::string filename;
    2639         [ #  # ]:          0 :     for (unsigned int i = 0; i < files.size(); i++) {
    2640 [ #  # ][ #  # ]:          0 :         if (files[i][0] == '.' && files[i][1] == '/') {
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2641 [ #  # ][ #  # ]:          0 :             filename = files[i].substr(2, files[i].length());
         [ #  # ][ #  # ]
    2642 [ #  # ][ #  # ]:          0 :           } else if (files[i][0] != '.' || files[i][1] != '/') {
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2643 [ #  # ][ #  # ]:          0 :             int loc1 = files[i].find_last_of(".");
    2644 [ #  # ][ #  # ]:          0 :             int loc2 = files[i].find_last_of("/");
    2645 [ #  # ][ #  # ]:          0 :             filename = files[i].substr(loc2 + 1, loc1);
                 [ #  # ]
    2646                 :            :           } else {
    2647 [ #  # ][ #  # ]:          0 :             filename = files[i];
    2648                 :            :           }
    2649         [ #  # ]:          0 :         mk_files.push_back(filename);
    2650 [ #  # ][ #  # ]:          0 :         make_file << all_meshfiles[i] << "  ";
                 [ #  # ]
    2651                 :            :       }
    2652                 :            : 
    2653                 :            :     // get file names without extension
    2654         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2655 [ #  # ][ #  # ]:          0 :         int loc = mk_files[i].find_first_of(".");
    2656 [ #  # ][ #  # ]:          0 :         f_no_ext.push_back(mk_files[i].substr(0, loc));
                 [ #  # ]
    2657                 :            :       }
    2658                 :            : 
    2659         [ #  # ]:          0 :     make_file << "\n\nGEOM_FILES = ";
    2660         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2661 [ #  # ][ #  # ]:          0 :         if (geom_engine == "occ")
    2662 [ #  # ][ #  # ]:          0 :           name = f_no_ext[i] + ".stp";
                 [ #  # ]
    2663                 :            :         else
    2664 [ #  # ][ #  # ]:          0 :           name = f_no_ext[i] + ".sat";
                 [ #  # ]
    2665         [ #  # ]:          0 :         f_sat.push_back(name);
    2666 [ #  # ][ #  # ]:          0 :         make_file << name << "  ";
    2667         [ #  # ]:          0 :         name = "";
    2668                 :            :       }
    2669                 :            : 
    2670         [ #  # ]:          0 :     make_file << "\n\nJOU_FILES = ";
    2671         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2672 [ #  # ][ #  # ]:          0 :         name = f_no_ext[i] + ".jou";
                 [ #  # ]
    2673         [ #  # ]:          0 :         f_jou.push_back(name);
    2674 [ #  # ][ #  # ]:          0 :         make_file << name << "  ";
    2675         [ #  # ]:          0 :         name = "";
    2676                 :            :       }
    2677                 :            : 
    2678         [ #  # ]:          0 :     make_file << "\n\nPYTHON_FILES = ";
    2679         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2680 [ #  # ][ #  # ]:          0 :         name = f_no_ext[i] + ".py";
                 [ #  # ]
    2681         [ #  # ]:          0 :         f_py.push_back(name);
    2682 [ #  # ][ #  # ]:          0 :         make_file << name << "  ";
    2683         [ #  # ]:          0 :         name = "";
    2684                 :            :       }
    2685                 :            : 
    2686         [ #  # ]:          0 :     make_file << "\n\nINJOU_FILES = ";
    2687         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2688 [ #  # ][ #  # ]:          0 :         name = f_no_ext[i] + ".template.jou";
                 [ #  # ]
    2689         [ #  # ]:          0 :         f_injou.push_back(name);
    2690 [ #  # ][ #  # ]:          0 :         make_file << name << "  ";
    2691         [ #  # ]:          0 :         name = "";
    2692                 :            :       }
    2693                 :            : 
    2694         [ #  # ]:          0 :     make_file << "\n\nASSYGEN_FILES = ";
    2695         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2696 [ #  # ][ #  # ]:          0 :         name = f_no_ext[i] + ".inp";
                 [ #  # ]
    2697         [ #  # ]:          0 :         f_inp.push_back(name);
    2698 [ #  # ][ #  # ]:          0 :         make_file << name << "  ";
    2699         [ #  # ]:          0 :         name = "";
    2700                 :            :       }
    2701                 :            : 
    2702 [ #  # ][ #  # ]:          0 :     make_file << "\n\n" << outfile << " : ${MESH_FILES} " << ifile << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    2703 [ #  # ][ #  # ]:          0 :     make_file << "\t" << "${COREGEN} " << iname << std::endl;
         [ #  # ][ #  # ]
    2704         [ #  # ]:          0 :     for (unsigned int i = 0; i < mk_files.size(); i++) {
    2705 [ #  # ][ #  # ]:          0 :         make_file << all_meshfiles[i] << " : " << f_sat[i] << "  " << f_jou[i]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2706 [ #  # ][ #  # ]:          0 :                      << "  " << f_injou[i] << std::endl;
         [ #  # ][ #  # ]
    2707 [ #  # ][ #  # ]:          0 :         make_file << "\t" << "${CUBIT} -batch " << f_jou[i] << "\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    2708         [ #  # ]:          0 :                   << std::endl;
    2709                 :            : 
    2710 [ #  # ][ #  # ]:          0 :         make_file << f_sat[i] << " : " << f_py[i] << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2711 [ #  # ][ #  # ]:          0 :         make_file << "\t" << "${CUBIT} -batch " << f_py[i] << "\n"
         [ #  # ][ #  # ]
                 [ #  # ]
    2712         [ #  # ]:          0 :                   << std::endl;
    2713                 :            : 
    2714 [ #  # ][ #  # ]:          0 :         make_file << f_py[i] << " " << f_jou[i] << " " << f_injou[i] << " : "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2715 [ #  # ][ #  # ]:          0 :                   << f_inp[i] << std::endl;
                 [ #  # ]
    2716 [ #  # ][ #  # ]:          0 :         make_file << "\t" << "${ASSYGEN} " << f_no_ext[i] << "\n" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2717                 :            :       }
    2718                 :            : 
    2719 [ #  # ][ #  # ]:          0 :     make_file << "make clean :" << "\n\trm *.sat *.cub *.py *.jou" << std::endl;  
                 [ #  # ]
    2720         [ #  # ]:          0 :     make_file.close();
    2721 [ #  # ][ #  # ]:          0 :     logfile << "Created makefile: " << mfile << std::endl;
         [ #  # ][ #  # ]
    2722                 :          0 :     return 0;
    2723                 :            :   }
    2724                 :            : 
    2725                 :          0 :   void CoreGen::banner()
    2726                 :            :   // ---------------------------------------------------------------------------
    2727                 :            :   // Function: display the program banner
    2728                 :            :   // Input:    none
    2729                 :            :   // Output:   none
    2730                 :            :   // ---------------------------------------------------------------------------
    2731                 :            :   {
    2732         [ #  # ]:          0 :     if(rank == 0 ){
    2733                 :          0 :         logfile << '\n';
    2734                 :            :         logfile
    2735                 :          0 :             << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    2736                 :          0 :             << '\n';
    2737                 :            :         logfile
    2738                 :          0 :             << "Program to Assemble Nuclear Reactor Assembly Meshes and Form a Core     "
    2739                 :          0 :             << '\n';
    2740                 :          0 :         logfile << "\t\t\tArgonne National Laboratory" << '\n';
    2741                 :          0 :         logfile << "\t\t\t        2015         " << '\n';
    2742                 :            :         logfile
    2743                 :          0 :             << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    2744                 :          0 :             << '\n';
    2745                 :            :       }
    2746                 :          0 :   }
    2747                 :            : 
    2748 [ +  - ][ +  - ]:        156 : } // namespace MeshKit

Generated by: LCOV version 1.11