Skip to content
Snippets Groups Projects
DirichletBC.h 3.25 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ==                                                                        ==
// ============================================================================
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.



/** \file DirichletBC.h */

#ifndef AMDIS_DIRICHLETBC_H
#define AMDIS_DIRICHLETBC_H

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

namespace AMDiS {

  /**
   * \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:
    DirichletBC(BoundaryType type,
		AbstractFunction<double, WorldVector<double> > *fct,
		FiniteElemSpace *rowFeSpace,
		FiniteElemSpace *colFeSpace = NULL,
		bool apply = true);
    DirichletBC(BoundaryType type,
		DOFVectorBase<double> *vec,
		bool apply = true);
    /// Implementation of BoundaryCondition::fillBoundaryCondition().
    void fillBoundaryCondition(DOFMatrix* matrix,
			       ElInfo* elInfo,
			       const DegreeOfFreedom* dofIndices,
			       const BoundaryType* localBound,
			       int nBasFcts);
    /// Implementation of BoundaryCondition::fillBoundaryCondition().
    void fillBoundaryCondition(DOFVectorBase<double>* vector, 
			       ElInfo* elInfo,
			       const DegreeOfFreedom* dofIndices,
			       const BoundaryType* localBound,
			       int nBasFcts);
    /// Implementation of BoundaryCondition::boundResidual().
    double boundResidual(ElInfo*, 
			 DOFMatrix *,
			 const DOFVectorBase<double>*) 
    { 
      return 0.0; 
    }
    /// Because this is a Dirichlet boundary condition, always return true.
    bool isDirichlet() 
    { 
    /// Returns \ref applyBC.
    bool applyBoundaryCondition() 
    {
      return applyBC;
    }

    inline AbstractFunction<double, WorldVector<double> > *getF() 
    {
    inline DOFVectorBase<double> *getDOFVector() 
    {
    /// Function which is evaluated at world coords of Dirichlet dofs.
    AbstractFunction<double, WorldVector<double> > *f;

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

    /** \brief
     * Defines, if the boundary condition must be applied to the matrix. See
     * comment of \ref BoundaryCondition::applyBoundaryCondition.
     */
    bool applyBC;