/****************************************************************************** * * 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 "ElInfo.h" #include "BasisFunction.h" #include "DOFVector.h" #include "DOFMatrix.h" namespace AMDiS { template DirichletBC::DirichletBC(BoundaryType type, AbstractFunction > *fct, const FiniteElemSpace *rowFeSpace, const FiniteElemSpace *colFeSpace, bool apply) : BoundaryCondition(type, rowFeSpace, colFeSpace), container(fct), applyBC(apply) {} #if __cplusplus > 199711L template DirichletBC::DirichletBC(BoundaryType type, std::function)> fct, const FiniteElemSpace *rowFeSpace, const FiniteElemSpace *colFeSpace, bool apply) : BoundaryCondition(type, rowFeSpace, colFeSpace), container(fct), applyBC(apply) {} #endif template DirichletBC::DirichletBC(BoundaryType type, DOFVectorBase *vec, bool apply) : BoundaryCondition(type, vec->getFeSpace(), vec->getFeSpace()), container(vec), applyBC(apply) {} template 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"); } template void DirichletBC::fillBoundaryCondition(DOFVectorBase* vector, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, const BoundaryType* localBound, int nBasFcts) { FUNCNAME_DBG("DirichletBC::fillBoundaryCondition()"); TEST_EXIT_DBG(vector->getFeSpace() == rowFeSpace)("invalid row fe space\n"); fillBC(Tag(), vector, elInfo, dofIndices, localBound, nBasFcts); } template void DirichletBC::fillBC(_value_by_abstractfunction, 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.value(worldCoords); vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } // c++11 std::function of lambda-functions template void DirichletBC::fillBC(_value_by_function, 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.value(worldCoords); vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } template void DirichletBC::fillBC(_value_by_dofvector, 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.value)[dofIndices[i]]; vector->setDirichletDofValue(dofIndices[i], value); (*vector)[dofIndices[i]] = value; } } template void DirichletBC::initVector(DOFVectorBase* vec) { if (dynamic_cast*>(vec)) dynamic_cast*>(vec)->getDirichletValues().clear(); } }