BoundaryManager.h 4.22 KB
Newer Older
1
2
3
4
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
5
// ==  http://www.amdis-fem.org                                              ==
6
7
// ==                                                                        ==
// ============================================================================
8
9
10
11
12
13
14
15
16
17
18
19
//
// 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.


20
21
22
23
24
25
26
27

/** \file BoundaryManager.h */

#ifndef AMDIS_BOUNDARYMANAGER_H
#define AMDIS_BOUNDARYMANAGER_H

#include <map>

28
#include "AMDiS_fwd.h"
29
30
31
32
33
#include "Boundary.h"
#include "BoundaryCondition.h"

namespace AMDiS {

34
35
  typedef std::map<BoundaryType, BoundaryCondition*> BoundaryIndexMap;

36
37
38
39
40
41
42
43
44
45
46
  /**
   * \ingroup Assembler
   *
   * \brief
   * A BoundaryManager handles a set of boundary conditions and applies
   * this conditions to DOFVectorBase and DOFMatrix objects. Each DOFVectorBase
   * and each DOFMatrix has its own BoundaryManager.
   */
  class BoundaryManager
  {
  public:
Thomas Witkowski's avatar
Thomas Witkowski committed
47
48
49
50
51
52
    BoundaryManager(const FiniteElemSpace *feSpace);

    BoundaryManager(BoundaryManager &bm);

    ~BoundaryManager();

53
    /// Adds a local boundary condition to the list of managed conditions.
54
    void addBoundaryCondition(BoundaryCondition *localBC);
55
56
57
58
59
60
61
62
63

    void initMatrix(DOFMatrix *matrix);

    void exitMatrix(DOFMatrix *matrix);

    void initVector(DOFVectorBase<double> *vector);

    void exitVector(DOFVectorBase<double> *vector);

64
65
    /// Calls DOFVectorBase::fillBoundaryCondition() for each local boundary
    /// condition in \ref localBCs.
66
67
    void fillBoundaryConditions(ElInfo *elInfo, DOFVectorBase<double> *vec);

68
69
    /// Calls DOFMatrix::fillBoundaryCondition() for each local boundary condition
    /// in \ref localBCs.
70
71
    void fillBoundaryConditions(ElInfo *elInfo, DOFMatrix *mat);

72
73
    /// Calls BoundaryCondition::boundResidual() for each boundary condition in 
    /// \ref localBCs.
74
    double boundResidual(ElInfo *elInfo, DOFMatrix *matrix, 
75
76
			 const DOFVectorBase<double> *dv);

77
78
    inline BoundaryCondition *getBoundaryCondition(BoundaryType type) 
    {
79
      return localBCs[type];
80
    }
81

82
    const BoundaryIndexMap& getBoundaryConditionMap() 
83
    {
84
      return localBCs;
85
    }
86

87
    void setBoundaryConditionMap(const BoundaryIndexMap& bcs) 
88
    {
89
      localBCs = bcs;
90
    }
91
    
92
93
    /// Returns true, if there is at least one boundary object with the given
    /// boundary id, which implements a periodic boundary.
94
95
96
97
98
99
100
101
    static bool isBoundaryPeriodic(BoundaryType b)
    {
      for (int i = 0; i < static_cast<int>(globalBoundaryMap[b].size()); i++)
	if (globalBoundaryMap[b][i]->isPeriodic())
	  return true;

      return false;
    }
102
103

  protected:
104
    /// Map of managed local boundary conditions.
105
    BoundaryIndexMap localBCs;
Thomas Witkowski's avatar
Thomas Witkowski committed
106

107
108
    /// Temporary variable for functions fillBoundaryconditions.
    BoundaryType* localBound;
Thomas Witkowski's avatar
Thomas Witkowski committed
109

110
111
    /// Temporary variable for functions fillBoundaryconditions.
    std::vector<DegreeOfFreedom> dofVec;
112

113
114
    /// Stores the number of byte that were allocated in the constructor for
    /// each localBounds value. Is used to free the memory in the destructor.
Thomas Witkowski's avatar
Thomas Witkowski committed
115
    int allocatedMemoryLocalBounds;
116
117
118

    /** \brief
     * For every boundary id we store here all possible boundary object (although
Thomas Witkowski's avatar
Thomas Witkowski committed
119
120
     * it's not clear if it is meaningful to have different boundary conditions on
     * the same boundary id). 
121
     *
Thomas Witkowski's avatar
Thomas Witkowski committed
122
123
124
     * We have to use this global variable, because the mesh traverse interface 
     * does not provide more information about traversed boundaries at elements
     * than the boundary id.
125
126
127
128
129
130
     *
     * TODO: Change interface such that mesh traverse returns the boundary objects
     * directly and we can remove this global variable. The biggest problem will be
     * than serialization and deserialization of the mesh.
     */
    static std::map<BoundaryType, std::vector<BoundaryCondition*> > globalBoundaryMap;
131
132
133
134
135
  };

}

#endif