Skip to content
Snippets Groups Projects
Commit a57f61e2 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Refinement bugfix (thanks to Florian :) )

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