static double F_Lc_aniso(GEdge *ge, double t) { #if defined(HAVE_ANN) FieldManager *fields = ge->model()->getFields(); BoundaryLayerField *blf = 0; Field *bl_field = fields->get(fields->getBoundaryLayerField()); blf = dynamic_cast<BoundaryLayerField*> (bl_field); #else bool blf = false; #endif GPoint p = ge->point(t); SMetric3 lc_here; Range<double> bounds = ge->parBounds(0); double t_begin = bounds.low(); double t_end = bounds.high(); if(t == t_begin) lc_here = BGM_MeshMetric(ge->getBeginVertex(), t, 0, p.x(), p.y(), p.z()); else if(t == t_end) lc_here = BGM_MeshMetric(ge->getEndVertex(), t, 0, p.x(), p.y(), p.z()); else lc_here = BGM_MeshMetric(ge, t, 0, p.x(), p.y(), p.z()); #if defined(HAVE_ANN) if (blf && !blf->isEdgeBL(ge->tag())){ SMetric3 lc_bgm; blf->computeFor1dMesh ( p.x(), p.y(), p.z() , lc_bgm ); lc_here = intersection_conserveM1 (lc_here, lc_bgm ); } #endif SVector3 der = ge->firstDer(t); double lSquared = dot(der, lc_here, der); return sqrt(lSquared); }
// Main function for fast curving void HighOrderMeshFastCurving(GModel *gm, FastCurvingParameters &p) { double t1 = Cpu(); Msg::StatusBar(true, "Optimizing high order mesh..."); std::vector<GEntity*> allEntities; gm->getEntities(allEntities); // Compute vert. -> elt. connectivity Msg::Info("Computing connectivity..."); std::map<MVertex*, std::vector<MElement *> > vertex2elements; for (int iEnt = 0; iEnt < allEntities.size(); ++iEnt) calcVertex2Elements(p.dim, allEntities[iEnt], vertex2elements); // Get BL field (if any) BoundaryLayerField *blf = getBLField(gm); // Build multimap of each geometric entity to its boundaries std::multimap<GEntity*,GEntity*> entities; if (blf) { // BF field? for (int iEnt = 0; iEnt < allEntities.size(); ++iEnt) { GEntity* &entity = allEntities[iEnt]; if (entity->dim() == p.dim && (!p.onlyVisible || entity->getVisibility())) // Consider only "domain" entities if (p.dim == 2) { // "Domain" face? std::list<GEdge*> edges = entity->edges(); for (std::list<GEdge*>::iterator itEd = edges.begin(); itEd != edges.end(); itEd++) // Loop over model boundary edges if (blf->isEdgeBL((*itEd)->tag())) // Already skip model edge if no BL there entities.insert(std::pair<GEntity*,GEntity*>(entity, *itEd)); } else if (p.dim == 3) { // "Domain" region? std::list<GFace*> faces = entity->faces(); for (std::list<GFace*>::iterator itF = faces.begin(); itF != faces.end(); itF++) // Loop over model boundary faces if (blf->isFaceBL((*itF)->tag())) // Already skip model face if no BL there entities.insert(std::pair<GEntity*,GEntity*>(entity, *itF)); } } } else { // No BL field for (int iEnt = 0; iEnt < allEntities.size(); ++iEnt) { GEntity* &entity = allEntities[iEnt]; if (entity->dim() == p.dim-1 && (!p.onlyVisible || entity->getVisibility())) // Consider boundary entities entities.insert(std::pair<GEntity*,GEntity*>(0, entity)); } } // Build normals if necessary std::map<GEntity*, std::map<MVertex*, SVector3> > normVertEnt; // Normal to each vertex for each geom. entity if (!blf) { Msg::Warning("Boundary layer data not found, trying to detect columns"); buildNormals(vertex2elements, entities, p, normVertEnt); } // Loop over geometric entities for (std::multimap<GEntity*,GEntity*>::iterator itBE = entities.begin(); itBE != entities.end(); itBE++) { GEntity *domEnt = itBE->first, *bndEnt = itBE->second; BoundaryLayerColumns *blc = 0; if (blf) { Msg::Info("Curving elements for entity %d bounding entity %d...", bndEnt->tag(), domEnt->tag()); if (p.dim == 2) blc = domEnt->cast2Face()->getColumns(); else if (p.dim == 3) blc = domEnt->cast2Region()->getColumns(); else Msg::Error("Fast curving implemented only in dim. 2 and 3"); } else Msg::Info("Curving elements for boundary entity %d...", bndEnt->tag()); std::map<MVertex*, SVector3> &normVert = normVertEnt[bndEnt]; curveMeshFromBnd(vertex2elements, normVert, blc, bndEnt, p); } double t2 = Cpu(); Msg::StatusBar(true, "Done curving high order mesh (%g s)", t2-t1); }