BoundaryManager.h 4.06 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 53 54 55
    void addBoundaryCondition(BoundaryCondition *localBC) {
      BoundaryType type = localBC->getBoundaryType();
      TEST_EXIT(localBCs[type] == NULL)
	("there is already a condition for this type\n");
      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 86 87

    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);

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

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

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

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

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

105 106 107
    /// Temporary thread-safe variable for functions fillBoundaryconditions.
    std::vector<Vector<DegreeOfFreedom> > dofIndices;

Thomas Witkowski's avatar
Thomas Witkowski committed
108 109 110 111 112
    /** \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;
113 114 115 116 117
  };

}

#endif