Skip to content
Snippets Groups Projects
DOFContainer.h 2.03 KiB
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==  http://www.amdis-fem.org                                              ==
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.



/** \file DOFContainer.h */

#ifndef AMDIS_DOFCONTAINER_H
#define AMDIS_DOFCONTAINER_H

#include "Global.h"

namespace AMDiS {

  /** \ingroup DOFAdministration
   * \brief
   * DOFContainer is the base class for objects that stores DOF indices.
   * After a DOFContainer object is registered to a DOFAdmin, the DOF
   * indices of the container will be managed during DOF compression. The
   * DOFAdmin then calls the compress method of every registered DOFContainer.
   */
  class DOFContainer
  {
  public:
    virtual ~DOFContainer() {}

    /** \brief
     * Returns the DOF index at position i. Must be overriden by a concrete
     * DOFContainer.
     */
    virtual DegreeOfFreedom& operator[](int i) = 0;

    virtual void freeDofIndex(DegreeOfFreedom dof) {}

    /** \brief
     * Used by DOFAdmin to actualize the DOF indices in this container after
     * DOF compression.
     */
    virtual void compressDofContainer(int size, std::vector<DegreeOfFreedom> &newDOF)
    {
      FUNCNAME("DOFContainer::compressDofContainer()");

      for (int i = 0; i < size; i++) {
	int j = newDOF[operator[](i)];

	TEST_EXIT_DBG(j >= 0)
	  ("Invalid DOF %d in DOF container! (%d %d)\n", j, i, operator[](i));

	operator[](i) = j;
      }
    }

  };
}
#endif