-
Thomas Witkowski authoredThomas Witkowski authored
ElementDofIterator.cc 2.86 KiB
#include "ElementDofIterator.h"
#include "Mesh.h"
#include "DOFAdmin.h"
#include "Element.h"
#include "BasisFunction.h"
namespace AMDiS {
void ElementDofIterator::reset(const Element* el)
{
FUNCNAME("ElementDofIterator::reset()");
TEST_EXIT_DBG(el->getMesh() == mesh)
("Mesh and element does not fit together!\n");
TEST_EXIT_DBG(el)("No element!\n");
element = el;
dofs = element->getDOF();
// Start with vertices.
pos = 0;
elementPos = 0;
dofPos = 0;
// Get geo index of vertices in the given dimension.
posIndex = INDEX_OF_DIM(pos, dim);
// Get number of dofs per vertex (should be one in all cases).
nDofs = admin->getNumberOfDOFs(posIndex);
TEST_EXIT_DBG(nDofs != 0)("Mh, I've to think about this situation!\n");
// Calculate displacement. Is used if there is more than one dof admin on the mesh.
n0 = admin->getNumberOfPreDOFs(posIndex);
// Get first dof index position for vertices.
node0 = mesh->getNode(posIndex);
// Get number of vertices in this dimension.
nElements = Global::getGeo(posIndex, mesh->getDim());
if (inOrder)
orderPosition = basisFcts->orderOfPositionIndices(element, posIndex, 0);
}
bool ElementDofIterator::next()
{
// First iterate over the dofs of one element (vertex, edge, face).
dofPos++;
if (dofPos >= nDofs) {
// We are finished with all dofs of on element. Go to the next one.
dofPos = 0;
elementPos++;
if (elementPos >= nElements) {
// We are finished with all element.
elementPos = 0;
// If we have iterated over all positions, we can finish the iteration.
if (pos >= dim)
return false;
// Increase position, i.e., go from vertices to edges to faces and search
// for the next position with dofs.
do {
pos++;
// Get geo index posistion.
posIndex = INDEX_OF_DIM(pos, dim);
// Get number of dofs in this position.
nDofs = admin->getNumberOfDOFs(posIndex);
} while (nDofs == 0 && pos < dim);
if (nDofs > 0 && pos <= dim) {
// We have found on more position with dofs.
// Get number of elements in this position, i.e, the number of vertices,.
// edges and faces in the given dimension.
nElements = Global::getGeo(posIndex, dim);
// Calculate displacement. Is used if there is more than one dof admin on the mesh.
n0 = admin->getNumberOfPreDOFs(posIndex);
// Get first dof index position for the geo index position.
node0 = mesh->getNode(posIndex);
if (inOrder)
orderPosition = basisFcts->orderOfPositionIndices(element, posIndex, 0);
} else {
// That's all, we jave traversed all dofs of the mesh element.
return false;
}
} else {
if (inOrder)
orderPosition =
basisFcts->orderOfPositionIndices(element, posIndex, elementPos);
}
}
return true;
}
bool ElementDofIterator::nextStrict()
{
dofPos = nDofs;
return next();
}
}