void Centerline::run() { double t1 = Cpu(); if (update_needed){ std::ifstream input; //std::string pattern = FixRelativePath(fileName, "./"); //Msg::StatusBar(true, "Reading TEST '%s'...", pattern.c_str()); //input.open(pattern.c_str()); input.open(fileName.c_str()); if(StatFile(fileName)) Msg::Fatal("Centerline file '%s' does not exist ", fileName.c_str()); importFile(fileName); buildKdTree(); update_needed = false; } if (is_cut) cutMesh(); else{ GFace *gf = current->getFaceByTag(1); gf->addPhysicalEntity(1); current->setPhysicalName("wall", 2, 1);//tag 1 current->createTopologyFromMesh(); NV = current->getMaxElementaryNumber(0); NE = current->getMaxElementaryNumber(1); NF = current->getMaxElementaryNumber(2); NR = current->getMaxElementaryNumber(3); } //identify the boundary edges by looping over all discreteFaces std::vector<GEdge*> boundEdges; double dist_inlet = 1.e6; GEdge *gin = NULL; for (int i= 0; i< NF; i++){ GFace *gf = current->getFaceByTag(i+1); std::list<GEdge*> l_edges = gf->edges(); for(std::list<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); it++){ std::vector<GEdge*>::iterator ite = std::find(boundEdges.begin(), boundEdges.end(), *it); if (ite != boundEdges.end()) boundEdges.erase(ite); else boundEdges.push_back(*it); GVertex *gv = (*it)->getBeginVertex(); SPoint3 pt(gv->x(), gv->y(), gv->z()); double dist = pt.distance(ptin); if(dist < dist_inlet){ dist_inlet = dist; gin = *it; } } } if (is_closed) createClosedVolume(gin, boundEdges); if (is_extruded) extrudeBoundaryLayerWall(gin, boundEdges); double t2 = Cpu(); Msg::Info("Centerline operators computed in %g (s) ",t2-t1); }
void Centerline::extrudeBoundaryLayerWall(GEdge* gin, std::vector<GEdge*> boundEdges) { Msg::Info("Centerline: extrude boundary layer wall (%d, %g%%R) ", nbElemLayer, hLayer); //orient extrude direction outward int dir = 0; MElement *e = current->getFaceByTag(1)->getMeshElement(0); SVector3 ne = e->getFace(0).normal(); SVector3 ps(e->getVertex(0)->x(), e->getVertex(0)->y(), e->getVertex(0)->z()); double xyz[3] = {ps.x(), ps.y(), ps.z()}; ANNidx index[1]; ANNdist dist[1]; kdtree->annkSearch(xyz, 1, index, dist); ANNpointArray nodes = kdtree->thePoints(); SVector3 pc(nodes[index[0]][0], nodes[index[0]][1], nodes[index[0]][2]); SVector3 nc = ps-pc; if (dot(ne,nc) < 0) dir = 1; if (dir == 1 && hLayer > 0 ) hLayer *= -1.0; //int shift = 0; //if(is_cut) shift = NE; for (int i= 0; i< NF; i++){ GFace *gfc ; if (is_cut) gfc = current->getFaceByTag(NF+i+1); else gfc = current->getFaceByTag(i+1); current->setFactory("Gmsh"); //view -5 to scale hLayer by radius in BoundaryLayers.cpp std::vector<GEntity*> extrudedE = current->extrudeBoundaryLayer (gfc, nbElemLayer, hLayer, dir, -5); GFace *eFace = (GFace*) extrudedE[0]; eFace->addPhysicalEntity(5); current->setPhysicalName("outerWall", 2, 5);//dim 2 tag 5 GRegion *eRegion = (GRegion*) extrudedE[1]; eRegion->addPhysicalEntity(6); current->setPhysicalName("wallVolume", 3, 6);//dim 3 tag 6 //if double extruded layer if (nbElemSecondLayer > 0){ std::vector<GEntity*> extrudedESec = current->extrudeBoundaryLayer (eFace, nbElemSecondLayer, hSecondLayer, dir, -5); GFace *eFaceSec = (GFace*) extrudedESec[0]; eFaceSec->addPhysicalEntity(9); //tag 9 current->setPhysicalName("outerSecondWall", 2, 9);//dim 2 tag 9 GRegion *eRegionSec = (GRegion*) extrudedESec[1]; eRegionSec->addPhysicalEntity(10); //tag 10 current->setPhysicalName("wallVolume", 3, 10);//dim 3 tag 10 } //end double extrusion for (unsigned int j = 2; j < extrudedE.size(); j++){ GFace *elFace = (GFace*) extrudedE[j]; std::list<GEdge*> l_edges = elFace->edges(); for(std::list<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); it++){ GEdge *myEdge = *it; if (is_cut) myEdge = current->getEdgeByTag((*it)->tag()-NE); if( std::find(boundEdges.begin(), boundEdges.end(), myEdge) != boundEdges.end() ){ if (myEdge==gin){ elFace->addPhysicalEntity(7); current->setPhysicalName("inletRing", 2, 7);//tag 7 } else{ elFace->addPhysicalEntity(8); current->setPhysicalName("outletRings", 2, 8);//tag 8 } } } } } }