LCOV - code coverage report
Current view: top level - algs/AssyGen - AssyGen.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 831 1590 52.3 %
Date: 2020-07-01 15:24:36 Functions: 20 27 74.1 %
Branches: 1423 5223 27.2 %

           Branch data     Line data    Source code
       1                 :            : /*********************************************
       2                 :            : AssyGen Tool: Reactor Geometry Generator
       3                 :            : Argonne National Laboratory
       4                 :            : *********************************************/
       5                 :            : 
       6                 :            : #ifdef _WIN32
       7                 :            : #define _USE_MATH_DEFINES
       8                 :            : #endif
       9                 :            : 
      10                 :            : #include "meshkit/AssyGen.hpp"
      11                 :            : 
      12                 :            : namespace MeshKit
      13                 :            : {
      14                 :            :   // static registration of this  mesh scheme
      15                 :            :   moab::EntityType AssyGen_tps[] = { moab::MBVERTEX,
      16                 :            :                                      moab::MBEDGE,
      17                 :            :                                      moab::MBTRI,
      18                 :            :                                      moab::MBHEX,
      19                 :            :                                      moab::MBMAXTYPE};
      20                 :         40 :   const moab::EntityType* AssyGen::output_types()
      21                 :         40 :   { return AssyGen_tps; }
      22                 :            : 
      23                 :          1 :   AssyGen::AssyGen( MKCore *mk, const MEntVector &me_vec)
      24                 :            :     : MeshScheme( mk, me_vec),
      25 [ +  - ][ +  - ]:          1 :       igeomImpl(mk->igeom_instance())
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
      26                 :            :   {
      27                 :          1 :     err = 0;
      28                 :          1 :     tmpSB = 1;
      29                 :          1 :     m_nPlanar = 0; //default is 3D
      30                 :          1 :     m_nLineNumber = 0;
      31                 :          1 :     root_set= NULL;
      32         [ +  - ]:          1 :     szComment = "!";
      33                 :          1 :     MAXCHARS = 10000;
      34                 :          1 :     MAXLINES = 1000;
      35                 :          1 :     pi = M_PI;
      36                 :          1 :     m_nTotalPincells = 0;
      37                 :          1 :     m_dRadialSize = -1.0;
      38                 :          1 :     m_dTetMeshSize = -1.0;
      39                 :          1 :     m_nDimensions = 0;
      40                 :          1 :     m_nMaterialSetId = 1;
      41                 :          1 :     m_nNeumannSetId = 1;
      42         [ +  - ]:          1 :     m_szEngine = "acis";
      43         [ +  - ]:          1 :     m_szMeshType = "hex";
      44                 :          1 :     m_nDuct = 0;
      45                 :          1 :     m_nDuctNum = 0;
      46                 :          1 :     m_nJouFlag = 0;
      47         [ +  - ]:          1 :     m_szSideset = "yes";
      48                 :          1 :     m_nAssyGenInputFiles = 0;
      49                 :          1 :     m_dMergeTol = 1e-4;
      50                 :          1 :     m_edgeInterval = 99;
      51                 :          1 :     m_nStartpinid = 1;
      52         [ +  - ]:          1 :     m_szInfo = "off";
      53         [ +  - ]:          1 :     m_szMeshScheme = "pave";
      54         [ +  - ]:          1 :     pin_name = "";
      55                 :          1 :     m_nHblock = -1;
      56                 :          1 :     m_nPincells = 0;
      57                 :          1 :     m_bCreateMatFiles = false;
      58                 :          1 :     m_nSuperBlocks = 0;
      59                 :          1 :     m_bmerge = true;
      60                 :          1 :     m_bimprint = true;
      61                 :          1 :     save_exodus = false;
      62                 :          1 :     have_common = true;
      63                 :          1 :     com_run_count = 0;
      64                 :          1 :     m_nBLAssemblyMat = 0;
      65         [ +  - ]:          1 :     m_szInnerDuct = "";
      66         [ +  - ]:          1 :     m_szSmooth  = "off";
      67                 :          1 :   }
      68                 :            : 
      69                 :          3 :   AssyGen::~AssyGen()
      70                 :            :   {
      71                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
      72                 :          1 :     iGeom_dtor(igeomImpl->instance(), &err);
      73                 :            : #endif
      74                 :            :     //CHECK( "Interface destruction didn't work properly." );
      75                 :            :     // close the input and output files
      76                 :          1 :     m_FileInput.close ();
      77                 :          1 :     m_FileOutput.close ();
      78                 :          1 :     m_SchemesFile.close ();
      79         [ +  - ]:          1 :     if(strcmp(m_szInfo.c_str(),"on") == 0)
      80                 :          1 :       m_AssmInfo.close ();
      81         [ -  + ]:          2 :   }
      82                 :            : 
      83                 :            : 
      84                 :          0 :   bool AssyGen::add_modelent(ModelEnt *model_ent)
      85                 :            :   {
      86                 :          0 :     return MeshOp::add_modelent(model_ent);
      87                 :            :   }
      88                 :            : 
      89                 :          1 :   void AssyGen::setup_this()
      90                 :            :   {
      91                 :            :     // start the timer
      92         [ +  - ]:          1 :     CClock Timer;
      93                 :          1 :     clock_t sTime = clock();
      94         [ +  - ]:          2 :     std::string szDateTime;
      95         [ +  - ]:          1 :     Timer.GetDateTime (szDateTime);
      96 [ +  - ][ +  - ]:          1 :     std::cout << "\nStarting out at : " << szDateTime << "\n";
                 [ +  - ]
      97                 :            : 
      98         [ +  - ]:          1 :     if (have_common == true)
      99         [ +  - ]:          1 :       ReadCommonInp();
     100                 :            : 
     101                 :            :     //count pin cylinders and cell material, needed for setting array size before actual read
     102         [ +  - ]:          1 :     ReadInputPhase1 ();
     103                 :            : 
     104         [ +  - ]:          1 :     if (have_common == true)
     105         [ +  - ]:          1 :       ReadCommonInp();
     106                 :            : 
     107                 :            :     // read the problem size and create pincell
     108         [ +  - ]:          1 :     ReadAndCreate ();
     109                 :            : 
     110                 :            :     // create the .jou file
     111         [ +  - ]:          1 :     CreateCubitJournal();
     112                 :            : 
     113         [ +  - ]:          1 :     CreateAssyGenInputFiles();
     114                 :            : 
     115                 :            :     // get the current date and time
     116         [ +  - ]:          1 :     Timer.GetDateTime (szDateTime);
     117 [ +  - ][ +  - ]:          1 :     std::cout << "Ending at : " << szDateTime;
     118                 :            : 
     119                 :            :     // compute the elapsed time
     120 [ +  - ][ +  - ]:          1 :     std::cout << "Elapsed wall clock time: " << Timer.DiffTime ()
                 [ +  - ]
     121 [ +  - ][ +  - ]:          2 :               << " seconds or " << (Timer.DiffTime ())/60.0 << " mins\n";
         [ +  - ][ +  - ]
     122                 :            : 
     123 [ +  - ][ +  - ]:          1 :     std::cout << "## Total CPU time used := " << (double) (clock() - sTime)/CLOCKS_PER_SEC \
     124 [ +  - ][ +  - ]:          2 :               << " seconds" << std::endl;
     125                 :          1 :   }
     126                 :            : 
     127                 :          1 :   void AssyGen::execute_this()
     128                 :            :   {
     129                 :          1 :   }
     130                 :            : 
     131                 :            : 
     132                 :          1 :   void AssyGen::PrepareIO (int argc, char *argv[],  std::string TestDir)
     133                 :            :   // ---------------------------------------------------------------------------
     134                 :            :   // Function: Obtains file names and opens input/output files
     135                 :            :   // Input:    command line arguments
     136                 :            :   // Output:   none
     137                 :            :   // ---------------------------------------------------------------------------
     138                 :            :   {
     139                 :          1 :     std::cout << '\n';
     140                 :          1 :     std::cout << "\t\t---------------------------------------------------------" << '\n';
     141                 :          1 :     std::cout << "\t\tProgram to Generate Nuclear Reactor Assembly Geometries      " << '\n';
     142                 :          1 :     std::cout << "\t\t\t\tArgonne National Laboratory" << '\n';
     143                 :          1 :     std::cout << "\t\t---------------------------------------------------------" << '\n';
     144                 :          1 :     std::cout << "\nsee http://press3.mcs.anl.gov/sigma/meshkit-library/rgg/ for details.\n"<< std::endl;
     145                 :            :     // set and open input output files
     146                 :          1 :     bool bDone = false;
     147         [ -  + ]:          1 :     do{
     148         [ -  + ]:          1 :         if (2 == argc) {
     149                 :          0 :             m_szFile = argv[1];
     150         [ #  # ]:          0 :             m_szInFile=m_szFile+".inp";
     151         [ #  # ]:          0 :             m_szJouFile = m_szFile+".jou";
     152         [ #  # ]:          0 :             m_szSchFile = m_szFile+".template.jou";
     153         [ #  # ]:          0 :             m_szAssmInfo = m_szFile + "_info.csv";
     154         [ #  # ]:          0 :             m_szLogFile = m_szFile + ".screenlog";
     155         [ #  # ]:          0 :             m_szPyCubGeom = m_szFile + ".py";
     156                 :          0 :             m_szCommonFile = "common.inp";
     157                 :            :           }
     158         [ -  + ]:          1 :         else if (3 == argc) {
     159                 :          0 :             int i=1;// will loop through arguments, and process them
     160         [ #  # ]:          0 :             for (i=1; i<argc-1 ; i++) {
     161         [ #  # ]:          0 :                 if (argv[i][0]=='-') {
     162      [ #  #  # ]:          0 :                     switch (argv[i][1])
     163                 :            :                       {
     164                 :            :                       case 'j':
     165                 :            :                         {
     166                 :          0 :                           m_nJouFlag = 1;
     167                 :          0 :                           std::cout << "Creating journal file only.\n Geometry file must exist in the same directory." << std::endl;
     168                 :          0 :                           m_szFile = argv[2];
     169         [ #  # ]:          0 :                           m_szInFile=m_szFile+".inp";
     170         [ #  # ]:          0 :                           m_szJouFile = m_szFile+".jou";
     171         [ #  # ]:          0 :                           m_szSchFile = m_szFile+".template.jou";
     172         [ #  # ]:          0 :                           m_szAssmInfo = m_szFile + "_info.csv";
     173         [ #  # ]:          0 :                           m_szLogFile = m_szFile + ".screenlog";
     174         [ #  # ]:          0 :                           m_szPyCubGeom = m_szFile + ".py";
     175                 :          0 :                           m_szCommonFile = "common.inp";
     176                 :          0 :                           break;
     177                 :            :                         }
     178                 :            :                       case 'h':
     179                 :            :                         {
     180                 :          0 :                           std::cout << "\nInstruction on writing assygen input file can also be found at: " << std::endl;
     181                 :          0 :                           std::cout << "        http://press3.mcs.anl.gov/sigma/meshkit/rgg/assygen-input-file-keyword-definitions/" << std::endl;
     182                 :          0 :                           std::cout << "Usage: assygen [-j -h] <input file name without extension>"<< std::endl;
     183                 :          0 :                           std::cout << "        -j create journal file only" << std::endl;
     184                 :          0 :                           std::cout << "        -h print help" << std::endl;
     185                 :            : 
     186                 :          0 :                           exit(0);
     187                 :            :                           break;
     188                 :            :                         }
     189                 :            :                       }
     190                 :            :                   }
     191                 :            :               }
     192                 :            :           }
     193         [ +  - ]:          1 :         else if (1 == argc){
     194                 :          1 :             std::cout << "\nInstruction on writing assygen input file can also be found at: " << std::endl;
     195                 :          1 :             std::cout << "        http://press3.mcs.anl.gov/sigma/meshkit/rgg/assygen-input-file-keyword-definitions/" << std::endl;
     196                 :          1 :             std::cout << "Usage: assygen [-t -j -h] <input file name without extension>"<< std::endl;
     197                 :          1 :             std::cout << "        -t print timing and memory usage info in each step" << std::endl;
     198                 :          1 :             std::cout << "        -j create journal file only" << std::endl;
     199                 :          1 :             std::cout << "        -h print help" << std::endl;
     200                 :            : 
     201 [ +  - ][ +  - ]:          1 :             m_szInFile = TestDir + "/" + (char *)DEFAULT_TEST_FILE;
     202                 :          1 :             m_szGeomFile = (char *)TEST_FILE_NAME;
     203                 :          1 :             m_szJouFile = (char *)TEST_FILE_NAME;
     204                 :          1 :             m_szFile =  (char *)TEST_FILE_NAME;
     205                 :          1 :             m_szInFile+=".inp";
     206                 :          1 :             m_szJouFile+=".jou";
     207         [ +  - ]:          1 :             m_szSchFile = m_szFile+".template.jou";
     208         [ +  - ]:          1 :             m_szAssmInfo = m_szFile + "_info.csv";
     209         [ +  - ]:          1 :             m_szLogFile = m_szFile + ".screenlog";
     210         [ +  - ]:          1 :             m_szPyCubGeom = m_szFile + ".py";
     211 [ +  - ][ +  - ]:          1 :             m_szCommonFile = TestDir + "/" + "common.inp";
     212                 :            : 
     213                 :          1 :             std::cout <<"Default case input file is located here <MeshKit/data> "<< std::endl;
     214                 :            :           }
     215                 :            :         // open the file
     216                 :          1 :         m_FileInput.open (m_szInFile.c_str(), std::ios::in);
     217         [ -  + ]:          1 :         if (!m_FileInput){
     218                 :          0 :             std::cout << "Usage: assygen <input filename WITHOUT EXTENSION>"<< std::endl;
     219                 :          0 :             m_FileInput.clear ();
     220                 :          0 :             exit(1);
     221                 :            :           }
     222                 :            :         else
     223                 :          1 :           bDone = true; // file opened successfully
     224                 :            : 
     225                 :            :         // open common.inp file, if not found do nothing.
     226                 :          1 :         m_FileCommon.open (m_szCommonFile.c_str(), std::ios::in);
     227         [ -  + ]:          1 :         if (!m_FileCommon){
     228                 :          0 :             have_common = false;
     229                 :          0 :             std::cout << "common.inp file not specified." << std::endl;
     230                 :          0 :             m_FileCommon.clear ();
     231                 :            :           }
     232                 :            :         else {
     233                 :          1 :             have_common = true;
     234                 :            :           }
     235                 :          1 :         std::cout << " opened file " << m_szCommonFile << " have common is "
     236                 :          1 :                   << have_common << std::endl;
     237                 :          1 :       } while (!bDone);
     238                 :          1 :     std::cout << "\nEntered input file name: " <<  m_szInFile <<std::endl;
     239                 :            : 
     240                 :            :     // open the file
     241         [ -  + ]:          1 :     do{
     242                 :          1 :         m_FileOutput.open (m_szJouFile.c_str(), std::ios::out);
     243         [ -  + ]:          1 :         if (!m_FileOutput){
     244                 :          0 :             std::cout << "Unable to open o/p file: " << m_szJouFile << std::endl;
     245                 :          0 :             m_FileOutput.clear ();
     246                 :          0 :             exit(1);
     247                 :            :           }
     248                 :            :         else
     249                 :          1 :           bDone = true; // file opened successfully
     250                 :          1 :       } while (!bDone);
     251                 :            : 
     252                 :            :     // open the template journal file for writing
     253         [ -  + ]:          1 :     do{
     254                 :          1 :         m_SchemesFile.open (m_szSchFile.c_str(), std::ios::out);
     255         [ -  + ]:          1 :         if (!m_SchemesFile){
     256                 :          0 :             std::cout << "Unable to open o/p file: " << m_szSchFile << std::endl;
     257                 :          0 :             m_SchemesFile.clear ();
     258                 :          0 :             exit(1);
     259                 :            :           }
     260                 :            :         else
     261                 :          1 :           bDone = true; // file opened successfully
     262                 :          1 :       } while (!bDone);
     263                 :            : 
     264         [ -  + ]:          1 :     do{
     265                 :          1 :         m_PyCubGeomFile.open (m_szPyCubGeom.c_str(), std::ios::out);
     266         [ -  + ]:          1 :         if (!m_PyCubGeomFile){
     267                 :          0 :             std::cout << "Unable to open o/p file: " << m_szPyCubGeom << std::endl;
     268                 :          0 :             m_PyCubGeomFile.clear ();
     269                 :          0 :             exit(1);
     270                 :            :           }
     271                 :            :         else
     272                 :          1 :           bDone = true; // file opened successfully
     273                 :          1 :       } while (!bDone);
     274                 :            : 
     275                 :          1 :     std::cout<<"\no/p Cubit journal file name: "<< m_szJouFile
     276                 :          1 :             << std::endl;
     277                 :            : 
     278                 :            :     // filename to be saved with cubit journal file
     279         [ +  - ]:          1 :     m_szGeomFile1 = m_szFile+".sat";
     280                 :            : 
     281                 :            :     //ACIS ENGINE
     282                 :            : #ifdef HAVE_ACIS
     283                 :            :     //  if(m_szEngine == "acis"){
     284                 :            :     m_szGeomFile = m_szFile+".sat";
     285                 :            :     //  }
     286                 :            : #elif defined(HAVE_OCC)
     287                 :            :     //  OCC ENGINE
     288                 :            :     //  if (m_szEngine == "occ"){
     289         [ +  - ]:          1 :     m_szGeomFile = m_szFile+".brep";
     290                 :            :     //  }
     291                 :            : #endif
     292                 :          1 :     std::cout << "\no/p geometry file name: " <<  m_szGeomFile <<std::endl;
     293                 :            : 
     294                 :            :     // writing schemes .jou file ends, now write the main journal file.
     295                 :            :     // stuff common to both surface and volume
     296                 :          1 :     m_FileOutput << "## This file is created by rgg program in MeshKit ##\n";
     297                 :          1 :     m_FileOutput << "#User needs to specify mesh interval and schemes in this file\n#" << std::endl;
     298                 :            : 
     299                 :          1 :     m_PyCubGeomFile << "## This python script is created by the RGG AssyGen program in MeshKit ##\n";
     300                 :          1 :     m_PyCubGeomFile << "# Here the RGG AssyGen program creates the assembly geometry and mesh\n#" << std::endl;
     301                 :          1 :     m_PyCubGeomFile << "\nimport cubit" << std::endl;
     302                 :            : 
     303                 :            : 
     304                 :            :     // write the name faces python function here
     305                 :            :     m_PyCubGeomFile << "def name_faces(name, body):\n"
     306                 :            :                        "    vector_locs = cubit.get_bounding_box(\"volume\", body.id())\n"
     307                 :            :                        "    topno = vector_locs[7] - 1e-2\n"
     308                 :            :                        "    botno = vector_locs[6] + 1e-2\n"
     309                 :            :                        "    cubit.cmd('group \"g1\" equals surf in vol {0} '.format(body.id()))\n"
     310                 :            :                        "    cubit.cmd('group \"g2\" equals surf  in g1 with z_coord  < {0} and z_coord > {1}'.format(topno,botno))\n"
     311                 :            :                        "    cubit.cmd('group  \"g3\" subtract g2 from g1')\n"
     312                 :            :                        "    cubit.cmd('group \"gtop\" equals surf in g3 with z_coord > {0}'.format(topno) )\n"
     313                 :            :                        "    cubit.cmd('group \"gbot\" equals surf in g3 with z_coord < {0}'.format(botno) )\n"
     314                 :            :                        "    g2id = cubit.get_id_from_name(\"g2\")\n"
     315                 :            :                        "    ssurfs = cubit.get_group_surfaces(g2id)\n"
     316                 :            :                        "    side_surfs = len(ssurfs)\n"
     317                 :            :                        "    for i in range(0,side_surfs):\n"
     318                 :            :                        "      sname = name + \"_side\" + str(i+1)\n"
     319                 :            :                        "      cubit.cmd('surf {0} name \"{1}\"'.format( ssurfs[i] , sname )  )\n"
     320                 :            :                        "    top_surf = name + \"_top\"\n"
     321                 :            :                        "    bot_surf = name + \"_bot\"\n"
     322                 :            :                        "    cubit.cmd('surf in gtop name \"{0}\"'.format(top_surf) )\n"
     323                 :            :                        "    cubit.cmd('surf in gbot name \"{0}\"'.format(bot_surf) )\n"
     324                 :          1 :                        "    cubit.cmd('delete group g1 g2 g3 gtop gbot')\n" << std::endl;
     325                 :            : 
     326                 :            : 
     327                 :            :     // write the name faces python function here
     328                 :            :     m_PyCubGeomFile << "\n\ndef section_assm(cDir, dOffset, szReverse):\n"
     329                 :            :                        "    vol = cubit.get_entities(\"volume\")\n"
     330                 :            :                        "    for i in range(len(vol)):\n"
     331                 :            :                        "      vl = cubit.get_bounding_box(\"volume\", vol[i])\n"
     332                 :            :                        "      xmin = vl[0]\n"
     333                 :            :                        "      xmax = vl[1]\n"
     334                 :            :                        "      ymin = vl[3]\n"
     335                 :            :                        "      ymax = vl[4]\n"
     336                 :            :                        "      print xmin, xmax, ymin, ymax\n"
     337                 :            :                        "      if(xmin > dOffset and cDir == \"x\" and szReverse == \"reverse\"):\n"
     338                 :            :                        "        cubit.cmd('delete vol {0}'.format(vol[i]) )\n"
     339                 :            :                        "        continue\n"
     340                 :            :                        "      if(ymin > dOffset and cDir == \"y\" and szReverse == \"reverse\"):\n"
     341                 :            :                        "        cubit.cmd('delete vol {0}'.format(vol[i]) )\n"
     342                 :            :                        "        continue\n"
     343                 :            :                        "      if(xmax < dOffset and cDir == \"x\" and szReverse == \"\"):\n"
     344                 :            :                        "        cubit.cmd('delete vol {0}'.format(vol[i]) )\n"
     345                 :            :                        "        continue\n"
     346                 :            :                        "      if(ymax < dOffset and cDir == \"y\" and szReverse == \"\"):\n"
     347                 :            :                        "        cubit.cmd('delete vol {0}'.format(vol[i]) )\n"
     348                 :            :                        "        continue\n"
     349                 :            :                        "      else:\n"
     350                 :            :                        "        if (ymax > dOffset and cDir == \"y\" and ymin < dOffset):\n"
     351                 :            :                        "          cubit.cmd('section vol {0} with yplane offset {1} {2}'.format(vol[i], dOffset, szReverse))\n"
     352                 :            :                        "        if (xmax > dOffset and cDir == \"x\" and xmin < dOffset):\n"
     353                 :          1 :                        "          cubit.cmd('section vol {0} with xplane offset {1} {2}'.format(vol[i], dOffset, szReverse))\n" << std::endl;
     354                 :            : 
     355                 :          1 :     m_PyCubGeomFile << "\ncubit.cmd('reset')" << std::endl;
     356                 :            : 
     357                 :            : 
     358                 :          1 :     m_FileOutput << "#" << std::endl;
     359                 :          1 :     m_FileOutput << "set logging on file '" << m_szLogFile << "'" <<std::endl;
     360                 :          1 :     m_FileOutput << "Timer Start" << std::endl;
     361                 :            :     // import the geometry file
     362                 :          1 :     m_FileOutput << "# Import geometry file " << std::endl;
     363                 :            :     // Use sat file always as step isn't supported
     364                 :          1 :     m_FileOutput << "import '" << m_szGeomFile1 <<"'" << std::endl;
     365                 :          1 :     m_FileOutput << "{include(\"" << m_szSchFile << "\")}" <<std::endl;
     366                 :          1 :     m_FileOutput << "#" << std::endl;
     367                 :            : 
     368                 :          1 :   }
     369                 :            : 
     370                 :            : 
     371                 :          2 :   void AssyGen::ReadCommonInp ()
     372                 :            :   // -------------------------------------------------------------------------------------------
     373                 :            :   // Function: reads the input file to count the no. of cyl in a pincell, before the actual read
     374                 :            :   // Input:    none
     375                 :            :   // Output:   none
     376                 :            :   // -------------------------------------------------------------------------------------------
     377                 :            :   {
     378                 :          2 :     ++com_run_count;
     379         [ +  + ]:          2 :     if(com_run_count > 1){
     380                 :            :         //Rewind the reader for common.inp file
     381         [ +  - ]:          1 :         m_FileCommon.clear (std::ios_base::goodbit);
     382         [ +  - ]:          1 :         m_FileCommon.seekg (0L, std::ios::beg);
     383                 :            :       }
     384         [ +  - ]:          2 :     CParser Parse1;
     385                 :          2 :     bool found = false;
     386         [ +  - ]:          4 :     std::string card;
     387                 :          2 :     m_nLineNumber = 0;
     388 [ +  - ][ +  - ]:          2 :     std::cout << "Reading from common.inp file." << std::endl;
     389                 :            :     for(;;){
     390         [ -  + ]:         16 :         if (!Parse1.ReadNextLine (m_FileCommon, m_nLineNumber, szInputString,
     391         [ +  - ]:         16 :                                   MAXCHARS, szComment))
     392         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
     393                 :            : 
     394 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,10) == "geomengine"){
                 [ +  + ]
     395                 :          2 :             found = true;
     396         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     397 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_szEngine;
     398 [ #  # ][ -  + ]:          4 :             if( ((strcmp (m_szEngine.c_str(), "acis") != 0) &&
     399 [ -  + ][ +  - ]:          2 :                  (strcmp (m_szEngine.c_str(), "occ") != 0)) || szFormatString.fail())
                 [ -  + ]
     400         [ #  # ]:          2 :               IOErrorHandler(EGEOMENGINE);
     401                 :            :           }
     402                 :            :         // start id for pin number
     403 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0, 10) == "startpinid") {
                 [ -  + ]
     404                 :          0 :             found = true;
     405         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
     406 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nStartpinid;
     407                 :            :           }
     408 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,8) == "meshtype"){
                 [ +  + ]
     409                 :          2 :             found = true;
     410         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     411 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_szMeshType;
     412 [ +  - ][ -  + ]:          6 :             if( ((strcmp (m_szMeshType.c_str(), "hex") != 0) &&
     413 [ +  - ][ +  - ]:          4 :                  (strcmp (m_szMeshType.c_str(), "tet") != 0)) || szFormatString.fail())
                 [ -  + ]
     414         [ #  # ]:          2 :               IOErrorHandler(INVALIDINPUT);
     415                 :            :           }
     416                 :            :         // info flag
     417 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,4) == "info"){
                 [ +  + ]
     418                 :          2 :             found = true;
     419         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     420 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_szInfo;
     421 [ +  - ][ +  - ]:          2 :             std::cout <<"--------------------------------------------------"<<std::endl;
     422                 :            :           }
     423                 :            :         // hex block along z
     424 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,6) == "hblock"){
                 [ -  + ]
     425                 :          0 :             found = true;
     426         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     427 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nHblock >> m_dZstart >> m_dZend;
         [ #  # ][ #  # ]
     428 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     429                 :            :           }
     430                 :            :         // Hex or Rect geometry type
     431 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,12) == "geometrytype"){
                 [ +  + ]
     432                 :          2 :             found = true;
     433         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     434 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_szGeomType;
     435 [ +  - ][ -  + ]:          6 :             if( ((strcmp (m_szGeomType.c_str(), "hexagonal") != 0) &&
     436 [ +  - ][ +  - ]:          4 :                  (strcmp (m_szGeomType.c_str(), "rectangular") != 0)) || szFormatString.fail())
                 [ -  + ]
     437         [ #  # ]:          0 :               IOErrorHandler(EGEOMTYPE);
     438                 :            : 
     439                 :            :             // set the number of sides in the geometry
     440 [ +  - ][ -  + ]:          2 :             if(m_szGeomType == "hexagonal")
     441                 :          0 :               m_nSides = 6;
     442 [ +  - ][ +  - ]:          2 :             else  if(m_szGeomType == "rectangular")
     443                 :          2 :               m_nSides = 4;
     444                 :            :           }
     445                 :            :         // Default if volume, set geometry type to surface for 2D assemblies
     446 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,8) == "geometry"){
                 [ +  + ]
     447                 :          2 :             found = true;
     448         [ +  - ]:          2 :             std::string outfile;
     449         [ +  - ]:          4 :             std::istringstream szFormatString (szInputString);
     450 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> outfile;
     451 [ +  - ][ +  - ]:          2 :             if(strcmp (outfile.c_str(), "surface") == 0 || szFormatString.fail())
         [ -  + ][ -  + ]
     452                 :          2 :               m_nPlanar=1;
     453                 :            :           }
     454                 :            :         // 'yes' or 'no' for creating sidesets
     455 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,13) == "createsideset"){
                 [ +  + ]
     456                 :          2 :             found = true;
     457         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     458 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_szSideset;
     459 [ +  - ][ +  - ]:          2 :             std::cout <<"--------------------------------------------------"<<std::endl;
     460                 :            :           }
     461                 :            :         // Create specified number of files with varying material ids
     462 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,11) == "createfiles"){
                 [ -  + ]
     463                 :          0 :             found = true;
     464         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     465 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nAssyGenInputFiles;
     466 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     467                 :            :           }
     468                 :            :         // Create specified number of files with varying material ids
     469 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,11) == "save_exodus"){
                 [ -  + ]
     470                 :          0 :             found = true;
     471                 :          0 :             save_exodus = true;
     472 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     473                 :            :           }
     474                 :            :         // specify a merge tolerance value for cubit journal file
     475 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,14) == "mergetolerance"){
                 [ +  + ]
     476                 :          2 :             found = true;
     477         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     478 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_dMergeTol;
     479 [ +  - ][ +  - ]:          2 :             std::cout <<"--------------------------------------------------"<<std::endl;
     480                 :            :           }
     481                 :            :         // Handle mesh size inputs
     482 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,14) == "radialmeshsize"){
                 [ -  + ]
     483                 :          0 :             found = true;
     484         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     485 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_dRadialSize;
     486 [ #  # ][ #  # ]:          0 :             if(m_dRadialSize < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
     487         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
     488 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     489                 :            : 
     490                 :            :           }
     491                 :            :         // Handle mesh size inputs
     492 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,11) == "tetmeshsize"){
                 [ +  + ]
     493                 :          2 :             found = true;
     494         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
     495 [ +  - ][ +  - ]:          2 :             szFormatString >> card >> m_dTetMeshSize;
     496 [ +  - ][ +  - ]:          2 :             if(m_dTetMeshSize < 0 || szFormatString.fail())
         [ -  + ][ -  + ]
     497         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
     498 [ +  - ][ +  - ]:          2 :             std::cout <<"--------------------------------------------------"<<std::endl;
     499                 :            : 
     500                 :            :           }
     501                 :            :         // Handle mesh size inputs
     502 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0,13) == "axialmeshsize"){
                 [ -  + ]
     503                 :          0 :             found = true;
     504         [ #  # ]:          0 :             if(com_run_count > 1){
     505         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     506         [ #  # ]:          0 :                 szFormatString >> card;
     507         [ #  # ]:          0 :                 m_dAxialSize.SetSize(m_nDuct);
     508                 :            :                 int num_ams_specified = std::distance(std::istream_iterator<std::string>(szFormatString),
     509 [ #  # ][ #  # ]:          0 :                                                       std::istream_iterator<std::string>());
                 [ #  # ]
     510         [ #  # ]:          0 :                 std::istringstream szFormatStringAgain (szInputString);
     511         [ #  # ]:          0 :                 szFormatStringAgain >> card;
     512         [ #  # ]:          0 :                 for (int p = 1; p <= m_nDuct; p++){
     513         [ #  # ]:          0 :                     if(p <= num_ams_specified)
     514 [ #  # ][ #  # ]:          0 :                       szFormatStringAgain >> m_dAxialSize(p);
     515                 :            :                     else
     516 [ #  # ][ #  # ]:          0 :                       m_dAxialSize(p) = m_dAxialSize(num_ams_specified);
     517 [ #  # ][ #  # ]:          0 :                     if(m_dAxialSize(p) < 0)
     518         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
     519                 :            :                   }
     520 [ #  # ][ #  # ]:          0 :                 std::cout <<"--------------------------------------------------"<<std::endl;
     521                 :            :               }
     522                 :            :           }
     523                 :            :         // edge interval
     524 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0, 12) == "edgeinterval") {
                 [ -  + ]
     525                 :          0 :             found = true;
     526         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
     527 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_edgeInterval;
     528                 :            :           }
     529                 :            :         // mesh scheme - hole or pave
     530 [ +  - ][ +  - ]:         16 :         if (szInputString.substr(0, 10) == "meshscheme") {
                 [ -  + ]
     531         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
     532 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_szMeshScheme;
     533                 :            :           }
     534                 :            :         // breaking condition
     535 [ +  - ][ +  - ]:         16 :         if(szInputString.substr(0,3) == "end" || m_nLineNumber == MAXLINES){
         [ +  + ][ -  + ]
                 [ +  - ]
           [ +  +  #  # ]
     536                 :          2 :             found = true;
     537                 :          2 :             break;
     538                 :            :           }
     539         [ -  + ]:         14 :         if (found == false){
     540 [ #  # ][ #  # ]:          0 :             std::cout << "Cannot specify: " << szInputString << " in common.inp files" << std::endl;
         [ #  # ][ #  # ]
     541                 :            :           }
     542                 :         16 :       }
     543                 :            : 
     544                 :          2 :   }
     545                 :            : 
     546                 :          1 :   void AssyGen::ReadInputPhase1 ()
     547                 :            :   // -------------------------------------------------------------------------------------------
     548                 :            :   // Function: reads the input file to count the no. of cyl in a pincell, before the actual read
     549                 :            :   // Input:    none
     550                 :            :   // Output:   none
     551                 :            :   // -------------------------------------------------------------------------------------------
     552                 :            :   {
     553 [ +  - ][ +  - ]:          1 :     std::cout << "Reading from AssyGen input file." << std::endl;
     554         [ +  - ]:          1 :     CParser Parse;  bool bDone = false;
     555                 :          1 :     int nCyl =0, nCellMat=0, nInputLines=0;
     556 [ +  - ][ +  - ]:          2 :     std::string card, szVolId, szVolAlias;
                 [ +  - ]
     557                 :          1 :     m_nLineNumber = 0;
     558                 :            :     // count the total number of cylinder commands in each pincell
     559                 :            :     for(;;){
     560         [ -  + ]:         17 :         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     561         [ +  - ]:         17 :                                  MAXCHARS, szComment))
     562         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
     563                 :            : 
     564 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,10) == "geomengine"){
                 [ -  + ]
     565         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     566 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_szEngine;
     567 [ #  # ][ #  # ]:          0 :             if( ((strcmp (m_szEngine.c_str(), "acis") != 0) &&
     568 [ #  # ][ #  # ]:          0 :                  (strcmp (m_szEngine.c_str(), "occ") != 0)) || szFormatString.fail())
                 [ #  # ]
     569         [ #  # ]:          0 :               IOErrorHandler(EGEOMENGINE);
     570                 :            :           }
     571                 :            :         // Read material data
     572 [ +  - ][ +  - ]:         17 :         if ((szInputString.substr(0,9) == "materials") && (szInputString.substr(0,19) != "materialset_startid")){
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
           [ +  +  #  #  
                   #  # ]
     573                 :            : 
     574         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
     575 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_nAssemblyMat;
     576 [ +  - ][ -  + ]:          1 :             if(szFormatString.fail())
     577         [ #  # ]:          0 :               IOErrorHandler(INVALIDINPUT);
     578 [ +  - ][ +  - ]:          1 :             m_szAssmMat.SetSize(m_nAssemblyMat); m_szAssmMatAlias.SetSize(m_nAssemblyMat);
     579         [ +  + ]:          4 :             for (int j=1; j<=m_nAssemblyMat; j++){
     580 [ +  - ][ +  - ]:          3 :                 szFormatString >> m_szAssmMat(j) >> m_szAssmMatAlias(j);
         [ +  - ][ +  - ]
     581         [ +  - ]:          6 :                 if( (strcmp (m_szAssmMat(j).c_str(), "") == 0) ||
           [ +  -  -  + ]
                 [ -  + ]
     582         [ +  - ]:          3 :                     (strcmp (m_szAssmMatAlias(j).c_str(), "") == 0)){
     583         [ #  # ]:          0 :                     IOErrorHandler(EMAT);
     584                 :            :                   }
     585                 :            :                 // checking if & inserted at the end of the material by mistake
     586         [ +  + ]:          3 :                 if (j == m_nAssemblyMat){
     587         [ +  - ]:          1 :                     std::string dummy = "";
     588         [ +  - ]:          1 :                     szFormatString >> dummy;
     589         [ -  + ]:          1 :                     if (strcmp (dummy.c_str(), "") != 0)
     590         [ #  # ]:          1 :                       IOErrorHandler(EMAT);
     591                 :            :                   }
     592                 :          1 :               }
     593                 :            :           }
     594                 :            :         // Read material data
     595 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,11) == "blmaterials"){
                 [ -  + ]
     596                 :            : 
     597         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     598 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nBLAssemblyMat;
     599 [ #  # ][ #  # ]:          0 :             if(szFormatString.fail())
     600         [ #  # ]:          0 :               IOErrorHandler(INVALIDINPUT);
     601 [ #  # ][ #  # ]:          0 :             m_szBLAssmMat.SetSize(m_nBLAssemblyMat); m_dBLMatBias.SetSize(m_nBLAssemblyMat);
     602         [ #  # ]:          0 :             m_nBLMatIntervals.SetSize(m_nBLAssemblyMat);
     603         [ #  # ]:          0 :             for (int j=1; j<=m_nBLAssemblyMat; j++){
     604 [ #  # ][ #  # ]:          0 :                 szFormatString >> m_szBLAssmMat(j) >> m_dBLMatBias(j) >> m_nBLMatIntervals(j);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     605 [ #  # ][ #  # ]:          0 :                 if( (strcmp (m_szBLAssmMat(j).c_str(), "") == 0) ||
         [ #  # ][ #  # ]
     606         [ #  # ]:          0 :                     (m_nBLMatIntervals(j) < 0) ){
     607         [ #  # ]:          0 :                     IOErrorHandler(EMAT);
     608                 :            :                   }
     609                 :            :                 // checking if & inserted at the end of the material by mistake
     610         [ #  # ]:          0 :                 if (j == m_nBLAssemblyMat){
     611         [ #  # ]:          0 :                     std::string dummy = "";
     612         [ #  # ]:          0 :                     szFormatString >> dummy;
     613         [ #  # ]:          0 :                     if (strcmp (dummy.c_str(), "") != 0)
     614         [ #  # ]:          0 :                       IOErrorHandler(EMAT);
     615                 :            :                   }
     616                 :          0 :               }
     617                 :            :           }
     618                 :            : 
     619                 :            :         // start id for pin number
     620 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0, 10) == "startpinid") {
                 [ -  + ]
     621         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
     622 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nStartpinid;
     623                 :            :           }
     624 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,8) == "meshtype"){
                 [ +  + ]
     625         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
     626 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_szMeshType;
     627 [ #  # ][ -  + ]:          2 :             if( ((strcmp (m_szMeshType.c_str(), "hex") != 0) &&
     628 [ -  + ][ +  - ]:          1 :                  (strcmp (m_szMeshType.c_str(), "tet") != 0)) || szFormatString.fail())
                 [ -  + ]
     629         [ #  # ]:          1 :               IOErrorHandler(INVALIDINPUT);
     630                 :            :           }
     631 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,4) == "duct" || szInputString.substr(0,10) == "dimensions"){
         [ +  + ][ +  - ]
         [ +  - ][ -  + ]
         [ +  + ][ +  - ]
           [ +  +  #  #  
                   #  # ]
     632                 :          1 :             ++m_nDuct;
     633                 :            :           }
     634 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,8) == "pincells"){
                 [ +  + ]
     635         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
     636 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_nPincells;
     637         [ +  - ]:          1 :             if(m_nPincells>0)
     638         [ +  - ]:          1 :               m_Pincell.SetSize(m_nPincells);
     639         [ #  # ]:          0 :             else if(m_nPincells ==0)
     640         [ #  # ]:          0 :               m_Pincell.SetSize(1); // assume for using dummy pincell
     641                 :            : 
     642                 :            :             // count the number of cylinder lines for each pincell
     643         [ +  + ]:          2 :             for (int i=1; i<=m_nPincells; i++){
     644                 :            :                 // read the no. of input lines first pincell
     645         [ -  + ]:          1 :                 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     646         [ +  - ]:          1 :                                          MAXCHARS, szComment))
     647         [ #  # ]:          0 :                   IOErrorHandler (INVALIDINPUT);
     648         [ +  - ]:          1 :                 std::istringstream szFormatString1 (szInputString);
     649 [ +  - ][ +  - ]:          1 :                 szFormatString1 >> szVolId >> szVolAlias >> nInputLines;
                 [ +  - ]
     650 [ +  - ][ -  + ]:          1 :                 if(szFormatString1.fail())
     651         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
     652                 :            :                 // loop thru the input lines of each pincell
     653         [ +  + ]:          4 :                 for(int l=1; l<=nInputLines; l++){
     654         [ -  + ]:          3 :                     if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     655         [ +  - ]:          3 :                                              MAXCHARS, szComment))
     656         [ #  # ]:          0 :                       IOErrorHandler (INVALIDINPUT);
     657 [ +  - ][ +  - ]:          3 :                     if (szInputString.substr(0,8) == "cylinder" || szInputString.substr(0,7) == "frustum"){
         [ +  + ][ +  - ]
         [ +  - ][ -  + ]
         [ +  + ][ +  - ]
           [ +  +  #  #  
                   #  # ]
     658                 :          1 :                         ++nCyl;
     659                 :            :                       }
     660 [ +  - ][ +  - ]:          3 :                     if (szInputString.substr(0,12) == "cellmaterial"){
                 [ -  + ]
     661                 :          0 :                         ++nCellMat;
     662                 :            :                       }
     663                 :            :                   }
     664                 :            : 
     665                 :            :                 // set the sizes
     666         [ +  - ]:          1 :                 if(nCyl>0){
     667         [ -  + ]:          1 :                     if  (nCellMat!=0){
     668 [ #  # ][ #  # ]:          0 :                         m_Pincell(i).SetCellMatSize(nCyl);
     669                 :            :                       }
     670 [ +  - ][ +  - ]:          1 :                     m_Pincell(i).SetNumCyl(nCyl);
     671                 :            :                   }
     672         [ #  # ]:          0 :                 else if(nCyl ==0){
     673         [ #  # ]:          0 :                     if(nInputLines >0)
     674 [ #  # ][ #  # ]:          0 :                       m_Pincell(i).SetCellMatSize(nCellMat);
     675                 :            :                   }
     676                 :          1 :                 nCyl = 0;
     677                 :          1 :                 nCellMat = 0;
     678                 :          2 :               }
     679                 :            :           }
     680                 :            :         // info flag
     681 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,4) == "info"){
                 [ -  + ]
     682         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     683 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_szInfo;
     684 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     685                 :            :           }
     686                 :            :         // merge
     687 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,7) == "imprint"){
                 [ -  + ]
     688                 :          0 :             m_bimprint = true;
     689 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     690                 :            :           }
     691                 :            :         // imprint
     692 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,5) == "merge"){
                 [ +  + ]
     693                 :          1 :             m_bmerge = true;
     694 [ +  - ][ +  - ]:          1 :             std::cout <<"--------------------------------------------------"<<std::endl;
     695                 :            :           }
     696                 :            :         // info flag
     697 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,6) == "smooth"){
                 [ -  + ]
     698         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     699 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_szSmooth;
     700 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     701                 :            :           }
     702                 :            :         // mesh scheme - hole or pave
     703 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0, 10) == "meshscheme") {
                 [ -  + ]
     704         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
     705 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_szMeshScheme;
     706                 :            :           }
     707                 :            :         // hex block along z
     708 [ +  - ][ +  - ]:         17 :         if (szInputString.substr(0,6) == "hblock"){
                 [ -  + ]
     709         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
     710 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nHblock >> m_dZstart >> m_dZend;
         [ #  # ][ #  # ]
     711 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
     712                 :            :           }
     713                 :            :         // breaking condition
     714 [ +  - ][ +  - ]:         17 :         if(szInputString.substr(0,3) == "end" || m_nLineNumber == MAXLINES){
         [ +  + ][ -  + ]
                 [ +  - ]
           [ +  +  #  # ]
     715                 :          1 :             break;
     716                 :            :           }
     717                 :         16 :       }
     718                 :            : 
     719         [ +  - ]:          1 :     if(strcmp(m_szInfo.c_str(),"on") == 0){
     720 [ +  - ][ +  - ]:          1 :         std::cout  << m_szAssmInfo <<std::endl;
     721         [ -  + ]:          1 :         do{
     722         [ +  - ]:          1 :             m_AssmInfo.open (m_szAssmInfo.c_str(), std::ios::out);
     723 [ +  - ][ -  + ]:          1 :             if (!m_AssmInfo){
     724 [ #  # ][ #  # ]:          0 :                 std::cout << "Unable to open o/p file: " << m_szAssmInfo << std::endl;
                 [ #  # ]
     725         [ #  # ]:          0 :                 m_AssmInfo.clear ();
     726                 :          0 :                 exit(1);
     727                 :            :               }
     728                 :            :             else
     729                 :          1 :               bDone = true; // file opened successfully
     730                 :          1 :           } while (!bDone);
     731                 :            : 
     732                 :            :         // write header for info file
     733 [ +  - ][ +  - ]:          1 :         m_AssmInfo <<"pincell"<<  " \t" <<
     734 [ +  - ][ +  - ]:          1 :                      "m" << " \t" << "n" << " \t" << "dX" << " \t" <<
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     735 [ +  - ][ +  - ]:          1 :                      "dY" << " \t" << "dZ"  << std::endl;
         [ +  - ][ +  - ]
     736                 :            :       }
     737                 :            :     // set the size of cp_inpins matrix
     738                 :            :     //  cp_inpins.resize(m_nDuct);
     739         [ +  + ]:          2 :     for (int j=0; j<m_nDuct ; j++)
     740 [ +  - ][ +  - ]:          2 :       cp_inpins.push_back(std::vector<iBase_EntityHandle>());
     741                 :            : 
     742                 :          1 :   }
     743                 :            : 
     744                 :          1 :   void AssyGen::ReadPinCellData (int i)
     745                 :            :   //---------------------------------------------------------------------------
     746                 :            :   //Function: reading pincell i from file and storing the data
     747                 :            :   //Input:    none
     748                 :            :   //Output:   none
     749                 :            :   //---------------------------------------------------------------------------
     750                 :            :   {
     751         [ +  - ]:          1 :     CParser Parse;
     752 [ +  - ][ +  - ]:          2 :     std::string card, szVolId, szVolAlias, szIFlag;
         [ +  - ][ +  - ]
     753                 :          1 :     int nInputLines, nMaterials, nCyl = 0, nRadii=0, nCellMat=0;
     754                 :          1 :     double dLZ=0.0, dFlatF=0.0, dPX=0.0, dPY=0.0, dPZ=0.0;
     755 [ +  - ][ +  - ]:          2 :     CVector <std::string> szVMatName, szVMatAlias, szVCylMat, szVCellMat;
         [ +  - ][ +  - ]
     756 [ +  - ][ +  - ]:          2 :     CVector<double> dVCoor(2), dVCylRadii, dVCylZPos, dZVStart, dZVEnd;
         [ +  - ][ +  - ]
                 [ +  - ]
     757                 :            : 
     758                 :            :     //loop over input lines
     759 [ +  - ][ +  - ]:          1 :     if (m_szGeomType == "rectangular"){
     760                 :            : 
     761         [ +  - ]:          1 :         std::cout << "\ngetting volume id";
     762         [ -  + ]:          1 :         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     763         [ +  - ]:          1 :                                  MAXCHARS, szComment))
     764         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
     765         [ +  - ]:          1 :         std::istringstream szFormatString (szInputString);
     766 [ +  - ][ +  - ]:          1 :         szFormatString >> szVolId >> szVolAlias >> nInputLines >> szIFlag;
         [ +  - ][ +  - ]
     767                 :            : 
     768                 :            :         // error checking
     769   [ +  -  -  + ]:          2 :         if( (strcmp (szVolAlias.c_str(), "") == 0) ||
                 [ -  + ]
     770                 :          1 :             (strcmp (szVolId.c_str(), "") == 0))
     771         [ #  # ]:          0 :           IOErrorHandler(EPIN);
     772         [ -  + ]:          1 :         if( nInputLines < 0 )
     773         [ #  # ]:          0 :           IOErrorHandler(ENEGATIVE);
     774                 :            : 
     775 [ +  - ][ +  - ]:          1 :         m_Pincell(i).SetLineOne (szVolId, szVolAlias, nInputLines);
         [ +  - ][ +  - ]
     776 [ +  - ][ -  + ]:          1 :         if(szIFlag == "intersect"){
     777 [ #  # ][ #  # ]:          0 :             m_Pincell(i).SetIntersectFlag(1);
     778                 :            :           }
     779                 :            :         else{
     780 [ +  - ][ +  - ]:          1 :             m_Pincell(i).SetIntersectFlag(0);
     781                 :            :           }
     782         [ +  + ]:          4 :         for(int l=1; l<=nInputLines; l++){
     783         [ -  + ]:          3 :             if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     784         [ +  - ]:          3 :                                      MAXCHARS, szComment))
     785         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
     786 [ +  - ][ +  - ]:          3 :             if (szInputString.substr(0,5) == "pitch"){
                 [ +  + ]
     787                 :            : 
     788         [ +  - ]:          1 :                 std::istringstream szFormatString (szInputString);
     789         [ +  - ]:          1 :                 std::cout << "\ngetting pitch data";
     790 [ +  - ][ +  - ]:          1 :                 szFormatString >> card >> dPX >> dPY >> dPZ;
         [ +  - ][ +  - ]
     791                 :            : 
     792 [ +  - ][ +  - ]:          1 :                 if( dPX < 0 || dPY < 0 || dPZ < 0 || szFormatString.fail())
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
     793         [ #  # ]:          0 :                   IOErrorHandler(ENEGATIVE);
     794 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetPitch (dPX, dPY, dPZ);
     795                 :            :               }
     796 [ +  - ][ +  - ]:          3 :             if (szInputString.substr(0,9) == "materials"){
                 [ -  + ]
     797                 :            : 
     798         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     799 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> nMaterials;
     800 [ #  # ][ #  # ]:          0 :                 if(szFormatString.fail())
     801         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
     802                 :            : 
     803                 :            :                 //setting local arrays
     804         [ #  # ]:          0 :                 szVMatName.SetSize(nMaterials);
     805         [ #  # ]:          0 :                 szVMatAlias.SetSize(nMaterials);
     806                 :            : 
     807                 :            :                 //set class variable sizes
     808 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetMatArray(nMaterials);
     809         [ #  # ]:          0 :                 std::cout << "\ngetting material data";
     810         [ #  # ]:          0 :                 for(int j=1; j<= nMaterials; j++){
     811 [ #  # ][ #  # ]:          0 :                     szFormatString >> szVMatName(j) >> szVMatAlias(j);
         [ #  # ][ #  # ]
     812 [ #  # ][ #  # ]:          0 :                     if(szFormatString.fail())
     813         [ #  # ]:          0 :                       IOErrorHandler(INVALIDINPUT);
     814                 :            :                   }
     815 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetMat(szVMatName, szVMatAlias);
         [ #  # ][ #  # ]
     816                 :            :               }
     817 [ +  - ][ +  - ]:          3 :             if (szInputString.substr(0,8) == "cylinder"){
                 [ +  + ]
     818                 :            : 
     819                 :          1 :                 ++nCyl;
     820         [ +  - ]:          1 :                 std::cout << "\ngetting cylinder data";
     821         [ +  - ]:          1 :                 std::istringstream szFormatString (szInputString);
     822 [ +  - ][ +  - ]:          1 :                 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     823 [ +  - ][ -  + ]:          1 :                 if(szFormatString.fail())
     824         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
     825 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
     826 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCylPos(nCyl, dVCoor);
                 [ +  - ]
     827 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCellType(nCyl, 0);
     828                 :            : 
     829                 :            :                 //set local array
     830         [ +  - ]:          1 :                 dVCylRadii.SetSize(2*nRadii);
     831         [ +  - ]:          1 :                 szVCylMat.SetSize(nRadii);
     832         [ +  - ]:          1 :                 dVCylZPos.SetSize(2);
     833 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
     834                 :            : 
     835                 :            :                 // reading ZCoords
     836         [ +  + ]:          3 :                 for(int k=1; k<=2; k++){
     837 [ +  - ][ +  - ]:          2 :                     szFormatString >> dVCylZPos(k);
     838 [ +  - ][ -  + ]:          2 :                     if(szFormatString.fail())
     839         [ #  # ]:          0 :                       IOErrorHandler(INVALIDINPUT);
     840                 :            :                   }
     841 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos);
                 [ +  - ]
     842                 :            : 
     843                 :            :                 // reading Radii
     844         [ +  + ]:          2 :                 for(int l=1; l<= nRadii; l++){
     845 [ +  - ][ +  - ]:          1 :                     szFormatString >> dVCylRadii(l);
     846 [ +  - ][ +  - ]:          1 :                     if( dVCylRadii(l) < 0  || szFormatString.fail())
         [ +  - ][ -  + ]
                 [ -  + ]
     847         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
     848                 :            :                   }
     849 [ +  - ][ +  - ]:          1 :                 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii);
                 [ +  - ]
     850                 :            : 
     851                 :            :                 // reading Material alias
     852         [ +  + ]:          2 :                 for(int m=1; m<= nRadii; m++){
     853 [ +  - ][ +  - ]:          1 :                     szFormatString >> szVCylMat(m);
     854 [ +  - ][ +  - ]:          1 :                     if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail())
         [ +  - ][ -  + ]
                 [ -  + ]
     855         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
     856                 :            :                     // setting stuff for hole scheme determination for meshing
     857 [ -  + ][ #  # ]:          1 :                     if (m > 1 && m_szMeshScheme == "hole" && m_nBLAssemblyMat == 0){
         [ #  # ][ #  # ]
                 [ -  + ]
     858                 :            :                         // find material name for this alias
     859         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
     860 [ #  # ][ #  # ]:          0 :                             if(szVCylMat(m) == m_szAssmMatAlias(ll)){
         [ #  # ][ #  # ]
     861                 :            : 
     862                 :            : #ifdef HAVE_RGG16
     863                 :            :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
     864                 :            : #else
     865 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     866                 :            : #endif
     867                 :            :                               }
     868                 :            :                           }
     869                 :            :                       }
     870 [ +  - ][ +  - ]:          1 :                     m_Pincell(i).SetCylMat(nCyl, szVCylMat);
                 [ +  - ]
     871                 :          1 :                   }
     872                 :            :               }
     873 [ +  - ][ +  - ]:          3 :             if (szInputString.substr(0,7) == "frustum"){
                 [ -  + ]
     874                 :            : 
     875                 :          0 :                 ++nCyl;
     876         [ #  # ]:          0 :                 std::cout << "\ngetting frustum data";
     877         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     878 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     879 [ #  # ][ #  # ]:          0 :                 if(szFormatString.fail())
     880         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
     881 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
     882 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylPos(nCyl, dVCoor);
                 [ #  # ]
     883 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCellType(nCyl, 1);
     884                 :            : 
     885                 :            :                 //set local array
     886         [ #  # ]:          0 :                 dVCylRadii.SetSize(2*nRadii);
     887         [ #  # ]:          0 :                 szVCylMat.SetSize(nRadii);
     888         [ #  # ]:          0 :                 dVCylZPos.SetSize(2);
     889 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
     890                 :            : 
     891                 :            :                 // reading ZCoords
     892         [ #  # ]:          0 :                 for(int k=1; k<=2; k++){
     893 [ #  # ][ #  # ]:          0 :                     szFormatString >> dVCylZPos(k);
     894 [ #  # ][ #  # ]:          0 :                     if(szFormatString.fail())
     895         [ #  # ]:          0 :                       IOErrorHandler(INVALIDINPUT);
     896                 :            :                   }
     897 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos);
                 [ #  # ]
     898                 :            : 
     899                 :            :                 // reading Radii
     900         [ #  # ]:          0 :                 for(int l=1; l<= 2*nRadii; l++){
     901 [ #  # ][ #  # ]:          0 :                     szFormatString >> dVCylRadii(l);
     902 [ #  # ][ #  # ]:          0 :                     if( dVCylRadii(l) < 0  || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
     903         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
     904                 :            :                   }
     905 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii);
                 [ #  # ]
     906                 :            : 
     907                 :            :                 // reading Material alias
     908         [ #  # ]:          0 :                 for(int m=1; m<= nRadii; m++){
     909 [ #  # ][ #  # ]:          0 :                     szFormatString >> szVCylMat(m);
     910 [ #  # ][ #  # ]:          0 :                     if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
     911         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
     912                 :            :                     // setting stuff for hole scheme determination for meshing
     913 [ #  # ][ #  # ]:          0 :                     if (m > 2 && m_szMeshScheme == "hole"){
         [ #  # ][ #  # ]
     914                 :            :                         // find material name for this alias
     915         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
     916 [ #  # ][ #  # ]:          0 :                             if(szVCylMat(m) == m_szAssmMatAlias(ll)){
         [ #  # ][ #  # ]
     917                 :            : #ifdef HAVE_RGG16
     918                 :            :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
     919                 :            : #else
     920 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     921                 :            : #endif
     922                 :            :                               }
     923                 :            :                           }
     924                 :            :                       }
     925                 :            :                   }
     926 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylMat(nCyl, szVCylMat);
                 [ #  # ]
     927                 :            :               }
     928 [ +  - ][ +  - ]:          3 :             if (szInputString.substr(0,12) == "cellmaterial"){
                 [ -  + ]
     929                 :            : 
     930         [ #  # ]:          0 :                 std::cout << "\ngetting cell material data\n";
     931         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     932         [ #  # ]:          0 :                 szFormatString >> card;
     933                 :            : 
     934                 :            :                 //set local arrays
     935 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).GetCellMatSize(nCellMat); // since size of cell material already set equal to number of cylinders
     936         [ #  # ]:          0 :                 dZVStart.SetSize(nCellMat);
     937         [ #  # ]:          0 :                 dZVEnd.SetSize(nCellMat);
     938         [ #  # ]:          0 :                 szVCellMat.SetSize(nCellMat);
     939                 :            : 
     940         [ #  # ]:          0 :                 for(int k=1; k<=nCellMat; k++){
     941 [ #  # ][ #  # ]:          0 :                     szFormatString >> dZVStart(k)>> dZVEnd(k) >> szVCellMat(k);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     942 [ #  # ][ #  # ]:          0 :                     if(strcmp (szVCellMat(k).c_str(), "") == 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
     943         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
     944                 :            :                   }
     945 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCellMat(dZVStart, dZVEnd, szVCellMat);
         [ #  # ][ #  # ]
                 [ #  # ]
     946                 :            :               }
     947                 :          1 :           }
     948                 :            :       }//if rectangular ends
     949                 :            : 
     950 [ +  - ][ -  + ]:          1 :     if (m_szGeomType == "hexagonal"){
     951                 :            : 
     952         [ #  # ]:          0 :         std::cout << "\ngetting volume id";
     953         [ #  # ]:          0 :         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     954         [ #  # ]:          0 :                                  MAXCHARS, szComment))
     955         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
     956         [ #  # ]:          0 :         std::istringstream szFormatString (szInputString);
     957 [ #  # ][ #  # ]:          0 :         szFormatString >> szVolId >> szVolAlias >> nInputLines >> szIFlag;
         [ #  # ][ #  # ]
     958                 :            : 
     959                 :            :         // error checking
     960   [ #  #  #  # ]:          0 :         if( (strcmp (szVolAlias.c_str(), "") == 0) ||
                 [ #  # ]
     961                 :          0 :             (strcmp (szVolId.c_str(), "") == 0))
     962         [ #  # ]:          0 :           IOErrorHandler(EPIN);
     963         [ #  # ]:          0 :         if( nInputLines < 0 )
     964         [ #  # ]:          0 :           IOErrorHandler(ENEGATIVE);
     965                 :            : 
     966 [ #  # ][ #  # ]:          0 :         m_Pincell(i).SetLineOne (szVolId, szVolAlias, nInputLines);
         [ #  # ][ #  # ]
     967 [ #  # ][ #  # ]:          0 :         if(szIFlag == "intersect"){
     968 [ #  # ][ #  # ]:          0 :             m_Pincell(i).SetIntersectFlag(1);
     969                 :            :           }
     970                 :            :         else{
     971 [ #  # ][ #  # ]:          0 :             m_Pincell(i).SetIntersectFlag(0);
     972                 :            :           }
     973         [ #  # ]:          0 :         for(int l=1; l<=nInputLines; l++){
     974         [ #  # ]:          0 :             if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
     975         [ #  # ]:          0 :                                      MAXCHARS, szComment))
     976         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
     977 [ #  # ][ #  # ]:          0 :             if (szInputString.substr(0,5) == "pitch"){
                 [ #  # ]
     978                 :            : 
     979         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     980         [ #  # ]:          0 :                 std::cout << "\ngetting pitch data";
     981 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> dFlatF >> dLZ;
                 [ #  # ]
     982 [ #  # ][ #  # ]:          0 :                 if( dFlatF < 0 || dLZ < 0  || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
     983         [ #  # ]:          0 :                   IOErrorHandler(ENEGATIVE);
     984 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetPitch (dFlatF, dLZ);
     985                 :            :               }
     986 [ #  # ][ #  # ]:          0 :             if (szInputString.substr(0,9) == "materials"){
                 [ #  # ]
     987                 :            : 
     988         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
     989 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> nMaterials;
     990 [ #  # ][ #  # ]:          0 :                 if(szFormatString.fail())
     991         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
     992                 :            :                 //setting local arrays
     993         [ #  # ]:          0 :                 szVMatName.SetSize(nMaterials);
     994         [ #  # ]:          0 :                 szVMatAlias.SetSize(nMaterials);
     995                 :            : 
     996                 :            :                 //set class variable sizes
     997 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetMatArray(nMaterials);
     998         [ #  # ]:          0 :                 std::cout << "\ngetting material data";
     999         [ #  # ]:          0 :                 for(int j=1; j<= nMaterials; j++){
    1000 [ #  # ][ #  # ]:          0 :                     szFormatString >> szVMatName(j) >> szVMatAlias(j);
         [ #  # ][ #  # ]
    1001 [ #  # ][ #  # ]:          0 :                     if(szFormatString.fail())
    1002         [ #  # ]:          0 :                       IOErrorHandler(INVALIDINPUT);
    1003                 :            :                   }
    1004 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetMat(szVMatName, szVMatAlias);
         [ #  # ][ #  # ]
    1005                 :            :               }
    1006 [ #  # ][ #  # ]:          0 :             if (szInputString.substr(0,8) == "cylinder"){
                 [ #  # ]
    1007                 :            : 
    1008                 :          0 :                 ++nCyl;
    1009         [ #  # ]:          0 :                 std::cout << "\ngetting cylinder data";
    1010         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
    1011 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1012 [ #  # ][ #  # ]:          0 :                 if(szFormatString.fail())
    1013         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
    1014 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
    1015 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylPos(nCyl, dVCoor);
                 [ #  # ]
    1016 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCellType(nCyl, 0);
    1017                 :            : 
    1018                 :            :                 //set local array
    1019         [ #  # ]:          0 :                 dVCylRadii.SetSize(2*nRadii);
    1020         [ #  # ]:          0 :                 szVCylMat.SetSize(nRadii);
    1021         [ #  # ]:          0 :                 dVCylZPos.SetSize(2);
    1022                 :            :                 //
    1023 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
    1024                 :            : 
    1025                 :            :                 // reading ZCoords - max and min 2 always
    1026         [ #  # ]:          0 :                 for(int k=1; k<=2; k++)
    1027 [ #  # ][ #  # ]:          0 :                   szFormatString >> dVCylZPos(k);
    1028 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos);
                 [ #  # ]
    1029                 :            : 
    1030                 :            :                 // reading Radii
    1031         [ #  # ]:          0 :                 for(int l=1; l<= nRadii; l++){
    1032 [ #  # ][ #  # ]:          0 :                     szFormatString >> dVCylRadii(l);
    1033 [ #  # ][ #  # ]:          0 :                     if( dVCylRadii(l) < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1034         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
    1035                 :            :                   }
    1036 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii);
                 [ #  # ]
    1037                 :            : 
    1038                 :            :                 // reading Material alias
    1039         [ #  # ]:          0 :                 for(int m=1; m<= nRadii; m++){
    1040 [ #  # ][ #  # ]:          0 :                     szFormatString >> szVCylMat(m);
    1041 [ #  # ][ #  # ]:          0 :                     if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1042         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    1043                 :            :                     // setting stuff for hole scheme determination for meshing
    1044 [ #  # ][ #  # ]:          0 :                     if (m > 1 && m_szMeshScheme == "hole" && m_nBLAssemblyMat == 0){
         [ #  # ][ #  # ]
                 [ #  # ]
    1045                 :            :                         // find material name for this alias
    1046         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1047                 :            :                             //   if(szVCylMat(m) == m_szAssmMatAlias(ll))
    1048 [ #  # ][ #  # ]:          0 :                             if(strcmp (m_szAssmMatAlias(ll).c_str(), szVCylMat(m).c_str()) == 0){
                 [ #  # ]
    1049                 :            : #ifdef HAVE_RGG16
    1050                 :            :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1051                 :            : #else
    1052 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1053                 :            : #endif
    1054                 :            :                               }
    1055                 :            :                           }
    1056                 :            :                       }
    1057                 :            :                   }
    1058                 :            : 
    1059 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylMat(nCyl, szVCylMat);
                 [ #  # ]
    1060                 :            :               }
    1061 [ #  # ][ #  # ]:          0 :             if (szInputString.substr(0,7) == "frustum"){
                 [ #  # ]
    1062                 :            : 
    1063                 :          0 :                 ++nCyl;
    1064         [ #  # ]:          0 :                 std::cout << "\ngetting frustum data";
    1065         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
    1066 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1067 [ #  # ][ #  # ]:          0 :                 if(szFormatString.fail())
    1068         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
    1069 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
    1070 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylPos(nCyl, dVCoor);
                 [ #  # ]
    1071 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCellType(nCyl, 1);
    1072                 :            : 
    1073                 :            :                 //set local array
    1074         [ #  # ]:          0 :                 dVCylRadii.SetSize(2*nRadii);
    1075         [ #  # ]:          0 :                 szVCylMat.SetSize(nRadii);
    1076         [ #  # ]:          0 :                 dVCylZPos.SetSize(2);
    1077 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylSizes(nCyl, nRadii);
    1078                 :            : 
    1079                 :            :                 // reading ZCoords
    1080         [ #  # ]:          0 :                 for(int k=1; k<=2; k++){
    1081 [ #  # ][ #  # ]:          0 :                     szFormatString >> dVCylZPos(k);
    1082 [ #  # ][ #  # ]:          0 :                     if(szFormatString.fail())
    1083         [ #  # ]:          0 :                       IOErrorHandler(INVALIDINPUT);
    1084                 :            :                   }
    1085 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos);
                 [ #  # ]
    1086                 :            : 
    1087                 :            :                 // reading Radii
    1088         [ #  # ]:          0 :                 for(int l=1; l<= 2*nRadii; l++){
    1089 [ #  # ][ #  # ]:          0 :                     szFormatString >> dVCylRadii(l);
    1090 [ #  # ][ #  # ]:          0 :                     if( dVCylRadii(l) < 0  || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1091         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
    1092                 :            :                   }
    1093 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii);
                 [ #  # ]
    1094                 :            : 
    1095                 :            :                 // reading Material alias
    1096         [ #  # ]:          0 :                 for(int m=1; m<= nRadii; m++){
    1097 [ #  # ][ #  # ]:          0 :                     szFormatString >> szVCylMat(m);
    1098 [ #  # ][ #  # ]:          0 :                     if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1099         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    1100                 :            :                     // setting stuff for hole scheme determination for meshing
    1101 [ #  # ][ #  # ]:          0 :                     if (m > 2 && m_szMeshScheme == "hole"){
         [ #  # ][ #  # ]
    1102                 :            :                         // find material name for this alias
    1103         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1104 [ #  # ][ #  # ]:          0 :                             if(szVCylMat(m) == m_szAssmMatAlias(ll)){
         [ #  # ][ #  # ]
    1105                 :            : #ifdef HAVE_RGG16
    1106                 :            :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1107                 :            : #else
    1108 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1109                 :            : #endif
    1110                 :            :                               }
    1111                 :            :                           }
    1112                 :            :                       }
    1113                 :            :                   }
    1114 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCylMat(nCyl, szVCylMat);
                 [ #  # ]
    1115                 :            :               }
    1116 [ #  # ][ #  # ]:          0 :             if (szInputString.substr(0,12) == "cellmaterial"){
                 [ #  # ]
    1117                 :            : 
    1118         [ #  # ]:          0 :                 std::cout << "\ngetting cell material data";
    1119         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
    1120         [ #  # ]:          0 :                 szFormatString >> card;
    1121                 :            : 
    1122                 :            :                 //set local arrays
    1123 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).GetCellMatSize(nCellMat); // since size of cell material already set equal to number of cylinders
    1124         [ #  # ]:          0 :                 dZVStart.SetSize(nCellMat);
    1125         [ #  # ]:          0 :                 dZVEnd.SetSize(nCellMat);
    1126         [ #  # ]:          0 :                 szVCellMat.SetSize(nCellMat);
    1127                 :            : 
    1128         [ #  # ]:          0 :                 for(int k=1; k<=nCellMat; k++){
    1129 [ #  # ][ #  # ]:          0 :                     szFormatString >> dZVStart(k)>> dZVEnd(k) >> szVCellMat(k);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1130 [ #  # ][ #  # ]:          0 :                     if(strcmp (szVCellMat(k).c_str(), "") == 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1131         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    1132                 :            :                   }
    1133 [ #  # ][ #  # ]:          0 :                 m_Pincell(i).SetCellMat(dZVStart, dZVEnd, szVCellMat);
         [ #  # ][ #  # ]
                 [ #  # ]
    1134                 :            :               }
    1135                 :          0 :           }
    1136                 :          1 :       }// if hexagonal end
    1137                 :            : 
    1138                 :          1 :   }
    1139                 :            : 
    1140                 :            : 
    1141                 :          1 :   void AssyGen::ReadAndCreate()
    1142                 :            :   //---------------------------------------------------------------------------
    1143                 :            :   //Function: reads the input file and creates assembly
    1144                 :            :   //Input:    none
    1145                 :            :   //Output:   none
    1146                 :            :   //---------------------------------------------------------------------------
    1147                 :            :   {
    1148                 :            :     //Rewind the input file
    1149         [ +  - ]:          1 :     m_FileInput.clear (std::ios_base::goodbit);
    1150         [ +  - ]:          1 :     m_FileInput.seekg (0L, std::ios::beg);
    1151                 :          1 :     m_nLineNumber = 0;
    1152         [ +  - ]:          1 :     CParser Parse;
    1153         [ +  - ]:          2 :     std::string card;
    1154                 :            : 
    1155                 :            :     // start reading the input file break when encounter end
    1156                 :            :     for(;;){
    1157         [ -  + ]:         13 :         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
    1158         [ +  - ]:         13 :                                  MAXCHARS, szComment))
    1159         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
    1160 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,12) == "geometrytype"){
                 [ +  + ]
    1161         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1162 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_szGeomType;
    1163 [ +  - ][ -  + ]:          3 :             if( ((strcmp (m_szGeomType.c_str(), "hexagonal") != 0) &&
    1164 [ +  - ][ +  - ]:          2 :                  (strcmp (m_szGeomType.c_str(), "rectangular") != 0)) || szFormatString.fail())
                 [ -  + ]
    1165         [ #  # ]:          0 :               IOErrorHandler(EGEOMTYPE);
    1166                 :            : 
    1167                 :            :             // set the number of sides in the geometry
    1168 [ +  - ][ -  + ]:          1 :             if(m_szGeomType == "hexagonal")
    1169                 :          0 :               m_nSides = 6;
    1170 [ +  - ][ +  - ]:          1 :             else  if(m_szGeomType == "rectangular")
    1171                 :          1 :               m_nSides = 4;
    1172                 :            :           }
    1173                 :            : 
    1174 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,8) == "geometry"){
                 [ +  + ]
    1175         [ +  - ]:          1 :             std::string outfile;
    1176         [ +  - ]:          2 :             std::istringstream szFormatString (szInputString);
    1177 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> outfile;
    1178 [ +  - ][ +  - ]:          1 :             if(strcmp (outfile.c_str(), "surface") == 0 || szFormatString.fail())
         [ -  + ][ -  + ]
    1179                 :          1 :               m_nPlanar=1;
    1180                 :            :           }
    1181 [ +  - ][ +  - ]:         39 :         if( (szInputString.substr(0,10) == "dimensions") ||
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
    1182 [ +  - ][ +  - ]:         26 :             (szInputString.substr(0,4) == "duct") ){
         [ +  - ][ #  # ]
    1183                 :            : 
    1184                 :          1 :             ++m_nDuctNum;
    1185 [ +  - ][ +  - ]:          1 :             std::cout << "getting assembly dimensions " << m_nDuctNum << std::endl;
                 [ +  - ]
    1186                 :            : 
    1187 [ +  - ][ -  + ]:          1 :             if(m_szGeomType =="hexagonal"){
    1188         [ #  # ]:          0 :                 std::istringstream szFormatString (szInputString);
    1189                 :            : 
    1190         [ #  # ]:          0 :                 if(m_nDuctNum == 1){
    1191 [ #  # ][ #  # ]:          0 :                     m_dMXYAssm.SetSize(m_nDuct, 2); m_dMZAssm.SetSize(m_nDuct, 2);
    1192                 :            :                   }
    1193 [ #  # ][ #  # ]:          0 :                 szFormatString >> card >> m_nDimensions
    1194 [ #  # ][ #  # ]:          0 :                     >> m_dMXYAssm(m_nDuctNum, 1) >> m_dMXYAssm(m_nDuctNum, 2)
         [ #  # ][ #  # ]
    1195 [ #  # ][ #  # ]:          0 :                                                  >> m_dMZAssm(m_nDuctNum, 1) >> m_dMZAssm(m_nDuctNum, 2);
         [ #  # ][ #  # ]
    1196         [ #  # ]:          0 :                 if(m_nDuctNum == 1){
    1197 [ #  # ][ #  # ]:          0 :                     m_dMAssmPitch.SetSize(m_nDuct, m_nDimensions); m_szMMAlias.SetSize(m_nDuct, m_nDimensions);
    1198                 :            : 
    1199         [ #  # ]:          0 :                     assms.resize(m_nDimensions*m_nDuct); // setup while reading the problem size
    1200                 :            :                     // Declaration for python script
    1201 [ #  # ][ #  # ]:          0 :                     m_PyCubGeomFile << "assms = range(" << m_nDimensions*m_nDuct << ")\ncp_inpins  = []\n" << std::endl;
         [ #  # ][ #  # ]
    1202                 :            :                   }
    1203                 :            : 
    1204         [ #  # ]:          0 :                 for (int i=1; i<=m_nDimensions; i++){
    1205 [ #  # ][ #  # ]:          0 :                     szFormatString >> m_dMAssmPitch(m_nDuctNum, i);
    1206 [ #  # ][ #  # ]:          0 :                     if( m_dMAssmPitch(m_nDuctNum, i) < 0 )
    1207         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
    1208                 :            :                   }
    1209                 :            : 
    1210         [ #  # ]:          0 :                 for (int i=1; i<=m_nDimensions; i++){
    1211 [ #  # ][ #  # ]:          0 :                     szFormatString >> m_szMMAlias(m_nDuctNum, i);
    1212 [ #  # ][ #  # ]:          0 :                     if(strcmp (m_szMMAlias(m_nDuctNum, i).c_str(), "") == 0)
    1213         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    1214 [ #  # ][ #  # ]:          0 :                     m_szDuctMats.push_back(m_szMMAlias(m_nDuctNum, i));
    1215                 :            :                     // this is the innermost duct add to group for journaling later
    1216         [ #  # ]:          0 :                     if (i==1){
    1217                 :            :                         // find material name for this alias
    1218         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1219                 :            :                             //   if(szVCylMat(m) == m_szAssmMatAlias(ll))
    1220 [ #  # ][ #  # ]:          0 :                             if(strcmp (m_szAssmMatAlias(ll).c_str(),  m_szMMAlias(m_nDuctNum, i).c_str()) == 0){
                 [ #  # ]
    1221                 :            : #ifdef HAVE_RGG16
    1222                 :            :                                 m_FileOutput << "group 'innerduct' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1223                 :            : #else
    1224 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'innerduct' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1225                 :            : #endif
    1226                 :            :                               }
    1227                 :            :                           }
    1228                 :            :                       }
    1229                 :            :                     // setting stuff for hole scheme determination for meshing
    1230 [ #  # ][ #  # ]:          0 :                     if (i > 1 && m_szMeshScheme == "hole"){
         [ #  # ][ #  # ]
    1231                 :            :                         // find material name for this alias
    1232         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1233                 :            :                             //   if(szVCylMat(m) == m_szAssmMatAlias(ll))
    1234 [ #  # ][ #  # ]:          0 :                             if(strcmp (m_szAssmMatAlias(ll).c_str(),  m_szMMAlias(m_nDuctNum, i).c_str()) == 0)
                 [ #  # ]
    1235                 :            : #ifdef HAVE_RGG16                              
    1236                 :            :                               m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1237                 :            : #else
    1238 [ #  # ][ #  # ]:          0 :                               m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1239                 :            : #endif
    1240                 :            :                           }
    1241                 :            :                       }
    1242                 :          0 :                   }
    1243                 :            :               }
    1244 [ +  - ][ +  - ]:          1 :             if(m_szGeomType =="rectangular"){
    1245         [ +  - ]:          1 :                 std::istringstream szFormatString (szInputString);
    1246         [ +  - ]:          1 :                 if(m_nDuctNum == 1){
    1247         [ +  - ]:          1 :                     m_dMXYAssm.SetSize(m_nDuct, 2);
    1248         [ +  - ]:          1 :                     m_dMZAssm.SetSize(m_nDuct, 2);
    1249                 :            :                   }
    1250 [ +  - ][ +  - ]:          1 :                 szFormatString >> card >> m_nDimensions
    1251 [ +  - ][ +  - ]:          2 :                     >> m_dMXYAssm(m_nDuctNum, 1) >> m_dMXYAssm(m_nDuctNum, 2)
         [ +  - ][ +  - ]
    1252 [ +  - ][ +  - ]:          2 :                                                  >> m_dMZAssm(m_nDuctNum, 1) >> m_dMZAssm(m_nDuctNum, 2);
         [ +  - ][ +  - ]
    1253 [ +  - ][ -  + ]:          1 :                 if (szFormatString.fail())
    1254         [ #  # ]:          0 :                   IOErrorHandler(INVALIDINPUT);
    1255         [ +  - ]:          1 :                 if(m_nDuctNum == 1){
    1256         [ +  - ]:          1 :                     m_dMAssmPitchX.SetSize(m_nDuct, m_nDimensions);
    1257         [ +  - ]:          1 :                     m_dMAssmPitchY.SetSize(m_nDuct, m_nDimensions);
    1258         [ +  - ]:          1 :                     m_szMMAlias.SetSize(m_nDuct, m_nDimensions);
    1259         [ +  - ]:          1 :                     assms.resize(m_nDimensions*m_nDuct);
    1260                 :            :                     // Declaration for python script
    1261 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "assms = range(" << m_nDimensions*m_nDuct << ")\ncp_inpins  = []\n" << std::endl;
         [ +  - ][ +  - ]
    1262                 :            :                   }
    1263         [ +  + ]:          3 :                 for (int i=1; i<=m_nDimensions; i++){
    1264 [ +  - ][ +  - ]:          2 :                     szFormatString >> m_dMAssmPitchX(m_nDuctNum, i) >> m_dMAssmPitchY(m_nDuctNum, i);
         [ +  - ][ +  - ]
    1265 [ +  - ][ +  - ]:          2 :                     if( m_dMAssmPitchX(m_nDuctNum, i) < 0 || m_dMAssmPitchY(m_nDuctNum, i) < 0 || szFormatString.fail())
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
                 [ -  + ]
    1266         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
    1267                 :            :                   }
    1268                 :            : 
    1269         [ +  + ]:          3 :                 for (int i=1; i<=m_nDimensions; i++){
    1270 [ +  - ][ +  - ]:          2 :                     szFormatString >> m_szMMAlias(m_nDuctNum, i);
    1271 [ +  - ][ +  - ]:          2 :                     if(strcmp (m_szMMAlias(m_nDuctNum, i).c_str(), "") == 0 || szFormatString.fail())
         [ +  - ][ -  + ]
                 [ -  + ]
    1272         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    1273 [ +  - ][ +  - ]:          2 :                     m_szDuctMats.push_back(m_szMMAlias(m_nDuctNum, i));
    1274                 :            :                     // this is the innermost duct
    1275         [ +  + ]:          2 :                     if (i==1){
    1276                 :            :                         // find material name for this alias
    1277         [ +  + ]:          4 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1278                 :            :                             //   if(szVCylMat(m) == m_szAssmMatAlias(ll))
    1279 [ +  - ][ +  - ]:          3 :                             if(strcmp (m_szAssmMatAlias(ll).c_str(),  m_szMMAlias(m_nDuctNum, i).c_str()) == 0){
                 [ +  + ]
    1280                 :            : #ifdef HAVE_RGG16
    1281                 :            :                                 m_FileOutput << "group 'innerduct' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1282                 :            : #else
    1283 [ +  - ][ +  - ]:          1 :                                 m_FileOutput << "group 'innerduct' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ +  - ][ +  - ]
                 [ +  - ]
    1284                 :            : #endif
    1285                 :            :                               }
    1286                 :            :                           }
    1287                 :            :                       }
    1288                 :            :                     // setting stuff for hole scheme determination for meshing
    1289 [ +  + ][ +  - ]:          2 :                     if (i > 1 && m_szMeshScheme == "hole"){
         [ -  + ][ -  + ]
    1290                 :            :                         // find material name for this alias
    1291         [ #  # ]:          0 :                         for (int ll=1; ll<= m_nAssemblyMat; ll++){
    1292                 :            :                             //   if(szVCylMat(m) == m_szAssmMatAlias(ll))
    1293 [ #  # ][ #  # ]:          0 :                             if(strcmp (m_szAssmMatAlias(ll).c_str(),  m_szMMAlias(m_nDuctNum, i).c_str()) == 0){
                 [ #  # ]
    1294                 :            : #ifdef HAVE_RGG16
    1295                 :            :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top*'" << std::endl;
    1296                 :            : #else
    1297 [ #  # ][ #  # ]:          0 :                                 m_FileOutput << "group 'hole_surfaces' add surface with name '"<< m_szAssmMat(ll)  << "_top'" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1298                 :            : #endif
    1299                 :            :                               }
    1300                 :            :                           }
    1301                 :            :                       }
    1302                 :          1 :                   }
    1303                 :            :               }
    1304                 :            :           }
    1305 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,8) == "pincells"){
                 [ +  + ]
    1306         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1307                 :            : 
    1308 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_nPincells >> m_dPitch;
                 [ +  - ]
    1309         [ -  + ]:          1 :             if(m_nPincells < 0)
    1310         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
    1311                 :            : 
    1312                 :            :             // this is an option if a user wants to specify pitch here
    1313                 :          1 :             double dTotalHeight = 0.0;
    1314                 :            : 
    1315                 :            :             //get the number of cylinder in each pincell
    1316                 :          1 :             int nTemp = 1;
    1317         [ +  - ]:          1 :             if(m_nDimensions > 0){
    1318 [ +  - ][ +  - ]:          1 :                 dTotalHeight = m_dMZAssm(nTemp, 2)-m_dMZAssm(nTemp, 1);
    1319                 :            :               }
    1320                 :            :             else{
    1321                 :          0 :                 dTotalHeight = 0; // nothing specified only pincells in the model
    1322                 :            :               }
    1323                 :            : 
    1324                 :            :             // loop thro' the pincells and read/store pincell data
    1325         [ +  + ]:          2 :             for (int i=1; i<=m_nPincells; i++){
    1326                 :            : 
    1327                 :            :                 // set pitch if specified in pincell card
    1328         [ -  + ]:          1 :                 if(m_dPitch > 0.0)
    1329 [ #  # ][ #  # ]:          0 :                   m_Pincell(i).SetPitch(m_dPitch, dTotalHeight);
    1330                 :            : 
    1331         [ +  - ]:          1 :                 ReadPinCellData(i);
    1332                 :            :                 //ERRORR("Error in ReadPinCellData", err);
    1333 [ +  - ][ +  - ]:          1 :                 std::cout << "\nread pincell " << i << std::endl;
                 [ +  - ]
    1334                 :          1 :               }
    1335                 :            :           }
    1336 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,8) == "assembly"){
                 [ +  + ]
    1337 [ +  - ][ -  + ]:          1 :             if(m_szGeomType =="hexagonal"){
    1338         [ #  # ]:          0 :                 Create_HexAssm(szInputString);
    1339                 :            :                 //ERRORR("Error in Create_HexAssm", err);
    1340                 :            :               }
    1341 [ +  - ][ +  - ]:          1 :             if(m_szGeomType =="rectangular"){
    1342         [ +  - ]:          1 :                 Create_CartAssm(szInputString);
    1343                 :            :                 //ERRORR("Error in Create_CartAssm", err);
    1344                 :            :               }
    1345         [ +  - ]:          1 :             if (m_nJouFlag == 0){
    1346         [ +  - ]:          1 :                 CreateOuterCovering();
    1347                 :            :                 //ERRORR("Error in CreateOuterCovering", err);
    1348                 :            : 
    1349                 :            :                 // subtract pins before save
    1350         [ +  - ]:          1 :                 if(m_nDuct > 0){
    1351         [ +  - ]:          1 :                     Subtract_Pins();
    1352                 :          1 :                     clock_t s_subtract = clock();
    1353 [ +  - ][ +  - ]:          1 :                     std::cout << "## Subract Pins CPU time used := " << (double) (clock() - s_subtract)/CLOCKS_PER_SEC
    1354 [ +  - ][ +  - ]:          1 :                               << " seconds" << std::endl;
    1355                 :            :                   }
    1356                 :            :               }
    1357                 :            :           }
    1358                 :            : 
    1359                 :            :         // section the assembly as described in section card
    1360 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,7) == "section" && m_nJouFlag == 0){
         [ -  + ][ #  # ]
                 [ +  - ]
           [ -  +  #  # ]
    1361 [ #  # ][ #  # ]:          0 :             std::cout << "Sectioning geometry .." << std::endl;
    1362                 :            :             char cDir;
    1363                 :            :             double dOffset;
    1364         [ #  # ]:          0 :             std::string szReverse = "";
    1365         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1366 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> cDir >> dOffset >> szReverse;
         [ #  # ][ #  # ]
    1367 [ #  # ][ #  # ]:          0 :             Section_Assm(cDir, dOffset, szReverse);
    1368 [ #  # ][ #  # ]:          0 :             m_PyCubGeomFile << "section_assm(\"" << cDir << "\", " << dOffset << ", \"" << szReverse << "\")" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1369                 :            :             //ERRORR("Error in Section_Assm", err);
    1370 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1371                 :            : 
    1372                 :            :           }
    1373 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,4) == "move" && m_nJouFlag == 0){
         [ -  + ][ #  # ]
                 [ +  - ]
           [ -  +  #  # ]
    1374 [ #  # ][ #  # ]:          0 :             std::cout << "Moving geometry .." << std::endl;
    1375                 :            :             double dX, dY, dZ;
    1376         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1377 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> dX >> dY >> dZ;
         [ #  # ][ #  # ]
    1378 [ #  # ][ #  # ]:          0 :             if(szFormatString.fail())
    1379         [ #  # ]:          0 :               IOErrorHandler(INVALIDINPUT);
    1380         [ #  # ]:          0 :             Move_Assm(dX, dY, dZ);
    1381                 :            :             //ERRORR("Error in Move_Assm", err);
    1382 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1383                 :            : 
    1384                 :            :           }
    1385                 :            :         // center the assembly
    1386 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,6) == "center" && m_nJouFlag == 0){
         [ +  + ][ +  - ]
                 [ +  - ]
           [ +  +  #  # ]
    1387                 :            : 
    1388                 :          3 :             char rDir = 'q';
    1389         [ +  - ]:          3 :             std::istringstream szFormatString (szInputString);
    1390 [ +  - ][ +  - ]:          3 :             szFormatString >> card >> rDir;
    1391         [ +  - ]:          3 :             if (rDir != 'q')
    1392 [ +  - ][ +  - ]:          3 :               std::cout << "Positioning assembly to "<< rDir << " center" << std::endl;
         [ +  - ][ +  - ]
    1393                 :            :             else
    1394 [ #  # ][ #  # ]:          0 :               std::cout << "Positioning assembly to xy center" << std::endl;
    1395         [ +  - ]:          3 :             Center_Assm(rDir);
    1396                 :            :             //ERRORR("Error in Center_Assm", err);
    1397 [ +  - ][ +  - ]:          3 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1398                 :            :           }
    1399                 :            :         // rotate the assembly if rotate card is specified
    1400 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,6) == "rotate" && m_nJouFlag == 0){
         [ -  + ][ #  # ]
                 [ +  - ]
           [ -  +  #  # ]
    1401                 :            :             char cDir;
    1402                 :            :             double dAngle;
    1403 [ #  # ][ #  # ]:          0 :             std::cout << "Rotating geometry .." << std::endl;
    1404         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1405 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> cDir >> dAngle;
                 [ #  # ]
    1406 [ #  # ][ #  # ]:          0 :             if(szFormatString.fail())
    1407         [ #  # ]:          0 :               IOErrorHandler(INVALIDINPUT);
    1408         [ #  # ]:          0 :             Rotate_Assm(cDir, dAngle);
    1409                 :            :             //ERRORR("Error in Rotate_Assm", err);
    1410 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1411                 :            : 
    1412                 :            :           }
    1413                 :            :         // 'yes' or 'no' for creating sidesets
    1414 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,13) == "createsideset"){
                 [ +  + ]
    1415         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1416 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_szSideset;
    1417 [ +  - ][ +  - ]:          1 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1418                 :            :           }
    1419                 :            :         // Create specified number of files with varying material ids
    1420 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,11) == "createfiles"){
                 [ -  + ]
    1421         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1422 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nAssyGenInputFiles;
    1423 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1424                 :            :           }
    1425                 :            :         // Create specified number of files with varying material ids
    1426 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,14) == "creatematfiles"){
                 [ -  + ]
    1427                 :          0 :             m_bCreateMatFiles = true;
    1428         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1429 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nAssyGenInputFiles;
    1430 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1431                 :            :           }
    1432                 :            :         // Create specified number of files with varying material ids
    1433 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,11) == "save_exodus"){
                 [ -  + ]
    1434                 :          0 :             save_exodus = true;
    1435 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1436                 :            :           }
    1437                 :            :         // specify a merge tolerance value for cubit journal file
    1438 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,14) == "mergetolerance"){
                 [ +  + ]
    1439         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1440 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_dMergeTol;
    1441 [ +  - ][ +  - ]:          1 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1442                 :            :           }
    1443                 :            :         // Handle mesh size inputs
    1444 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,14) == "radialmeshsize"){
                 [ +  + ]
    1445         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1446 [ +  - ][ +  - ]:          1 :             szFormatString >> card >> m_dRadialSize;
    1447 [ +  - ][ +  - ]:          1 :             if(m_dRadialSize < 0 || szFormatString.fail())
         [ -  + ][ -  + ]
    1448         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
    1449 [ +  - ][ +  - ]:          1 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1450                 :            : 
    1451                 :            :           }
    1452                 :            :         // Handle mesh size inputs
    1453 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,11) == "tetmeshsize"){
                 [ -  + ]
    1454         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1455 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_dTetMeshSize;
    1456 [ #  # ][ #  # ]:          0 :             if(m_dTetMeshSize < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
    1457         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
    1458 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1459                 :            : 
    1460                 :            :           }
    1461                 :            :         // Handle mesh size inputs
    1462 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,13) == "axialmeshsize"){
                 [ +  + ]
    1463         [ +  - ]:          1 :             std::istringstream szFormatString (szInputString);
    1464         [ +  - ]:          1 :             szFormatString >> card;
    1465         [ +  - ]:          1 :             if(m_nDuct > 0){
    1466         [ +  - ]:          1 :                 m_dAxialSize.SetSize(m_nDuct);
    1467                 :            :                 int num_ams_specified = std::distance(std::istream_iterator<std::string>(szFormatString),
    1468 [ +  - ][ +  - ]:          1 :                                                       std::istream_iterator<std::string>());
                 [ +  - ]
    1469         [ +  - ]:          1 :                 std::istringstream szFormatStringAgain (szInputString);
    1470         [ +  - ]:          1 :                 szFormatStringAgain >> card;
    1471         [ +  + ]:          2 :                 for (int p = 1; p <= m_nDuct; p++){
    1472         [ +  - ]:          1 :                     if(p <= num_ams_specified)
    1473 [ +  - ][ +  - ]:          1 :                       szFormatStringAgain >> m_dAxialSize(p);
    1474                 :            :                     else
    1475 [ #  # ][ #  # ]:          0 :                       m_dAxialSize(p) = m_dAxialSize(num_ams_specified);
    1476 [ +  - ][ -  + ]:          1 :                     if(m_dAxialSize(p) < 0)
    1477         [ #  # ]:          0 :                       IOErrorHandler(ENEGATIVE);
    1478                 :          1 :                   }
    1479                 :            :               }
    1480                 :            :             else{
    1481         [ #  # ]:          0 :                 m_dAxialSize.SetSize(1);
    1482 [ #  # ][ #  # ]:          0 :                 szFormatString >> m_dAxialSize(1);
    1483                 :            :               }
    1484 [ +  - ][ +  - ]:          1 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1485                 :            : 
    1486                 :            :           }
    1487                 :            :         // edge interval
    1488 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0, 12) == "edgeinterval") {
                 [ -  + ]
    1489         [ #  # ]:          0 :             std::istringstream szFormatString(szInputString);
    1490 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_edgeInterval;
    1491                 :            :           }
    1492                 :            :         // Handle mesh size inputs
    1493 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,18) == "neumannset_startid"){
                 [ -  + ]
    1494         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1495 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nNeumannSetId;
    1496 [ #  # ][ #  # ]:          0 :             if(m_nNeumannSetId < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
    1497         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
    1498 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1499                 :            : 
    1500                 :            :           }
    1501                 :            :         // Handle mesh size inputs
    1502 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,19) == "materialset_startid"){
                 [ -  + ]
    1503         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1504 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nMaterialSetId;
    1505 [ #  # ][ #  # ]:          0 :             if(m_nMaterialSetId < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
    1506         [ #  # ]:          0 :               IOErrorHandler(ENEGATIVE);
    1507 [ #  # ][ #  # ]:          0 :             std::cout <<"--------------------------------------------------"<<std::endl;
    1508                 :            : 
    1509                 :            :           }
    1510 [ +  - ][ +  - ]:         13 :         if ((szInputString.substr(0,23) == "list_neumannset_startid") ){
                 [ -  + ]
    1511         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1512                 :          0 :             int num_nset_ids = 0;
    1513 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> num_nset_ids;
    1514         [ #  # ]:          0 :             m_nListNeuSet.SetSize(num_nset_ids);
    1515         [ #  # ]:          0 :             for (int p = 1; p <= num_nset_ids; p++){
    1516 [ #  # ][ #  # ]:          0 :                 szFormatString >> m_nListNeuSet(p);
    1517 [ #  # ][ #  # ]:          0 :                 if(m_nListNeuSet(p) < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1518         [ #  # ]:          0 :                   IOErrorHandler(ENEGATIVE);
    1519                 :          0 :               }
    1520                 :            :           }
    1521 [ +  - ][ +  - ]:         13 :         if ((szInputString.substr(0,14) == "numsuperblocks") ){
                 [ -  + ]
    1522         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1523 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> m_nSuperBlocks;
    1524         [ #  # ]:          0 :             sb.SetSize(m_nSuperBlocks);
    1525                 :            :           }
    1526 [ +  - ][ +  - ]:         13 :         if ((szInputString.substr(0,10) == "superblock") ){
                 [ -  + ]
    1527         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1528 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> sb(tmpSB).m_nSuperBlockId  >> sb(tmpSB).m_szSuperBlockAlias >> sb(tmpSB).m_nNumSBContents;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1529 [ #  # ][ #  # ]:          0 :             sb(tmpSB).m_nSBContents.SetSize(sb(tmpSB).m_nNumSBContents);
                 [ #  # ]
    1530 [ #  # ][ #  # ]:          0 :             for (int p = 1; p <= sb(tmpSB).m_nNumSBContents; p++){
    1531 [ #  # ][ #  # ]:          0 :                 szFormatString >> sb(tmpSB).m_nSBContents(p);
                 [ #  # ]
    1532 [ #  # ][ #  # ]:          0 :                 if(sb(tmpSB).m_nSBContents(p) < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1533         [ #  # ]:          0 :                   IOErrorHandler(ENEGATIVE);
    1534                 :            :               }
    1535                 :          0 :             ++tmpSB;
    1536                 :            :           }
    1537 [ +  - ][ +  - ]:         13 :         if ((szInputString.substr(0,24) == "list_materialset_startid") ){
                 [ -  + ]
    1538         [ #  # ]:          0 :             std::istringstream szFormatString (szInputString);
    1539                 :          0 :             int num_mset_ids = 0;
    1540 [ #  # ][ #  # ]:          0 :             szFormatString >> card >> num_mset_ids;
    1541         [ #  # ]:          0 :             m_nListMatSet.SetSize(num_mset_ids);
    1542         [ #  # ]:          0 :             for (int p = 1; p <= num_mset_ids; p++){
    1543 [ #  # ][ #  # ]:          0 :                 szFormatString >> m_nListMatSet(p);
    1544 [ #  # ][ #  # ]:          0 :                 if(m_nListMatSet(p) < 0 || szFormatString.fail())
         [ #  # ][ #  # ]
                 [ #  # ]
    1545         [ #  # ]:          0 :                   IOErrorHandler(ENEGATIVE);
    1546                 :          0 :               }
    1547                 :            :           }
    1548 [ +  - ][ +  - ]:         13 :         if (szInputString.substr(0,3) == "end" || m_nLineNumber == MAXLINES){
         [ +  + ][ -  + ]
                 [ +  - ]
           [ +  +  #  # ]
    1549                 :            :             // if this is a surface only case, delete all the volume entities create so far
    1550         [ -  + ]:          1 :             if(m_nPlanar ==1){
    1551         [ #  # ]:          0 :                 Create2DSurf();
    1552                 :            :               }
    1553         [ +  - ]:          1 :             if ( m_nJouFlag == 0){
    1554                 :            :                 // impring merge before saving
    1555         [ +  - ]:          1 :                 Imprint_Merge(m_bimprint, m_bmerge);
    1556                 :            : 
    1557                 :          1 :                 clock_t s_save= clock();
    1558                 :            :                 // save .sat file
    1559                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1560 [ +  - ][ +  - ]:          1 :                 iGeom_save(igeomImpl->instance(), m_szGeomFile.c_str(), NULL, &err, m_szGeomFile.length() , 0);
    1561                 :            : #endif
    1562                 :            : 
    1563 [ +  - ][ +  - ]:          1 :                 std::cout << "## Saving CPU time used := " << (double) (clock() - s_save)/CLOCKS_PER_SEC
    1564 [ +  - ][ +  - ]:          1 :                           << " seconds" << std::endl;
    1565                 :            : 
    1566 [ +  - ][ +  - ]:          1 :                 m_PyCubGeomFile << "cubit.cmd('export acis \"" <<m_szGeomFile1 << "\" over')\nexit()" << std::endl;
         [ +  - ][ +  - ]
    1567                 :            : 
    1568 [ +  - ][ +  - ]:          1 :                 std::cout << "Normal Termination.\n"<< "Geometry file: " << m_szGeomFile << " saved." << std::endl;
         [ +  - ][ +  - ]
                 [ +  - ]
    1569                 :            :                 //                // Now run the journal file from the python script
    1570                 :            :                 //                m_PyCubGeomFile << "infile = open(\""<< m_szJouFile << "\", \"r\")" << std::endl;
    1571                 :            :                 //                m_PyCubGeomFile << "for line in infile:\n  cubit.cmd(line)" << std::endl;
    1572                 :            : 
    1573                 :            :                 // Reloading file to check load times
    1574                 :          1 :                 bool if_loadagain = false;
    1575         [ -  + ]:          1 :                 if (if_loadagain == true){
    1576                 :          0 :                     clock_t s_load= clock();
    1577                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1578                 :            :                     iGeom_load(igeomImpl->instance(), m_szGeomFile.c_str(), NULL, &err,
    1579 [ #  # ][ #  # ]:          0 :                                strlen(m_szGeomFile.c_str()), 0);
    1580                 :            : #endif
    1581 [ #  # ][ #  # ]:          0 :                     std::cout << "## Load again CPU time used := " << (double) (clock() - s_load)/CLOCKS_PER_SEC
    1582 [ #  # ][ #  # ]:          1 :                               << " seconds" << std::endl;
    1583                 :            :                   }
    1584                 :            :               }
    1585                 :          1 :             break;
    1586                 :            :           }
    1587                 :         13 :       }
    1588                 :            : 
    1589                 :          1 :   }
    1590                 :            : 
    1591                 :          1 :   void AssyGen::CreateAssyGenInputFiles()
    1592                 :            :   //---------------------------------------------------------------------------
    1593                 :            :   //Function: Create Cubit Journal File for generating mesh
    1594                 :            :   //Input:    none
    1595                 :            :   //Output:   none
    1596                 :            :   //---------------------------------------------------------------------------
    1597                 :            :   {
    1598                 :            :     // create file names
    1599         [ +  - ]:          1 :     std::ostringstream os;
    1600 [ +  - ][ +  - ]:          2 :     std::string file, temp, temp1;
                 [ +  - ]
    1601                 :          1 :     int counter_ms = 0;
    1602                 :          1 :     int counter_ns = 0;
    1603         [ -  + ]:          1 :     for(int i=1; i<=m_nAssyGenInputFiles; i++){
    1604                 :            :         // form the name of the AssyGen input file
    1605         [ #  # ]:          0 :         if(m_bCreateMatFiles)
    1606 [ #  # ][ #  # ]:          0 :           os << m_nListMatSet(i) << ".inp";
                 [ #  # ]
    1607                 :            :         else
    1608 [ #  # ][ #  # ]:          0 :           os << m_szFile << i << ".inp";
                 [ #  # ]
    1609         [ #  # ]:          0 :         std::ofstream ofs;
    1610                 :            :         // open input file
    1611                 :            : 
    1612 [ #  # ][ #  # ]:          0 :         std::cout << os.str() << std::endl;
                 [ #  # ]
    1613                 :          0 :         bool bDone = false;
    1614         [ #  # ]:          0 :         do{
    1615 [ #  # ][ #  # ]:          0 :             file = os.str();
    1616         [ #  # ]:          0 :             ofs.open (file.c_str(), std::ios::out);
    1617 [ #  # ][ #  # ]:          0 :             if(!ofs){
    1618         [ #  # ]:          0 :                 ofs.clear();
    1619 [ #  # ][ #  # ]:          0 :                 std::cout << "Unable to open AssyGen Input File(s) for writing" << std::endl;
    1620                 :          0 :                 exit(1);
    1621                 :            :               }
    1622                 :            :             else {
    1623                 :          0 :                 bDone = true;
    1624 [ #  # ][ #  # ]:          0 :                 std::cout << "File Opened" << std::endl;
    1625                 :            :               }
    1626 [ #  # ][ #  # ]:          0 :             os.str("");
    1627                 :            : 
    1628                 :            :             // write the input deck
    1629 [ #  # ][ #  # ]:          0 :             ofs << "! ## This is an automatically created AssyGen Input File: "<< file << std::endl;
                 [ #  # ]
    1630 [ #  # ][ #  # ]:          0 :             ofs << "MeshType " << m_szMeshType << std::endl;
                 [ #  # ]
    1631 [ #  # ][ #  # ]:          0 :             ofs << "GeomEngine " << m_szEngine << std::endl;
                 [ #  # ]
    1632 [ #  # ][ #  # ]:          0 :             ofs << "GeometryType " << m_szGeomType << std::endl;
                 [ #  # ]
    1633 [ #  # ][ #  # ]:          0 :             ofs << "Materials " << m_nAssemblyMat;
    1634                 :            : 
    1635                 :            :             // list all materials and alias with subscripts
    1636         [ #  # ]:          0 :             for (int j =1;j<=m_nAssemblyMat; j++){
    1637         [ #  # ]:          0 :                 if(!m_bCreateMatFiles){
    1638 [ #  # ][ #  # ]:          0 :                     os << m_szAssmMat(j) << "_" << (i-1)*m_nAssemblyMat + j;
         [ #  # ][ #  # ]
    1639 [ #  # ][ #  # ]:          0 :                     temp = os.str();
    1640                 :            : 
    1641 [ #  # ][ #  # ]:          0 :                     ofs << "  " << temp << " " << m_szAssmMatAlias(j);
         [ #  # ][ #  # ]
                 [ #  # ]
    1642 [ #  # ][ #  # ]:          0 :                     os.str("");
    1643                 :            :                   }
    1644                 :            :                 else{
    1645 [ #  # ][ #  # ]:          0 :                     ofs << "  " << m_szAssmMat(j) << " " << m_szAssmMatAlias(j);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1646                 :            :                   }
    1647                 :            :               }
    1648         [ #  # ]:          0 :             ofs << "\n";
    1649                 :            : 
    1650                 :            :             //Rewind the input file
    1651                 :          0 :             int nDumpAllLinesAfter = 0, nMid = 0;
    1652         [ #  # ]:          0 :             m_FileInput.clear (std::ios_base::goodbit);
    1653         [ #  # ]:          0 :             m_FileInput.seekg (0L, std::ios::beg);
    1654                 :          0 :             m_nLineNumber = 0;
    1655         [ #  # ]:          0 :             CParser Parse;
    1656         [ #  # ]:          0 :             std::string card;
    1657                 :            : 
    1658                 :            :             // start reading the input file break when encounter end
    1659                 :            :             for(;;){
    1660         [ #  # ]:          0 :                 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
    1661         [ #  # ]:          0 :                                          MAXCHARS, szComment))
    1662         [ #  # ]:          0 :                   IOErrorHandler (INVALIDINPUT);
    1663                 :            :                 // dump all the lines after duct command, limiting the format for writing AssyGen Files
    1664 [ #  # ][ #  # ]:          0 :                 if( (szInputString.substr(0,10) == "dimensions") ||
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1665 [ #  # ][ #  # ]:          0 :                     (szInputString.substr(0,4) == "duct") ){
         [ #  # ][ #  # ]
    1666 [ #  # ][ #  # ]:          0 :                     ofs << szInputString << std::endl;
    1667                 :          0 :                     nDumpAllLinesAfter = m_nLineNumber;
    1668                 :            :                   }
    1669 [ #  # ][ #  # ]:          0 :                 else if ((szInputString.substr(0,19) == "materialset_startid") ){
                 [ #  # ]
    1670                 :          0 :                     nMid = (i-1)*m_nAssemblyMat + 1;
    1671 [ #  # ][ #  # ]:          0 :                     ofs << "MaterialSet_StartId " << nMid << std::endl;
                 [ #  # ]
    1672                 :            :                   }
    1673 [ #  # ][ #  # ]:          0 :                 else if ((szInputString.substr(0,18) == "neumannset_startid") ){
                 [ #  # ]
    1674                 :          0 :                     nMid = (i-1)*m_nAssemblyMat + 1;
    1675 [ #  # ][ #  # ]:          0 :                     ofs << "NeumannSet_StartId " << nMid << std::endl;
                 [ #  # ]
    1676                 :            :                   }
    1677 [ #  # ][ #  # ]:          0 :                 else if ((szInputString.substr(0,24) == "list_materialset_startid") ){
                 [ #  # ]
    1678                 :          0 :                     ++counter_ms;
    1679 [ #  # ][ #  # ]:          0 :                     ofs << "MaterialSet_StartId " << m_nListMatSet(counter_ms) << std::endl;
         [ #  # ][ #  # ]
    1680                 :            :                   }
    1681 [ #  # ][ #  # ]:          0 :                 else if ((szInputString.substr(0,23) == "list_neumannset_startid") ){
                 [ #  # ]
    1682                 :          0 :                     ++counter_ns;
    1683 [ #  # ][ #  # ]:          0 :                     ofs << "NeumannSet_StartId " << m_nListNeuSet(counter_ns) << std::endl;
         [ #  # ][ #  # ]
    1684                 :            :                   }
    1685 [ #  # ][ #  # ]:          0 :                 else if((szInputString.substr(0,11) == "createfiles")){
                 [ #  # ]
    1686                 :            :                     //skip this line
    1687                 :            :                   }
    1688 [ #  # ][ #  # ]:          0 :                 else if((szInputString.substr(0,14) == "creatematfiles")){
                 [ #  # ]
    1689                 :            :                     //skip this line
    1690                 :            :                   }
    1691 [ #  # ][ #  # ]:          0 :                 else if (nDumpAllLinesAfter > 0 && m_nLineNumber > nDumpAllLinesAfter){
    1692 [ #  # ][ #  # ]:          0 :                     ofs << szInputString << std::endl;
    1693                 :            :                   }
    1694                 :            : 
    1695 [ #  # ][ #  # ]:          0 :                 if (szInputString.substr(0,3) == "end" || m_nLineNumber == MAXLINES){
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1696                 :          0 :                     break;
    1697                 :            :                   }
    1698                 :            :               }
    1699         [ #  # ]:          0 :             ofs.close();
    1700                 :          0 :           } while(!bDone);
    1701                 :          1 :       }
    1702                 :            : 
    1703                 :            : 
    1704                 :            : 
    1705                 :          1 :   }
    1706                 :            : 
    1707                 :         16 :   void AssyGen:: ComputePinCentroid(int nTempPin, CMatrix<std::string> MAssembly,
    1708                 :            :                                     int m, int n, double &dX, double &dY, double &dZ)
    1709                 :            :   // ---------------------------------------------------------------------------
    1710                 :            :   // Function: computes the centroid in the whole assembly of rectangular or hexagonal pincell
    1711                 :            :   // Input:    number and location of the pincell
    1712                 :            :   // Output:   coordinates of pin in assembly
    1713                 :            :   // ---------------------------------------------------------------------------
    1714                 :            :   {
    1715                 :         16 :     int nTempPin1 = -1, nTempPin2 = 0, nInputLines;
    1716 [ +  - ][ +  - ]:         32 :     std::string szVolId, szVolAlias;
    1717 [ +  - ][ -  + ]:         16 :     if(m_szGeomType == "hexagonal"){
    1718                 :            :         double dP, dZ;
    1719 [ #  # ][ #  # ]:          0 :         m_Pincell(nTempPin).GetPitch(dP, dZ);
    1720                 :            : 
    1721         [ #  # ]:          0 :         if (m < m_nPin){
    1722                 :          0 :             dX = (m_nPin - n + 1)*dP/2.0 + n*dP/2.0 + (n-1)*dP - (m-1)*dP/2.0;
    1723                 :          0 :             dY = (m-1)*(0.5*dP/sin(pi/3.0) + 0.5*dP*sin(pi/6.0)/sin(pi/3.0));
    1724                 :            :           }
    1725                 :            :         else{
    1726                 :          0 :             dX = (m_nPin - n + 1)*dP/2.0 + n*dP/2.0 + (n-1)*dP - (2*m_nPin - m -1)*dP/2.0;
    1727                 :          0 :             dY = (m-1)*(0.5*dP/sin(pi/3.0) + 0.5*dP*sin(pi/6.0)/sin(pi/3.0));
    1728                 :            :           }
    1729                 :            :       }
    1730 [ +  - ][ +  - ]:         16 :     if(m_szGeomType == "rectangular"){
    1731                 :            :         double dPX, dPY, dPZ, dPX1, dPY1, dPZ1, dPX2, dPY2, dPZ2;
    1732 [ +  - ][ +  - ]:         16 :         if((m_Assembly(m,n)=="x")||(m_Assembly(m,n)=="xx"))
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
    1733 [ +  - ][ +  - ]:         14 :           m_Pincell(1).GetPitch(dPX, dPY, dPZ);
    1734                 :            :         else
    1735 [ +  - ][ +  - ]:          2 :           m_Pincell(nTempPin).GetPitch(dPX, dPY, dPZ);
    1736                 :            : 
    1737         [ +  + ]:         16 :         if (n==1){
    1738                 :          4 :             dX = 0;
    1739         [ +  + ]:          4 :             if(m==1)
    1740                 :          1 :               dY = 0;
    1741                 :            :           }
    1742                 :            :         else{
    1743                 :         12 :             dX+= dPX/2.0;
    1744                 :            :             // find the previous pincell type
    1745                 :            :             // check if it's dummy
    1746 [ +  - ][ +  - ]:         12 :             if((m_Assembly(m,n-1)=="x")||(m_Assembly(m,n-1)=="xx")){
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
    1747                 :         10 :                 dX+=dPX/2.0;
    1748                 :            :               }
    1749                 :            :             else{
    1750         [ +  + ]:          4 :                 for(int b=1; b<=m_nPincells; b++){
    1751 [ +  - ][ +  - ]:          2 :                     m_Pincell(b).GetLineOne(szVolId, szVolAlias, nInputLines);
    1752 [ +  - ][ +  - ]:          2 :                     if(m_Assembly(m,n-1) == szVolAlias)
                 [ +  - ]
    1753                 :          2 :                       nTempPin1 = b;
    1754                 :            :                   }
    1755         [ -  + ]:          2 :                 if(nTempPin1 == -1){
    1756 [ #  # ][ #  # ]:          0 :                     std::cout << "Unknown pincell, pincell " << m_Assembly(m,n-1) << " not declared" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1757                 :          0 :                     exit(1);
    1758                 :            :                   }
    1759 [ +  - ][ +  - ]:          2 :                 m_Pincell(nTempPin1).GetPitch(dPX1, dPY1, dPZ1);
    1760                 :            :                 // now add half of X pitch to the previous cells pitch
    1761                 :          2 :                 dX+= dPX1/2.0;
    1762                 :            :               }
    1763                 :            :           }
    1764 [ +  + ][ +  + ]:         16 :         if (m > 1 && n==1){
    1765                 :          3 :             dY+= dPY/2.0;
    1766                 :            :             // check if it's dummy
    1767 [ +  - ][ +  - ]:          3 :             if((m_Assembly(m-1,n)=="x")||(m_Assembly(m-1,n)=="xx")){
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1768                 :          3 :                 dY+= dPY/2.0;
    1769                 :            :               }
    1770                 :            :             else{
    1771         [ #  # ]:          0 :                 for(int c=1; c<=m_nPincells; c++){
    1772 [ #  # ][ #  # ]:          0 :                     m_Pincell(c).GetLineOne(szVolId, szVolAlias, nInputLines);
    1773 [ #  # ][ #  # ]:          0 :                     if(m_Assembly(m-1,n) == szVolAlias)
                 [ #  # ]
    1774                 :          0 :                       nTempPin2 = c;
    1775                 :            :                   }
    1776 [ #  # ][ #  # ]:          0 :                 m_Pincell(nTempPin2).GetPitch(dPX2, dPY2, dPZ2);
    1777                 :          3 :                 dY+= dPY2/2.0;
    1778                 :            :               }
    1779                 :            :           }
    1780                 :         16 :         dZ = 0.0; // moving in XY plane only
    1781                 :         16 :       }//if rectangular ends
    1782                 :            : 
    1783                 :         16 :   }
    1784                 :            : 
    1785                 :          0 :   void AssyGen::IOErrorHandler (ErrorStates ECode) const
    1786                 :            :   // ---------------------------------------------------------------------------
    1787                 :            :   // Function: displays error messages related to input data
    1788                 :            :   // Input:    error code
    1789                 :            :   // Output:   none
    1790                 :            :   // ---------------------------------------------------------------------------
    1791                 :            :   {
    1792                 :          0 :     std::cerr << '\n';
    1793                 :            : 
    1794         [ #  # ]:          0 :     if (ECode == PINCELLS) // invalid number of pincells
    1795                 :          0 :       std::cerr << "Number of pincells must be >= 0.";
    1796         [ #  # ]:          0 :     else if (ECode == INVALIDINPUT) // invalid input
    1797                 :          0 :       std::cerr << "Invalid input.";
    1798         [ #  # ]:          0 :     else if (ECode == EMAT) // invalid input
    1799                 :          0 :       std::cerr << "Invalid Material Data.";
    1800         [ #  # ]:          0 :     else if (ECode == EGEOMTYPE) // invalid input
    1801                 :          0 :       std::cerr << "Invalid GeomType Data.";
    1802         [ #  # ]:          0 :     else if (ECode == EGEOMENGINE) // invalid input
    1803                 :          0 :       std::cerr << "Invalid Geometry Engine.";
    1804         [ #  # ]:          0 :     else if (ECode == EALIAS) // invalid input
    1805                 :          0 :       std::cerr << "Error Reading Aliases.";
    1806         [ #  # ]:          0 :     else if (ECode == ENEGATIVE) // invalid input
    1807                 :          0 :       std::cerr << "Unexpected negative value.";
    1808         [ #  # ]:          0 :     else if (ECode == EPIN) // invalid input
    1809                 :          0 :       std::cerr << "Invalid pinCell specs.";
    1810         [ #  # ]:          0 :     else if (ECode == EUNEQUAL) // invalid input
    1811                 :          0 :       std::cerr << "Number of cyliders and ducts in Z don't match, check .inp file.";
    1812                 :            :     else
    1813                 :          0 :       std::cerr << "Unknown error ...?";
    1814                 :            : 
    1815                 :          0 :     std::cerr << '\n' << "Error in input file line : " << m_nLineNumber;
    1816                 :          0 :     std::cerr << std::endl;
    1817                 :          0 :     exit (1);
    1818                 :            :   }
    1819                 :            : 
    1820                 :          4 :   void AssyGen:: Name_Faces(const std::string sMatName, const iBase_EntityHandle body,  iBase_TagHandle this_tag )
    1821                 :            :   // ---------------------------------------------------------------------------
    1822                 :            :   // Function: names all the faces in the body
    1823                 :            :   // Input:    none
    1824                 :            :   // Output:   none
    1825                 :            :   // ---------------------------------------------------------------------------
    1826                 :            :   {
    1827                 :          4 :     double dTol = 1e-4, ttol = 1e-2;
    1828 [ +  - ][ -  + ]:          4 :     if(m_dMAssmPitch.GetRows()!=0 && m_dMAssmPitch.GetColumns()!=0){
         [ #  # ][ #  # ]
                 [ -  + ]
    1829 [ #  # ][ #  # ]:          0 :         if(m_szGeomType == "hexagonal")
    1830         [ #  # ]:          0 :           ttol = m_dMAssmPitch(1, 1);
    1831 [ #  # ][ #  # ]:          0 :         else if (m_szGeomType == "rectangular")
    1832         [ #  # ]:          0 :           ttol = m_dMAssmPitchX(1,1);
    1833                 :            :       }
    1834                 :            :     // set tolerance for surface identification
    1835         [ +  - ]:          4 :     if (ttol != 0){
    1836                 :          4 :         dTol=ttol*1.0e-2;
    1837                 :            :       }
    1838                 :          4 :     double dZTemp = 0.0;
    1839                 :          4 :     int flag = 0, locTemp = 0;
    1840                 :          4 :     iBase_EntityHandle max_surf = NULL, min_surf = NULL, side_surf =NULL;
    1841         [ +  - ]:          4 :     SimpleArray<iBase_EntityHandle> surfs;
    1842                 :          4 :     int nSide = 0;
    1843         [ +  - ]:          8 :     std::ostringstream os;
    1844         [ +  - ]:          8 :     std::string sMatName0=sMatName+"_top";
    1845         [ +  - ]:          8 :     std::string sMatName1=sMatName+"_bot";
    1846         [ +  - ]:          8 :     std::string sSideName;
    1847                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1848 [ +  - ][ +  - ]:          4 :     iGeom_getEntAdj( igeomImpl->instance(), body, iBase_FACE, ARRAY_INOUT(surfs), &err );
         [ +  - ][ +  - ]
                 [ +  - ]
    1849                 :            : #endif
    1850                 :            : 
    1851 [ +  - ][ +  - ]:          8 :     SimpleArray<double> max_corn, min_corn;
    1852                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1853         [ +  - ]:          4 :     iGeom_getArrBoundBox( igeomImpl->instance(), ARRAY_IN(surfs), iBase_INTERLEAVED,
    1854                 :            :                           ARRAY_INOUT( min_corn ),
    1855                 :            :                           ARRAY_INOUT( max_corn ),
    1856 [ +  - ][ +  - ]:          8 :                           &err );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1857                 :            : #endif
    1858                 :            : 
    1859 [ +  - ][ +  + ]:         26 :     for (int i = 0; i < surfs.size(); ++i){
    1860                 :            :         // first find the max z-coordinate
    1861 [ +  - ][ +  - ]:         22 :         if( (fabs(min_corn[3*i+2]-max_corn[3*i+2])) < dTol ) {
                 [ +  + ]
    1862         [ +  + ]:          8 :             if(flag == 0){
    1863         [ +  - ]:          4 :                 dZTemp = min_corn[3*i+2];
    1864                 :          4 :                 locTemp = i;
    1865                 :          4 :                 flag = 1;
    1866                 :            :               }
    1867 [ +  - ][ +  + ]:          4 :             else if(dZTemp > min_corn[3*i+2]){
    1868                 :            :                 // we have a bot surface
    1869         [ +  - ]:          3 :                 min_surf = surfs[i];
    1870                 :            :                 // the top surface is dZTemp
    1871         [ +  - ]:          3 :                 max_surf = surfs[locTemp];
    1872                 :            :               }
    1873                 :            :             else{
    1874                 :            :                 //we have a top surface
    1875         [ +  - ]:          1 :                 min_surf = surfs[locTemp];
    1876                 :            :                 // the top surface is dZTemp
    1877         [ +  - ]:          8 :                 max_surf = surfs[i];
    1878                 :            :               }
    1879                 :            :           }
    1880                 :            :         // see if max or min set name
    1881         [ +  + ]:         22 :         if(max_surf !=0){
    1882                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1883                 :            :             iGeom_setData(igeomImpl->instance(), max_surf, this_tag,
    1884 [ +  - ][ +  - ]:          4 :                           sMatName0.c_str(), sMatName0.size(), &err);
    1885                 :            : #endif
    1886                 :            : 
    1887 [ +  - ][ +  - ]:          4 :             std::cout << sMatName0 << ",  ";
    1888                 :          4 :             max_surf = NULL;
    1889                 :            : 
    1890                 :            :           }
    1891         [ +  + ]:         22 :         if(min_surf !=0){
    1892                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1893                 :            :             iGeom_setData(igeomImpl->instance(), min_surf, this_tag,
    1894 [ +  - ][ +  - ]:          4 :                           sMatName1.c_str(), sMatName1.size(), &err);
    1895                 :            : #endif
    1896 [ +  - ][ +  - ]:          4 :             std::cout << sMatName1 << ",  ";
    1897                 :          4 :             min_surf = NULL;
    1898                 :            : 
    1899                 :            :           }
    1900                 :            :       }
    1901 [ +  - ][ +  + ]:         26 :     for (int i = 0; i < surfs.size(); ++i){
    1902 [ +  - ][ +  - ]:         22 :         if( (fabs(min_corn[3*i+2]-max_corn[3*i+2])) < dTol ) {
                 [ +  + ]
    1903                 :          8 :             continue; // its a max of min surface
    1904                 :            :           }
    1905                 :            :         else{ // its a side surface
    1906         [ +  - ]:         14 :             side_surf = surfs[i];
    1907                 :            :           }
    1908                 :            :         //set name for the sidesurf now
    1909         [ +  - ]:         14 :         if(side_surf !=0){
    1910                 :         14 :             ++nSide;
    1911 [ +  - ][ +  - ]:         14 :             sSideName = sMatName + "_side";
    1912 [ +  - ][ -  + ]:         14 :             if(m_szGeomType == "hexagonal") {
    1913         [ #  # ]:          0 :                 if(nSide <= 6)
    1914 [ #  # ][ #  # ]:          0 :                   os << sSideName << nSide;
    1915                 :            :                 else
    1916 [ #  # ][ #  # ]:          0 :                   os << sSideName << "_" << nSide;
                 [ #  # ]
    1917                 :            :               }
    1918                 :            : 
    1919 [ +  - ][ +  - ]:         14 :             if(m_szGeomType == "rectangular"){
    1920         [ +  + ]:         14 :                 if(nSide <= 4)
    1921 [ +  - ][ +  - ]:         10 :                   os << sSideName << nSide;
    1922                 :            :                 else
    1923 [ +  - ][ +  - ]:         14 :                   os << sSideName << "_" << nSide;
                 [ +  - ]
    1924                 :            :               }
    1925 [ +  - ][ +  - ]:         14 :             sSideName = os.str();
    1926                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1927                 :            :             iGeom_setData(igeomImpl->instance(), side_surf, this_tag,
    1928 [ +  - ][ +  - ]:         14 :                           sSideName.c_str(), sMatName1.size(), &err);
    1929                 :            : #endif
    1930 [ +  - ][ +  - ]:         14 :             std::cout << sSideName << ",  " ;
    1931         [ +  - ]:         14 :             sSideName = "";
    1932 [ +  - ][ +  - ]:         14 :             os.str("");
    1933                 :         14 :             side_surf = NULL;
    1934                 :            :           }
    1935                 :            :         else {
    1936 [ #  # ][ #  # ]:          0 :             std::cerr << "Couldn't find surface for naming" << std::endl;
    1937                 :            :           }
    1938                 :            :       }
    1939         [ +  - ]:          8 :     std::cout <<"\n";
    1940                 :            : 
    1941                 :          4 :   }
    1942                 :            : 
    1943                 :            : 
    1944                 :          3 :   void AssyGen::Center_Assm (char &rDir)
    1945                 :            :   // ---------------------------------------------------------------------------
    1946                 :            :   // Function: centers all the entities along x and y axis
    1947                 :            :   // Input:    none
    1948                 :            :   // Output:   none
    1949                 :            :   // ---------------------------------------------------------------------------
    1950                 :            :   {
    1951                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    1952                 :          3 :     double xmin = 0.0, xmax = 0.0, ymin = 0.0, ymax = 0.0, zmin = 0.0, zmax = 0.0, xcenter = 0.0, ycenter = 0.0, zcenter = 0.0;
    1953                 :            :     // position the assembly such that origin is at the center before sa
    1954                 :            :     iGeom_getBoundBox(igeomImpl->instance(),&xmin,&ymin,&zmin,
    1955 [ +  - ][ +  - ]:          3 :                       &xmax,&ymax,&zmax, &err);
    1956                 :            :     // moving all geom entities to center
    1957                 :            : 
    1958                 :            : 
    1959         [ +  + ]:          3 :     if( rDir =='x'){
    1960                 :          1 :         xcenter = (xmin+xmax)/2.0;
    1961                 :            :       }
    1962         [ +  + ]:          2 :     else if( rDir =='y'){
    1963                 :          1 :         ycenter = (ymin+ymax)/2.0;
    1964                 :            :       }
    1965         [ +  - ]:          1 :     else if ( rDir =='z'){
    1966                 :          1 :         zcenter = (zmin+zmax)/2.0;
    1967                 :            :       }
    1968                 :            :     else{
    1969                 :            :         // assume that it is centered along x and y and not z direction
    1970                 :          0 :         xcenter = (xmin+xmax)/2.0;
    1971                 :          0 :         ycenter = (ymin+ymax)/2.0;
    1972                 :            :       }
    1973                 :            : 
    1974         [ +  - ]:          3 :     SimpleArray<iBase_EntityHandle> all;
    1975 [ +  - ][ +  - ]:          3 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all),&err );
         [ +  - ][ +  - ]
                 [ +  - ]
    1976 [ +  - ][ +  + ]:         15 :     for(int i=0; i<all.size(); i++){
    1977 [ +  - ][ +  - ]:         12 :         iGeom_moveEnt(igeomImpl->instance(),all[i],-xcenter,-ycenter,-zcenter,&err);
                 [ +  - ]
    1978                 :            :       }
    1979                 :            : #endif
    1980                 :            : 
    1981                 :            :     // OCC bounding box computation is buggy, better to compute bounding box in python and supply to the script.
    1982 [ +  - ][ +  - ]:          3 :     m_PyCubGeomFile << "vol = cubit.get_entities(\"volume\")" << std::endl;
    1983 [ +  - ][ +  - ]:          3 :     m_PyCubGeomFile << "vl = cubit.get_total_bounding_box(\"volume\", vol)\nzcenter = 0.0" << std::endl;
    1984                 :            : 
    1985         [ +  + ]:          3 :     if( rDir =='x'){
    1986 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "xcenter = (vl[0]+vl[1])/2.0" << std::endl;
    1987 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "ycenter = 0" << std::endl;
    1988 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "zcenter = 0" << std::endl;
    1989                 :            :       }
    1990         [ +  + ]:          2 :     else if( rDir =='y'){
    1991 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "ycenter = (vl[3]+vl[4])/2.0" << std::endl;
    1992 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "xcenter = 0" << std::endl;
    1993 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "zcenter = 0" << std::endl;
    1994                 :            :       }
    1995         [ +  - ]:          1 :     else if ( rDir =='z'){
    1996 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "zcenter = (vl[6]+vl[7])/2.0" << std::endl;
    1997 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "xcenter = 0" << std::endl;
    1998 [ +  - ][ +  - ]:          1 :         m_PyCubGeomFile << "ycenter = 0" << std::endl;
    1999                 :            :       }
    2000                 :            :     else{
    2001                 :            :         // assume that it is centered along x and y and not z direction
    2002 [ #  # ][ #  # ]:          0 :         m_PyCubGeomFile << "xcenter = (vl[0]+vl[1])/2.0" << std::endl;
    2003 [ #  # ][ #  # ]:          0 :         m_PyCubGeomFile << "ycenter = (vl[3]+vl[4])/2.0" << std::endl;
    2004                 :            :       }
    2005                 :            : 
    2006 [ +  - ][ +  - ]:          3 :     m_PyCubGeomFile << "cubit.cmd('move vol all x {0} y {1} z {2}'.format(-xcenter, -ycenter, -zcenter) )" <<  std::endl;
    2007                 :          3 :   }
    2008                 :            : 
    2009                 :          0 :   void AssyGen::Section_Assm (char &cDir, double &dOffset, const std::string szReverse)
    2010                 :            :   // ---------------------------------------------------------------------------
    2011                 :            :   // Function: sections the assembly about the cutting plane
    2012                 :            :   // Input:    none
    2013                 :            :   // Output:   none
    2014                 :            :   // ---------------------------------------------------------------------------
    2015                 :            :   {
    2016                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)    
    2017                 :          0 :     double xmin = 0.0, xmax = 0.0, ymin = 0.0, ymax = 0.0, zmin = 0.0, zmax = 0.0, yzplane = 0.0, xzplane = 0.0;
    2018                 :          0 :     iBase_EntityHandle sec = NULL;
    2019                 :          0 :     int nReverse = 0;
    2020                 :            :     // check if reverse side is needed
    2021 [ #  # ][ #  # ]:          0 :     if(szReverse == "reverse"){
    2022                 :          0 :         nReverse = 1;
    2023                 :            :       }
    2024         [ #  # ]:          0 :     if( cDir =='x'){
    2025                 :          0 :         yzplane = 1.0;
    2026                 :          0 :         xzplane = 0.0;
    2027                 :            :       }
    2028         [ #  # ]:          0 :     if( cDir =='y'){
    2029                 :          0 :         yzplane = 0.0;
    2030                 :          0 :         xzplane = 1.0;
    2031                 :            :       }
    2032         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> all;
    2033 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2034                 :            :     // loop and section/delete entities
    2035 [ #  # ][ #  # ]:          0 :     for(int i=0; i < all.size(); i++){
    2036                 :            :         //get the bounding box to decide
    2037         [ #  # ]:          0 :         iGeom_getEntBoundBox(igeomImpl->instance(),all[i],&xmin,&ymin,&zmin,
    2038 [ #  # ][ #  # ]:          0 :                              &xmax,&ymax,&zmax, &err);
    2039                 :            : 
    2040 [ #  # ][ #  # ]:          0 :         if(xmin > dOffset && yzplane ==1 && nReverse ==1){
                 [ #  # ]
    2041 [ #  # ][ #  # ]:          0 :             iGeom_deleteEnt(igeomImpl->instance(),all[i],&err);
                 [ #  # ]
    2042                 :          0 :             continue;
    2043                 :            :           }
    2044 [ #  # ][ #  # ]:          0 :         if(ymin > dOffset && xzplane == 1 && nReverse ==1){
                 [ #  # ]
    2045 [ #  # ][ #  # ]:          0 :             iGeom_deleteEnt(igeomImpl->instance(),all[i],&err);
                 [ #  # ]
    2046                 :          0 :             continue;
    2047                 :            :           }
    2048 [ #  # ][ #  # ]:          0 :         if(xmax < dOffset && yzplane ==1 && nReverse ==0){
                 [ #  # ]
    2049 [ #  # ][ #  # ]:          0 :             iGeom_deleteEnt(igeomImpl->instance(),all[i],&err);
                 [ #  # ]
    2050                 :          0 :             continue;
    2051                 :            :           }
    2052 [ #  # ][ #  # ]:          0 :         if(ymax < dOffset && xzplane == 1 && nReverse ==0){
                 [ #  # ]
    2053 [ #  # ][ #  # ]:          0 :             iGeom_deleteEnt(igeomImpl->instance(),all[i],&err);
                 [ #  # ]
    2054                 :          0 :             continue;
    2055                 :            :           }
    2056                 :            :         else{
    2057 [ #  # ][ #  # ]:          0 :             if(xzplane ==1 && ymax >dOffset && ymin < dOffset){
                 [ #  # ]
    2058 [ #  # ][ #  # ]:          0 :                 iGeom_sectionEnt(igeomImpl->instance(), all[i],yzplane,xzplane,0, dOffset, nReverse,&sec,&err);
                 [ #  # ]
    2059                 :            :               }
    2060 [ #  # ][ #  # ]:          0 :             if(yzplane ==1 && xmax >dOffset && xmin < dOffset){
                 [ #  # ]
    2061 [ #  # ][ #  # ]:          0 :                 iGeom_sectionEnt(igeomImpl->instance(), all[i],yzplane,xzplane,0, dOffset,nReverse,&sec,&err);
                 [ #  # ]
    2062                 :            :               }
    2063                 :            :           }
    2064                 :          0 :       }
    2065                 :            : #endif    
    2066                 :          0 :   }
    2067                 :            : 
    2068                 :          0 :   void AssyGen::Rotate_Assm (char &cDir, double &dAngle)
    2069                 :            :   // ---------------------------------------------------------------------------
    2070                 :            :   // Function: rotates the whole assembly
    2071                 :            :   // Input:    none
    2072                 :            :   // Output:   none
    2073                 :            :   // ---------------------------------------------------------------------------
    2074                 :            :   {
    2075 [ #  # ][ #  # ]:          0 :     m_PyCubGeomFile << "cDir = '" << cDir << "'" << "\ncubit.cmd('rotate vol all angle " << dAngle << " about {0}'.format(cDir))" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2076                 :            : 
    2077                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2078                 :          0 :     double dX = 0.0, dY=0.0, dZ=0.0;
    2079         [ #  # ]:          0 :     if( cDir =='x'){
    2080                 :          0 :         dX = 1.0;
    2081                 :            :       }
    2082         [ #  # ]:          0 :     if( cDir =='y'){
    2083                 :          0 :         dY = 1.0;
    2084                 :            :       }
    2085         [ #  # ]:          0 :     if( cDir =='z'){
    2086                 :          0 :         dZ = 1.0;
    2087                 :            :       }
    2088         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> all;
    2089 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2090                 :            : 
    2091                 :            :     // loop and rotate all entities
    2092 [ #  # ][ #  # ]:          0 :     for(int i=0; i<all.size(); i++){
    2093                 :            :         //get the bounding box to decide
    2094         [ #  # ]:          0 :         iGeom_rotateEnt(igeomImpl->instance(),all[i],dAngle,
    2095 [ #  # ][ #  # ]:          0 :                         dX, dY, dZ, &err);
    2096                 :          0 :       }
    2097                 :            : #endif
    2098                 :          0 :   }
    2099                 :            : 
    2100                 :          0 :   void AssyGen::Move_Assm (double &dX,double &dY, double &dZ)
    2101                 :            :   // ---------------------------------------------------------------------------
    2102                 :            :   // Function: move's the model by dX, dY and dZ
    2103                 :            :   // Input:    none
    2104                 :            :   // Output:   none
    2105                 :            :   // ---------------------------------------------------------------------------
    2106                 :            :   {
    2107         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> all;
    2108                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2109 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2110                 :            : #endif
    2111 [ #  # ][ #  # ]:          0 :     m_PyCubGeomFile << "cubit.cmd('move vol all x " << dX << " y " << dY << " dZ " << dZ << "')" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2112                 :            : 
    2113                 :            :     // loop and rotate all entities
    2114 [ #  # ][ #  # ]:          0 :     for(int i=0; i<all.size(); i++){
    2115                 :            :         //get the bounding box to decide
    2116                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2117         [ #  # ]:          0 :         iGeom_moveEnt(igeomImpl->instance(),all[i],
    2118 [ #  # ][ #  # ]:          0 :                       dX, dY, dZ, &err);
    2119                 :            : #endif
    2120                 :          0 :       }
    2121                 :            : 
    2122                 :          0 :   }
    2123                 :            : 
    2124                 :          0 :   void AssyGen::Create_HexAssm(std::string &szInputString)
    2125                 :            :   // ---------------------------------------------------------------------------
    2126                 :            :   // Function: read and create the assembly for hexagonal lattice
    2127                 :            :   // Input:    error code
    2128                 :            :   // Output:   none
    2129                 :            :   // ---------------------------------------------------------------------------
    2130                 :            :   {
    2131         [ #  # ]:          0 :     CParser Parse;
    2132 [ #  # ][ #  # ]:          0 :     std::string card, szVolId, szVolAlias;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2133                 :          0 :     int nInputLines, nTempPin = 1, t, nIFlag = 0, total_pincells = 0;
    2134                 :          0 :     double dX = 0.0, dY =0.0, dZ=0.0;
    2135                 :            :     double  dP, dH, dSide, dHeight;
    2136                 :          0 :     iBase_EntityHandle assm = NULL;
    2137 [ #  # ][ #  # ]:          0 :     std::cout << "\ngetting Assembly data and creating ..\n"<< std::endl;
    2138 [ #  # ][ #  # ]:          0 :     std::istringstream szFormatString (szInputString);
    2139                 :            : 
    2140 [ #  # ][ #  # ]:          0 :     szFormatString >> card >> m_nPin;
    2141         [ #  # ]:          0 :     if(m_nPin <=0 )
    2142         [ #  # ]:          0 :       IOErrorHandler (INVALIDINPUT);
    2143                 :            : 
    2144                 :            :     // width of the hexagon is n*n+1/2
    2145                 :          0 :     int nWidth =2*m_nPin -1;
    2146                 :            : 
    2147                 :            :     // creating a square array of size width
    2148         [ #  # ]:          0 :     m_Assembly.SetSize(nWidth, nWidth);
    2149         [ #  # ]:          0 :     if (m_nJouFlag == 1)
    2150                 :          0 :       return;
    2151                 :            : 
    2152         [ #  # ]:          0 :     for(int m=1; m<=nWidth; m++){
    2153         [ #  # ]:          0 :         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
    2154         [ #  # ]:          0 :                                  MAXCHARS, szComment))
    2155         [ #  # ]:          0 :           IOErrorHandler (INVALIDINPUT);
    2156         [ #  # ]:          0 :         if(m>m_nPin)
    2157                 :          0 :           t = 2*m_nPin - m;
    2158                 :            :         else
    2159                 :          0 :           t = m;
    2160         [ #  # ]:          0 :         std::istringstream szFormatString1 (szInputString);
    2161                 :            : 
    2162         [ #  # ]:          0 :         for(int n=1; n<=(m_nPin + t - 1); n++){
    2163                 :          0 :             ++total_pincells;
    2164                 :          0 :             nTempPin = -1;
    2165 [ #  # ][ #  # ]:          0 :             szFormatString1 >> m_Assembly(m,n);
    2166 [ #  # ][ #  # ]:          0 :             if(szFormatString1.fail())
    2167         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2168                 :            :             // if dummy pincell skip and continue
    2169 [ #  # ][ #  # ]:          0 :             if((m_Assembly(m,n)=="x")||(m_Assembly(m,n)=="xx")){
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2170                 :          0 :                 continue;
    2171                 :            :               }
    2172                 :            :             // find that pincell
    2173                 :          0 :             ++m_nTotalPincells;
    2174         [ #  # ]:          0 :             for(int b=1; b<=m_nPincells; b++){
    2175 [ #  # ][ #  # ]:          0 :                 m_Pincell(b).GetLineOne(szVolId, szVolAlias, nInputLines);
    2176 [ #  # ][ #  # ]:          0 :                 if(m_Assembly(m,n) == szVolAlias)
                 [ #  # ]
    2177                 :          0 :                   nTempPin = b;
    2178                 :            :               }
    2179         [ #  # ]:          0 :             if(nTempPin == -1){
    2180 [ #  # ][ #  # ]:          0 :                 std::cout << "Unknown pincell, pincell " << m_Assembly(m,n) << " not declared" << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    2181                 :          0 :                 exit(1);
    2182                 :            :               }
    2183                 :            : 
    2184                 :            :             // now compute the location and create it
    2185 [ #  # ][ #  # ]:          0 :             ComputePinCentroid(nTempPin, m_Assembly, m, n, dX, dY, dZ);
    2186                 :            :             //ERRORR("Error in function ComputePinCentroid", err);
    2187                 :            : 
    2188                 :            :             // now create the pincell in the location found
    2189 [ #  # ][ #  # ]:          0 :             std::cout << "\n--------------------------------------------------"<<std::endl;
    2190 [ #  # ][ #  # ]:          0 :             std::cout << " m = " << m <<" n = " << n << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    2191 [ #  # ][ #  # ]:          0 :             std::cout << "creating pin: " << nTempPin;
    2192 [ #  # ][ #  # ]:          0 :             std::cout << " at X Y Z " << dX << " " << dY << " " << dZ << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2193                 :            : 
    2194         [ #  # ]:          0 :             if(strcmp(m_szInfo.c_str(),"on") == 0)
    2195 [ #  # ][ #  # ]:          0 :               m_AssmInfo << nTempPin  << " \t" << m << " \t" << n << " \t" << dX << " \t" << dY << " \t" << dZ << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2196                 :            : 
    2197 [ #  # ][ #  # ]:          0 :             m_Pincell(nTempPin).GetIntersectFlag(nIFlag);
    2198         [ #  # ]:          0 :             if(nIFlag){
    2199         [ #  # ]:          0 :                 CreatePinCell_Intersect(nTempPin, dX, -dY, dZ);
    2200                 :            :                 //ERRORR("Error in function CreatePinCell_Intersect", err);
    2201                 :            :               }
    2202                 :            :             else{
    2203         [ #  # ]:          0 :                 CreatePinCell(nTempPin, dX, -dY, dZ);
    2204                 :            :                 //ERRORR("Error in function CreatePinCell", err);
    2205                 :            :               }
    2206                 :            :           }
    2207                 :          0 :       }
    2208                 :            : 
    2209                 :            :     // get all the entities (in pins)defined so far, in an entity set - for subtraction later
    2210                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2211 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION, ARRAY_INOUT(in_pins),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2212                 :            : #endif
    2213 [ #  # ][ #  # ]:          0 :     std::cout << "Expected pin definitions: " << total_pincells << "\n\nCreating surrounding outer hexes .." << std::endl;
         [ #  # ][ #  # ]
    2214                 :            : 
    2215 [ #  # ][ #  # ]:          0 :     for (int nTemp = 1; nTemp <= m_nDuct; nTemp ++){
    2216         [ #  # ]:          0 :         if(m_nDimensions >0){
    2217                 :            : 
    2218                 :            :             // create outermost hexes
    2219         [ #  # ]:          0 :             for(int n=1;n<=m_nDimensions; n++){
    2220         [ #  # ]:          0 :                 dSide = m_dMAssmPitch(nTemp, n)/(sqrt(3));
    2221 [ #  # ][ #  # ]:          0 :                 dHeight = m_dMZAssm(nTemp, 2) - m_dMZAssm(nTemp, 1);
    2222                 :            : 
    2223                 :            :                 // creating coverings
    2224                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2225                 :            :                 iGeom_createPrism(igeomImpl->instance(), dHeight, 6,
    2226                 :            :                                   dSide, dSide,
    2227 [ #  # ][ #  # ]:          0 :                                   &assm, &err);
    2228                 :            : #endif
    2229 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "##\nassm = cubit.prism(" << dHeight << ", 6, " << dSide << ", " << dSide << ")" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2230                 :            : 
    2231                 :            :                 // rotate the prism to match the pins
    2232                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2233 [ #  # ][ #  # ]:          0 :                 iGeom_rotateEnt (igeomImpl->instance(), assm, 30, 0, 0, 1, &err);
    2234                 :            : #endif
    2235 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "cubit.cmd('rotate body {0} angle 30 about z'.format(assm.id()) )" << std::endl;
    2236                 :            : 
    2237 [ #  # ][ #  # ]:          0 :                 if(0 != m_Pincell.GetSize()){
    2238 [ #  # ][ #  # ]:          0 :                     m_Pincell(1).GetPitch(dP, dH);
    2239                 :          0 :                     dX = m_nPin*dP;
    2240                 :          0 :                     dY = -(m_nPin-1)*dP*sqrt(3.0)/2.0;
    2241                 :            :                   }
    2242                 :            :                 else{
    2243                 :          0 :                     dX = 0.0;
    2244                 :          0 :                     dY = 0.0;
    2245                 :            :                   }
    2246 [ #  # ][ #  # ]:          0 :                 dZ = (m_dMZAssm(nTemp, 2) + m_dMZAssm(nTemp, 1))/2.0;
    2247                 :            : 
    2248                 :            :                 // position the prism
    2249                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2250 [ #  # ][ #  # ]:          0 :                 iGeom_moveEnt(igeomImpl->instance(), assm, dX,dY,dZ, &err);
    2251                 :            : #endif
    2252 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "vector = [" << dX << ", " << dY << ", " << dZ << "]" << std::endl;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2253 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "cubit.move(assm, vector)" << std::endl;
    2254                 :            : 
    2255                 :            :                 // populate the coverings array
    2256                 :          0 :                 int loc = (nTemp-1)*m_nDimensions + n -1;
    2257         [ #  # ]:          0 :                 assms[(nTemp-1)*m_nDimensions + n -1]=assm;
    2258 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "assms.insert(" << loc << ", assm)" << std::endl;
         [ #  # ][ #  # ]
    2259                 :            :               }
    2260                 :            :           }
    2261                 :          0 :       }
    2262                 :            : 
    2263                 :            :   }
    2264                 :            : 
    2265                 :          1 :   void AssyGen::Create_CartAssm(std::string &szInputString)
    2266                 :            :   // ---------------------------------------------------------------------------
    2267                 :            :   // Function: read and create the assembly for rectangular lattice
    2268                 :            :   // Input:    error code
    2269                 :            :   // Output:   none
    2270                 :            :   // ---------------------------------------------------------------------------
    2271                 :            :   {
    2272         [ +  - ]:          1 :     CParser Parse;
    2273 [ +  - ][ +  - ]:          2 :     std::string card, szVolId, szVolAlias;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2274                 :          1 :     int nInputLines, nTempPin = 1, nIFlag = 0.0;
    2275                 :          1 :     double dX = 0.0, dY =0.0, dZ=0.0, dMoveX = 0.0, dMoveY = 0.0, dHeight = 0, dPX=0.0, dPY=0.0, dPZ=0.0;
    2276                 :          1 :     iBase_EntityHandle assm = NULL;
    2277                 :            : 
    2278 [ +  - ][ +  - ]:          2 :     std::istringstream szFormatString (szInputString);
    2279 [ +  - ][ +  - ]:          1 :     szFormatString >> card >> m_nPinX >> m_nPinY;
                 [ +  - ]
    2280 [ +  - ][ -  + ]:          1 :     if(m_nPinX <=0 || m_nPinY <=0)
    2281         [ #  # ]:          0 :       IOErrorHandler (INVALIDINPUT);
    2282         [ +  - ]:          1 :     m_Assembly.SetSize(m_nPinY,m_nPinX);
    2283                 :            : 
    2284         [ -  + ]:          1 :     if (m_nJouFlag == 1)
    2285                 :          1 :       return;
    2286                 :            : 
    2287                 :            :     //read the next line to get assembly info &store assembly info
    2288 [ +  - ][ +  - ]:          1 :     if(0 != m_Pincell.GetSize()){
    2289         [ +  + ]:          5 :         for(int m=1; m<=m_nPinY; m++){
    2290         [ -  + ]:          4 :             if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
    2291         [ +  - ]:          4 :                                      MAXCHARS, szComment))
    2292         [ #  # ]:          0 :               IOErrorHandler (INVALIDINPUT);
    2293         [ +  - ]:          4 :             std::istringstream szFormatString1 (szInputString);
    2294                 :            : 
    2295                 :            :             //store the line read in Assembly array and create / position the pin in the core
    2296         [ +  + ]:         20 :             for(int n=1; n<=m_nPinX; n++){
    2297 [ +  - ][ +  - ]:         16 :                 szFormatString1 >> m_Assembly(m,n);
    2298 [ +  - ][ -  + ]:         16 :                 if(szFormatString1.fail())
    2299         [ #  # ]:          0 :                   IOErrorHandler (INVALIDINPUT);
    2300                 :            : 
    2301                 :            : 
    2302                 :            :                 // loop thro' all pins to get the type of pin
    2303         [ +  + ]:         32 :                 for(int b=1; b<=m_nPincells; b++){
    2304 [ +  - ][ +  - ]:         16 :                     m_Pincell(b).GetLineOne(szVolId, szVolAlias, nInputLines);
    2305 [ +  - ][ +  - ]:         16 :                     if(m_Assembly(m,n) == szVolAlias)
                 [ +  + ]
    2306                 :          2 :                       nTempPin = b;
    2307                 :            :                   }
    2308                 :            : 
    2309                 :            :                 //now compute the location where the pin needs to be placed
    2310 [ +  - ][ +  - ]:         16 :                 ComputePinCentroid(nTempPin, m_Assembly, m, n, dX, dY, dZ);
    2311                 :            :                 //ERRORR("Error in function ComputePinCentroid", err);
    2312                 :            : 
    2313                 :            :                 // if dummy pincell skip and continue
    2314 [ +  - ][ +  - ]:         16 :                 if((m_Assembly(m,n)=="x")||(m_Assembly(m,n)=="xx")){
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
    2315 [ +  - ][ +  - ]:         14 :                     m_Pincell(1).GetPitch(dPX, dPY, dPZ);
    2316                 :            :                     // dMoveX and dMoveY are stored for positioning the outer squares later
    2317 [ +  + ][ +  + ]:         14 :                     if(m == m_nPinY && n ==m_nPinX){
    2318                 :          1 :                         dMoveX = dX/2.0;
    2319                 :          1 :                         dMoveY = -dY/2.0;
    2320                 :            :                       }
    2321                 :         14 :                     continue;
    2322                 :            :                   }
    2323                 :          2 :                 ++m_nTotalPincells;
    2324                 :            :                 // now create the pincell in the location found
    2325 [ +  - ][ +  - ]:          2 :                 std::cout << "\n--------------------------------------------------"<<std::endl;
    2326 [ +  - ][ +  - ]:          2 :                 std::cout << " m = " << m <<" n = " << n << std::endl;
         [ +  - ][ +  - ]
                 [ +  - ]
    2327 [ +  - ][ +  - ]:          2 :                 std::cout << "creating pin: " << nTempPin;
    2328 [ +  - ][ +  - ]:          2 :                 std::cout << " at X Y Z " << dX << " " << -dY << " " << dZ << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    2329                 :            : 
    2330         [ +  - ]:          2 :                 if(strcmp(m_szInfo.c_str(),"on") == 0)
    2331 [ +  - ][ +  - ]:          2 :                   m_AssmInfo << nTempPin  << " \t" << m << " \t" << n << " \t" << dX << " \t" << dY << " \t" << dZ << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2332                 :            : 
    2333 [ +  - ][ +  - ]:          2 :                 m_Pincell(nTempPin).GetIntersectFlag(nIFlag);
    2334         [ -  + ]:          2 :                 if(nIFlag){
    2335         [ #  # ]:          0 :                     CreatePinCell_Intersect(nTempPin, dX, -dY, dZ);
    2336                 :            :                     //ERRORR("Error in function CreatePinCell_Intersect", err);
    2337                 :            :                   }
    2338                 :            :                 else{
    2339         [ +  - ]:          2 :                     CreatePinCell(nTempPin, dX, -dY, dZ);
    2340                 :            :                     //ERRORR("Error in function CreatePinCell", err);
    2341                 :            :                   }
    2342                 :            :                 // dMoveX and dMoveY are stored for positioning the outer squares later
    2343 [ -  + ][ #  # ]:          2 :                 if(m == m_nPinY && n ==m_nPinX){
    2344                 :          0 :                     dMoveX = dX/2.0;
    2345                 :          0 :                     dMoveY = -dY/2.0;
    2346                 :            :                   }
    2347                 :            :               }
    2348                 :          4 :           }
    2349                 :            :       }
    2350 [ +  - ][ +  - ]:          1 :     std::cout << "\n--------------------------------------------------"<<std::endl;
    2351                 :            : 
    2352                 :            :     // get all the entities (in pins)defined so far, in an entity set - for subtraction later
    2353                 :            :     //  iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION, ARRAY_INOUT(in_pins),&err );
    2354                 :            :     //  //CHECK( "ERROR : getRootSet failed!" );
    2355                 :            : 
    2356                 :            : 
    2357         [ +  - ]:          1 :     if(m_nDimensions > 0){
    2358                 :            : 
    2359                 :            :         // create outermost rectangular blocks
    2360 [ +  - ][ +  - ]:          1 :         std::cout << "\nCreating surrounding outer blocks .." << std::endl;
    2361                 :          1 :         int nCount = -1;
    2362 [ +  + ][ +  - ]:          2 :         for(int nTemp = 1; nTemp <= m_nDuct; nTemp ++){
    2363         [ +  + ]:          3 :             for(int n=1;n<=m_nDimensions; n++){
    2364                 :          2 :                 ++nCount;
    2365 [ +  - ][ +  - ]:          2 :                 dHeight = m_dMZAssm(nTemp, 2) - m_dMZAssm(nTemp, 1);
    2366                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2367 [ +  - ][ +  - ]:          2 :                 iGeom_createBrick(igeomImpl->instance(), m_dMAssmPitchX(nTemp, n),  m_dMAssmPitchY(nTemp, n), dHeight,
    2368 [ +  - ][ +  - ]:          2 :                                   &assm, &err);
    2369                 :            : #endif
    2370 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "assm = cubit.brick( " << m_dMAssmPitchX(nTemp, n) << ", " << m_dMAssmPitchY(nTemp, n) << ", " << dHeight << ")" << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2371                 :            : 
    2372                 :            :                 // position the outer block to match the pins
    2373 [ +  - ][ +  - ]:          2 :                 dZ = (m_dMZAssm(nTemp, 2) + m_dMZAssm(nTemp, 1))/2.0;
    2374 [ +  - ][ +  - ]:          2 :                 std::cout << "Move " <<   dMoveX << " " << dMoveY <<std::endl;
         [ +  - ][ +  - ]
                 [ +  - ]
    2375                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2376 [ +  - ][ +  - ]:          2 :                 iGeom_moveEnt(igeomImpl->instance(), assm, dMoveX,dMoveY,dZ, &err);
    2377                 :            : #endif
    2378 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "vector = [" << dMoveX << ", " << dMoveY << ", " << dZ << "]" << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2379 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "cubit.move(assm, vector)" << std::endl;
    2380                 :            : 
    2381                 :            :                 // populate the outer covering array squares
    2382         [ +  - ]:          2 :                 assms[nCount]=assm;
    2383 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "assms.insert(" << nCount << ", assm)" << std::endl;
         [ +  - ][ +  - ]
    2384                 :            : 
    2385                 :            :               }
    2386                 :            :           }
    2387                 :          1 :       }
    2388                 :            : 
    2389                 :            :   }
    2390                 :            : 
    2391                 :          1 :   void AssyGen::CreateOuterCovering ()
    2392                 :            :   // ---------------------------------------------------------------------------
    2393                 :            :   // Function: this function sets the names of the coverings
    2394                 :            :   // Input:    error code
    2395                 :            :   // Output:   none
    2396                 :            :   // ---------------------------------------------------------------------------
    2397                 :            :   {
    2398                 :          1 :     double zmin = 0.0, zmax = 0.0;
    2399                 :          1 :     iBase_TagHandle this_tag = NULL;
    2400         [ +  - ]:          1 :     std::string sMatName = "";
    2401         [ +  - ]:          2 :     std::string sMatName0 = "";
    2402         [ +  - ]:          2 :     std::string sMatName1 = "";
    2403 [ +  - ][ +  - ]:          1 :     m_PyCubGeomFile << "sub1 = []\nsub2=[]" << std::endl;
    2404                 :            : 
    2405                 :            :     // get tag handle for 'NAME' tag, already created as iGeom instance is created
    2406                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2407                 :          1 :     char* tag_name =(char *)"NAME";
    2408 [ +  - ][ +  - ]:          1 :     iGeom_getTagHandle(igeomImpl->instance(), tag_name, &this_tag, &err, 4);
    2409                 :            : #endif
    2410                 :          1 :     iBase_EntityHandle tmp_vol= NULL, tmp_new= NULL;
    2411                 :            : 
    2412                 :            :     // name the innermost outer covering common for both rectangular and hexagonal assembliees
    2413         [ +  - ]:          1 :     if(m_nDimensions >0){
    2414                 :            :         //    int tag_no = 0;
    2415         [ +  + ]:          2 :         for (int nTemp1 = 1; nTemp1 <=m_nDuct; nTemp1++){
    2416 [ +  - ][ +  + ]:          4 :             for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
    2417 [ +  - ][ +  - ]:          3 :                 if(strcmp ( m_szMMAlias(nTemp1, 1).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
                 [ +  + ]
    2418 [ +  - ][ +  - ]:          1 :                     sMatName =  m_szAssmMat(p);
    2419                 :            :                     //    tag_no=p;
    2420                 :            :                   }
    2421                 :            :               }
    2422                 :            : 
    2423 [ +  - ][ +  - ]:          1 :             std::cout << "\ncreated innermost block: " << sMatName << std::endl;
                 [ +  - ]
    2424                 :            : 
    2425         [ +  - ]:          1 :             tmp_vol = assms[(nTemp1 - 1)*m_nDimensions];
    2426                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2427                 :            :             iGeom_setData(igeomImpl->instance(), tmp_vol, this_tag,
    2428 [ +  - ][ +  - ]:          1 :                           sMatName.c_str(), sMatName.size(), &err);
    2429                 :            : #endif
    2430 [ +  - ][ +  - ]:          1 :             Name_Faces(sMatName, tmp_vol, this_tag);
    2431 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "lid = assms[" << (nTemp1 - 1)*m_nDimensions << "].id()" << std::endl;
         [ +  - ][ +  - ]
    2432 [ +  - ][ -  + ]:          1 :             if (sMatName == "")
    2433         [ #  # ]:          0 :               IOErrorHandler(EALIAS);
    2434 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
         [ +  - ][ +  - ]
    2435 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", assms[" << (nTemp1 - 1)*m_nDimensions << "])" << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2436                 :            :           }
    2437                 :            : 
    2438                 :          1 :         int count =0;//index for edge names
    2439         [ +  + ]:          2 :         for (int nTemp = 1; nTemp <= m_nDuct; nTemp++){
    2440                 :            :             //  Naming outermost block edges - sidesets in cubit journal file
    2441 [ +  - ][ +  - ]:          1 :             std::cout << "Naming outermost block edges" << std::endl;
    2442         [ +  - ]:          1 :             SimpleArray<iBase_EntityHandle> edges;
    2443                 :            : 
    2444                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2445         [ +  - ]:          1 :             iGeom_getEntAdj( igeomImpl->instance(), assms[nTemp*m_nDimensions-1] , iBase_EDGE,ARRAY_INOUT(edges),
    2446 [ +  - ][ +  - ]:          2 :                 &err );
         [ +  - ][ +  - ]
                 [ +  - ]
    2447                 :            : #endif
    2448                 :            :             // get the top corner edges of the outer most covering
    2449                 :            :             //m_PyCubGeomFile << "lid=assms<<["<< nTemp*m_nDimensions-1 << "].id()" << std::endl;
    2450 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "cubit.cmd('group \"g1\" equals curve in vol {0} '.format(assms[" << nTemp*m_nDimensions-1 << "].id()))" << std::endl;
         [ +  - ][ +  - ]
    2451 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "cubit.cmd('group \"g2\" equals curve with z_max<> z_min in g1')\ncubit.cmd('group  \"g3\" subtract g2 from g1')" << std::endl;
    2452                 :            :             m_PyCubGeomFile <<                        "tmp_g3id = cubit.get_id_from_name(\"g3\")\n"
    2453                 :            :                                                       "gs_curves = cubit.get_group_curves(tmp_g3id)\n"
    2454                 :            :                                                       "side_curves = len(gs_curves)\n"
    2455                 :            :                                                       "for i in range(0,side_curves):\n"
    2456                 :            :                                                       "  sname = \"side_edge\" + str(i+1)\n"
    2457 [ +  - ][ +  - ]:          1 :                                                       "  cubit.cmd('curve {0} name \"{1}\"'.format( gs_curves[i] , sname )  )\n" << std::endl;
    2458         [ +  - ]:          2 :             std::ostringstream os;
    2459 [ +  - ][ +  + ]:         13 :             for (int i = 0; i < edges.size(); ++i){
    2460                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2461                 :         12 :                 double xmin = 0.0, xmax = 0.0, ymin = 0.0, ymax = 0.0;
    2462         [ +  - ]:         12 :                 iGeom_getEntBoundBox(igeomImpl->instance(), edges[i],&xmin,&ymin,&zmin,
    2463 [ +  - ][ +  - ]:         12 :                                      &xmax,&ymax,&zmax, &err);
    2464                 :            : #endif
    2465                 :         12 :                 double dTol = 1e-5; // tolerance for comparing coordinates
    2466                 :            : 
    2467 [ +  - ][ +  + ]:         12 :                 if(fabs(zmax - m_dMZAssm(nTemp, 2)) <  dTol){
    2468         [ +  + ]:          8 :                     if(fabs(zmax-zmin) < dTol){
    2469                 :            : 
    2470                 :            :                         //we have a corner edge - name it
    2471         [ +  - ]:          4 :                         sMatName="side_edge";
    2472                 :          4 :                         ++count;
    2473 [ +  - ][ +  - ]:          4 :                         os << sMatName << count;
    2474 [ +  - ][ +  - ]:          4 :                         sMatName=os.str();
    2475 [ +  - ][ +  - ]:          4 :                         std::cout << sMatName << std::endl;
    2476         [ +  - ]:          4 :                         tmp_vol=edges[i];
    2477                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2478                 :            :                         iGeom_setData(igeomImpl->instance(), tmp_vol, this_tag,
    2479 [ +  - ][ +  - ]:          4 :                                       sMatName.c_str(), sMatName.size(), &err);
    2480                 :            : #endif
    2481 [ +  - ][ +  - ]:          4 :                         std::cout << "created: " << sMatName << std::endl;
                 [ +  - ]
    2482 [ +  - ][ +  - ]:          4 :                         os.str("");
    2483         [ +  - ]:          4 :                         sMatName="";
    2484                 :            :                       }
    2485                 :            :                   }
    2486                 :            :               }
    2487                 :          1 :           }
    2488                 :            :         // now subtract the outermost hexes and name them
    2489 [ +  - ][ +  - ]:          1 :         std::cout << "Subtract outermost hexes and naming them" << std::endl;
    2490                 :          1 :         int nCount = 0;
    2491         [ +  + ]:          2 :         for(int nTemp=1; nTemp<=m_nDuct; nTemp++){
    2492         [ +  + ]:          2 :             for(int n=m_nDimensions; n>1 ; n--){
    2493         [ +  - ]:          1 :                 if(n>1){
    2494                 :          1 :                     ++nCount;
    2495                 :            :                     // copy cyl before subtract
    2496                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2497 [ +  - ][ +  - ]:          1 :                     iGeom_copyEnt(igeomImpl->instance(), assms[(nTemp-1)*m_nDimensions + n-2], &tmp_vol, &err);
                 [ +  - ]
    2498                 :            : #endif
    2499 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "tmp_vol = cubit.copy_body(assms[" << (nTemp-1)*m_nDimensions + n-2 << "])" << std::endl;
         [ +  - ][ +  - ]
    2500                 :            : 
    2501                 :            :                     // subtract outer most cyl from brick
    2502 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "\nsub1.append(tmp_vol)" << std::endl;
    2503 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "\nsub2.append(assms[" << (nTemp-1)*m_nDimensions + n-1 <<"])" << std::endl;
         [ +  - ][ +  - ]
    2504                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2505 [ +  - ][ +  - ]:          1 :                     iGeom_subtractEnts(igeomImpl->instance(), assms[(nTemp-1)*m_nDimensions + n-1], tmp_vol, &tmp_new, &err);
                 [ +  - ]
    2506                 :            : #endif
    2507 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "tmp_new = cubit.subtract(sub1, sub2)" << std::endl;
    2508 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "assms[" << (nTemp-1)*m_nDimensions + n-1 << "] = tmp_new[0]\n\nsub1[:]=[]\nsub2[:]=[]"   << std::endl;
         [ +  - ][ +  - ]
    2509                 :            : 
    2510         [ +  - ]:          1 :                     assms[(nTemp-1)*m_nDimensions + n-1]=tmp_new;
    2511                 :            : 
    2512                 :            :                     // name the vols by searching for the full name of the abbreviated Cell Mat
    2513 [ +  - ][ +  + ]:          4 :                     for(int p=1;p<=m_szAssmMatAlias.GetSize();p++){
    2514 [ +  - ][ +  - ]:          3 :                         if(strcmp ( m_szMMAlias(nTemp, n).c_str(), m_szAssmMatAlias(p).c_str()) == 0){
                 [ +  + ]
    2515 [ +  - ][ +  - ]:          1 :                             sMatName =  m_szAssmMat(p);
    2516                 :            :                           }
    2517                 :            :                       }
    2518 [ +  - ][ +  - ]:          1 :                     std::cout << "created: " << sMatName << std::endl;
                 [ +  - ]
    2519                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2520                 :            :                     iGeom_setData(igeomImpl->instance(), tmp_new, this_tag,
    2521 [ +  - ][ +  - ]:          1 :                                   sMatName.c_str(), sMatName.size(), &err);
    2522                 :            : #endif
    2523 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "lid = tmp_new[0].id()" << std::endl;
    2524 [ +  - ][ -  + ]:          1 :                     if (sMatName == "")
    2525         [ #  # ]:          0 :                       IOErrorHandler(EALIAS);
    2526 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "cubit.set_entity_name(\"body\", lid, \""  << sMatName <<  "\" )" << std::endl;
         [ +  - ][ +  - ]
    2527 [ +  - ][ +  - ]:          1 :                     m_PyCubGeomFile << "name_faces(\"" << sMatName << "\", tmp_new[0]) " << std::endl;
         [ +  - ][ +  - ]
    2528 [ +  - ][ +  - ]:          1 :                     Name_Faces(sMatName, tmp_new, this_tag);
    2529                 :            :                   }
    2530                 :            :               }
    2531                 :            :           }
    2532 [ +  - ][ +  - ]:          1 :         std::cout << "\n--------------------------------------------------"<<std::endl;
    2533                 :          1 :       }
    2534                 :            : 
    2535                 :          1 :   }
    2536                 :            : 
    2537                 :          1 :   void AssyGen::Subtract_Pins()
    2538                 :            :   // ---------------------------------------------------------------------------
    2539                 :            :   // Function: subtract the pins from the outer block
    2540                 :            :   // Input:    none
    2541                 :            :   // Output:   none
    2542                 :            :   // ---------------------------------------------------------------------------
    2543                 :            :   {
    2544         [ +  - ]:          1 :     if (m_nDimensions >0){
    2545                 :          1 :         std::cout <<"Total number of pins in the model = " << m_nTotalPincells << std::endl;
    2546                 :            : 
    2547         [ +  + ]:          2 :         for (int k=1; k<=m_nDuct; k++){
    2548 [ +  - ][ -  + ]:          1 :             if(cp_inpins[k-1].size() ==0)
    2549                 :          0 :               continue;
    2550                 :            :             // put all the in pins in a matrix of size duct for subtraction with ducts
    2551 [ +  - ][ +  - ]:          1 :             std::vector <iBase_EntityHandle> pin_copy( cp_inpins[k-1].size(), NULL);
    2552 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "pin_copy=[]\n\nsub1=[]\nsub2=[]\n" << std::endl;
    2553 [ +  - ][ +  + ]:          3 :             for (int i=0; i< (int) cp_inpins[k-1].size();i++){
    2554                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2555 [ +  - ][ +  - ]:          2 :                 iGeom_copyEnt(igeomImpl->instance(), cp_inpins[k-1][i], &pin_copy[i], &err);
         [ +  - ][ +  - ]
                 [ +  - ]
    2556                 :            : #endif
    2557 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "tmp_vol = cubit.copy_body(cp_inpins[" << k-1 << "][" << i << "])" << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2558 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "pin_copy.append(tmp_vol)" << std::endl;
    2559 [ +  - ][ +  - ]:          2 :                 m_PyCubGeomFile << "\nsub2.append(cp_inpins[" << k-1 << "]["<< i << "])" << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    2560                 :            :               }
    2561                 :            : 
    2562                 :          1 :             iBase_EntityHandle tmp_vol = NULL;
    2563                 :            :             (void) tmp_vol;
    2564         [ +  - ]:          1 :             tmp_vol = assms[(k-1)*m_nDimensions];
    2565 [ +  - ][ +  - ]:          1 :             m_PyCubGeomFile << "tmp_vol = assms[" << k << "]" << std::endl;
         [ +  - ][ +  - ]
    2566                 :            : 
    2567                 :            :             // subtract the innermost hex from the pins
    2568 [ +  - ][ +  - ]:          1 :             std::cout << "Duct no.: " << k << " subtracting " <<  cp_inpins[k-1].size() << " pins from the duct .. " << std::endl;
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    2569                 :            : 
    2570                 :            :             //#if HAVE_ACIS
    2571                 :          1 :             iBase_EntityHandle unite= NULL, tmp_new1 = NULL;
    2572                 :            :             (void) unite;
    2573                 :            : 
    2574                 :            :             // if there are more than one pins
    2575 [ +  - ][ +  - ]:          1 :             if( cp_inpins[k-1].size() > 1){
    2576                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2577 [ +  - ][ +  - ]:          1 :                 iGeom_uniteEnts(igeomImpl->instance(), &cp_inpins[k-1][0], cp_inpins[k-1].size(), &unite, &err);
         [ +  - ][ +  - ]
                 [ +  - ]
    2578                 :            : #endif
    2579 [ +  - ][ +  - ]:          1 :                 m_PyCubGeomFile << "\nsub1.append(assms[" << (k-1)*m_nDimensions <<"])" << std::endl;
         [ +  - ][ +  - ]
    2580                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2581 [ +  - ][ +  - ]:          1 :                 iGeom_subtractEnts(igeomImpl->instance(), tmp_vol,unite, &tmp_new1, &err);
    2582                 :            : #endif
    2583 [ +  - ][ +  - ]:          1 :                 m_PyCubGeomFile << "tmp_new1 = cubit.subtract(sub2, sub1)" << std::endl;
    2584 [ +  - ][ +  - ]:          1 :                 m_PyCubGeomFile << "tmp_vol = tmp_new1" << std::endl;
    2585                 :            : 
    2586                 :          1 :                 tmp_vol = tmp_new1;
    2587                 :          1 :                 unite = NULL;
    2588                 :          1 :                 tmp_new1=NULL;
    2589                 :            :               }
    2590                 :            :             else{ // only one pin in in_pins
    2591                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2592 [ #  # ][ #  # ]:          0 :                 iGeom_subtractEnts(igeomImpl->instance(), tmp_vol, cp_inpins[k-1][0], &tmp_new1, &err);
         [ #  # ][ #  # ]
    2593                 :            : #endif
    2594 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "\nsub1.append(assms[" << (k-1)*m_nDimensions <<"])" << std::endl;
         [ #  # ][ #  # ]
    2595 [ #  # ][ #  # ]:          0 :                 m_PyCubGeomFile << "tmp_new1 = cubit.subtract(sub2, sub1)" << std::endl;
    2596                 :            :               }
    2597                 :            :             //#endif
    2598                 :            :             // This block was needed for OCE below 0.13 or OCC 6.6
    2599                 :            :             //#if HAVE_OCC
    2600                 :            :             //            iBase_EntityHandle tmp_new1 = NULL;
    2601                 :            :             //            // if there are more than one pins
    2602                 :            :             //            if( cp_inpins[k-1].size() > 1){
    2603                 :            :             //                std::cout << "Subtraction is slower in OCC, since each pin is subtracted one by one" << std::endl;
    2604                 :            :             //                for (int i=0; i< (int)cp_inpins[k-1].size(); i++){
    2605                 :            :             //                    // iGeom_copyEnt(igeomImpl->instance(), cp_inpins[k-1][i], &unite, &err);
    2606                 :            :             //                    iGeom_subtractEnts(igeomImpl->instance(), tmp_vol,cp_inpins[k-1][i], &tmp_new1, &err);
    2607                 :            :             //                    ////CHECK("Couldn't subtract pins from block.");
    2608                 :            :             //                    tmp_vol = tmp_new1;
    2609                 :            :             //                    tmp_new1=NULL;
    2610                 :            :             //                  }
    2611                 :            : 
    2612                 :            :             //              }
    2613                 :            :             //            else{ // only one pin in in_pins
    2614                 :            :             //                iGeom_subtractEnts(igeomImpl->instance(), tmp_vol, cp_inpins[k-1][0], &tmp_new1, &err);
    2615                 :            :             //                ////CHECK("Couldn't subtract pins from block.");
    2616                 :            :             //              }
    2617                 :            :             //#endif
    2618                 :            : 
    2619                 :          1 :           }
    2620                 :          1 :         std::cout << "\n--------------------------------------------------"<<std::endl;
    2621                 :            :       }
    2622                 :            :     else{
    2623                 :          0 :         std::cout <<"Nothing to subtract" << std::endl;
    2624                 :            :       }
    2625                 :            : 
    2626                 :          1 :   }
    2627                 :            : 
    2628                 :          1 :   void AssyGen::Imprint_Merge(bool if_merge, bool if_imprint)
    2629                 :            :   // ---------------------------------------------------------------------------
    2630                 :            :   // Function: Imprint and Merge
    2631                 :            :   // Input:    none
    2632                 :            :   // Output:   none
    2633                 :            :   // ---------------------------------------------------------------------------
    2634                 :            :   {
    2635                 :            :     // getting all entities for merge and imprint
    2636         [ +  - ]:          1 :     SimpleArray<iBase_EntityHandle> entities;
    2637                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2638 [ +  - ][ +  - ]:          1 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION, ARRAY_INOUT(entities),&err );
         [ +  - ][ +  - ]
                 [ +  - ]
    2639                 :            : #endif
    2640                 :            : 
    2641         [ +  - ]:          1 :     if(if_imprint ==  true){
    2642                 :            :         //  now imprint
    2643 [ +  - ][ +  - ]:          1 :         std::cout << "\n\nImprinting...." << std::endl;
    2644                 :          1 :         clock_t s_imprint = clock();
    2645                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2646 [ +  - ][ +  - ]:          1 :         iGeom_imprintEnts(igeomImpl->instance(), ARRAY_IN(entities),&err);
         [ +  - ][ +  - ]
    2647                 :            : #endif
    2648 [ +  - ][ +  - ]:          1 :         std::cout << "## Imprint CPU time used := " << (double) (clock() - s_imprint)/CLOCKS_PER_SEC
    2649 [ +  - ][ +  - ]:          1 :                   << " seconds" << std::endl;
    2650 [ +  - ][ +  - ]:          1 :         std::cout << "\n--------------------------------------------------"<<std::endl;
    2651                 :            :       }
    2652                 :            : 
    2653         [ +  - ]:          1 :     if(if_merge == true){
    2654                 :            :         // merge tolerance
    2655                 :            :         // now  merge
    2656 [ +  - ][ +  - ]:          1 :         std::cout << "\n\nMerging...." << std::endl;
    2657                 :          1 :         clock_t s_merge = clock();
    2658                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2659                 :          1 :         double dTol = 1e-4;
    2660 [ +  - ][ +  - ]:          1 :         iGeom_mergeEnts(igeomImpl->instance(), ARRAY_IN(entities), dTol, &err);
         [ +  - ][ +  - ]
    2661                 :            : #endif
    2662 [ +  - ][ +  - ]:          1 :         std::cout << "## Merge CPU time used := " << (double) (clock() - s_merge)/CLOCKS_PER_SEC
    2663 [ +  - ][ +  - ]:          1 :                   << " seconds" << std::endl;
    2664 [ +  - ][ +  - ]:          1 :         std::cout <<"merging finished."<< std::endl;
    2665 [ +  - ][ +  - ]:          1 :         std::cout << "\n--------------------------------------------------"<<std::endl;
    2666                 :          1 :       }
    2667                 :          1 :   }
    2668                 :            : 
    2669                 :          0 :   void AssyGen::Create2DSurf ()
    2670                 :            :   // ---------------------------------------------------------------------------
    2671                 :            :   // Function: creating planar top surface with zmax
    2672                 :            :   // Input:    error code
    2673                 :            :   // Output:   none
    2674                 :            :   // ---------------------------------------------------------------------------
    2675                 :            :   {
    2676 [ #  # ][ #  # ]:          0 :     m_PyCubGeomFile << "#keep top surface delete the rest" << std::endl;
    2677 [ #  # ][ #  # ]:          0 :     m_PyCubGeomFile << "cubit.cmd('surf with z_coord == {0} copy'.format(vl[7]) )" << std::endl;
    2678 [ #  # ][ #  # ]:          0 :     m_PyCubGeomFile << "cubit.cmd('delete vol with z_coord < {0}'.format(vl[7]) )" << std::endl;
    2679                 :            : 
    2680                 :            : #if defined (HAVE_ACIS) || defined (HAVE_OCC)
    2681 [ #  # ][ #  # ]:          0 :     std::cout << "Creating surface; 2D assembly specified..." << std::endl;
    2682         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle>  all_geom;
    2683         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> surfs;
    2684                 :          0 :     int t=0;
    2685 [ #  # ][ #  # ]:          0 :     SimpleArray<double> max_corn, min_corn;
    2686                 :            : 
    2687                 :            :     // get all the entities in the model (delete after making a copy of top surface)
    2688                 :          0 :     int *offset = NULL, offset_alloc = 0, offset_size = -1;
    2689 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all_geom),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2690                 :            : 
    2691                 :            :     // get all the surfaces in the model
    2692         [ #  # ]:          0 :     iGeom_getArrAdj( igeomImpl->instance(), ARRAY_IN(all_geom) , iBase_FACE, ARRAY_INOUT(surfs),
    2693 [ #  # ][ #  # ]:          0 :                      &offset, &offset_alloc, &offset_size, &err );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2694                 :            : 
    2695         [ #  # ]:          0 :     iGeom_getArrBoundBox( igeomImpl->instance(), ARRAY_IN(surfs), iBase_INTERLEAVED,
    2696                 :            :                           ARRAY_INOUT( min_corn ),
    2697                 :            :                           ARRAY_INOUT( max_corn ),
    2698 [ #  # ][ #  # ]:          0 :                           &err );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2699                 :            : 
    2700                 :            :     // find the number of surfaces 't' for array allocation
    2701                 :          0 :     int nTemp = 1;
    2702                 :          0 :     double dTol = 1e-5;
    2703         [ #  # ]:          0 :     double dtop = m_dMZAssm(nTemp, 2);
    2704 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < surfs.size(); ++i){
    2705 [ #  # ][ #  # ]:          0 :         if((fabs(max_corn[3*i+2] -  dtop) < dTol) && (fabs(min_corn[3*i+2] - dtop)<dTol))
         [ #  # ][ #  # ]
                 [ #  # ]
    2706                 :          0 :           t++;
    2707                 :            :       }
    2708                 :            : 
    2709                 :            :     // allocate arrays
    2710         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> max_surfs(t);
    2711         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> new_surfs(t);
    2712                 :          0 :     t=0;
    2713                 :            : 
    2714                 :            :     // store the max surfaces in max_surfs
    2715 [ #  # ][ #  # ]:          0 :     for (int i = 0; i < surfs.size(); ++i){
    2716                 :            : 
    2717                 :            :         // locate surfaces for which max and min zcoord is same as maxz coord
    2718 [ #  # ][ #  # ]:          0 :         if((fabs(max_corn[3*i+2] -  dtop) < dTol) && (fabs(min_corn[3*i+2] - dtop) < dTol)){
         [ #  # ][ #  # ]
                 [ #  # ]
    2719 [ #  # ][ #  # ]:          0 :             max_surfs[t] = surfs[i];
    2720                 :          0 :             t++;
    2721                 :            :           }
    2722                 :            :       }
    2723                 :            : 
    2724                 :            :     // make a copy of max_surfs
    2725 [ #  # ][ #  # ]:          0 :     for(int i = 0; i < max_surfs.size(); ++i){
    2726 [ #  # ][ #  # ]:          0 :         iGeom_copyEnt(igeomImpl->instance(), max_surfs[i], &new_surfs[i], &err);
         [ #  # ][ #  # ]
    2727                 :            :       }
    2728                 :            : 
    2729                 :            :     // delete all the old ents
    2730 [ #  # ][ #  # ]:          0 :     for(int i=0; i<all_geom.size(); i++){
    2731 [ #  # ][ #  # ]:          0 :         iGeom_deleteEnt(igeomImpl->instance(), all_geom[i], &err);
                 [ #  # ]
    2732                 :            :       }
    2733                 :            :     // position the final assembly at the center
    2734                 :            :     // get the assembly on z=0 plane
    2735                 :            : 
    2736         [ #  # ]:          0 :     double zcenter = m_dMZAssm(nTemp, 2)/2.0;//move up
    2737         [ #  # ]:          0 :     SimpleArray<iBase_EntityHandle> all;
    2738 [ #  # ][ #  # ]:          0 :     iGeom_getEntities( igeomImpl->instance(), root_set, iBase_REGION,ARRAY_INOUT(all),&err );
         [ #  # ][ #  # ]
                 [ #  # ]
    2739                 :            : 
    2740 [ #  # ][ #  # ]:          0 :     for(int i=0; i<all.size(); i++){
    2741 [ #  # ][ #  # ]:          0 :         iGeom_moveEnt(igeomImpl->instance(),all[i],0,0,-zcenter,&err);
                 [ #  # ]
    2742                 :            :       }
    2743                 :          0 :     free(offset);
    2744                 :            : #endif
    2745 [ #  # ][ #  # ]:          0 :     std::cout << "-----Done creating 2D surface-----"<<std::endl;
    2746                 :            :     
    2747                 :          0 :   }
    2748 [ +  - ][ +  - ]:        156 : }

Generated by: LCOV version 1.11