// ============================================================================ // == == // == 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 #include "Boundary.h" #include "BoundaryCondition.h" namespace AMDiS { class DOFMatrix; class FiniteElemSpace; template class Vector; template 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); BoundaryManager(const FiniteElemSpace *feSpace); BoundaryManager(BoundaryManager &bm); ~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 *vector); void exitVector(DOFVectorBase *vector); /** \brief * Calls DOFVectorBase::fillBoundaryCondition() for each local boundary condition * in \ref localBCs. */ void fillBoundaryConditions(ElInfo *elInfo, DOFVectorBase *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 *dv); inline BoundaryCondition *getBoundaryCondition(BoundaryType type) { return localBCs[type]; } const std::map& getBoundaryConditionMap() { return localBCs; } void setBoundaryConditionMap(const std::map& bcs) { localBCs = bcs; } protected: /// Map of managed local boundary conditions. std::map localBCs; /// Temporary thread-safe variable for functions fillBoundaryconditions. std::vector localBounds; /// Temporary thread-safe variable for functions fillBoundaryconditions. std::vector > dofIndices; /** \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; }; } #endif