// // Description : Filters for function space dof selection // // // Author: <Eric Bechet>::<Boris Sedji>, 02/2010 // // Copyright: See COPYING file that comes with this distribution // // #ifndef _FILTERS_H_ #define _FILTERS_H_ #include "simpleFunction.h" #include "dofManager.h" #include "GModel.h" #include "groupOfElements.h" #include "DILevelset.h" class FilterNodeEnriched { private : std::set<int> *_TagEnrichedVertex; std::set<int> * _EnrichComp; public : FilterNodeEnriched(std::set<int > * TagEnrichedVertex , std::set<int> * EnrichComp) { _TagEnrichedVertex = TagEnrichedVertex; _EnrichComp = EnrichComp; } virtual bool operator () (Dof & key) const { std::set<int>::iterator it1; std::set<int>::iterator it2; int i1,i2; Dof::getTwoIntsFromType(key.getType(), i1,i2); it2 = _EnrichComp->find(i1); it1 = _TagEnrichedVertex->find(key.getEntity()); if (it1!=_TagEnrichedVertex->end() & it2 != _EnrichComp->end()) { return true; } else return false; } //std::vector<int> * getEnrichComp(){return _EnrichComp;} // void SetEnrichedVertex(MElement *elep, std::vector<int> & EnrichedVertex,int &nbdofs) // { // EnrichedVertex.clear(); // nbdofs = 0; // for (int i=0 ;i<elep->getNumVertices();i++) // { // std::set<int>::iterator it; // it = _TagEnrichedVertex->find(elep->getVertex(i)->getNum()); // if (it!=_TagEnrichedVertex->end()) // { // EnrichedVertex.push_back(i); // nbdofs = nbdofs + 1*_EnrichComp->size(); // enriched dof // } // } // } }; class FilterElementsCutByLevelSet { private : std::set<int> _TagEnrichedVertex; std::pair<int,int> _LevelSetEntity; std::set<int> *_EnrichComp; public : FilterElementsCutByLevelSet(std::pair<int,int> LevelSetEntity , std::set<int> * EnrichComp) { _EnrichComp = EnrichComp; _LevelSetEntity = LevelSetEntity; // groupOfElements to get all the elements associate with the level set -- (work with *current GModel) groupOfElements *LevelSetElements = new groupOfElements (_LevelSetEntity.first, _LevelSetEntity.second); // tag enriched vertex determination std::set<MElement*>::const_iterator it = LevelSetElements->begin(); for (; it != LevelSetElements->end(); it++) { MElement *e = *it; if (e->getParent()) // if element got parents { for (int k = 0; k < e->getParent()->getNumVertices(); ++k) { // for all vertices in the element parent _TagEnrichedVertex.insert(e->getParent()->getVertex(k)->getNum()); } } } } virtual bool operator () (Dof & key) const { std::set<int>::iterator it1; std::set<int>::iterator it2; int i1,i2; Dof::getTwoIntsFromType(key.getType(), i1,i2); it2 = _EnrichComp->find(i1); it1 = _TagEnrichedVertex.find(key.getEntity()); if (it1!=_TagEnrichedVertex.end() & it2 != _EnrichComp->end()) { return true; } else return false; } }; class FilterLevelSetForLagMultSpace { private : typedef MVertex * NodeType; typedef std::pair <NodeType , NodeType > EdgeType; typedef std::pair <EdgeType , double > EdgeScoreType; private : groupOfElements * _LevelSetElements; std::pair<int,int> _LevelSetEntity; std::set< NodeType > _winner_nodes; std::set< NodeType > _looser_nodes; gLevelset *_ls; private : // decimation algorithm result in _winner_nodes set void SortNodes (void) ; // initialisation of needed sets void fillNodeToEdgeMap(std::map < NodeType , EdgeType > & NodeToEdgeMap, std::set< EdgeType > & Se , std::set< NodeType > & Sn) ; // find edge in the element associate with node EdgeType findEdge(NodeType v, MElement * e); // verify if node belong to edge // ...normaly has to be done when cutting model ... bool NodeBelongToEdge(NodeType v, EdgeType edge); // compute score void ComputeScore(std::map < NodeType , EdgeType > & NodeToEdgeMap, std::set< EdgeType > & Se, std::set< NodeType > & Sn, std::map < NodeType , int > & NodesScore); // compute number of incident edges in Se to node v int ComputeIncidentEdges(std::set< EdgeType > & Se, NodeType & v); // get lowest (no need to sort just get the lowest) NodeType getNodeWithLowestScore(std::map < NodeType , int > & NodesScore); // kill connected edges void killConnectedEdges (std::map < NodeType , EdgeType > & NodeToEdgeMap, std::set< EdgeType > & Se , std::set< NodeType > & Sn, NodeType v); public : FilterLevelSetForLagMultSpace(std::pair<int,int> LevelSetEntity , gLevelset *ls) : _LevelSetEntity(LevelSetEntity), _ls(ls) { groupOfElements *_LevelSetElements = new groupOfElements (_LevelSetEntity.first, _LevelSetEntity.second); SortNodes(); } virtual bool operator () (Dof & key) const { ; } }; #endif