BoundaryManager.h 4.03 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 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 88 89 90 91 92 93 94 95 96 97 98 99
// ============================================================================
// ==                                                                        ==
// == 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>

#include "Boundary.h"
#include "BoundaryCondition.h"

namespace AMDiS {

  class DOFMatrix;
  class FiniteElemSpace;
  template<typename T> class DOFVectorBase;

  // ============================================================================
  // ===== class BoundaryManager ================================================
  // ============================================================================

  /**
   * \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:
    MEMORY_MANAGED(BoundaryManager);

    /** \brief
     * Adds a local boundary condition to the list of managed conditions.
     */
    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;
    };

    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];
    };

    //   /** \brief
    //    * Fills boundary types in DOFVectorBase bound.
    //    */
    //   void fillGlobalBoundVector(DOFVectorBase<BoundaryType> *bound);

100
    const std::map<BoundaryType, BoundaryCondition*>& getBoundaryConditionMap() {
101 102 103
      return localBCs;
    };

104
    void setBoundaryConditionMap(const std::map<BoundaryType, BoundaryCondition*>& bcs) {
105 106 107 108 109 110 111
      localBCs = bcs;
    };

  protected:
    /** \brief
     * Map of managed local boundary conditions.
     */
112
    std::map<BoundaryType, BoundaryCondition*> localBCs;
113 114 115 116 117
  };

}

#endif