DOFContainer.h 2.56 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut für Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// ==                                                                        ==
// ============================================================================

/** \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:
39
    virtual ~DOFContainer() {}
40
41
42
43
44
45
46

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

Thomas Witkowski's avatar
Thomas Witkowski committed
47
    virtual void freeDOFIndex(DegreeOfFreedom dof) {}
48
49
50
51
52

    /** \brief
     * Used by DOFAdmin to actualize the DOF indices in this container after
     * DOF compression.
     */
53
    virtual void compressDOFContainer(int size, std::vector<DegreeOfFreedom> &newDOF) 
54
    {
55
56
57
      for (int i = 0; i < size; i++) {
	int j = newDOF[operator[](i)];
	if (j >= 0)
58
	  operator[](i) = j;
59
	else
60
61
	  ERROR_EXIT("invalid dof in dof container\n");
      }
62
    }
63
64
65
66
  };
}

#endif