void Centerline::createClosedVolume(GEdge *gin, std::vector<GEdge*> boundEdges) { current->setFactory("Gmsh"); std::vector<std::vector<GFace *> > myFaceLoops; std::vector<GFace *> myFaces; for (unsigned int i = 0; i< boundEdges.size(); i++){ std::vector<std::vector<GEdge *> > myEdgeLoops; std::vector<GEdge *> myEdges; GEdge * gec; if(is_cut) gec = current->getEdgeByTag(NE+boundEdges[i]->tag()); else gec = current->getEdgeByTag(boundEdges[i]->tag()); myEdges.push_back(gec); myEdgeLoops.push_back(myEdges); GFace *newFace = current->addPlanarFace(myEdgeLoops); if (gin==boundEdges[i]) { newFace->addPhysicalEntity(2); current->setPhysicalName("inlet", 2, 2);//tag 2 } else{ newFace->addPhysicalEntity(3); current->setPhysicalName("outlets", 2, 3);//tag 3 } myFaces.push_back(newFace); } Msg::Info("Centerline: action (closeVolume) has created %d in/out planar faces ", (int)boundEdges.size()); for (int i = 0; i < NF; i++){ GFace * gf; if(is_cut) gf = current->getFaceByTag(NF+i+1); else gf = current->getFaceByTag(i+1); myFaces.push_back(gf); } myFaceLoops.push_back(myFaces); GRegion *reg = current->addVolume(myFaceLoops); reg->addPhysicalEntity(reg->tag()); current->setPhysicalName("lumenVolume", 3, reg->tag()); Msg::Info("Centerline: action (closeVolume) has created volume %d ", reg->tag()); }
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 } } } } } }