MeshKit  1.0
PostBL.cpp
Go to the documentation of this file.
00001 #include "meshkit/PostBL.hpp"
00002 
00003 namespace MeshKit
00004 {
00005   
00006   // static registration of this mesh scheme
00007   moab::EntityType PostBL_tps[] = {moab::MBHEX,
00008                                    moab::MBMAXTYPE};
00009   const moab::EntityType* PostBL::output_types()
00010   { return PostBL_tps; }
00011   
00012   PostBL::PostBL( MKCore *mk, const MEntVector &me_vec)
00013     : MeshScheme( mk, me_vec),
00014       igeom(mk->igeom_instance()), imesh(mk->imesh_instance()),
00015       mb (mk->moab_instance())
00016     // ---------------------------------------------------------------------------
00020     // ---------------------------------------------------------------------------
00021   {
00022     tri_sch = 2;
00023     m_Conn = 0;
00024     m_BElemNodes = 0;
00025     m_SurfId = -1;
00026     check_bl_edge_length = false;
00027     debug = false;
00028     hybrid = false;
00029     m_NeumannSet = -1;
00030     m_Material = 999999;
00031     m_nLineNumber = 0;
00032     szComment = "!";
00033     MAXCHARS = 300;
00034     m_JacCalls = 0;
00035     m_JLo = 0.0;
00036     m_JHi = 0.0;
00037     err = 0;
00038     fixmat = -1;
00039     hex27 = 0;
00040 //    hex = NULL;
00041 //    hex1 = NULL;
00042 //    hex2 = NULL;
00043   }
00044   
00045   PostBL::~PostBL()
00046   // ---------------------------------------------------------------------------
00050   // ---------------------------------------------------------------------------
00051   {}
00052   
00053   bool PostBL::add_modelent(ModelEnt *model_ent)
00054   // ---------------------------------------------------------------------------
00058   // ---------------------------------------------------------------------------
00059   {
00060     return MeshOp::add_modelent(model_ent);
00061   }
00062   
00063   void PostBL::setup_this()
00064   // ---------------------------------------------------------------------------
00068   // ---------------------------------------------------------------------------
00069   {
00070     if (debug) {
00071         m_LogFile <<  "\nIn setup this : " <<  std::endl;
00072       }
00073     
00074   }
00075   
00076   void PostBL::execute_this()
00077   // ---------------------------------------------------------------------------
00081   // ---------------------------------------------------------------------------
00082   {
00083     m_LogFile << "\nIn execute this : creating boundary layer elements.." <<  std::endl;
00084     // start the timer
00085     CClock Timer;
00086     clock_t sTime = clock();
00087     std::string szDateTime;
00088     Timer.GetDateTime (szDateTime);
00089     VerdictWrapper vw(mb);
00090     
00091     m_LogFile <<  "\nStarting out at : " << szDateTime << std::endl;
00092     m_LogFile <<  "\n Loading meshfile: " << m_MeshFile << std::endl;
00093     
00094     // load specified mesh file
00095     IBERRCHK(imesh->load(0, m_MeshFile.c_str(),0), *imesh);
00096     
00097     //check if intervals is read from input file
00098     if(m_Intervals == 0){
00099         m_LogFile << "Please specify desired number of intervals using 'Intervals' keyword" << std::endl;
00100         exit(0);
00101       }
00102     // if no NS specified, take all d-1 elements as BL input
00103     if (m_NeumannSet == -1 && m_SurfId == -1) {
00104         // create a neumann set with id 99999 in the model and set it for BL generation
00105         moab::Range neuEnts;
00106         moab::EntityHandle neuEntSet;
00107         moab::Tag neuTag;
00108         mb->create_meshset(moab::MESHSET_SET, neuEntSet);
00109         mb->get_entities_by_dimension(mb->get_root_set(), 2, neuEnts, true);
00110         mb->add_entities(neuEntSet, neuEnts);
00111         mb->tag_get_handle("NEUMANN_SET", neuTag);
00112         m_NeumannSet = 999999;
00113         mb->tag_set_data(neuTag, &neuEntSet, 1, (void*) &m_NeumannSet);
00114       }
00115     
00116     moab::Range all_elems, all_verts;
00117     MBERRCHK(mb->get_entities_by_dimension(0, 3, all_elems,true),mb);
00118     if (all_elems.size() == 0)
00119       m_GD = 2;
00120     else if (all_elems.size() > 0)
00121       m_GD = 3;
00122     else
00123       exit(0);
00124     all_elems.clear();
00125     m_LogFile << "Geometric dimension of meshfile = "<< m_GD <<std::endl;
00126     
00127     // obtain existing tag handles
00128     MBERRCHK(mb->tag_get_handle("GEOM_DIMENSION", 1, moab::MB_TYPE_INTEGER, GDTag),mb);
00129     MBERRCHK(mb->tag_get_handle("NEUMANN_SET", 1, moab::MB_TYPE_INTEGER, NTag),mb);
00130     MBERRCHK(mb->tag_get_handle("MATERIAL_SET", 1, moab::MB_TYPE_INTEGER, MTag),mb);
00131     MBERRCHK(mb->tag_get_handle("GLOBAL_ID", 1, moab::MB_TYPE_INTEGER, GIDTag),mb);
00132     // create smoothset and fixed tag for mesquite
00133     MBERRCHK(mb->tag_get_handle("SMOOTHSET", 1, moab::MB_TYPE_INTEGER, STag,
00134                                 moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT),mb);
00135     MBERRCHK(mb->tag_get_handle("fixed", 1, moab::MB_TYPE_INTEGER, FTag,
00136                                 moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT),mb);
00137     MBERRCHK(mb->tag_get_handle("mnode", 1, moab::MB_TYPE_INTEGER, MNTag,
00138                                 moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT),mb);
00139     MBERRCHK(mb->tag_get_handle("matid", 1, moab::MB_TYPE_INTEGER, MatIDTag,
00140                                 moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT),mb);
00141     MBERRCHK(mb->tag_get_handle("BLNODEID", 1, moab::MB_TYPE_INTEGER, BLNodeIDTag,
00142                                 moab::MB_TAG_SPARSE|moab::MB_TAG_CREAT),mb);
00143     
00144     // get all the entity sets with boundary layer geom dimension, neumann sets and material sets
00145     m_BLDim = m_GD - 1;
00146     
00147     const void* gdim[] = {&m_BLDim};
00148     
00149     MBERRCHK(mb->get_entities_by_type_and_tag(0, moab::MBENTITYSET, &GDTag,
00150                                               gdim, 1 , sets, moab::Interface::INTERSECT, false), mb);
00151     MBERRCHK(mb->get_entities_by_type_and_tag(0, moab::MBENTITYSET, &NTag, 0, 1 , n_sets),mb);
00152     MBERRCHK(mb->get_entities_by_type_and_tag(0, moab::MBENTITYSET, &MTag, 0, 1 , m_sets),mb);
00153     
00154     // Handling NeumannSets (if BL surf in input via NS)
00155     moab::EntityHandle this_set = 0;
00156     for (set_it = n_sets.begin(); set_it != n_sets.end(); set_it++)  {
00157         
00158         this_set = *set_it;
00159         
00160         // get entity handle of NS specified in the input file
00161         int set_id;
00162         MBERRCHK(mb->tag_get_data(NTag, &this_set, 1, &set_id), mb);
00163         if(set_id == m_NeumannSet)
00164           break;
00165         this_set = 0;
00166       }
00167     if (debug && m_NeumannSet != -1 && this_set != 0){
00168         m_LogFile <<  "Looking for NS with id " << m_NeumannSet <<
00169                       ". Total NS found are: "<< n_sets.size() << std::endl;
00170       }
00171     
00172     // For specified surface: get the  all the quads and nodes in a range
00173     moab::EntityHandle s1;
00174     // variable to store global id of boundary layer specified in the input file
00175     int dims; 
00176     
00177     // Method 1: INPUT by NeumannSet
00178     if(m_NeumannSet != -1 && this_set != 0){
00179         MBERRCHK(mb->get_entities_by_dimension(this_set, m_BLDim, quads,true),mb);
00180         if (quads.size() <=0){
00181             m_LogFile <<  " No quads found, aborting.. " << std::endl;
00182             exit(0);
00183           }
00184         
00185         MBERRCHK(mb->get_adjacencies(quads, 0, false, nodes, moab::Interface::UNION),mb);
00186         if(m_GD == 3)
00187           MBERRCHK(mb->get_adjacencies(quads, 1, true, edges, moab::Interface::UNION),mb);
00188         
00189         if (debug) {
00190             m_LogFile <<  "Found NeumannSet with id : " << m_NeumannSet <<  std::endl;
00191             m_LogFile <<  "#Quads in this surface: " << quads.size() << std::endl;
00192             m_LogFile <<  "#Nodes in this surface: " << nodes.size() << std::endl;
00193             m_LogFile << "#New nodes to be created:" << m_Intervals*nodes.size() << std::endl;
00194           }
00195       }
00196     // Method 2: INPUT by surface id (geom dimension)
00197     else if (m_SurfId !=-1){
00198         for(moab::Range::iterator rit=sets.begin(); rit != sets.end(); ++rit){
00199             s1 = *rit;
00200             MBERRCHK(mb->tag_get_data(GIDTag, &s1, 1, &dims),mb);
00201             
00202             if(dims == m_SurfId && m_SurfId != -1){
00203                 MBERRCHK(mb->get_entities_by_dimension(s1, m_BLDim, quads,true),mb);
00204                 if (quads.size() <=0){
00205                     m_LogFile <<  " No quads found, aborting.. " << std::endl;
00206                     exit(0);
00207                   }
00208                 
00209                 MBERRCHK(mb->get_adjacencies(quads, 0, false, nodes, moab::Interface::UNION),mb);
00210                 if(m_GD == 3)
00211                   MBERRCHK(mb->get_adjacencies(edges, 0, false, nodes, moab::Interface::UNION),mb);
00212                 if (debug) {
00213                     m_LogFile <<  "Found surface with id : " << m_SurfId <<  std::endl;
00214                     m_LogFile <<  "#Quads in this surface: " << quads.size() << std::endl;
00215                     m_LogFile <<  "#Nodes in this surface: " << nodes.size() << std::endl;
00216                     m_LogFile << "#New nodes to be created:" << m_Intervals*nodes.size() << std::endl;
00217                   }
00218               }
00219           }
00220       }
00221     
00222     if (quads.size() == 0 || nodes.size() == 0) {
00223         m_LogFile <<  "Invalid boundary layer specification, aborting.." <<  std::endl;
00224         exit(0);
00225       }
00226     
00227     // placeholder for storing smoothing entities
00228     moab::EntityHandle smooth_set;
00229     int s_id = 100;
00230     MBERRCHK(mb->create_meshset(moab::MESHSET_SET, smooth_set, 1), mb);
00231     MBERRCHK(mb->tag_set_data(STag, &smooth_set, 1, &s_id), mb);
00232     
00233     // placeholder for storing gd on new entities
00234     MBERRCHK(mb->create_meshset(moab::MESHSET_SET, geom_set, 1), mb);
00235     MBERRCHK(mb->tag_set_data(GDTag, &geom_set, 1, &m_GD), mb);
00236     
00237     // declare variables before starting BL creation
00238     std::vector <bool> node_status(false); // size of verts of bl surface
00239     node_status.resize(nodes.size());
00240     blmaterial_id.resize(quads.size());
00241     
00242     //size of the following is based on element type  
00243     new_vert.resize(m_Intervals*nodes.size());
00244     // element on the boundary
00245     Range::iterator kter = quads.begin();
00246     
00247     MBERRCHK(mb->get_adjacencies(&(*kter), 1, m_GD, false, old_hex),mb);
00248     std::cout << "old_hex size is - before filtering fixmat - " << old_hex.size() << std::endl;
00249     if((int) old_hex.size() == 0){
00250         m_LogFile << "unable to find adjacent hex for BL quad, aborting...";
00251         exit(0);
00252       }
00253     
00254     // allocate space for connectivity/adjacency during the first pass of this loop
00255     if(mb->type_from_handle(old_hex[0]) == moab::MBHEX){
00256         m_Conn = 8;
00257         m_BElemNodes = 4;
00258         m_HConn = 8;
00259         //allocating based on element type
00260         conn.resize(m_Intervals*m_Conn), qconn.resize(m_BElemNodes), adj_qconn.resize(m_BElemNodes),
00261             old_hex_conn.resize(m_Conn), adj_hex_nodes1.resize(m_Conn);
00262       }
00263     else if(mb->type_from_handle(old_hex[0]) == MBTET){
00264         m_Conn = 4;
00265         m_BElemNodes = 3;
00266         //allocating based on element type - thrice the number of elements
00267         if(hybrid){
00268             m_HConn = 6;
00269             conn.resize(m_Intervals*6);
00270           }
00271         else{
00272             m_HConn = 6; // we use the prism for making tets
00273             tet_conn.resize(3*m_Intervals*m_Conn);
00274             conn.resize(m_Intervals*6);
00275           }
00276         qconn.resize(m_BElemNodes), adj_qconn.resize(m_BElemNodes),
00277             old_hex_conn.resize(m_Conn), adj_hex_nodes1.resize(m_Conn);
00278       }
00279     else if(mb->type_from_handle(old_hex[0]) == MBQUAD){
00280         m_Conn = 4;
00281         m_HConn = 4;
00282         m_BElemNodes = 2;
00283         //allocating based on element type
00284         conn.resize(m_Intervals*m_Conn), qconn.resize(m_BElemNodes), adj_qconn.resize(m_BElemNodes),
00285             old_hex_conn.resize(m_Conn), adj_hex_nodes1.resize(m_Conn);
00286       }
00287     else if(mb->type_from_handle(old_hex[0]) == MBTRI){
00288         m_Conn = 3;
00289         m_HConn = 4;
00290         m_BElemNodes = 2;
00291         //allocating based on element type - twice the number of elements
00292         if(hybrid){
00293             m_HConn = 4;
00294             conn.resize(m_Intervals*m_HConn);
00295           }
00296         else{
00297             tri_conn.resize(2*m_Intervals*m_Conn);
00298             conn.resize(2*m_Intervals*m_Conn);
00299           }
00300         qconn.resize(m_BElemNodes), adj_qconn.resize(m_BElemNodes),
00301             old_hex_conn.resize(m_Conn), adj_hex_nodes1.resize(m_Conn);
00302       }
00303     else if(m_Conn == 0 || m_BElemNodes == 0){
00304         m_LogFile << "This mesh type is not supported by this tool" << std::endl;
00305         exit(0);
00306       }
00307     
00308     // Tag all nodes on outer boundary with a unique number
00309     int node_id = 0;
00310     std::vector<int> NId(nodes.size());
00311     for(moab::Range::iterator nodes_iter = nodes.begin(); nodes_iter != nodes.end(); nodes_iter++){
00312         NId[node_id] = node_id;
00313         MBERRCHK(mb->tag_set_data(BLNodeIDTag, &(*nodes_iter),1, &NId[node_id]), mb);
00314         ++node_id;
00315       }
00316     
00317     // Handling MaterialSet
00318     int mset_id = 0, found = 0;
00319     for (mset_it = m_sets.begin(); mset_it != m_sets.end(); mset_it++)  {
00320         
00321         mthis_set = *mset_it;
00322         
00323         // get entity handle of MS specified in the input file
00324         MBERRCHK(mb->tag_get_data(MTag, &mthis_set, 1, &mset_id), mb);
00325         
00326         // if no material set is specified, we'll have to resolve else just set all the MNTag to 0
00327         if(mset_id == m_Material){
00328             found = 1;
00329             break;
00330           }
00331         else if(mset_id == fixmat){
00332             MBERRCHK(mb->get_entities_by_dimension(mthis_set, m_GD, fixmat_ents ,true),mb);
00333           }
00334         
00335         // get all the nodes in the material and tag bl nodes
00336         moab::Range mat_nodes, mat_hexes;
00337         if(m_GD == 3){
00338             if(m_Conn == 8)
00339               MBERRCHK(mb->get_entities_by_type(mthis_set, moab::MBHEX, mat_hexes, true), mb);
00340             else if(m_Conn ==4)
00341               MBERRCHK(mb->get_entities_by_type(mthis_set, moab::MBTET, mat_hexes, true), mb);
00342           }
00343         else if(m_GD == 2){
00344             if(m_Conn == 4)
00345               MBERRCHK(mb->get_entities_by_type(mthis_set, moab::MBQUAD, mat_hexes, true), mb);
00346             else if(m_Conn == 3)
00347               MBERRCHK(mb->get_entities_by_type(mthis_set, moab::MBTRI, mat_hexes, true), mb);
00348           }
00349         
00350         // tag all the mat_hexes with matid
00351         std::vector<int> matID(mat_hexes.size(), mset_id);
00352         MBERRCHK(mb->tag_set_data(MatIDTag, mat_hexes, &matID[0]), mb);
00353         //
00354         MBERRCHK(mb->get_adjacencies(mat_hexes, 0, false, mat_nodes, Interface::UNION), mb);
00355         moab::Range mat_b_nodes = intersect(nodes, mat_nodes);
00356         
00357         std::vector<int> bl_node_data(mat_b_nodes.size(), 0);
00358         std::vector<int> node_tag_data(mat_b_nodes.size(),-1);
00359         
00360         // don't do error check, as it is supposed to give error when multiple material case is encountered
00361         mb->tag_get_data(MNTag, mat_b_nodes, &node_tag_data[0]);
00362         for(int i=0; i< (int)mat_b_nodes.size(); i++){
00363             // already a part of some material
00364             if(node_tag_data[i] != -1){
00365                 bl_node_data[i] = node_tag_data[i]+1;
00366               }
00367           }
00368         
00369         MBERRCHK(mb->tag_set_data(MNTag, mat_b_nodes, &bl_node_data[0]), mb);
00370         mat_hexes.clear();
00371         mat_b_nodes.clear();
00372         mat_nodes.clear();
00373         mthis_set = 0;
00374       } // end handling material set
00375     
00376     // if fixmat specified, filter old hex, we don't have to correct both sides of the boundary
00377     if (fixmat !=-1 && (int) old_hex.size() > 1){
00378         moab::EntityHandle old_hex_set;
00379         MBERRCHK(mb->create_meshset(moab::MESHSET_SET, old_hex_set, 1), mb);
00380         MBERRCHK(mb->add_entities(old_hex_set,&old_hex[0], (int) old_hex.size()), mb);
00381         // TODO: Find a faster way of doing this
00382         MBERRCHK(mb->remove_entities(old_hex_set, fixmat_ents), mb);
00383         old_hex.clear();
00384         old_hex.empty();
00385         // the the old hex to be modified
00386         MBERRCHK(mb->get_entities_by_dimension(old_hex_set, m_GD, old_hex), mb);
00387       }
00388     else if(fixmat ==-1 && (int) old_hex.size()>1){
00389         m_LogFile << "FIXMAT not defined, elements found on either side of specified BL surface, aborting...";
00390         m_LogFile << "\n\n Define FIXMAT keyword with material id that remains fixed." << std::endl;
00391         exit(0);
00392       }
00393     
00394     MBERRCHK(mb->get_connectivity(&(*kter), 1, qconn),mb);
00395     MBERRCHK(mb->get_connectivity(&old_hex[0], 1, old_hex_conn),mb);
00396     
00397     // get the normal to the plane of the 2D mesh
00398     if(m_GD==2)
00399       get_normal_quad (old_hex_conn, surf_normal);
00400     if(found == 1 && m_Material !=999999){
00401         m_LogFile << "Found material set with id " << m_Material << std::endl;
00402       }
00403     else if (m_Material !=999999 && found == 0){
00404         // material set found, but non-existant. Now create this material set
00405         m_LogFile << "Creating material set with id " << m_Material << std::endl;
00406         MBERRCHK(mb->create_meshset(moab::MESHSET_SET, mthis_set, 1), mb);
00407         MBERRCHK(mb->tag_set_data(MTag, &mthis_set, 1, &m_Material), mb);
00408       }
00409     else if (m_Material == 999999 && found == 0){
00410         m_LogFile << "Use old materials for new boundary layer elements. No material specified." << std::endl;
00411         
00412         // If no material tag exists in the model create one now
00413         if((int)m_sets.size() == 0){
00414             m_LogFile << "Creating material set with id " << m_Material << std::endl;
00415             MBERRCHK(mb->create_meshset(moab::MESHSET_SET, mthis_set, 1), mb);
00416             MBERRCHK(mb->tag_set_data(MTag, &mthis_set, 1, &m_Material), mb);
00417           }
00418       }
00419     else{
00420         m_LogFile << "Unhandled case" << std::endl;
00421         exit(0);
00422       }
00423     
00424     err = compute_normals();
00425     if (err!=0){
00426         m_LogFile << "Failed to compute normals" << std::endl;
00427         exit(0);
00428       }
00429       
00430     err = push_bulk_mesh(vw);
00431     if (err!=0){
00432         m_LogFile << "Failed to push bulk mesh" << std::endl;
00433         exit(0);
00434       }
00435     err = create_bl_elements(vw);
00436     if (err!=0){
00437         m_LogFile << "Failed to create boundary layer elements after pushing bulk mesh" << std::endl;
00438         exit(0);
00439       }
00440       
00441     m_LogFile << "\nTotal Jacobian calls/Min/Max of penultimate hex elements:" << m_JacCalls << ", " << m_JLo << ", " << m_JHi << std::endl;
00442     
00443     // convert the final mesh to hex27 for Nek5000 
00444     if(hex27 == 1){
00445         moab::Range entities;
00446         moab::EntityHandle meshset;
00447         mb->get_entities_by_type(0, MBHEX, entities);
00448         mb->create_meshset(MESHSET_SET, meshset);
00449         mb->add_entities(meshset, entities);
00450         // Add nodes along mid- edge, face and region
00451         mb->convert_entities(meshset, true, true, true);
00452         m_LogFile << "Mesh converted from hex 8 to hex 27 elements" << std::endl;
00453       }
00454     
00455     // save the final mesh with boundary layer elements
00456     MBERRCHK(mb->write_mesh(m_OutFile.c_str()),mb);
00457     m_LogFile <<  "\n\nWrote Mesh File: " << m_OutFile << std::endl;
00458     // get the current date and time
00459     Timer.GetDateTime (szDateTime);
00460     m_LogFile << "Ending at : " << szDateTime;
00461     // report/compute the elapsed time
00462     m_LogFile <<  "Elapsed wall clock time: " << Timer.DiffTime ()
00463                << " seconds or " << (Timer.DiffTime ())/60.0 << " mins\n";
00464     m_LogFile <<  "Total CPU time used: " << (double) (clock() - sTime)/CLOCKS_PER_SEC \
00465                << " seconds" << std::endl;
00466   }
00467   
00468   void PostBL::PrepareIO (int argc, char *argv[], std::string  TestDir)
00469   // ---------------------------------------------------------------------------
00473   // ---------------------------------------------------------------------------
00474   {
00475     // set and open input output files
00476     bool bDone = false;
00477     do{
00478         if (2 == argc) {
00479             m_InputFile = argv[1];
00480             m_LogName = m_InputFile + ".log";
00481           }
00482         else if (1 == argc){            
00483             m_InputFile = TestDir + "/" + (char *)DEFAULT_TEST_POSTBL;
00484             m_LogName = (std::string)DEFAULT_TEST_POSTBL + ".log";
00485           }
00486         
00487         // open input file for reading
00488         m_FileInput.open (m_InputFile.c_str(), std::ios::in);
00489         if (!m_FileInput){
00490             m_LogFile << "Usage: postbl <filename.inp> " << std::endl;
00491             m_LogFile << "Default test file can be found here <Meshkit/data>" << std::endl;
00492             m_LogFile << " Examples input and mesh files are located here <MeshKit/test/algs/postbl_examples>" << std::endl;
00493             m_FileInput.clear ();
00494             exit(1);
00495           }
00496         else
00497           bDone = true; // file opened successfully
00498         
00499         // open the log file for dumping debug/output statements
00500         m_LogFile.coss.open (m_LogName.c_str(), std::ios::out);
00501         if (!m_LogFile.coss){
00502             m_LogFile <<  "Unable to open file: " << m_LogName << std::endl;
00503             m_LogFile.coss.clear ();
00504             exit(1);
00505           }
00506         else
00507           bDone = true; // file opened successfully
00508         m_LogFile <<  '\n';
00509         m_LogFile <<  "\t\t---------------------------------------------------------" << '\n';
00510         m_LogFile <<  "\t\t         Tool to generate Post-mesh Boundary Layers      " << '\n';
00511         m_LogFile <<  "\t\t\t\tArgonne National Laboratory" << '\n';
00512         m_LogFile <<  "\t\t\t\t        2012         " << '\n';
00513         m_LogFile <<  "\t\t---------------------------------------------------------" << '\n';
00514         m_LogFile <<  "\nsee README file for using the program and details on various cards.\n"<< std::endl;
00515         
00516       }while (!bDone);
00517     
00518     // Get the meshfile name, surface(s), thickness, intervals and bias
00519     CParser Parse;
00520     int maxloop = 1000;
00521     // count the total number of cylinder commands in each pincellh
00522     for(;;){
00523         if(m_nLineNumber > maxloop){
00524             m_LogFile << "Warning: Didn't find End keyword, stopping after reading 1000 lines from input file" << std::endl;
00525             break;
00526           }
00527         if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString,
00528                                  MAXCHARS, szComment))
00529           IOErrorHandler (INVALIDINPUT);
00530         
00531         // Get tri scheme
00532         if (szInputString.substr(0,9) == "trischeme"){
00533             std::istringstream szFormatString (szInputString);
00534             szFormatString >> m_Card >> tri_sch;
00535             if(szFormatString.fail())
00536               IOErrorHandler(INVALIDINPUT);
00537             m_LogFile <<  m_Card << " name read: "<< tri_sch << std::endl;
00538           }
00539         // Get hybrid
00540         if (szInputString.substr(0,6) == "hybrid"){
00541             std::istringstream szFormatString (szInputString);
00542             szFormatString >> m_Card >> hybrid;
00543             if(szFormatString.fail())
00544               IOErrorHandler(INVALIDINPUT);
00545             m_LogFile <<  m_Card << " name read: "<< hybrid << std::endl;
00546           }
00547         // Get hybrid
00548         if (szInputString.substr(0,6) == "fixmat"){
00549             std::istringstream szFormatString (szInputString);
00550             szFormatString >> m_Card >> fixmat;
00551             if(szFormatString.fail())
00552               IOErrorHandler(INVALIDINPUT);
00553             m_LogFile <<  m_Card << " name read: "<< fixmat << std::endl;
00554           }
00555         // Get MeshFile name
00556         if (szInputString.substr(0,8) == "meshfile"){
00557             std::istringstream szFormatString (szInputString);
00558             szFormatString >> m_Card >> m_MeshFile;
00559             if(szFormatString.fail())
00560               IOErrorHandler(INVALIDINPUT);
00561             m_LogFile <<  m_Card << " name read: "<< m_MeshFile << std::endl;
00562             if (argc == 1){
00563                 m_MeshFile = TestDir + "/" + m_MeshFile;
00564               }
00565           }
00566         // Get BL surface
00567         if (szInputString.substr(0,8) == "surfaces"){
00568             std::istringstream szFormatString (szInputString);
00569             szFormatString >> m_Card >> m_SurfId;
00570             if(m_SurfId < 0 || szFormatString.fail())
00571               IOErrorHandler(INVALIDINPUT);
00572             m_LogFile <<  m_Card << " read: "<< m_SurfId <<std::endl;
00573           }
00574         // Get BL surface via neumann set or sideset
00575         if (szInputString.substr(0,10) == "neumannset"){
00576             std::istringstream szFormatString (szInputString);
00577             szFormatString >> m_Card >> m_NeumannSet;
00578             if(m_NeumannSet < 0 || szFormatString.fail())
00579               IOErrorHandler(INVALIDINPUT);
00580             m_LogFile <<  m_Card << " read: "<< m_NeumannSet <<std::endl;
00581           }
00582         // Get BL material (block) number
00583         if (szInputString.substr(0,8) == "material"){
00584             std::istringstream szFormatString (szInputString);
00585             szFormatString >> m_Card >> m_Material;
00586             if(m_Material < 0 || szFormatString.fail())
00587               IOErrorHandler(INVALIDINPUT);
00588             m_LogFile <<  m_Card << " read: "<< m_Material <<std::endl;
00589           }
00590         
00591         // Get thickness
00592         if (szInputString.substr(0,9) == "thickness"){
00593             std::istringstream szFormatString (szInputString);
00594             szFormatString >> m_Card >> m_Thickness;
00595             if(m_Thickness < 0 || szFormatString.fail())
00596               IOErrorHandler(INVALIDINPUT);
00597             m_LogFile <<  m_Card << " read: "<< m_Thickness <<std::endl;
00598           }
00599         // Get intervals
00600         if (szInputString.substr(0,9) == "intervals"){
00601             std::istringstream szFormatString (szInputString);
00602             szFormatString >> m_Card >> m_Intervals;
00603             if(m_Intervals < 0 || szFormatString.fail())
00604               IOErrorHandler(INVALIDINPUT);
00605             m_LogFile <<  m_Card << " read: "<< m_Intervals <<std::endl;
00606           }
00607         // Get bias
00608         if (szInputString.substr(0,4) == "bias"){
00609             std::istringstream szFormatString (szInputString);
00610             szFormatString >> m_Card >> m_Bias;
00611             if(m_Bias < 0 || szFormatString.fail())
00612               IOErrorHandler(INVALIDINPUT);
00613             m_LogFile <<  m_Card << " read: "<< m_Bias <<std::endl;
00614           }
00615         // Output file name
00616         if (szInputString.substr(0,7) == "outfile"){
00617             std::istringstream szFormatString (szInputString);
00618             szFormatString >> m_Card >> m_OutFile;
00619             if(szFormatString.fail())
00620               IOErrorHandler(INVALIDINPUT);
00621             m_LogFile <<  m_Card << " name read: "<< m_OutFile <<std::endl;
00622           }
00623         // Output file name
00624         if (szInputString.substr(0,7) == "outfile"){
00625             std::istringstream szFormatString (szInputString);
00626             szFormatString >> m_Card >> m_OutFile;
00627             if(szFormatString.fail())
00628               IOErrorHandler(INVALIDINPUT);
00629             m_LogFile <<  m_Card << " name read: "<< m_OutFile <<std::endl;
00630           }
00631         // save hex27 mesh
00632         if (szInputString.substr(0,5) == "hex27"){
00633             std::istringstream szFormatString (szInputString);
00634             szFormatString >> m_Card >> hex27;
00635             if(szFormatString.fail())
00636               IOErrorHandler(INVALIDINPUT);
00637             m_LogFile <<  m_Card << " hex27 creation: "<< hex27 <<std::endl;
00638           }
00639         if (szInputString.substr(0,3) == "end"){
00640             break;
00641           }
00642       }
00643   }
00644   
00645   void PostBL::IOErrorHandler (ErrorStates ECode) const
00646   // ---------------------------------------------------------------------------
00650   // ---------------------------------------------------------------------------
00651   {
00652     std::cerr << '\n';
00653     if (ECode == INVALIDINPUT) // invalid input
00654       std::cerr << "Invalid input.";
00655     else
00656       std::cerr << "Unknown error ...?";
00657     
00658     std::cerr << '\n' << "Error in input file line : " << m_nLineNumber;
00659     std::cerr << std::endl;
00660     exit (1);
00661   }
00662   
00663   
00664 } // namespace MeshKit
00665 
00666 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines