Newer
Older
//
//
// 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"
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
// }
// }
// }
};
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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;
}
};
private :
typedef MVertex * NodeType;
typedef std::pair <NodeType , NodeType > EdgeType;
typedef std::pair <EdgeType , double > EdgeScoreType;
std::set< NodeType > _winner_nodes;
std::set< NodeType > _looser_nodes;
gLevelset *_ls;
// 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);
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
{
;
}
};