DirichletBC.cc 3.24 KB
Newer Older
1
2
3
4
5
6
7
/******************************************************************************
 *
 * AMDiS - Adaptive multidimensional simulations
 *
 * Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
 * Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
 *
8
 * Authors:
9
10
11
12
13
14
15
16
17
 * 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.
18
 *
19
 ******************************************************************************/
20
21


22
23
24
25
26
27
28
#include "DirichletBC.h"
#include "ElInfo.h"
#include "BasisFunction.h"
#include "DOFVector.h"
#include "DOFMatrix.h"

namespace AMDiS {
29

30
  namespace detail {
31

32
33
34
35
36
37
38
39
40
      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");
      }
41

42
43
44
45
46
47
      void DirichletBC::initVector(DOFVectorBase<double>* vec)
      {
	if (dynamic_cast<DOFVector<double>*>(vec))
	  dynamic_cast<DOFVector<double>*>(vec)->getDirichletValues().clear();
      }
  }
48
49


50
51
52
53
54
55
56
  DirichletBC<_value_by_dofvector>::DirichletBC(
	  BoundaryType type,
	  DOFVectorBase<double> *vec,
	  bool apply)
    : super(type, vec->getFeSpace(), vec->getFeSpace(), apply),
      container(vec)
  { }
57
58


59
60
61
62
63
64
  void DirichletBC<_value_by_dofvector>::fillBoundaryCondition(
	  DOFVectorBase<double>* vector,
	  ElInfo* elInfo,
	  const DegreeOfFreedom* dofIndices,
	  const BoundaryType* localBound,
	  int nBasFcts)
65
  {
66
67
68
69
70
71
    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;
      }
72
  }
73
74


75
#if AMDIS_HAS_CXX11
76
77
78
79
80
81
82
  // c++11 std::function of lambda-functions
  void DirichletBC<_value_by_function>::fillBoundaryCondition(
	  DOFVectorBase<double>* vector,
	  ElInfo* elInfo,
	  const DegreeOfFreedom* dofIndices,
	  const BoundaryType* localBound,
	  int nBasFcts)
83
  {
84
    WorldVector<double> worldCoords;
85
    const BasisFunction *basFcts = rowFeSpace->getBasisFcts();
86

87
88
89
90
91
92
93
    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;
      }
94
  }
95
#endif
96

97
98
99
100
101
102
  void DirichletBC<_value_by_abstractfunction>::fillBoundaryCondition(
	  DOFVectorBase<double>* vector,
	  ElInfo* elInfo,
	  const DegreeOfFreedom* dofIndices,
	  const BoundaryType* localBound,
	  int nBasFcts)
103
  {
104
105
    WorldVector<double> worldCoords;
    const BasisFunction *basFcts = rowFeSpace->getBasisFcts();
106

107
108
109
110
111
112
113
114
    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;
      }
  }
115
}