Commit a71670c0 authored by Thomas Witkowski's avatar Thomas Witkowski

Fixed bug when coarsening periodic DOFs.

parent 5ee37e42
This diff is collapsed.
......@@ -102,13 +102,13 @@ namespace AMDiS {
if (mesh->getNumberOfDOFs(VERTEX)) /*--- midpoint of parent ---*/
{
mesh->freeDOF(const_cast<int*>( child[1]->getDOF(mesh->getNode(VERTEX))), VERTEX);
mesh->freeDof(const_cast<int*>( child[1]->getDOF(mesh->getNode(VERTEX))), VERTEX);
}
if (mesh->getNumberOfDOFs(CENTER)) /*--- center of the children ---*/
{
mesh->freeDOF(const_cast<int*>( child[0]->getDOF(mesh->getNode(CENTER))), CENTER);
mesh->freeDOF(const_cast<int*>( child[1]->getDOF(mesh->getNode(CENTER))), CENTER);
mesh->freeDof(const_cast<int*>( child[0]->getDOF(mesh->getNode(CENTER))), CENTER);
mesh->freeDof(const_cast<int*>( child[1]->getDOF(mesh->getNode(CENTER))), CENTER);
}
parent->coarsenElementData(child[0], child[1]);
......
......@@ -31,14 +31,14 @@ namespace AMDiS {
// remove dof from common edge of child[0] and child[1]
if (mesh->getNumberOfDOFs(EDGE))
mesh->freeDOF(const_cast<int*>(child[0]->getDOF(4)), EDGE);
mesh->freeDof(const_cast<int*>(child[0]->getDOF(4)), EDGE);
// remove dof from the barycenters of child[0] and child[1]
if (mesh->getNumberOfDOFs(CENTER)) {
int node = mesh->getNode(CENTER);
mesh->freeDOF(const_cast<int*>(child[0]->getDOF(node)), CENTER);
mesh->freeDOF(const_cast<int*>(child[1]->getDOF(node)), CENTER);
mesh->freeDof(const_cast<int*>(child[0]->getDOF(node)), CENTER);
mesh->freeDof(const_cast<int*>(child[1]->getDOF(node)), CENTER);
}
el->coarsenElementData(child[0], child[1]);
......@@ -110,16 +110,17 @@ namespace AMDiS {
// now, remove those dofs in the coarcening edge
mesh->freeDOF(dof[0], VERTEX);
mesh->freeDof(dof[0], VERTEX);
if (mesh->getNumberOfDOFs(EDGE)) {
mesh->freeDOF(dof[1], EDGE);
mesh->freeDOF(dof[2], EDGE);
mesh->freeDof(dof[1], EDGE);
mesh->freeDof(dof[2], EDGE);
}
mesh->incrementNumberOfVertices(-1);
mesh->incrementNumberOfEdges(-1);
}
int CoarseningManager2d::coarsenFunction(ElInfo *el_info)
{
Triangle *el = dynamic_cast<Triangle*>(const_cast<Element*>(el_info->getElement()));
......
......@@ -12,7 +12,7 @@ namespace AMDiS {
int CoarseningManager3d::coarsenFunction(ElInfo *el_info)
{
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>( el_info->getElement()));
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el_info->getElement()));
DegreeOfFreedom *edge[2];
int n_neigh, bound = 0;
ElInfo *elinfo = el_info;
......@@ -77,9 +77,7 @@ namespace AMDiS {
if (coarsenList->doCoarsePatch(n_neigh)) {
int n_neigh_periodic;
DegreeOfFreedom *next_edge[2];
RCNeighbourList *periodicList;
while (edge[0] != NULL) {
......@@ -110,14 +108,15 @@ namespace AMDiS {
/*****************************************************************************/
void CoarseningManager3d::coarsenTetrahedron(RCNeighbourList *coarsenList,
int index)
int index)
{
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>( coarsenList->getElement(index))), *child[2];
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(index)));
Tetrahedron *child[2];
Tetrahedron *neigh;
int dir, el_type, i, node, opp_v;
int dir, el_type, i, node, opp_v;
child[0] = dynamic_cast<Tetrahedron*>(const_cast<Element*>( el->getChild(0)));
child[1] = dynamic_cast<Tetrahedron*>(const_cast<Element*>( el->getChild(1)));
child[0] = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el->getChild(0)));
child[1] = dynamic_cast<Tetrahedron*>(const_cast<Element*>(el->getChild(1)));
el_type = coarsenList->getType(index);
/****************************************************************************/
......@@ -136,15 +135,14 @@ namespace AMDiS {
if (mesh->getNumberOfDOFs(EDGE)) {
node = mesh->getNode(EDGE) + Tetrahedron::nChildEdge[el_type][0][dir];
mesh->freeDOF(const_cast<int*>( child[0]->getDOF(node)), EDGE);
mesh->freeDof(const_cast<int*>( child[0]->getDOF(node)), EDGE);
}
if (mesh->getNumberOfDOFs(FACE)) {
node = mesh->getNode(FACE) + Tetrahedron::nChildFace[el_type][0][dir];
mesh->freeDof(const_cast<int*>( child[0]->getDOF(node)), FACE);
node = mesh->getNode(FACE) + Tetrahedron::nChildFace[el_type][1][dir];
mesh->freeDof(const_cast<int*>( child[1]->getDOF(node)), FACE);
}
if (mesh->getNumberOfDOFs(FACE))
{
node = mesh->getNode(FACE) + Tetrahedron::nChildFace[el_type][0][dir];
mesh->freeDOF(const_cast<int*>( child[0]->getDOF(node)), FACE);
node = mesh->getNode(FACE) + Tetrahedron::nChildFace[el_type][1][dir];
mesh->freeDOF(const_cast<int*>( child[1]->getDOF(node)), FACE);
}
}
}
......@@ -155,14 +153,14 @@ namespace AMDiS {
if (mesh->getNumberOfDOFs(FACE)) {
node = mesh->getNode(FACE);
mesh->freeDOF(const_cast<int*>( child[0]->getDOF(node)), FACE);
mesh->freeDof(const_cast<int*>( child[0]->getDOF(node)), FACE);
}
if (mesh->getNumberOfDOFs(CENTER)) {
node = mesh->getNode(CENTER);
for (i = 0; i < 2; i++)
mesh->freeDOF(const_cast<int*>( child[i]->getDOF(node)), CENTER);
mesh->freeDof(const_cast<int*>( child[i]->getDOF(node)), CENTER);
}
/****************************************************************************/
......@@ -181,8 +179,6 @@ namespace AMDiS {
mesh->incrementNumberOfLeaves(-1);
mesh->incrementNumberOfElements(-2);
return;
}
/****************************************************************************/
......@@ -201,16 +197,16 @@ namespace AMDiS {
/* the starting element before we return */
/****************************************************************************/
bool CoarseningManager3d::getCoarsenPatch(ElInfo *el_info,
bool CoarseningManager3d::getCoarsenPatch(ElInfo *el_info,
DegreeOfFreedom *edge[2],
int dir,
int dir,
RCNeighbourList *coarsenList,
int *n_neigh)
int *n_neigh)
{
FUNCNAME("CoarseningManager3d::getCoarsenPatch");
ElInfo *neigh_info;
Tetrahedron *el, *neigh;
int i, j, k, opp_v, edge_no;
int i, j, k, opp_v, edge_no;
static unsigned char next_el[6][2] = {{3,2},
{1,3},
......@@ -246,7 +242,7 @@ namespace AMDiS {
for (k = 0; k < n_vertices; k++)
if (neigh->getDOF(k) == edge[1]) break;
if(j > 3 || k > 3) {
if (j > 3 || k > 3) {
for (j = 0; j < n_vertices; j++)
if (mesh->associated(neigh->getDOF(j, 0), edge[0][0])) break;
for (k = 0; k < n_vertices; k++)
......@@ -315,11 +311,11 @@ namespace AMDiS {
/****************************************************************************/
void CoarseningManager3d::coarsenPatch(RCNeighbourList *coarsenList,
int n_neigh,
int bound)
int n_neigh,
int bound)
{
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>( coarsenList->getElement(0)));
int i, node;
int i, node;
DegreeOfFreedom *dof;
if (mesh->getNumberOfDOFs(EDGE)) {
......@@ -329,28 +325,28 @@ namespace AMDiS {
node = mesh->getNode(EDGE);
if (!(dof = const_cast<int*>( el->getDOF(node))))
dof = mesh->getDOF(EDGE);
} else
} else {
dof = NULL;
}
if (mesh->getNumberOfDOFs(EDGE) ||
mesh->getNumberOfDOFs(FACE) ||
mesh->getNumberOfDOFs(CENTER))
{
for (i = 0; i < n_neigh; i++)
coarsenList->addDOFParent(i, dof);
}
mesh->getNumberOfDOFs(CENTER)) {
for (i = 0; i < n_neigh; i++)
coarsenList->addDOFParent(i, dof);
}
/****************************************************************************/
/* restrict dof vectors to the parents on the patch */
/****************************************************************************/
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)->coarseRestrict(*coarsenList, n_neigh);
}
......@@ -360,25 +356,22 @@ namespace AMDiS {
/* remove dof's of the coarsening edge */
/****************************************************************************/
mesh->freeDOF(const_cast<int*>( el->getChild(0)->getDOF(3)), VERTEX);
mesh->freeDof(const_cast<int*>( el->getChild(0)->getDOF(3)), VERTEX);
mesh->incrementNumberOfVertices(-1);
if (mesh->getNumberOfDOFs(EDGE))
{
node = mesh->getNode(EDGE)+2;
mesh->freeDOF(const_cast<int*>( el->getChild(0)->getDOF(node)), EDGE);
mesh->freeDOF(const_cast<int*>( el->getChild(1)->getDOF(node)), EDGE);
}
if (coarsenList->getElement(0)->isNewCoordSet()) {
coarsenList->getElement(0)->eraseNewCoord();
if (mesh->getNumberOfDOFs(EDGE)) {
node = mesh->getNode(EDGE) + 2;
mesh->freeDof(const_cast<int*>( el->getChild(0)->getDOF(node)), EDGE);
mesh->freeDof(const_cast<int*>( el->getChild(1)->getDOF(node)), EDGE);
}
for (i = 0; i < n_neigh; i++)
{
coarsenList->getElement(i)->setNewCoord(NULL);
coarsenTetrahedron(coarsenList, i);
}
if (coarsenList->getElement(0)->isNewCoordSet())
coarsenList->getElement(0)->eraseNewCoord();
for (i = 0; i < n_neigh; i++) {
coarsenList->getElement(i)->setNewCoord(NULL);
coarsenTetrahedron(coarsenList, i);
}
/****************************************************************************/
/* if the coarsening edge is an interior edge there are n_neigh + 1 edges */
......@@ -393,8 +386,6 @@ namespace AMDiS {
mesh->incrementNumberOfEdges(-(n_neigh + 1));
mesh->incrementNumberOfFaces(-(2*n_neigh));
}
return;
}
}
......@@ -97,7 +97,7 @@ namespace AMDiS {
FUNCNAME("DOFAdmin::freeDofIndex()");
TEST_EXIT_DBG(usedCount > 0)("no dofs in use\n");
TEST_EXIT_DBG((dof >= 0) && (dof < size))("invalid dof index %d\n",dof);
TEST_EXIT_DBG(dof >= 0 && dof < size)("invalid dof index %d\n",dof);
std::list<DOFIndexedBase*>::iterator di;
std::list<DOFIndexedBase*>::iterator end = dofIndexedList.end();
......@@ -273,7 +273,7 @@ namespace AMDiS {
// mark used dofs
DOFIteratorBase it(this, USED_DOFS);
for (it.reset(); !it.end(); ++it)
new_dof[it.getDOFIndex()] = 1;
new_dof[it.getDOFIndex()] = 1;
int n = 0, last = 0;
for (int i = 0; i < size; i++) { /* create a MONOTONE compress */
......@@ -315,7 +315,7 @@ namespace AMDiS {
std::list<DOFContainer*>::iterator dc;
std::list<DOFContainer*>::iterator endc = dofContainerList.end();
for (dc = dofContainerList.begin(); dc != endc; ++dc)
(*dc)->compressDofContainer(n, new_dof);
(*dc)->compressDofContainer(n, new_dof);
}
......
......@@ -170,7 +170,7 @@ namespace AMDiS {
// change periodic vertex dofs
for (int i = 0; i < mesh->getNumberOfVertices(); i++) {
if (periodicMap.getEntry(i) != -1) {
mesh->freeDOF(dof[i], VERTEX);
mesh->freeDof(dof[i], VERTEX);
dof[i] = dof[periodicMap.getEntry(i)];
std::map<BoundaryType, VertexVector*>::iterator assoc;
......
......@@ -352,7 +352,7 @@ namespace AMDiS {
}
if (deleteDof)
freeDOF(const_cast<DegreeOfFreedom*>(dofsIt->first),
freeDof(const_cast<DegreeOfFreedom*>(dofsIt->first),
dofsPosIndex[dofsIt->first]);
else
nRemainDofs++;
......@@ -518,7 +518,7 @@ namespace AMDiS {
{
FUNCNAME("Mesh::freeDOFPtrs()");
TEST_EXIT_DBG(ptrs)("ptrs=NULL\n");
TEST_EXIT_DBG(ptrs)("ptrs is NULL!\n");
if (nNodeEl <= 0)
return;
......@@ -559,9 +559,9 @@ namespace AMDiS {
}
void Mesh::freeDOF(DegreeOfFreedom* dof, GeoIndex position)
void Mesh::freeDof(DegreeOfFreedom* dof, GeoIndex position)
{
FUNCNAME("Mesh::freeDOF()");
FUNCNAME("Mesh::freeDof()");
TEST_EXIT_DBG(position >= CENTER && position <= FACE)
("unknown position %d\n", position);
......@@ -587,10 +587,11 @@ namespace AMDiS {
int n = localAdmin->getNumberOfDOFs(position);
int n0 = localAdmin->getNumberOfPreDOFs(position);
TEST_EXIT_DBG(n + n0 <= ndof)("n=%d, n0=%d too large: ndof=%d\n", n, n0, ndof);
TEST_EXIT_DBG(n + n0 <= ndof)
("n = %d, n0 = %d too large: ndof = %d\n", n, n0, ndof);
for (int j = 0; j < n; j++)
localAdmin->freeDofIndex(dof[n0 + j]);
localAdmin->freeDofIndex(dof[n0 + j]);
}
delete [] dof;
......
......@@ -375,7 +375,7 @@ namespace AMDiS {
ElInfo* createNewElInfo();
/// Frees DOFs at the given position pointed by dof
void freeDOF(DegreeOfFreedom* dof, GeoIndex position);
void freeDof(DegreeOfFreedom* dof, GeoIndex position);
/// Frees memory for the given element el
void freeElement(Element* el);
......
......@@ -253,7 +253,7 @@ namespace AMDiS {
if (mesh->getNumberOfDOFs(CENTER)) {
int node = mesh->getNode(CENTER);
for (int i = 0; i < n_neigh; i++) {
mesh->freeDOF(const_cast<int*>(rclist[i]->el->getDOF(node)), CENTER);
mesh->freeDof(const_cast<int*>(rclist[i]->el->getDOF(node)), CENTER);
rclist[i]->el->setDOF(node, NULL);
}
}
......@@ -280,12 +280,12 @@ namespace AMDiS {
// face 2
if (!neigh || neigh > rclist[index])
mesh->freeDOF(const_cast<int*>(el->getDOF(node + 2)), FACE);
mesh->freeDof(const_cast<int*>(el->getDOF(node + 2)), FACE);
neigh = rclist[index]->neigh[1];
// face 3
if (!neigh || neigh > rclist[index])
mesh->freeDOF(const_cast<int*>(el->getDOF(node + 3)), FACE);
mesh->freeDof(const_cast<int*>(el->getDOF(node + 3)), FACE);
for (int j = 0; j < faces; j++)
el->setDOF(node + j, NULL);
......@@ -293,7 +293,7 @@ namespace AMDiS {
if (mesh->getNumberOfDOFs(CENTER)) {
int node = mesh->getNode(CENTER);
mesh->freeDOF(const_cast<int*>(el->getDOF(node)), CENTER);
mesh->freeDof(const_cast<int*>(el->getDOF(node)), CENTER);
el->setDOF(node, NULL);
}
}
......
......@@ -90,7 +90,7 @@ namespace AMDiS {
}
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);
}
}
......
......@@ -220,7 +220,7 @@ namespace AMDiS {
// === The only DOF that can be freed is that in the refinement edge; all ===
// === other DOFs are handed on the children. ===
mesh->freeDOF(const_cast<int*>(el->getDOF(node+2)), EDGE);
mesh->freeDof(const_cast<int*>(el->getDOF(node+2)), EDGE);
}
if (mesh->getNumberOfDOFs(EDGE) || mesh->getNumberOfDOFs(CENTER))
refineList->removeDOFParents(n_neigh);
......
......@@ -351,7 +351,7 @@ namespace AMDiS {
/****************************************************************************/
el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(refineList->getElement(0)));
mesh->freeDOF(const_cast<int*>(el->getDOF(mesh->getNode(EDGE))), EDGE);
mesh->freeDof(const_cast<int*>(el->getDOF(mesh->getNode(EDGE))), EDGE);
}
if (mesh->getNumberOfDOFs(EDGE) ||
......
......@@ -21,6 +21,15 @@ namespace AMDiS {
~VertexVector();
void freeDofIndex(DegreeOfFreedom dof)
{
FUNCNAME("VertexVector::freeDofIndex()");
TEST_EXIT_DBG(dof < static_cast<int>(vec.size()))("Should not happen!\n");
vec[dof] = dof;
}
const DOFAdmin *getAdmin()
{
return admin;
......
Markdown is supported
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