/****************************************************************************** * * AMDiS - Adaptive multidimensional simulations * * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved. * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis * * Authors: * Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * * This file is part of AMDiS * * See also license.opensource.txt in the distribution. * ******************************************************************************/ #include "DirichletBC.h" #include "ElInfo.h" #include "BasisFunction.h" #include "DOFVector.h" #include "DOFMatrix.h" namespace AMDiS { namespace detail { void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, const BoundaryType* localBound, int nBasFcts) { FUNCNAME_DBG("DirichletBC::fillBoundaryCondition()"); TEST_EXIT_DBG(matrix->getRowFeSpace() == rowFeSpace)("invalid row fe space\n"); } void DirichletBC::initVector(DOFVectorBase* vec) { if (dynamic_cast*>(vec)) dynamic_cast*>(vec)->getDirichletValues().clear(); } } DirichletBC<_value_by_dofvector>::DirichletBC( BoundaryType type, DOFVectorBase *vec, bool apply) : super(type, vec->getFeSpace(), vec->getFeSpace(), apply), container(vec) { } void DirichletBC<_value_by_dofvector>::fillBoundaryCondition( DOFVectorBase* vector, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, const BoundaryType* localBound, int nBasFcts) { for (int i = 0; i < nBasFcts; i++) if (localBound[i] == boundaryType) { double value = (*container)[dofIndices[i]]; vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } #if AMDIS_HAS_CXX11 // c++11 std::function of lambda-functions void DirichletBC<_value_by_function>::fillBoundaryCondition( DOFVectorBase* vector, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, const BoundaryType* localBound, int nBasFcts) { WorldVector worldCoords; const BasisFunction *basFcts = rowFeSpace->getBasisFcts(); for (int i = 0; i < nBasFcts; i++) if (localBound[i] == boundaryType) { elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords); double value = container(worldCoords); vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } #endif void DirichletBC<_value_by_abstractfunction>::fillBoundaryCondition( DOFVectorBase* vector, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, const BoundaryType* localBound, int nBasFcts) { WorldVector worldCoords; const BasisFunction *basFcts = rowFeSpace->getBasisFcts(); for (int i = 0; i < nBasFcts; i++) if (localBound[i] == boundaryType) { elInfo->coordToWorld(*(basFcts->getCoords(i)), worldCoords); double value = container(worldCoords); vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } }