BoundaryManager.h 4.07 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
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file BoundaryManager.h */

#ifndef AMDIS_BOUNDARYMANAGER_H
#define AMDIS_BOUNDARYMANAGER_H

#include <map>

27
#include "AMDiS_fwd.h"
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include "Boundary.h"
#include "BoundaryCondition.h"

namespace AMDiS {

  /**
   * \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
44 45 46 47 48 49
    BoundaryManager(const FiniteElemSpace *feSpace);

    BoundaryManager(BoundaryManager &bm);

    ~BoundaryManager();

50
    /// Adds a local boundary condition to the list of managed conditions.
51 52
    void addBoundaryCondition(BoundaryCondition *localBC) 
    {
53
      BoundaryType type = localBC->getBoundaryType();
54
      TEST_EXIT(localBCs[type] == NULL)("there is already a condition for this type\n");
55
      localBCs[type] = localBC;
56
    }
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

    void initMatrix(DOFMatrix *matrix);

    void exitMatrix(DOFMatrix *matrix);

    void initVector(DOFVectorBase<double> *vector);

    void exitVector(DOFVectorBase<double> *vector);

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

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

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

86 87
    inline BoundaryCondition *getBoundaryCondition(BoundaryType type) 
    {
88
      return localBCs[type];
89
    }
90

91 92
    const std::map<BoundaryType, BoundaryCondition*>& getBoundaryConditionMap() 
    {
93
      return localBCs;
94
    }
95

96 97
    void setBoundaryConditionMap(const std::map<BoundaryType, BoundaryCondition*>& bcs) 
    {
98
      localBCs = bcs;
99
    }
100 101

  protected:
102
    /// Map of managed local boundary conditions.
103
    std::map<BoundaryType, BoundaryCondition*> localBCs;
Thomas Witkowski's avatar
Thomas Witkowski committed
104

105
    /// Temporary thread-safe variable for functions fillBoundaryconditions.
Thomas Witkowski's avatar
Thomas Witkowski committed
106 107
    std::vector<BoundaryType*> localBounds;

108 109 110
    /// Temporary thread-safe variable for functions fillBoundaryconditions.
    std::vector<Vector<DegreeOfFreedom> > dofIndices;

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

}

#endif