Skip to content
Snippets Groups Projects
DirichletBC.h 3.88 KiB
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  crystal growth group                                                  ==
// ==                                                                        ==
// ==  Stiftung caesar                                                       ==
// ==  Ludwig-Erhard-Allee 2                                                 ==
// ==  53175 Bonn                                                            ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  http://www.caesar.de/cg/AMDiS                                         ==
// ==                                                                        ==
// ============================================================================

/** \file DirichletBC.h */

#ifndef AMDIS_DIRICHLETBC_H
#define AMDIS_DIRICHLETBC_H

#include "BoundaryCondition.h"
#include "AbstractFunction.h"
#include "OpenMP.h"

namespace AMDiS {

  template<typename T> class DOFVectorBase;
  class ElInfo;

  // ============================================================================
  // ===== class DirichletBC ==================================================== 
  // ============================================================================

  /**
   * \ingroup Assembler
   *
   * \brief
   * Sub class of BoundaryCondition. Implements Dirichlet boundary conditions.
   * A DOFVectors is set to a given value at a Dirichlet dof and in a DOFMatrix
   * the row corresponding to a Dirichlet dof is replaced by a row containing
   * only a 1.0 in the diagonal.
   */
  class DirichletBC : public BoundaryCondition
  {
  public:
    /** \brief
     * Constructor.
     */
    DirichletBC(BoundaryType type,
		AbstractFunction<double, WorldVector<double> > *fct,
		FiniteElemSpace *rowFESpace,
		FiniteElemSpace *colFESpace = NULL);

    /** \brief
     * Constructor.
     */
    DirichletBC(BoundaryType type,
		DOFVectorBase<double> *vec);

    /** \brief
     * Implementation of BoundaryCondition::fillBoundaryCondition().
     */
    void fillBoundaryCondition(DOFMatrix* matrix,
			       ElInfo* elInfo,
			       const DegreeOfFreedom* dofIndices,
			       const BoundaryType* localBound,
			       int nBasFcts);
  
    /** \brief
     * Implementation of BoundaryCondition::fillBoundaryCondition().
     */
    void fillBoundaryCondition(DOFVectorBase<double>* vector, 
			       ElInfo* elInfo,
			       const DegreeOfFreedom* dofIndices,
			       const BoundaryType* localBound,
			       int nBasFcts);

    /** \brief
     * Implementation of BoundaryCondition::boundResidual().
     */
    double boundResidual(ElInfo*, 
			 DOFMatrix *,
			 const DOFVectorBase<double>*) { 
      return 0.0; 
    };

    bool isDirichlet() { 
      return true; 
    };

    inline AbstractFunction<double, WorldVector<double> > *getF() {
      return f;
    };

    inline DOFVectorBase<double> *getDOFVector() {
      return dofVec;
    };

  protected:
    /** \brief
     * Function which is evaluated at world coords of Dirichlet dofs.
     */
    AbstractFunction<double, WorldVector<double> > *f;

    std::vector<WorldVector<double> > worldCoords;

    /** \brief
     * DOFVector containing the boundary values
     */
    DOFVectorBase<double> *dofVec;
  };

}

#endif