DOFContainer.h 2.81 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
50
51
52
53
54
55
56
57
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file DOFContainer.h */

#ifndef AMDIS_DOFCONTAINER_H
#define AMDIS_DOFCONTAINER_H

#include "Global.h"

namespace AMDiS {

  // ===========================================================================
  // ===== class DOFContainer ==================================================
  // ===========================================================================

  /** \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.
     */

58
    virtual void compressDOFContainer(int size, std::vector<DegreeOfFreedom> &newDOF) 
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
    {
      int i, j;
      for(i=0; i < size; i++) {
	if((j = newDOF[operator[](i)]) >= 0) {
	  operator[](i) = j;
	} else {
	  ERROR_EXIT("invalid dof in dof container\n");
	}
      }
    };
  };

}

#endif