Skip to content
Snippets Groups Projects
Commit 7640d4e5 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

change interface in dgGroupConnection

parent badad0ec
Branches
Tags
No related merge requests found
...@@ -154,32 +154,26 @@ void dgGroupOfConnections::addElement(int iElement, int iClosure) { ...@@ -154,32 +154,26 @@ void dgGroupOfConnections::addElement(int iElement, int iClosure) {
} }
void dgGroupOfFaces::addFace(const MFace &topoFace, const std::vector<int> &iEls){
if (iEls.size() != _connections.size())
throw;
void dgGroupOfFaces::addFace(const MFace &topoFace, int iElLeft, int iElRight){
// compute the face element that correspond to the geometrical closure
// get the vertices of the face
std::vector<MVertex*> vertices; std::vector<MVertex*> vertices;
int closureId; for (size_t i=0; i<iEls.size(); i++){
const MElement *el; int closureId;
int ithFace, sign, rot; const MElement *el;
if(iElRight>=0){ int ithFace, sign, rot;
el = _connections[1]->getGroupOfElements().getElement(iElRight); el = _connections[i]->getGroupOfElements().getElement(iEls[i]);
el->getFaceInfo(topoFace, ithFace, sign, rot); el->getFaceInfo(topoFace, ithFace, sign, rot);
closureId = _connections[1]->getFunctionSpace()->getFaceClosureId(ithFace,sign,rot); closureId = _connections[i]->getFunctionSpace()->getFaceClosureId(ithFace,sign,rot);
_connections[1]->addElement(iElRight, closureId); _connections[i]->addElement(iEls[i], closureId);
if (i==0) {
const std::vector<int> & geomClosure = el->getFunctionSpace()->getFaceClosure(closureId);
for (int j=0; j<geomClosure.size() ; j++)
vertices.push_back( const_cast<MElement*>(el)->getVertex(geomClosure[j]) );
}
} }
el = _connections[0]->getGroupOfElements().getElement(iElLeft);
el->getFaceInfo(topoFace, ithFace, sign, rot);
closureId = _connections[0]->getFunctionSpace()->getFaceClosureId(ithFace,sign,rot);
_connections[0]->addElement(iElLeft, closureId);
const std::vector<int> & geomClosure = el->getFunctionSpace()->getFaceClosure(closureId);
for (int j=0; j<geomClosure.size() ; j++)
vertices.push_back( const_cast<MElement*>(el)->getVertex(geomClosure[j]) );
// triangular face
if (topoFace.getNumVertices() == 3){ if (topoFace.getNumVertices() == 3){
switch(vertices.size()){ switch(vertices.size()){
case 3 : _faces.push_back(new MTriangle (vertices) ); break; case 3 : _faces.push_back(new MTriangle (vertices) ); break;
...@@ -204,40 +198,42 @@ void dgGroupOfFaces::addFace(const MFace &topoFace, int iElLeft, int iElRight){ ...@@ -204,40 +198,42 @@ void dgGroupOfFaces::addFace(const MFace &topoFace, int iElLeft, int iElRight){
} }
} }
void dgGroupOfFaces::addEdge(const MEdge &topoEdge, int iElLeft, int iElRight) { void dgGroupOfFaces::addEdge(const MEdge &topoEdge, const std::vector<int> &iEls)
{
if (iEls.size() != _connections.size() )
throw;
std::vector<MVertex*> vertices; std::vector<MVertex*> vertices;
const MElement *el ; for (size_t i = 0; i<_connections.size(); i++) {
int closureId; const MElement *el ;
int ithFace, sign; int closureId;
if(iElRight>=0) { int ithFace, sign;
el = _connections[1]->getGroupOfElements().getElement(iElRight); el = _connections[i]->getGroupOfElements().getElement(iEls[i]);
el->getEdgeInfo(topoEdge, ithFace, sign); el->getEdgeInfo(topoEdge, ithFace, sign);
closureId = _connections[1]->getFunctionSpace()->getEdgeClosureId(ithFace,sign); closureId = _connections[i]->getFunctionSpace()->getEdgeClosureId(ithFace,sign);
_connections[1]->addElement(iElRight, closureId); _connections[i]->addElement(iEls[i], closureId);
if (i==0) {
const std::vector<int> & geomClosure = el->getFunctionSpace()->getEdgeClosure(closureId);
for (int j=0; j<geomClosure.size() ; j++)
vertices.push_back( const_cast<MElement*>(el)->getVertex(geomClosure[j]) );
}
} }
el = _connections[0]->getGroupOfElements().getElement(iElLeft); switch(vertices.size()) {
el->getEdgeInfo(topoEdge, ithFace, sign);
closureId = _connections[0]->getFunctionSpace()->getEdgeClosureId(ithFace,sign);
_connections[0]->addElement(iElLeft, closureId);
const std::vector<int> & geomClosure = el->getFunctionSpace()->getEdgeClosure(closureId);
for (int j=0; j<geomClosure.size() ; j++)
vertices.push_back( const_cast<MElement*>(el)->getVertex(geomClosure[j]) );
switch(vertices.size())
{
case 2 : _faces.push_back(new MLine (vertices) ); break; case 2 : _faces.push_back(new MLine (vertices) ); break;
case 3 : _faces.push_back(new MLine3 (vertices) ); break; case 3 : _faces.push_back(new MLine3 (vertices) ); break;
default : _faces.push_back(new MLineN (vertices) ); break; default : _faces.push_back(new MLineN (vertices) ); break;
} }
} }
void dgGroupOfFaces::addVertex(MVertex *topoVertex, int iElLeft, int iElRight){ void dgGroupOfFaces::addVertex(MVertex *topoVertex, const std::vector<int> &iEls){
int ithVertex; if (iEls.size() != _connections.size() )
_connections[0]->getGroupOfElements().getElement(iElLeft)->getVertexInfo(topoVertex, ithVertex); throw;
_connections[0]->addElement(iElLeft,ithVertex);
if(iElRight>=0){ for (size_t i=0; i<iEls.size(); i++) {
_connections[1]->getGroupOfElements().getElement(iElRight)->getVertexInfo(topoVertex, ithVertex); int ithVertex;
_connections[1]->addElement(iElRight, ithVertex); _connections[i]->getGroupOfElements().getElement(iEls[i])->getVertexInfo(topoVertex, ithVertex);
_connections[i]->addElement(iEls[i],ithVertex);
} }
_faces.push_back(new MPoint(topoVertex) ); _faces.push_back(new MPoint(topoVertex) );
} }
...@@ -290,12 +286,15 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo ...@@ -290,12 +286,15 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
Msg::Warning ("empty boundary tag, group of boundary faces not created"); Msg::Warning ("empty boundary tag, group of boundary faces not created");
return; return;
} }
std::vector<int> iEls(1);
for(int i=0; i<elGroup.getNbElements(); i++){ for(int i=0; i<elGroup.getNbElements(); i++){
MElement &el = *elGroup.getElement(i); MElement &el = *elGroup.getElement(i);
for (int j=0; j<el.getNumVertices(); j++){ for (int j=0; j<el.getNumVertices(); j++){
MVertex* vertex = el.getVertex(j); MVertex* vertex = el.getVertex(j);
if(boundaryVertices.find(vertex)!=boundaryVertices.end()) if(boundaryVertices.find(vertex)!=boundaryVertices.end()){
addVertex(vertex,i,-1); iEls[0] = i;
addVertex(vertex,iEls);
}
} }
} }
init(pOrder); init(pOrder);
...@@ -308,13 +307,16 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo ...@@ -308,13 +307,16 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
if(boundaryTag==""){ if(boundaryTag==""){
Msg::Warning ("empty boundary tag, group of boundary faces not created"); Msg::Warning ("empty boundary tag, group of boundary faces not created");
return; return;
} }
std::vector<int> iEls(1);
for(int i=0; i<elGroup.getNbElements(); i++){ for(int i=0; i<elGroup.getNbElements(); i++){
MElement &el = *elGroup.getElement(i); MElement &el = *elGroup.getElement(i);
for (int j=0; j<el.getNumEdges(); j++){ for (int j=0; j<el.getNumEdges(); j++){
MEdge edge = el.getEdge(j); MEdge edge = el.getEdge(j);
if(boundaryEdges.find(edge)!=boundaryEdges.end()) if(boundaryEdges.find(edge)!=boundaryEdges.end()){
addEdge(edge,i,-1); iEls[0] = i;
addEdge(edge, iEls);
}
} }
} }
init(pOrder); init(pOrder);
...@@ -326,12 +328,15 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo ...@@ -326,12 +328,15 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, std::string bo
_boundaryTag=boundaryTag; _boundaryTag=boundaryTag;
if(boundaryTag=="") if(boundaryTag=="")
throw; throw;
std::vector<int> iEls(1);
for(int i=0; i<elGroup.getNbElements(); i++){ for(int i=0; i<elGroup.getNbElements(); i++){
MElement &el = *elGroup.getElement(i); MElement &el = *elGroup.getElement(i);
for (int j=0; j<el.getNumFaces(); j++){ for (int j=0; j<el.getNumFaces(); j++){
MFace face = el.getFace(j); MFace face = el.getFace(j);
if(boundaryFaces.find(face)!=boundaryFaces.end()) if(boundaryFaces.find(face)!=boundaryFaces.end()) {
addFace(face,i,-1); iEls[0] = i;
addFace(face, iEls);
}
} }
} }
init(pOrder); init(pOrder);
...@@ -348,6 +353,7 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in ...@@ -348,6 +353,7 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in
{ {
_connections.push_back(new dgGroupOfConnections(elGroup, *this, pOrder)); _connections.push_back(new dgGroupOfConnections(elGroup, *this, pOrder));
_connections.push_back(new dgGroupOfConnections(elGroup, *this, pOrder)); _connections.push_back(new dgGroupOfConnections(elGroup, *this, pOrder));
std::vector<int> iEls(2);
switch (_connections[0]->getGroupOfElements().getElement(0)->getDim()) { switch (_connections[0]->getGroupOfElements().getElement(0)->getDim()) {
case 1 : { case 1 : {
std::map<MVertex*,int> vertexMap; std::map<MVertex*,int> vertexMap;
...@@ -358,7 +364,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in ...@@ -358,7 +364,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in
if(vertexMap.find(vertex) == vertexMap.end()){ if(vertexMap.find(vertex) == vertexMap.end()){
vertexMap[vertex] = i; vertexMap[vertex] = i;
}else{ }else{
addVertex(vertex,vertexMap[vertex],i); iEls[0] = vertexMap[vertex];
iEls[1] = i;
addVertex(vertex,iEls);
} }
} }
} }
...@@ -373,7 +381,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in ...@@ -373,7 +381,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in
if(edgeMap.find(edge) == edgeMap.end()){ if(edgeMap.find(edge) == edgeMap.end()){
edgeMap[edge] = i; edgeMap[edge] = i;
}else{ }else{
addEdge(edge,edgeMap[edge],i); iEls[0] = edgeMap[edge];
iEls[1] = i;
addEdge(edge,iEls);
} }
} }
} }
...@@ -389,7 +399,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in ...@@ -389,7 +399,9 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup, int pOrder, in
if(faceMap.find(face) == faceMap.end()){ if(faceMap.find(face) == faceMap.end()){
faceMap[face] = i; faceMap[face] = i;
}else{ }else{
addFace(face,faceMap[face],i); iEls[0] = faceMap[face];
iEls[1] = i;
addFace(face,iEls);
} }
} }
} }
...@@ -405,6 +417,7 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup ...@@ -405,6 +417,7 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup
{ {
_connections.push_back(new dgGroupOfConnections(elGroup1, *this, pOrder)); _connections.push_back(new dgGroupOfConnections(elGroup1, *this, pOrder));
_connections.push_back(new dgGroupOfConnections(elGroup2, *this, pOrder)); _connections.push_back(new dgGroupOfConnections(elGroup2, *this, pOrder));
std::vector<int> iEls(2);
switch (_connections[0]->getGroupOfElements().getElement(0)->getDim()) { switch (_connections[0]->getGroupOfElements().getElement(0)->getDim()) {
case 1 : { case 1 : {
std::map<MVertex*,int> vertexMap1; std::map<MVertex*,int> vertexMap1;
...@@ -420,14 +433,16 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup ...@@ -420,14 +433,16 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup
} }
} }
for(int i=0; i<elGroup2.getNbElements(); i++){ for(int i=0; i<elGroup2.getNbElements(); i++) {
MElement &el = *elGroup2.getElement(i); MElement &el = *elGroup2.getElement(i);
for (int j=0; j<el.getNumVertices(); j++){ for (int j=0; j<el.getNumVertices(); j++) {
MVertex* vertex = el.getVertex(j); MVertex* vertex = el.getVertex(j);
std::map<MVertex*,int>::iterator it = vertexMap1.find(vertex); std::map<MVertex*,int>::iterator it = vertexMap1.find(vertex);
if(it != vertexMap1.end()){ if(it != vertexMap1.end()) {
addVertex(vertex,it->second,i); iEls[0] = it->second;
} iEls[1] = i;
addVertex(vertex,iEls);
}
} }
} }
} }
...@@ -449,9 +464,11 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup ...@@ -449,9 +464,11 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup
MElement &el = *elGroup2.getElement(i); MElement &el = *elGroup2.getElement(i);
for (int j=0; j<el.getNumEdges(); j++){ for (int j=0; j<el.getNumEdges(); j++){
MEdge edge = el.getEdge(j); MEdge edge = el.getEdge(j);
std::map<MEdge,int,Less_Edge>::iterator it = edgeMap.find(edge); std::map<MEdge,int,Less_Edge>::iterator it = edgeMap.find(edge);
if(it != edgeMap.end()){ if(it != edgeMap.end()){
addEdge(edge,it->second,i); iEls[0] = it->second;
iEls[1] = i;
addEdge(edge,iEls);
} }
} }
} }
...@@ -477,9 +494,11 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup ...@@ -477,9 +494,11 @@ dgGroupOfFaces::dgGroupOfFaces (const dgGroupOfElements &elGroup1, const dgGroup
MElement &el = *elGroup2.getElement(i); MElement &el = *elGroup2.getElement(i);
for (int j=0; j<el.getNumFaces(); j++){ for (int j=0; j<el.getNumFaces(); j++){
MFace face = el.getFace(j); MFace face = el.getFace(j);
std::map<MFace,int,Less_Face>::iterator it = faceMap.find(face); std::map<MFace,int,Less_Face>::iterator it = faceMap.find(face);
if(it != faceMap.end()){ if(it != faceMap.end()){
addFace(face,it->second,i); iEls[0] = it->second;
iEls[1] = i;
addFace(face, iEls);
} }
} }
} }
......
...@@ -201,13 +201,12 @@ public: ...@@ -201,13 +201,12 @@ public:
inline double getInterfaceSurface (int iFace)const {return (*_interfaceSurface)(iFace,0);} inline double getInterfaceSurface (int iFace)const {return (*_interfaceSurface)(iFace,0);}
const polynomialBasis * getPolynomialBasis() const {return _fsFace;} const polynomialBasis * getPolynomialBasis() const {return _fsFace;}
inline MElement* getFace (int iElement) const {return _faces[iElement];} inline MElement* getFace (int iElement) const {return _faces[iElement];}
// duplicate
private: private:
void addFace(const MFace &topoFace, int iElLeft, int iElRight); void addFace(const MFace &topoFace, const std::vector<int> &iEls);
void addEdge(const MEdge &topoEdge, int iElLeft, int iElRight); void addEdge(const MEdge &topoEdge, const std::vector<int> &iEls);
void addVertex(MVertex *topoVertex, int iElLeft, int iElRight); void addVertex(MVertex *topoVertex, const std::vector<int> &iEls);
public: public:
//keep this outside the Algorithm because this is the only place where data overlap // duplicate
inline fullMatrix<double> &getNormals () const {return _connections[0]->getNormals();} inline fullMatrix<double> &getNormals () const {return _connections[0]->getNormals();}
void mapToInterface(int nFields, const fullMatrix<double> &vLeft, const fullMatrix<double> &vRight, fullMatrix<double> &v); void mapToInterface(int nFields, const fullMatrix<double> &vLeft, const fullMatrix<double> &vRight, fullMatrix<double> &v);
void mapFromInterface(int nFields, const fullMatrix<double> &v, fullMatrix<double> &vLeft, fullMatrix<double> &vRight); void mapFromInterface(int nFields, const fullMatrix<double> &v, fullMatrix<double> &vLeft, fullMatrix<double> &vRight);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment