Commit a57f61e2 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Refinement bugfix (thanks to Florian :) )

parent 807e9d57
...@@ -40,6 +40,7 @@ namespace AMDiS { ...@@ -40,6 +40,7 @@ namespace AMDiS {
child[1] = NULL; child[1] = NULL;
newCoord = NULL; newCoord = NULL;
elementData = NULL; elementData = NULL;
mark = 0;
if (mesh) { if (mesh) {
setDOFPtrs(); setDOFPtrs();
......
...@@ -13,21 +13,21 @@ ...@@ -13,21 +13,21 @@
namespace AMDiS { namespace AMDiS {
int RefinementManager1d::recursiveRefineFunction(ElInfo* el_info) int RefinementManager1d::recursiveRefineFunction(ElInfo* elInfo)
{ {
Line *el = dynamic_cast<Line*>(const_cast<Element*>( el_info->getElement())), *child[2]; Line *el = dynamic_cast<Line*>(const_cast<Element*>(elInfo->getElement())), *child[2];
Mesh* mesh = el_info->getMesh(); Mesh* mesh = elInfo->getMesh();
if(el_info->getProjection(0)) { if (elInfo->getProjection(0)) {
traversePtr->newCoord(true); traversePtr->newCoord(true);
} }
if (el->getMark() <= 0) if (el->getMark() <= 0)
return 0; return 0;
child[0] = dynamic_cast<Line*>( mesh->createNewElement(el)); child[0] = dynamic_cast<Line*>(mesh->createNewElement(el));
child[1] = dynamic_cast<Line*>( mesh->createNewElement(el)); child[1] = dynamic_cast<Line*>(mesh->createNewElement(el));
int mark = max(0, el->getMark() - 1); int mark = max(0, el->getMark() - 1);
child[0]->setMark(mark); child[0]->setMark(mark);
...@@ -52,8 +52,8 @@ namespace AMDiS { ...@@ -52,8 +52,8 @@ namespace AMDiS {
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* the other vertices are handed on from the parent */ /* the other vertices are handed on from the parent */
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
child[0]->setDOF(0, const_cast<int*>( el->getDOF(0))); child[0]->setDOF(0, const_cast<int*>(el->getDOF(0)));
child[1]->setDOF(1, const_cast<int*>( el->getDOF(1))); child[1]->setDOF(1, const_cast<int*>(el->getDOF(1)));
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* there is one more leaf element, two hierachical elements, */ /* there is one more leaf element, two hierachical elements, */
...@@ -64,14 +64,13 @@ namespace AMDiS { ...@@ -64,14 +64,13 @@ namespace AMDiS {
mesh->incrementNumberOfVertices(1); mesh->incrementNumberOfVertices(1);
mesh->incrementNumberOfElements(2); mesh->incrementNumberOfElements(2);
if (mesh->getNumberOfDOFs(CENTER)) if (mesh->getNumberOfDOFs(CENTER)) {
{ /*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/ /* there are dofs at the barycenter of the triangles */
/* there are dofs at the barycenter of the triangles */ /*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/ child[0]->setDOF(mesh->getNode(CENTER), const_cast<int*>(mesh->getDOF(CENTER)));
child[0]->setDOF(mesh->getNode(CENTER), const_cast<int*>( mesh->getDOF(CENTER))); child[1]->setDOF(mesh->getNode(CENTER), const_cast<int*>(mesh->getDOF(CENTER)));
child[1]->setDOF(mesh->getNode(CENTER), const_cast<int*>( mesh->getDOF(CENTER))); }
}
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
/* if there are functions to interpolate data to the finer grid, do so */ /* if there are functions to interpolate data to the finer grid, do so */
...@@ -80,82 +79,69 @@ namespace AMDiS { ...@@ -80,82 +79,69 @@ namespace AMDiS {
RCNeighbourList ref_list(1); // = {{nil, 0, 0}}; RCNeighbourList ref_list(1); // = {{nil, 0, 0}};
ref_list.setElement(0, el); ref_list.setElement(0, el);
int iadmin;
int nrAdmin = mesh->getNumberOfDOFAdmin(); int nrAdmin = mesh->getNumberOfDOFAdmin();
for(iadmin = 0; iadmin < nrAdmin; iadmin++) { for (int iadmin = 0; iadmin < nrAdmin; iadmin++) {
std::list<DOFIndexedBase*>::iterator it; std::list<DOFIndexedBase*>::iterator it;
DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDOFAdmin(iadmin)); DOFAdmin* admin = const_cast<DOFAdmin*>(&mesh->getDOFAdmin(iadmin));
std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed(); std::list<DOFIndexedBase*>::iterator end = admin->endDOFIndexed();
for(it = admin->beginDOFIndexed(); it != end; it++) for (it = admin->beginDOFIndexed(); it != end; it++)
(*it)->refineInterpol(ref_list, 1); (*it)->refineInterpol(ref_list, 1);
} }
if (!mesh->queryCoarseDOFs() && mesh->getNumberOfDOFs(CENTER)) if (!mesh->queryCoarseDOFs() && mesh->getNumberOfDOFs(CENTER)) {
{ mesh->freeDOF(const_cast<int*>( el->getDOF(mesh->getNode(CENTER))), CENTER);
mesh->freeDOF(const_cast<int*>( el->getDOF(mesh->getNode(CENTER))), CENTER); el->setDOF(mesh->getNode(CENTER), NULL);
el->setDOF(mesh->getNode(CENTER), NULL); }
}
return 0; return 0;
} }
Flag RefinementManager1d::refineMesh(Mesh *aMesh) Flag RefinementManager1d::refineMesh(Mesh *aMesh)
{ {
int n_elements;
mesh = aMesh; mesh = aMesh;
int nElements = mesh->getNumberOfLeaves();
n_elements = mesh->getNumberOfLeaves();
doMoreRecursiveRefine = true; doMoreRecursiveRefine = true;
while (doMoreRecursiveRefine) while (doMoreRecursiveRefine) {
{ doMoreRecursiveRefine = false;
doMoreRecursiveRefine = false; traversePtr = this;
traversePtr = this; mesh->traverse(-1, Mesh::CALL_LEAF_EL | Mesh::FILL_BOUND | Mesh::FILL_COORDS,
mesh->traverse(-1, recursiveRefineFunction);
Mesh::CALL_LEAF_EL | WAIT_REALLY;
Mesh::FILL_BOUND | }
Mesh::FILL_COORDS,
recursiveRefineFunction);
}
n_elements = mesh->getNumberOfLeaves() - n_elements; nElements = mesh->getNumberOfLeaves() - nElements;
if(newCoords) { if (newCoords) {
setNewCoords(); // call of sub-class method setNewCoords(); // call of sub-class method
} }
return(n_elements ? MESH_REFINED : Flag(0)); return (nElements ? MESH_REFINED : Flag(0));
} }
int RefinementManager1d::newCoordsFct(ElInfo *el_info) int RefinementManager1d::newCoordsFct(ElInfo *elInfo)
{ {
Element *el = el_info->getElement(); Element *el = elInfo->getElement();
int j;
int dow = Global::getGeo(WORLD); int dow = Global::getGeo(WORLD);
Projection *projector = el_info->getProjection(0); Projection *projector = elInfo->getProjection(0);
if (el->getFirstChild() && projector && (!el->isNewCoordSet())) if (el->getFirstChild() && projector && (!el->isNewCoordSet())) {
{ WorldVector<double> *new_coord = NEW WorldVector<double>;
WorldVector<double> *new_coord = NEW WorldVector<double>;
for (int j = 0; j < dow; j++)
for (j = 0; j < dow; j++) (*new_coord)[j] = (elInfo->getCoord(0)[j] + elInfo->getCoord(1)[j]) * 0.5;
(*new_coord)[j] = (el_info->getCoord(0)[j] + el_info->getCoord(1)[j])*0.5;
projector->project(*new_coord);
projector->project(*new_coord); el->setNewCoord(new_coord);
}
el->setNewCoord(new_coord);
}
return 0; return 0;
} }
void RefinementManager1d::setNewCoords() void RefinementManager1d::setNewCoords()
{ {
Flag fillFlag = Mesh::CALL_EVERY_EL_PREORDER| Flag fillFlag = Mesh::CALL_EVERY_EL_PREORDER | Mesh::FILL_BOUND | Mesh::FILL_COORDS;
Mesh::FILL_BOUND|
Mesh::FILL_COORDS;
mesh->traverse(-1, fillFlag, newCoordsFct); mesh->traverse(-1, fillFlag, newCoordsFct);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment