Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

ElementDofIterator.cc 2.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#include "ElementDofIterator.h"
#include "Mesh.h"
#include "DOFAdmin.h"
#include "Element.h"

namespace AMDiS {

  void ElementDofIterator::reset(Element* element)
  {
    FUNCNAME("ElementDofIterator::reset()");

    dofs = element->getDOF();
    mesh = element->getMesh();
    dim = mesh->getDim();

    // 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());
  }

  bool ElementDofIterator::next()
  {
    // First iteratore 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;

50 51 52 53
	// If we have iterated over all positions, we can finish the iteration.
	if (pos >= dim)
	  return false;

54 55 56 57 58 59 60 61
	// 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);
62
	} while (nDofs == 0 && pos < dim);
63
	
64
	if (nDofs > 0 && pos <= dim) {
65 66 67 68 69
	  // 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);
70

71 72
	  // Calculate displacement. Is used if there is more than one dof admin on the mesh.
	  n0 = admin->getNumberOfPreDOFs(posIndex);
73

74 75 76 77 78 79 80 81 82 83 84
	  // Get first dof index position for the geo index position.
	  node0 = mesh->getNode(posIndex);
	} else {
	  // That's all, we jave traversed all dofs of the mesh element.
	  return false;
	}

      }
    }

    return true;
Thomas Witkowski's avatar
Thomas Witkowski committed
85 86
  }

87
}