/usr/include/gmsh/groupOfElements.h is in libgmsh-dev 2.15.0+dfsg1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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 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 125 126 127 128 | // Gmsh - Copyright (C) 1997-2016 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
#ifndef _GROUPOFELEMENTS_H_
#define _GROUPOFELEMENTS_H_
#include <set>
#include "GFace.h"
#include "MElement.h"
class elementFilter {
public:
virtual ~elementFilter(){}
virtual bool operator() (MElement *) const = 0;
};
class elementFilterTrivial : public elementFilter {
public:
bool operator() (MElement *) const {return true;}
};
class groupOfElements {
public:
typedef std::set<MElement*> elementContainer;
typedef std::set<MVertex*> vertexContainer;
protected:
vertexContainer _vertices;
elementContainer _elements;
elementContainer _parents;
public:
groupOfElements(){}
groupOfElements (int dim, int physical) { addPhysical (dim, physical); }
groupOfElements (GFace*);
groupOfElements (GRegion*);
groupOfElements(std::vector<MElement*> &elems);
virtual ~groupOfElements(){}
virtual void addPhysical(int dim, int physical)
{
elementFilterTrivial filter;
addPhysical (dim, physical, filter);
}
virtual void addElementary(GEntity *ge, const elementFilter &f);
virtual void addPhysical(int dim, int physical, const elementFilter &);
vertexContainer::const_iterator vbegin() const { return _vertices.begin(); }
vertexContainer::const_iterator vend() const { return _vertices.end(); }
elementContainer::const_iterator begin() const { return _elements.begin(); }
elementContainer::const_iterator end() const { return _elements.end(); }
size_t size() const { return _elements.size(); }
size_t vsize() const { return _vertices.size(); }
// FIXME : NOT VERY ELEGANT !!!
bool find (MElement *e) const // if same parent but different physicals return true ?!
{
if (e->getParent() && _parents.find(e->getParent()) != _parents.end()) return true;
return (_elements.find(e) != _elements.end());
}
inline void insert (MElement *e)
{
_elements.insert(e);
if (e->getParent()){
_parents.insert(e->getParent());
for (int i = 0; i < e->getParent()->getNumVertices(); i++){
_vertices.insert(e->getParent()->getVertex(i));
}
}
else{
for (int i = 0; i < e->getNumVertices(); i++){
_vertices.insert(e->getVertex(i));
}
}
}
inline void clearAll()
{
_vertices.clear();
_elements.clear();
_parents.clear();
}
};
// child elements in pElem restricted to elements who have parent in sElem
class groupOfLagMultElements : public groupOfElements
{
private :
void fillElementContainer(groupOfElements &pElem, groupOfElements &sElem)
{
groupOfElements::elementContainer::const_iterator itp = pElem.begin();
for (;itp!=pElem.end(); itp++)
{
if ((*itp)->getParent())
{
if (sElem.find(*itp)) insert((*itp)) ; // warning : find method used to check if parent is in sElem
}
else std::cout << "groupOfLagMultElements : Warning, level set element has no parent ?! " << std::endl;
}
}
public :
groupOfLagMultElements(int dim, int physical, groupOfElements &sElem) : groupOfElements()
{
groupOfElements pElem(dim , physical);
fillElementContainer(pElem,sElem);
}
groupOfLagMultElements(int dim, int physical, std::vector < groupOfElements *> sElem) : groupOfElements()
{
groupOfElements pElem(dim , physical);
for (unsigned int i = 0 ;i < sElem.size() ; i ++)
{
fillElementContainer(pElem,(*sElem[i]));
}
}
};
#endif
|