Commit 760c8ad6 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

Added 3D mesh check after mesh repartitioning.

parent 94ee2720
......@@ -24,7 +24,8 @@ 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;
......@@ -122,7 +123,8 @@ namespace AMDiS {
void CoarseningManager3d::coarsenTetrahedron(RCNeighbourList *coarsenList,
int index)
{
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(index)));
Tetrahedron *el =
dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(index)));
Tetrahedron *child[2];
Tetrahedron *neigh;
int dir, el_type, i, node, opp_v;
......@@ -137,7 +139,8 @@ namespace AMDiS {
/****************************************************************************/
for (dir = 0; dir < 2; dir++) {
neigh = dynamic_cast<Tetrahedron*>(const_cast<Element*>( coarsenList->getNeighbourElement(index, dir)));
neigh =
dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getNeighbourElement(index, dir)));
opp_v = coarsenList->getOppVertex(index, dir);
if (!neigh || neigh->isLeaf()) {
......@@ -147,13 +150,13 @@ 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);
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);
mesh->freeDof(const_cast<int*>(child[1]->getDof(node)), FACE);
}
}
}
......@@ -165,14 +168,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);
}
/****************************************************************************/
......@@ -250,15 +253,19 @@ namespace AMDiS {
while (neigh != el) {
for (j = 0; j < n_vertices; j++)
if (neigh->getDof(j) == edge[0]) break;
if (neigh->getDof(j) == edge[0])
break;
for (k = 0; k < n_vertices; k++)
if (neigh->getDof(k) == edge[1]) break;
if (neigh->getDof(k) == edge[1])
break;
if (j > 3 || k > 3) {
for (j = 0; j < n_vertices; j++)
if (mesh->associated(neigh->getDof(j, 0), edge[0][0])) break;
if (mesh->associated(neigh->getDof(j, 0), edge[0][0]))
break;
for (k = 0; k < n_vertices; k++)
if (mesh->associated(neigh->getDof(k, 0), edge[1][0])) break;
if (mesh->associated(neigh->getDof(k, 0), edge[1][0]))
break;
TEST_EXIT_DBG(j < n_vertices && k < n_vertices)
("dof %d or dof %d not found on element %d with nodes (%d %d %d %d)\n",
......@@ -305,7 +312,7 @@ namespace AMDiS {
/* the domain's boundary is reached; loop back to the starting el */
/****************************************************************************/
i = *n_neigh-1;
i = *n_neigh - 1;
opp_v = coarsenList->getOppVertex(i, 0);
do {
TEST_EXIT_DBG(neigh_info->getNeighbour(opp_v) && i > 0)
......@@ -326,32 +333,32 @@ namespace AMDiS {
int n_neigh,
int bound)
{
Tetrahedron *el = dynamic_cast<Tetrahedron*>(const_cast<Element*>( coarsenList->getElement(0)));
int i, node;
DegreeOfFreedom *dof;
FUNCNAME("CoarseningManager3d::coarsenPatch()");
Tetrahedron *el =
dynamic_cast<Tetrahedron*>(const_cast<Element*>(coarsenList->getElement(0)));
DegreeOfFreedom *dof = NULL;
TEST_EXIT_DBG(el)("No element!\n");
TEST_EXIT_DBG(el->getChild(0))("No child in element!\n");
if (mesh->getNumberOfDofs(EDGE)) {
/****************************************************************************/
/* get dof for coarsening edge */
/****************************************************************************/
node = mesh->getNode(EDGE);
if (!(dof = const_cast<int*>( el->getDof(node))))
// === Get dof for coarsening edge. ===
int node = mesh->getNode(EDGE);
if (!(dof = const_cast<int*>(el->getDof(node))))
dof = mesh->getDof(EDGE);
} else {
dof = NULL;
}
if (mesh->getNumberOfDofs(EDGE) ||
mesh->getNumberOfDofs(FACE) ||
mesh->getNumberOfDofs(CENTER)) {
for (i = 0; i < n_neigh; i++)
for (int i = 0; i < n_neigh; i++)
coarsenList->addDOFParent(i, dof);
}
/****************************************************************************/
/* restrict dof vectors to the parents on the patch */
/****************************************************************************/
// === Restrict dof vectors to the parents on the patch. ===
int nrAdmin = mesh->getNumberOfDOFAdmin();
for (int iadmin = 0; iadmin < nrAdmin; iadmin++) {
......@@ -362,41 +369,35 @@ namespace AMDiS {
(*it)->coarseRestrict(*coarsenList, n_neigh);
}
/****************************************************************************/
/* and now start to coarsen the patch: */
/****************************************************************************/
/* remove dof's of the coarsening edge */
/****************************************************************************/
// === And now start to coarsen the patch: 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);
int 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();
for (i = 0; i < n_neigh; i++) {
for (int 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 */
/* and 2*n_neigh + 1 faces removed; if it is a boundary edge it is one */
/* more edge and one more face */
/****************************************************************************/
// === If the coarsening edge is an interior edge there are n_neigh + 1 edges ===
// === and 2 * n_neigh + 1 faces removed; if it is a boundary edge it is one ===
// === more edge and one more face. ===
if (bound) {
mesh->incrementNumberOfEdges(-(n_neigh + 2));
mesh->incrementNumberOfFaces(-(2*n_neigh + 1));
mesh->incrementNumberOfFaces(-(2 * n_neigh + 1));
} else {
mesh->incrementNumberOfEdges(-(n_neigh + 1));
mesh->incrementNumberOfFaces(-(2*n_neigh));
mesh->incrementNumberOfFaces(-(2 * n_neigh));
}
}
......
......@@ -1132,6 +1132,12 @@ namespace AMDiS {
MSG("Debug mode tests finished!\n");
#endif
// === In 3D we have to make some test, if the resulting mesh is valid. If ===
// === it is not valid, there is no possiblity yet to fix this problem, just ===
// === exit with an error message. ===
check3dValidMesh();
MSG("Mesh repartitioning needed %.5f seconds\n", MPI::Wtime() - timePoint);
}
......
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