BasisFunction.cc 2.51 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/******************************************************************************
 *
 * 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.
 * 
 ******************************************************************************/
20
21


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <algorithm>

#include "FixVec.h"
#include "DOFVector.h"
#include "BasisFunction.h"
#include "Lagrange.h"

namespace AMDiS {


  /****************************************************************************/
  /*  Lagrangian basisfunctions of order 0-4; these                           */
  /*  functions are evaluated in barycentric coordinates; the derivatives     */
  /*  are those corresponding to these barycentric coordinates.               */
  /****************************************************************************/

Thomas Witkowski's avatar
Thomas Witkowski committed
38
  BasisFunction::BasisFunction(std::string name_, int dim_, int degree_)
Thomas Witkowski's avatar
Thomas Witkowski committed
39
40
41
    : name(name_), 
      degree(degree_), 
      dim(dim_)
42
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
43
    nDOF = new DimVec<int>(dim, DEFAULT_VALUE, -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
44
    dow = Global::getGeo(WORLD);
45
  }
46

47

Thomas Witkowski's avatar
Thomas Witkowski committed
48
49
  BasisFunction::~BasisFunction()
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
50
    delete nDOF;
Thomas Witkowski's avatar
Thomas Witkowski committed
51
  }
52

53

54
55
  const WorldMatrix<double>& BasisFunction::evalD2Uh(const DimVec<double>& lambda,
						     const DimVec<WorldVector<double> >& grd_lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
56
57
						     const ElementVector& uh_loc, 
						     WorldMatrix<double>* D2_uh) const
58
  {
59
    // TODO: REMOVE STATIC
Thomas Witkowski's avatar
Thomas Witkowski committed
60
    static WorldMatrix<double> D2(DEFAULT_VALUE, 0.0);
61
    DimMat<double> D2_b(dim, DEFAULT_VALUE, 0.0);
62
    DimMat<double> D2_tmp(dim, DEFAULT_VALUE, 0.0);
63
    WorldMatrix<double> *val = D2_uh ? D2_uh : &D2;
64
65
  
    for (int i = 0; i < nBasFcts; i++) {
66
      (*(*d2Phi)[i])(lambda, D2_b);
67
68
69
70
71
72
73
74
      for (int k = 0; k < dim + 1; k++)
	for (int l = 0; l < dim + 1; l++)
	  D2_tmp[k][l] += uh_loc[i] * D2_b[k][l];
    }

    for (int i = 0; i < dow; i++)
      for (int j = 0; j < dow; j++) {
	(*val)[i][j] = 0.0;
75
76
	for (int k = 0; k < dim + 1; k++)
	  for (int l = 0; l < dim + 1; l++)
77
78
79
	    (*val)[i][j] += grd_lambda[k][i] * grd_lambda[l][j] * D2_tmp[k][l];
      }
    
80
    return ((*val));
81
82
  }

83

84
  int BasisFunction::getNumberOfDofs(int i) const
85
86
87
88
89
  { 
    return (*nDOF)[i];
  }

}