MeshKit
1.0
|
00001 #include <stdio.h> 00002 #include "meshkit/AssyMesher.hpp" 00003 #include "meshkit/LocalSet.hpp" 00004 #include "meshkit/MKCore.hpp" 00005 #include "meshkit/ModelEnt.hpp" 00006 #include "meshkit/OneToOneSwept.hpp" 00007 #include "meshkit/RegisterMeshOp.hpp" 00008 #include "meshkit/SizingFunction.hpp" 00009 00010 #include "iMesh_extensions.h" 00011 #include "MBCN.h" 00012 #include "moab/Types.hpp" 00013 #include "MBTagConventions.hpp" 00014 00015 00016 namespace MeshKit 00017 { 00018 // static registration of this mesh scheme 00019 moab::EntityType AssyMesher_tps[] = { moab::MBTET, 00020 moab::MBQUAD, 00021 moab::MBTRI, 00022 moab::MBHEX, 00023 moab::MBMAXTYPE}; 00024 const moab::EntityType* AssyMesher::output_types() 00025 { return AssyMesher_tps; } 00026 00027 AssyMesher::AssyMesher(MKCore *mk, const MEntVector &me_vec) 00028 : MeshScheme( mk, me_vec), 00029 igeom(mk->igeom_instance()), imesh(mk->imesh_instance()), 00030 mb (mk->moab_instance()) 00031 { 00032 m_nPlanar = 0; //default is 3D 00033 m_nLineNumber = 0; 00034 szComment = "!"; 00035 MAXCHARS = 300; 00036 pi = M_PI; 00037 m_dRadialSize = -1.0; 00038 m_dAxialSize = -1.0; 00039 m_dTetMeshSize = -1.0; 00040 m_nDimensions = 0; 00041 m_nMaterialSetId = 1; 00042 m_nNeumannSetId = 1; 00043 m_szEngine = "acis"; 00044 m_szMeshType = "hex"; 00045 m_nDuct = 0; 00046 m_nDuctNum = 0; 00047 m_nJouFlag = 0; 00048 m_szSideset = "yes"; 00049 m_dMergeTol = 1e-4; 00050 m_GeomFile = ""; 00051 } 00052 00053 AssyMesher::~AssyMesher() 00054 {} 00055 00056 bool AssyMesher::add_modelent(ModelEnt *model_ent) 00057 { 00058 return MeshOp::add_modelent(model_ent); 00059 } 00060 00061 void AssyMesher::setup_this() 00062 { 00063 // populate the model entities based on the geometry 00064 mk_core()->populate_model_ents(); 00065 00066 // create a set with the names of materials as std::string 00067 for (int mtrlIndx = 1; mtrlIndx <= m_nAssemblyMat; ++mtrlIndx) 00068 { 00069 allMtrlsSet.insert(m_szAssmMat(mtrlIndx)); 00070 } 00071 00072 // get a vector of all surfaces 00073 std::vector<iGeom::EntityHandle> allSurfs; 00074 iGeom::EntitySetHandle rootSetHandle = igeom->getRootSet(); 00075 igeom->getEntities(rootSetHandle, iBase_FACE, allSurfs); 00076 00077 // get a vector of all surfaces that have are identified 00078 // as top surfaces for some material 00079 std::vector<iGeom::EntityHandle> *allTopSurfs = 00080 selectByMaterialsAndNameSuffix(allSurfs, allMtrlsSet, "_top"); 00081 00082 // get the tag on the geometry that identifies the associated model entity 00083 iGeom::TagHandle meTag = mk_core()->igeom_model_tag(); 00084 00085 // sizing function for radial mesh size . . . MeshKit core will delete it 00086 SizingFunction* radialMeshSizePtr; 00087 if (m_dRadialSize <= 0 && m_nDimensions > 0) 00088 { 00089 // the radial size was not specified in the input 00090 // but there are pins 00091 if (m_szGeomType == "hexagonal") 00092 { 00093 double pitch = m_dMAssmPitch(1, m_nDimensions); 00094 radialMeshSizePtr = new SizingFunction(mk_core(), -1, 0.1*pitch); 00095 } 00096 else 00097 { 00098 double pitchX = m_dMAssmPitchX(1, m_nDimensions); 00099 double pitchY = m_dMAssmPitchY(1, m_nDimensions); 00100 radialMeshSizePtr = new SizingFunction(mk_core(), -1, 00101 0.02*0.5*(pitchX + pitchY)); 00102 } 00103 } 00104 else if (m_dRadialSize <= 0) 00105 { 00106 // there are no pins and no radial mesh size 00107 radialMeshSizePtr = new SizingFunction(mk_core(), -1, 1.0); 00108 } 00109 else 00110 { 00111 radialMeshSizePtr = new SizingFunction(mk_core(), -1, m_dRadialSize); 00112 } 00113 int radialSizeIndex = radialMeshSizePtr->core_index(); 00114 00115 // sizing function for axial mesh size . . . MeshKit core will delete it 00116 // it looks like axial mesh size can be more complicated depending 00117 // on number of ducts but for the moment assume it is uniform 00118 SizingFunction* axialMeshSizePtr; 00119 if (m_dAxialSize <= 0) // the axial size was not specified in the input 00120 { 00121 // in uniform size case, default is 10 intervals, i.e. 10% of height 00122 axialMeshSizePtr = new SizingFunction(mk_core(), 10, -1); 00123 } 00124 else 00125 { 00126 axialMeshSizePtr = new SizingFunction(mk_core(), -1, m_dAxialSize); 00127 } 00128 int axialSizeIndex = axialMeshSizePtr->core_index(); 00129 00130 // set the mesh sizes and operations starting from top surfaces 00131 for (unsigned int tsi = 0; tsi < allTopSurfs->size(); ++tsi) 00132 { 00133 // Remark: iterator pattern may perform better that indexed loop here 00134 iGeom::EntityHandle topGeoHandle = (*allTopSurfs)[tsi]; 00135 ModelEnt* meTopSurf; 00136 igeom->getData(topGeoHandle, meTag, &meTopSurf); 00137 // TODO: check success 00138 meTopSurf->sizing_function_index(radialSizeIndex); 00139 00140 MEntVector topSurfVec; 00141 topSurfVec.push_back(meTopSurf); 00142 MeshOp* paveOp = mk_core()->construct_meshop("CAMALPaver", topSurfVec); 00143 mk_core()->insert_node(paveOp, (MeshOp*) this, mk_core()->root_node()); 00144 00145 double topBBMinX, topBBMinY, topBBMinZ, topBBMaxX, topBBMaxY, topBBMaxZ; 00146 igeom->getEntBoundBox(topGeoHandle, 00147 topBBMinX, topBBMinY, topBBMinZ, topBBMaxX, topBBMaxY, topBBMaxZ); 00148 00149 std::vector<iGeom::EntityHandle> adjRegions; 00150 igeom->getEntAdj(topGeoHandle, iBase_REGION, adjRegions); 00151 for (size_t ari = 0; ari < adjRegions.size(); ++ari) 00152 { 00153 iGeom::EntityHandle adjRegionHandle = adjRegions[ari]; 00154 00155 // confirm that the adjacent region is really below the top surface 00156 double arBBMinX, arBBMinY, arBBMinZ, arBBMaxX, arBBMaxY, arBBMaxZ; 00157 igeom->getEntBoundBox(adjRegionHandle, 00158 arBBMinX, arBBMinY, arBBMinZ, arBBMaxX, arBBMaxY, arBBMaxZ); 00159 if (arBBMinZ >= topBBMinZ) 00160 { 00161 // this is not the correct region since it is not below the top surface 00162 continue; 00163 } 00164 00165 ModelEnt* regionME; 00166 igeom->getData(adjRegionHandle, meTag, ®ionME); 00167 // TODO: check success 00168 00169 regionME->sizing_function_index(axialSizeIndex, false); 00170 00171 // examine the faces of the region in order to 00172 // (1) identify indices of the top and bottom face 00173 // (2) set sizes on vertical faces and bottom face as needed 00174 std::vector<iGeom::EntityHandle> regionSurfs; 00175 igeom->getEntAdj(adjRegionHandle, iBase_FACE, regionSurfs); 00176 size_t topFaceIndex=0, bottomFaceIndex=0; 00177 for (size_t rfi = 0; rfi < regionSurfs.size(); ++rfi) 00178 { 00179 iGeom::EntityHandle regionFaceHandle = regionSurfs[rfi]; 00180 if (regionFaceHandle == topGeoHandle) 00181 { 00182 topFaceIndex = rfi; 00183 continue; 00184 } 00185 00186 // check whether this face shares an edge with the top face 00187 bool commonEdge = false; 00188 std::vector<iGeom::EntityHandle> edgesOfFace; 00189 igeom->getEntAdj(regionFaceHandle, iBase_EDGE, edgesOfFace); 00190 for (size_t eofci = 0; eofci < edgesOfFace.size(); ++eofci) 00191 { 00192 igeom->isEntAdj(topGeoHandle, edgesOfFace[eofci], commonEdge); 00193 if (commonEdge) break; 00194 } 00195 00196 if (commonEdge) 00197 { 00198 // this is a vertical face 00199 ModelEnt* meVertSurf; 00200 igeom->getData(regionFaceHandle, meTag, &meVertSurf); 00201 // TODO: check success 00202 if (meVertSurf->sizing_function_index() == -1) 00203 { 00204 // the vertical surface has not yet been processed, since no 00205 // sizing function index is set on it 00206 meVertSurf->sizing_function_index(axialSizeIndex, false); 00207 // sizing function needs to be set on the vertical edges . . . 00208 // it should be okay to set it on all boundary edges not yet set 00209 MEntVector edgeMEsVec; 00210 std::vector<int> senses; 00211 meVertSurf->boundary(1, edgeMEsVec, &senses); 00212 for (size_t emei = 0; emei < edgeMEsVec.size(); ++emei) 00213 { 00214 if (edgeMEsVec[emei]->sizing_function_index() == -1) 00215 { 00216 edgeMEsVec[emei]->sizing_function_index(axialSizeIndex, false); 00217 } 00218 } 00219 } 00220 } 00221 else 00222 { 00223 // this is the bottom face 00224 bottomFaceIndex = rfi; 00225 ModelEnt* meBottomSurf; 00226 igeom->getData(regionFaceHandle, meTag, &meBottomSurf); 00227 // TODO: check success 00228 if (meBottomSurf->sizing_function_index() == -1) 00229 { 00230 // the bottom surface does not yet have a 00231 // sizing function set on it 00232 meBottomSurf->sizing_function_index(radialSizeIndex); 00233 } 00234 MEntVector edgeMEsVec; 00235 std::vector<int> senses; 00236 meBottomSurf->boundary(1, edgeMEsVec, &senses); 00237 for (size_t emei = 0; emei < edgeMEsVec.size(); ++emei) 00238 { 00239 edgeMEsVec[emei]->constrain_even(true); 00240 } 00241 } 00242 } 00243 00244 MEntVector regionVec; 00245 regionVec.push_back(regionME); 00246 OneToOneSwept *sweepOp = (OneToOneSwept*) 00247 mk_core()->construct_meshop("OneToOneSwept", regionVec); 00248 sweepOp->SetSourceSurface(topFaceIndex); 00249 sweepOp->SetTargetSurface(bottomFaceIndex); 00250 mk_core()->insert_node(sweepOp, (MeshOp*)this, paveOp); 00251 } 00252 } 00253 00254 delete allTopSurfs; 00255 00256 mk_core()->print_graph(); 00257 } 00258 00259 void AssyMesher::execute_this() 00260 { 00261 std::cout << "Execute : start meshing the assembly" << std::endl; 00262 createMaterialNeumannSets(allMtrlsSet); 00263 //createMaterialNeumannSets(); 00264 // Start doing the steps in .jou file: /MeshKit/rgg/io.cpp:routine:CreateCubitJournal() 00265 // AssyMesher 00266 // 1. Find surfaces with names <pin_material>_top and set radial mesh size, also set mesh scheme to CAMALTriMesher or GRUMMP trimesher 00267 // 2. Sweep the volumes with top surfaces of pins, use bottom surfaces of the pins if required: bottom surfaces are name as <pin_material_bot> 00268 // 3. Find edges in surfaces with names <material_side> set size equal to edge length 00269 // 4. After meshing assign block names for all pins, by filtering using volumes 00270 // 5. Now mesh the top cutout portion using CAMALTriMesher or GRUMMP trim//esher (Report if this fails, if this fails change in radial mesh size and edge interval might be needed) 00271 // 6. Now sweep and name blocks. 00272 // 7. Create Neumann Sets 00273 00274 // step 1 00275 00276 00277 } 00278 00279 void AssyMesher::PrepareIO (int argc, char *argv[], std::string TestDir) 00280 // --------------------------------------------------------------------------- 00281 // Function: Obtains file names and opens input/output files 00282 // Input: command line arguments 00283 // Output: none 00284 // --------------------------------------------------------------------------- 00285 { 00286 // set and open input output files 00287 bool bDone = false; 00288 #ifdef HAVE_OCC 00289 //switch to else to protect from having define twice 00290 #define EXTENSION ".brep"; 00291 #else 00292 #define EXTENSION "" 00293 #endif 00294 do{ 00295 if (2 == argc) { 00296 m_InputFile = (std::string)argv[1] + ".inp"; 00297 m_LogName = m_InputFile + ".log"; 00298 m_GeomFile = (std::string)argv[1] + EXTENSION; 00299 m_szCommonFile = "common.inp"; 00300 } 00301 else if (1 == argc){ 00302 m_LogFile << "\nRunning default case:\n" << std::endl; 00303 m_GeomFile = TestDir + "/" + (char *)DEFAULT_TEST_AM+ EXTENSION; 00304 m_InputFile = TestDir + "/" + (char *)DEFAULT_TEST_AM + ".inp"; 00305 m_LogName = (std::string)DEFAULT_TEST_AM + ".log"; 00306 m_szCommonFile = TestDir + "/" + "common.inp"; 00307 00308 } 00309 // open input file for reading 00310 m_FileInput.open (m_InputFile.c_str(), std::ios::in); 00311 if (!m_FileInput){ 00312 m_LogFile << "Unable to open file: " << m_InputFile << std::endl; 00313 m_FileInput.clear (); 00314 exit(1); 00315 } 00316 else 00317 bDone = true; // file opened successfully 00318 00319 // open common.inp file, if not found do nothing. 00320 m_FileCommon.open (m_szCommonFile.c_str(), std::ios::in); 00321 if (!m_FileCommon){ 00322 have_common = false; 00323 std::cout << "common.inp file not specified." << std::endl; 00324 m_FileCommon.clear (); 00325 } 00326 else { 00327 have_common = true; 00328 } 00329 std::cout << " opened file " << m_szCommonFile << " have common is " 00330 << have_common << std::endl; 00331 // } while (!bDone); 00332 00333 00334 // open the log file for dumping debug/output statements 00335 m_LogFile.coss.open (m_LogName.c_str(), std::ios::out); 00336 if (!m_LogFile.coss){ 00337 m_LogFile << "Unable to open file: " << m_LogName << std::endl; 00338 m_LogFile.coss.clear (); 00339 exit(1); 00340 } 00341 else 00342 bDone = true; // file opened successfully 00343 m_LogFile << '\n'; 00344 m_LogFile << "\t\t---------------------------------------------------------" << '\n'; 00345 m_LogFile << "\t\t Tool to generate assembly mesh " << '\n'; 00346 m_LogFile << "\t\t\t\tArgonne National Laboratory" << '\n'; 00347 m_LogFile << "\t\t\t\t 2015 " << '\n'; 00348 m_LogFile << "\t\t---------------------------------------------------------" << '\n'; 00349 m_LogFile << "\nsee README file for using the program and details on various cards.\n"<< std::endl; 00350 00351 }while (!bDone); 00352 00355 CParser Parse1; 00356 bool found = false; 00357 std::string card; 00358 m_nLineNumber = 0; 00359 std::cout << "Reading from common.inp file." << std::endl; 00360 for(;;){ 00361 if (!Parse1.ReadNextLine (m_FileCommon, m_nLineNumber, szInputString, 00362 MAXCHARS, szComment)) 00363 IOErrorHandler (INVALIDINPUT); 00364 00365 if (szInputString.substr(0,10) == "geomengine"){ 00366 found = true; 00367 std::istringstream szFormatString (szInputString); 00368 szFormatString >> card >> m_szEngine; 00369 if( ((strcmp (m_szEngine.c_str(), "acis") != 0) && 00370 (strcmp (m_szEngine.c_str(), "occ") != 0)) || szFormatString.fail()) 00371 IOErrorHandler(EGEOMENGINE); 00372 } 00373 if (szInputString.substr(0,8) == "meshtype"){ 00374 found = true; 00375 std::istringstream szFormatString (szInputString); 00376 szFormatString >> card >> m_szMeshType; 00377 if( ((strcmp (m_szMeshType.c_str(), "hex") != 0) && 00378 (strcmp (m_szMeshType.c_str(), "tet") != 0)) || szFormatString.fail()) 00379 IOErrorHandler(INVALIDINPUT); 00380 } 00381 00382 // Hex or Rect geometry type 00383 if (szInputString.substr(0,12) == "geometrytype"){ 00384 found = true; 00385 std::istringstream szFormatString (szInputString); 00386 szFormatString >> card >> m_szGeomType; 00387 if( ((strcmp (m_szGeomType.c_str(), "hexagonal") != 0) && 00388 (strcmp (m_szGeomType.c_str(), "rectangular") != 0)) || szFormatString.fail()) 00389 IOErrorHandler(EGEOMTYPE); 00390 00391 // set the number of sides in the geometry 00392 if(m_szGeomType == "hexagonal") 00393 m_nSides = 6; 00394 else if(m_szGeomType == "rectangular") 00395 m_nSides = 4; 00396 } 00397 // Default if volume, set geometry type to surface for 2D assemblies 00398 if (szInputString.substr(0,8) == "geometry"){ 00399 found = true; 00400 std::string outfile; 00401 std::istringstream szFormatString (szInputString); 00402 szFormatString >> card >> outfile; 00403 if(strcmp (outfile.c_str(), "surface") == 0 || szFormatString.fail()) 00404 m_nPlanar=1; 00405 } 00406 00407 // breaking condition 00408 if(szInputString.substr(0,3) == "end" || m_nLineNumber == 500){ 00409 found = true; 00410 break; 00411 } 00412 if (found == false){ 00413 std::cout << "Cannot specify: " << szInputString << " in common.inp files" << std::endl; 00414 } 00415 } 00416 00421 00422 // Read AssyGen input file 00423 CParser Parse; 00424 int nCyl =0, nCellMat=0, nInputLines=0; 00425 std::string szVolId, szVolAlias; 00426 // count the total number of cylinder commands in each pincell 00427 for(;;){ 00428 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00429 MAXCHARS, szComment)) 00430 IOErrorHandler (INVALIDINPUT); 00431 00432 if (szInputString.substr(0,10) == "geomengine"){ 00433 std::istringstream szFormatString (szInputString); 00434 szFormatString >> card >> m_szEngine; 00435 if( ((strcmp (m_szEngine.c_str(), "acis") != 0) && 00436 (strcmp (m_szEngine.c_str(), "occ") != 0)) || szFormatString.fail()) 00437 IOErrorHandler(EGEOMENGINE); 00438 } 00439 if (szInputString.substr(0,8) == "meshtype"){ 00440 std::istringstream szFormatString (szInputString); 00441 szFormatString >> card >> m_szMeshType; 00442 if( ((strcmp (m_szMeshType.c_str(), "hex") != 0) && 00443 (strcmp (m_szMeshType.c_str(), "tet") != 0)) || szFormatString.fail()) 00444 IOErrorHandler(INVALIDINPUT); 00445 } 00446 if (szInputString.substr(0,4) == "duct" || szInputString.substr(0,10) == "dimensions"){ 00447 ++m_nDuct; 00448 } 00449 if (szInputString.substr(0,8) == "pincells"){ 00450 std::istringstream szFormatString (szInputString); 00451 szFormatString >> card >> m_nPincells; 00452 if(m_nPincells>0) 00453 m_Pincell.SetSize(m_nPincells); 00454 else if(m_nPincells ==0) 00455 m_Pincell.SetSize(1); // assume for using dummy pincell 00456 00457 // count the number of cylinder lines for each pincell 00458 for (int i=1; i<=m_nPincells; i++){ 00459 // read the no. of input lines first pincell 00460 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00461 MAXCHARS, szComment)) 00462 IOErrorHandler (INVALIDINPUT); 00463 std::istringstream szFormatString1 (szInputString); 00464 szFormatString1 >> szVolId >> szVolAlias >> nInputLines; 00465 if(szFormatString1.fail()) 00466 IOErrorHandler(INVALIDINPUT); 00467 // loop thru the input lines of each pincell 00468 for(int l=1; l<=nInputLines; l++){ 00469 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00470 MAXCHARS, szComment)) 00471 IOErrorHandler (INVALIDINPUT); 00472 if (szInputString.substr(0,8) == "cylinder"){ 00473 ++nCyl; 00474 } 00475 if (szInputString.substr(0,12) == "cellmaterial"){ 00476 ++nCellMat; 00477 } 00478 } 00479 00480 // set the sizes 00481 if (nCyl>0) { 00482 if (nCellMat > 0) { 00483 m_Pincell(i).SetCellMatSize(nCellMat); 00484 } 00485 m_Pincell(i).SetNumCyl(nCyl); 00486 } 00487 else if (nCyl ==0) { 00488 // used to be nInputLines > 0 . . . is it an error if 00489 // neither a cylinder nor a material line in the pin cell input? 00490 if (nCellMat > 0) 00491 m_Pincell(i).SetCellMatSize(nCellMat); 00492 } 00493 nCyl = 0; 00494 nCellMat = 0; 00495 } 00496 } 00497 // breaking condition 00498 if(szInputString.substr(0,3) == "end"){ 00499 std::istringstream szFormatString (szInputString); 00500 break; 00501 } 00502 } 00503 00504 // //ACIS ENGINE 00505 //#ifdef HAVE_ACIS 00506 // // if(m_szEngine == "acis"){ 00507 // m_szGeomFile = m_InputFile+".sat"; 00508 // // } 00509 //#elif defined(HAVE_OCC) 00510 // // OCC ENGINE 00511 // // if (m_szEngine == "occ"){ 00512 // m_szG= m_InputFile+".stp"; 00513 // // } 00514 //#endif 00515 // std::cout << "\no/p geometry file name: " << m_szGeomFile <<std::endl; 00516 00517 //Rewind the input file 00518 m_FileInput.clear (std::ios_base::goodbit); 00519 m_FileInput.seekg (0L, std::ios::beg); 00520 m_nLineNumber = 0; 00521 // CParser Parse; 00522 // std::string card; 00523 00524 // start reading the input file break when encounter end 00525 for(;;){ 00526 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00527 MAXCHARS, szComment)) 00528 IOErrorHandler (INVALIDINPUT); 00529 if (szInputString.substr(0,12) == "geometrytype"){ 00530 std::istringstream szFormatString (szInputString); 00531 szFormatString >> card >> m_szGeomType; 00532 if( ((strcmp (m_szGeomType.c_str(), "hexagonal") != 0) && 00533 (strcmp (m_szGeomType.c_str(), "rectangular") != 0)) || szFormatString.fail()) 00534 IOErrorHandler(EGEOMTYPE); 00535 00536 // set the number of sides in the geometry 00537 if(m_szGeomType == "hexagonal") 00538 m_nSides = 6; 00539 else if(m_szGeomType == "rectangular") 00540 m_nSides = 4; 00541 } 00542 else if (szInputString.substr(0,8) == "geometry"){ 00543 std::string outfile; 00544 std::istringstream szFormatString (szInputString); 00545 szFormatString >> card >> outfile; 00546 if(strcmp (outfile.c_str(), "surface") == 0 || szFormatString.fail()) 00547 m_nPlanar=1; 00548 } 00549 if ((szInputString.substr(0,9) == "materials") && (szInputString.substr(0,19) != "materialset_startid")){ 00550 00551 std::istringstream szFormatString (szInputString); 00552 szFormatString >> card >> m_nAssemblyMat; 00553 if(szFormatString.fail()) 00554 IOErrorHandler(INVALIDINPUT); 00555 m_szAssmMat.SetSize(m_nAssemblyMat); m_szAssmMatAlias.SetSize(m_nAssemblyMat); 00556 for (int j=1; j<=m_nAssemblyMat; j++){ 00557 szFormatString >> m_szAssmMat(j) >> m_szAssmMatAlias(j); 00558 if( (strcmp (m_szAssmMat(j).c_str(), "") == 0) || 00559 (strcmp (m_szAssmMatAlias(j).c_str(), "") == 0)){ 00560 IOErrorHandler(EMAT); 00561 } 00562 // checking if & inserted at the end of the material by mistake 00563 if (j == m_nAssemblyMat){ 00564 std::string dummy = ""; 00565 szFormatString >> dummy; 00566 if (strcmp (dummy.c_str(), "") != 0) 00567 IOErrorHandler(EMAT); 00568 } 00569 } 00570 } 00571 if( (szInputString.substr(0,10) == "dimensions") || 00572 (szInputString.substr(0,4) == "duct") ){ 00573 00574 ++m_nDuctNum; 00575 std::cout << "getting assembly dimensions " << m_nDuctNum << std::endl; 00576 00577 if(m_szGeomType =="hexagonal"){ 00578 std::istringstream szFormatString (szInputString); 00579 00580 if(m_nDuctNum == 1){ 00581 m_dMXYAssm.SetSize(m_nDuct, 2); m_dMZAssm.SetSize(m_nDuct, 2); 00582 } 00583 szFormatString >> card >> m_nDimensions 00584 >> m_dMXYAssm(m_nDuctNum, 1) >> m_dMXYAssm(m_nDuctNum, 2) 00585 >> m_dMZAssm(m_nDuctNum, 1) >> m_dMZAssm(m_nDuctNum, 2); 00586 if(m_nDuctNum == 1){ 00587 m_dMAssmPitch.SetSize(m_nDuct, m_nDimensions); m_szMMAlias.SetSize(m_nDuct, m_nDimensions); 00588 00589 assms.resize(m_nDimensions*m_nDuct); // setup while reading the problem size 00590 } 00591 00592 for (int i=1; i<=m_nDimensions; i++){ 00593 szFormatString >> m_dMAssmPitch(m_nDuctNum, i); 00594 if( m_dMAssmPitch(m_nDuctNum, i) < 0 ) 00595 IOErrorHandler(ENEGATIVE); 00596 } 00597 00598 for (int i=1; i<=m_nDimensions; i++){ 00599 szFormatString >> m_szMMAlias(m_nDuctNum, i); 00600 if(strcmp (m_szMMAlias(m_nDuctNum, i).c_str(), "") == 0) 00601 IOErrorHandler(EALIAS); 00602 } 00603 } 00604 if(m_szGeomType =="rectangular"){ 00605 std::istringstream szFormatString (szInputString); 00606 if(m_nDuctNum == 1){ 00607 m_dMXYAssm.SetSize(m_nDuct, 2); 00608 m_dMZAssm.SetSize(m_nDuct, 2); 00609 } 00610 szFormatString >> card >> m_nDimensions 00611 >> m_dMXYAssm(m_nDuctNum, 1) >> m_dMXYAssm(m_nDuctNum, 2) 00612 >> m_dMZAssm(m_nDuctNum, 1) >> m_dMZAssm(m_nDuctNum, 2); 00613 if (szFormatString.fail()) 00614 IOErrorHandler(INVALIDINPUT); 00615 if(m_nDuctNum == 1){ 00616 m_dMAssmPitchX.SetSize(m_nDuct, m_nDimensions); 00617 m_dMAssmPitchY.SetSize(m_nDuct, m_nDimensions); 00618 m_szMMAlias.SetSize(m_nDuct, m_nDimensions); 00619 assms.resize(m_nDimensions*m_nDuct); 00620 } 00621 for (int i=1; i<=m_nDimensions; i++){ 00622 szFormatString >> m_dMAssmPitchX(m_nDuctNum, i) >> m_dMAssmPitchY(m_nDuctNum, i); 00623 if( m_dMAssmPitchX(m_nDuctNum, i) < 0 || m_dMAssmPitchY(m_nDuctNum, i) < 0 || szFormatString.fail()) 00624 IOErrorHandler(ENEGATIVE); 00625 } 00626 00627 for (int i=1; i<=m_nDimensions; i++){ 00628 szFormatString >> m_szMMAlias(m_nDuctNum, i); 00629 if(strcmp (m_szMMAlias(m_nDuctNum, i).c_str(), "") == 0 || szFormatString.fail()) 00630 IOErrorHandler(EALIAS); 00631 } 00632 } 00633 } 00634 if (szInputString.substr(0,8) == "pincells"){ 00635 std::istringstream szFormatString (szInputString); 00636 00637 szFormatString >> card >> m_nPincells >> m_dPitch; 00638 if(m_nPincells < 0) 00639 IOErrorHandler(ENEGATIVE); 00640 00641 // this is an option if a user wants to specify pitch here 00642 double dTotalHeight = 0.0; 00643 00644 //get the number of cylinder in each pincell 00645 int nTemp = 1; 00646 if(m_nDimensions > 0){ 00647 dTotalHeight = m_dMZAssm(nTemp, 2)-m_dMZAssm(nTemp, 1); 00648 } 00649 else{ 00650 dTotalHeight = 0; // nothing specified only pincells in the model 00651 } 00652 00653 // loop thro' the pincells and read/store pincell data 00654 for (int i=1; i<=m_nPincells; i++){ 00655 00656 // set pitch if specified in pincell card 00657 if(m_dPitch > 0.0) 00658 m_Pincell(i).SetPitch(m_dPitch, dTotalHeight); 00659 00660 ReadPinCellData( i); 00661 std::cout << "\nread pincell " << i << std::endl; 00662 } 00663 } 00664 00665 // 'yes' or 'no' for creating sidesets 00666 if (szInputString.substr(0,13) == "createsideset"){ 00667 std::istringstream szFormatString (szInputString); 00668 szFormatString >> card >> m_szSideset; 00669 std::cout <<"--------------------------------------------------"<<std::endl; 00670 } 00671 // specify a merge tolerance value for cubit journal file 00672 if (szInputString.substr(0,14) == "mergetolerance"){ 00673 std::istringstream szFormatString (szInputString); 00674 szFormatString >> card >> m_dMergeTol; 00675 std::cout <<"--------------------------------------------------"<<std::endl; 00676 } // Handle mesh size inputs 00677 if (szInputString.substr(0,14) == "radialmeshsize"){ 00678 std::istringstream szFormatString (szInputString); 00679 szFormatString >> card >> m_dRadialSize; 00680 if(m_dRadialSize < 0 || szFormatString.fail()) 00681 IOErrorHandler(ENEGATIVE); 00682 std::cout <<"--------------------------------------------------"<<std::endl; 00683 00684 } 00685 // Handle mesh size inputs 00686 if (szInputString.substr(0,11) == "tetmeshsize"){ 00687 std::istringstream szFormatString (szInputString); 00688 szFormatString >> card >> m_dTetMeshSize; 00689 if(m_dTetMeshSize < 0 || szFormatString.fail()) 00690 IOErrorHandler(ENEGATIVE); 00691 std::cout <<"--------------------------------------------------"<<std::endl; 00692 00693 } 00694 // Handle mesh size inputs 00695 if (szInputString.substr(0,13) == "axialmeshsize"){ 00696 std::istringstream szFormatString (szInputString); 00697 szFormatString >> card >> m_dAxialSize; 00698 if(m_dAxialSize < 0 || szFormatString.fail()) 00699 IOErrorHandler(ENEGATIVE); 00700 std::cout <<"--------------------------------------------------"<<std::endl; 00701 00702 } 00703 // Handle mesh size inputs 00704 if (szInputString.substr(0,18) == "neumannset_startid"){ 00705 std::istringstream szFormatString (szInputString); 00706 szFormatString >> card >> m_nNeumannSetId; 00707 if(m_nNeumannSetId < 0 || szFormatString.fail()) 00708 IOErrorHandler(ENEGATIVE); 00709 std::cout <<"--------------------------------------------------"<<std::endl; 00710 00711 } 00712 // Handle mesh size inputs 00713 if (szInputString.substr(0,19) == "materialset_startid"){ 00714 std::istringstream szFormatString (szInputString); 00715 szFormatString >> card >> m_nMaterialSetId; 00716 if(m_nMaterialSetId < 0 || szFormatString.fail()) 00717 IOErrorHandler(ENEGATIVE); 00718 std::cout <<"--------------------------------------------------"<<std::endl; 00719 00720 } 00721 if (szInputString.substr(0,3) == "end"){ 00722 00723 00724 // if ( m_nJouFlag == 0){ 00725 // // impring merge before saving 00726 // // Imprint_Merge(); 00727 00728 // // save .sat file 00729 // IBERRCHK(igeom->save(m_szGeomFile.c_str()), *igeom); 00730 // std::cout << "Normal Termination.\n"<< "Geometry file: " << m_szGeomFile << " saved." << std::endl; 00731 // } 00732 break; 00733 } 00734 } 00735 00736 // Done reading now load file 00737 00738 IBERRCHK(igeom->load(m_GeomFile.c_str()), *igeom); 00739 00740 } 00741 00743 00744 void AssyMesher::ReadPinCellData ( int i) 00745 //--------------------------------------------------------------------------- 00746 //Function: reading pincell i from file and storing the data 00747 //Input: none 00748 //Output: none 00749 //--------------------------------------------------------------------------- 00750 { 00751 CParser Parse; 00752 std::string card, szVolId, szVolAlias, szIFlag; 00753 int nInputLines, nMaterials, nCyl = 0, nRadii=0, nCellMat=0; 00754 double dLZ=0.0, dFlatF=0.0, dPX=0.0, dPY=0.0, dPZ=0.0; 00755 CVector <std::string> szVMatName, szVMatAlias, szVCylMat, szVCellMat; 00756 CVector<double> dVCoor(2), dVCylRadii, dVCylZPos, dZVStart, dZVEnd; 00757 00758 //loop over input lines 00759 if (m_szGeomType == "rectangular"){ 00760 00761 std::cout << "\ngetting volume id"; 00762 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00763 MAXCHARS, szComment)) 00764 IOErrorHandler (INVALIDINPUT); 00765 std::istringstream szFormatString (szInputString); 00766 szFormatString >> szVolId >> szVolAlias >> nInputLines >> szIFlag; 00767 00768 // error checking 00769 if( (strcmp (szVolAlias.c_str(), "") == 0) || 00770 (strcmp (szVolId.c_str(), "") == 0)) 00771 IOErrorHandler(EPIN); 00772 if( nInputLines < 0 ) 00773 IOErrorHandler(ENEGATIVE); 00774 00775 m_Pincell(i).SetLineOne (szVolId, szVolAlias, nInputLines); 00776 if(szIFlag == "intersect"){ 00777 m_Pincell(i).SetIntersectFlag(1); 00778 } 00779 else{ 00780 m_Pincell(i).SetIntersectFlag(0); 00781 } 00782 for(int l=1; l<=nInputLines; l++){ 00783 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00784 MAXCHARS, szComment)) 00785 IOErrorHandler (INVALIDINPUT); 00786 if (szInputString.substr(0,5) == "pitch"){ 00787 00788 std::istringstream szFormatString (szInputString); 00789 std::cout << "\ngetting pitch data"; 00790 szFormatString >> card >> dPX >> dPY >> dPZ; 00791 00792 if( dPX < 0 || dPY < 0 || dPZ < 0 || szFormatString.fail()) 00793 IOErrorHandler(ENEGATIVE); 00794 m_Pincell(i).SetPitch (dPX, dPY, dPZ); 00795 } 00796 if (szInputString.substr(0,9) == "materials"){ 00797 00798 std::istringstream szFormatString (szInputString); 00799 szFormatString >> card >> nMaterials; 00800 if(szFormatString.fail()) 00801 IOErrorHandler(INVALIDINPUT); 00802 00803 //setting local arrays 00804 szVMatName.SetSize(nMaterials); 00805 szVMatAlias.SetSize(nMaterials); 00806 00807 //set class variable sizes 00808 m_Pincell(i).SetMatArray(nMaterials); 00809 std::cout << "\ngetting material data"; 00810 for(int j=1; j<= nMaterials; j++){ 00811 szFormatString >> szVMatName(j) >> szVMatAlias(j); 00812 if(szFormatString.fail()) 00813 IOErrorHandler(INVALIDINPUT); 00814 } 00815 m_Pincell(i).SetMat(szVMatName, szVMatAlias); 00816 } 00817 if (szInputString.substr(0,8) == "cylinder"){ 00818 00819 ++nCyl; 00820 std::cout << "\ngetting cylinder data"; 00821 std::istringstream szFormatString (szInputString); 00822 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2); 00823 if(szFormatString.fail()) 00824 IOErrorHandler(INVALIDINPUT); 00825 m_Pincell(i).SetCylSizes(nCyl, nRadii); 00826 m_Pincell(i).SetCylPos(nCyl, dVCoor); 00827 00828 //set local array 00829 dVCylRadii.SetSize(2*nRadii); 00830 szVCylMat.SetSize(nRadii); 00831 dVCylZPos.SetSize(2); 00832 m_Pincell(i).SetCylSizes(nCyl, nRadii); 00833 00834 // reading ZCoords 00835 for(int k=1; k<=2; k++){ 00836 szFormatString >> dVCylZPos(k); 00837 if(szFormatString.fail()) 00838 IOErrorHandler(INVALIDINPUT); 00839 } 00840 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos); 00841 00842 // reading Radii 00843 for(int l=1; l<= nRadii; l++){ 00844 szFormatString >> dVCylRadii(l); 00845 if( dVCylRadii(l) < 0 || szFormatString.fail()) 00846 IOErrorHandler(ENEGATIVE); 00847 } 00848 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii); 00849 00850 // reading Material alias 00851 for(int m=1; m<= nRadii; m++){ 00852 szFormatString >> szVCylMat(m); 00853 if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail()) 00854 IOErrorHandler(EALIAS); 00855 } 00856 m_Pincell(i).SetCylMat(nCyl, szVCylMat); 00857 } 00858 if (szInputString.substr(0,12) == "cellmaterial"){ 00859 00860 std::cout << "\ngetting cell material data\n"; 00861 std::istringstream szFormatString (szInputString); 00862 szFormatString >> card; 00863 00864 //set local arrays 00865 m_Pincell(i).GetCellMatSize(nCellMat); // since size of cell material already set equal to number of cylinders 00866 dZVStart.SetSize(nCellMat); 00867 dZVEnd.SetSize(nCellMat); 00868 szVCellMat.SetSize(nCellMat); 00869 00870 for(int k=1; k<=nCellMat; k++){ 00871 szFormatString >> dZVStart(k)>> dZVEnd(k) >> szVCellMat(k); 00872 if(strcmp (szVCellMat(k).c_str(), "") == 0 || szFormatString.fail()) 00873 IOErrorHandler(EALIAS); 00874 } 00875 m_Pincell(i).SetCellMat(dZVStart, dZVEnd, szVCellMat); 00876 } 00877 } 00878 }//if rectangular ends 00879 00880 if (m_szGeomType == "hexagonal"){ 00881 00882 std::cout << "\ngetting volume id"; 00883 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00884 MAXCHARS, szComment)) 00885 IOErrorHandler (INVALIDINPUT); 00886 std::istringstream szFormatString (szInputString); 00887 szFormatString >> szVolId >> szVolAlias >> nInputLines >> szIFlag; 00888 00889 // error checking 00890 if( (strcmp (szVolAlias.c_str(), "") == 0) || 00891 (strcmp (szVolId.c_str(), "") == 0)) 00892 IOErrorHandler(EPIN); 00893 if( nInputLines < 0 ) 00894 IOErrorHandler(ENEGATIVE); 00895 00896 m_Pincell(i).SetLineOne (szVolId, szVolAlias, nInputLines); 00897 if(szIFlag == "intersect"){ 00898 m_Pincell(i).SetIntersectFlag(1); 00899 } 00900 else{ 00901 m_Pincell(i).SetIntersectFlag(0); 00902 } 00903 for(int l=1; l<=nInputLines; l++){ 00904 if (!Parse.ReadNextLine (m_FileInput, m_nLineNumber, szInputString, 00905 MAXCHARS, szComment)) 00906 IOErrorHandler (INVALIDINPUT); 00907 if (szInputString.substr(0,5) == "pitch"){ 00908 00909 std::istringstream szFormatString (szInputString); 00910 std::cout << "\ngetting pitch data"; 00911 szFormatString >> card >> dFlatF >> dLZ; 00912 if( dFlatF < 0 || dLZ < 0 || szFormatString.fail()) 00913 IOErrorHandler(ENEGATIVE); 00914 m_Pincell(i).SetPitch (dFlatF, dLZ); 00915 } 00916 if (szInputString.substr(0,9) == "materials"){ 00917 00918 std::istringstream szFormatString (szInputString); 00919 szFormatString >> card >> nMaterials; 00920 if(szFormatString.fail()) 00921 IOErrorHandler(INVALIDINPUT); 00922 //setting local arrays 00923 szVMatName.SetSize(nMaterials); 00924 szVMatAlias.SetSize(nMaterials); 00925 00926 //set class variable sizes 00927 m_Pincell(i).SetMatArray(nMaterials); 00928 std::cout << "\ngetting material data"; 00929 for(int j=1; j<= nMaterials; j++){ 00930 szFormatString >> szVMatName(j) >> szVMatAlias(j); 00931 if(szFormatString.fail()) 00932 IOErrorHandler(INVALIDINPUT); 00933 } 00934 m_Pincell(i).SetMat(szVMatName, szVMatAlias); 00935 } 00936 if (szInputString.substr(0,8) == "cylinder"){ 00937 00938 ++nCyl; 00939 std::cout << "\ngetting cylinder data"; 00940 std::istringstream szFormatString (szInputString); 00941 szFormatString >> card >> nRadii >> dVCoor(1) >> dVCoor(2); 00942 if(szFormatString.fail()) 00943 IOErrorHandler(INVALIDINPUT); 00944 m_Pincell(i).SetCylSizes(nCyl, nRadii); 00945 m_Pincell(i).SetCylPos(nCyl, dVCoor); 00946 00947 //set local array 00948 dVCylRadii.SetSize(nRadii); 00949 szVCylMat.SetSize(nRadii); 00950 dVCylZPos.SetSize(2); 00951 // 00952 m_Pincell(i).SetCylSizes(nCyl, nRadii); 00953 00954 // reading ZCoords - max and min 2 always 00955 for(int k=1; k<=2; k++) 00956 szFormatString >> dVCylZPos(k); 00957 m_Pincell(i).SetCylZPos(nCyl, dVCylZPos); 00958 00959 // reading Radii 00960 for(int l=1; l<= nRadii; l++){ 00961 szFormatString >> dVCylRadii(l); 00962 if( dVCylRadii(l) < 0 || szFormatString.fail()) 00963 IOErrorHandler(ENEGATIVE); 00964 } 00965 m_Pincell(i).SetCylRadii(nCyl, dVCylRadii); 00966 00967 // reading Material alias 00968 for(int m=1; m<= nRadii; m++){ 00969 szFormatString >> szVCylMat(m); 00970 if(strcmp (szVCylMat(m).c_str(), "") == 0 || szFormatString.fail()) 00971 IOErrorHandler(EALIAS); 00972 } 00973 00974 m_Pincell(i).SetCylMat(nCyl, szVCylMat); 00975 } 00976 if (szInputString.substr(0,12) == "cellmaterial"){ 00977 00978 std::cout << "\ngetting cell material data"; 00979 std::istringstream szFormatString (szInputString); 00980 szFormatString >> card; 00981 00982 //set local arrays 00983 m_Pincell(i).GetCellMatSize(nCellMat); // since size of cell material already set equal to number of cylinders 00984 dZVStart.SetSize(nCellMat); 00985 dZVEnd.SetSize(nCellMat); 00986 szVCellMat.SetSize(nCellMat); 00987 00988 for(int k=1; k<=nCellMat; k++){ 00989 szFormatString >> dZVStart(k)>> dZVEnd(k) >> szVCellMat(k); 00990 if(strcmp (szVCellMat(k).c_str(), "") == 0 || szFormatString.fail()) 00991 IOErrorHandler(EALIAS); 00992 } 00993 m_Pincell(i).SetCellMat(dZVStart, dZVEnd, szVCellMat); 00994 } 00995 } 00996 }// if hexagonal end 00997 00998 } 00999 01000 01001 void AssyMesher::IOErrorHandler (ErrorStates ECode) const 01002 // --------------------------------------------------------------------------- 01006 // --------------------------------------------------------------------------- 01007 { 01008 std::cerr << '\n'; 01009 01010 if (ECode == PINCELLS) // invalid number of pincells 01011 std::cerr << "Number of pincells must be >= 0."; 01012 else if (ECode == INVALIDINPUT) // invalid input 01013 std::cerr << "Invalid input."; 01014 else if (ECode == EMAT) // invalid input 01015 std::cerr << "Invalid Material Data."; 01016 else if (ECode == EGEOMTYPE) // invalid input 01017 std::cerr << "Invalid GeomType Data."; 01018 else if (ECode == EGEOMENGINE) // invalid input 01019 std::cerr << "Invalid Geometry Engine."; 01020 else if (ECode == EALIAS) // invalid input 01021 std::cerr << "Error Reading Aliases."; 01022 else if (ECode == ENEGATIVE) // invalid input 01023 std::cerr << "Unexpected negative value."; 01024 else if (ECode == EPIN) // invalid input 01025 std::cerr << "Invalid pinCell specs."; 01026 else 01027 std::cerr << "Unknown error ...?"; 01028 01029 std::cerr << '\n' << "Error in input file line : " << m_nLineNumber; 01030 std::cerr << std::endl; 01031 exit (1); 01032 } 01033 01034 std::vector<iGeom::EntityHandle>* AssyMesher::selectByMaterialsAndNameSuffix( 01035 std::vector<iGeom::EntityHandle> const &geoEntVec, 01036 std::set<std::string> const &matFilter, const char* suffix) const 01037 { 01038 // get the name tag 01039 iGeom::TagHandle nameTag; 01040 int tagSize; 01041 igeom->getTagHandle("NAME", nameTag); 01042 igeom->getTagSizeBytes(nameTag, tagSize); 01043 01044 // get the length of the suffix 01045 int suffixLen = strlen(suffix); 01046 01047 // allocate space to store the entity name retrieved from geometric entity 01048 char* entName = new char[tagSize]; 01049 01050 // allocate the vector that will be recturned 01051 std::vector<iGeom::EntityHandle> *selectedEnts = 01052 new std::vector<iGeom::EntityHandle>; 01053 01054 for (unsigned int ei = 0; ei < geoEntVec.size(); ++ei) 01055 { 01056 entName[0] = 0; 01057 igeom->getData(geoEntVec[ei], nameTag, entName); 01058 // TODO: error check for result == iBase_SUCCESS 01059 // it should always be true for current code of CGM 01060 01061 // the suffix, if present, should end at the first @ character in the 01062 // name or at the end of the name if there are no @ characters 01063 size_t enLen = strlen(entName); 01064 char* endMatchChar = strchr(entName, '@'); 01065 if (endMatchChar == NULL) 01066 { 01067 endMatchChar = &entName[enLen]; 01068 } 01069 01070 // if the suffix is present 01071 if ((endMatchChar - entName) > suffixLen && 01072 strncmp(endMatchChar - suffixLen, suffix, suffixLen) == 0) 01073 { 01074 // if the part of the name before the suffix is in the 01075 // set of acceptable materials 01076 std::string matNameStr(entName, endMatchChar - suffixLen); 01077 if (matFilter.find(matNameStr) != matFilter.end()) 01078 { 01079 // add it to the vector 01080 selectedEnts->push_back(geoEntVec[ei]); 01081 } 01082 } 01083 } 01084 01085 // release the memory allocated for the entity name 01086 delete[] entName; 01087 01088 return selectedEnts; 01089 } 01090 01091 void AssyMesher::createMaterialNeumannSets(std::set <std::string> const &matFilter){ 01092 // Name by material names in AssyGen input file 01093 01094 std::set<std::string>::iterator it; 01095 int matId = 1; 01096 moab::Tag geomTag, matTag, neuTag, nameTag; 01097 mb->tag_get_handle( "MATERIAL_SET", matTag ); 01098 //mb->tag_get_handle( "NAME", nameTag ); 01099 char dum_val[64] = {0}; 01100 mb->tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, moab::MB_TYPE_OPAQUE, 01101 nameTag, moab::MB_TAG_SPARSE | moab::MB_TAG_CREAT, dum_val); 01102 01103 for(it = matFilter.begin(); it != matFilter.end(); ++it){ 01104 01105 std::cout << *it << std::endl; 01106 // std::string matName = *it; 01107 01108 //create a material set with id=matId 01109 moab::EntityHandle jj; // material meshset 01110 mb->create_meshset(moab::MESHSET_SET,jj); 01111 01112 mb->tag_set_data(matTag, &jj, 1, (void*)&matId); 01113 // mb->tag_set_data(nameTag, &jj, 1, (void*)matName.c_str()); 01114 //TODO: 01115 // if(matName == volumeName){ 01116 // // Add the set to this material set 01117 // } 01118 ++matId; 01119 } 01120 01121 } 01122 01123 void AssyMesher::createMaterialNeumannSets() 01124 { 01125 iRel::PairHandle * pair; 01126 mk_core()->irel_instance()->createPair ( 01127 mk_core()->igeom_instance()->instance(), iRel::ENTITY, iRel::IGEOM_IFACE, iRel::ACTIVE, 01128 mk_core()->imesh_instance()->instance(), iRel::SET, iRel::IMESH_IFACE, iRel::ACTIVE, pair); 01129 01130 int ixrel = mk_core()->add_irel_pair(pair); 01131 01132 01133 moab::Tag geomTag, matTag, neuTag; 01134 mb->tag_get_handle( "MATERIAL_SET", matTag ); 01135 mb->tag_get_handle( "NEUMANN_SET", neuTag ); 01136 01137 geomTag = mk_core()->moab_geom_dim_tag(); 01138 moab::Range geom_sets[2]; 01139 moab::EntityHandle jj; // meshset 01140 int ss = 0; 01141 01142 bool name_all_vol_surfs = true; 01143 if(name_all_vol_surfs){ 01144 for(unsigned dim=2; dim<4; dim++) { 01145 void *val[] = {&dim}; 01146 mb->get_entities_by_type_and_tag(0, 01147 moab::MBENTITYSET, &geomTag, val, 1, geom_sets[ss], moab::Interface::UNION); 01148 int n_id = 1, m_id = 1; 01149 for(moab::Range::iterator i=geom_sets[ss].begin(); i!=geom_sets[ss].end(); i++) 01150 { 01151 mb->create_meshset(moab::MESHSET_SET,jj); 01152 mb->add_entities(jj, &(*i), 1); 01153 if (dim == 2){ 01154 mb->tag_set_data(neuTag, &jj, 1, (void*)&n_id); 01155 n_id+=1; 01156 } 01157 else{ 01158 mb->tag_set_data(matTag, &jj, 1, (void*)&m_id); 01159 m_id+=1;; 01160 } 01161 } 01162 ss++; 01163 } 01164 } 01165 // // get the name tag 01166 // iGeom::TagHandle nameTag; 01167 // //moab::Tag geomTag; 01168 // int tagSize; 01169 // int dim = 3; 01170 // void *val[] = {&dim}; 01171 // igeom->getTagHandle("NAME", nameTag); 01172 01173 // mb->get_entities_by_type_and_tag(0, 01174 // moab::MBENTITYSET, &geomTag, val, 1, geom_sets[0], moab::Interface::UNION); 01175 // std::cout << geom_sets[0].size() << std::endl; 01176 // char matname[64]; 01177 // mb->tag_get_data(nameTag, &geom_sets[0].front(), 1, &matname); 01178 // std::cout << matname << std::endl; 01179 01180 01181 01182 // moab::Range vol_sets, surf_sets; 01183 // int dim = 3; 01184 // void *val[] = {&dim}; 01185 // mb->get_entities_by_type_and_tag(0, 01186 // moab::MBENTITYSET, &geomTag, val, 1, vol_sets, moab::Interface::UNION); 01187 // dim = 2; 01188 // void *val2[] = {&dim}; 01189 // mb->get_entities_by_type_and_tag(0, 01190 // moab::MBENTITYSET, &geomTag, val2, 1, surf_sets, moab::Interface::UNION); 01191 01192 01193 //MBERRCHK(rval, mk_core()->moab_instance()); 01194 01195 01196 01197 // igeom->getTagSizeBytes(nameTag, tagSize); 01198 01199 01200 01201 01202 } 01203 01204 } // namespace MeshKit