BasisFunction.cc 2.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
//
// 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.


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#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
29
  BasisFunction::BasisFunction(std::string name_, int dim_, int degree_)
Thomas Witkowski's avatar
Thomas Witkowski committed
30
31
32
    : name(name_), 
      degree(degree_), 
      dim(dim_)
33
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
34
    nDOF = new DimVec<int>(dim, DEFAULT_VALUE, -1);
Thomas Witkowski's avatar
Thomas Witkowski committed
35
    dow = Global::getGeo(WORLD);
36
  }
37

38

Thomas Witkowski's avatar
Thomas Witkowski committed
39
40
  BasisFunction::~BasisFunction()
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
41
    delete nDOF;
Thomas Witkowski's avatar
Thomas Witkowski committed
42
  }
43

44

45
46
  const WorldMatrix<double>& BasisFunction::evalD2Uh(const DimVec<double>& lambda,
						     const DimVec<WorldVector<double> >& grd_lambda,
Thomas Witkowski's avatar
Thomas Witkowski committed
47
48
						     const ElementVector& uh_loc, 
						     WorldMatrix<double>* D2_uh) const
49
  {
Thomas Witkowski's avatar
Thomas Witkowski committed
50
    static WorldMatrix<double> D2(DEFAULT_VALUE, 0.0);
51
    DimMat<double> D2_b(dim, DEFAULT_VALUE, 0.0);
52
    DimMat<double> D2_tmp(dim, DEFAULT_VALUE, 0.0);
53
    WorldMatrix<double> *val = D2_uh ? D2_uh : &D2;
54
55
  
    for (int i = 0; i < nBasFcts; i++) {
56
      (*(*d2Phi)[i])(lambda, D2_b);
57
58
59
60
61
62
63
64
      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;
65
66
	for (int k = 0; k < dim + 1; k++)
	  for (int l = 0; l < dim + 1; l++)
67
68
69
	    (*val)[i][j] += grd_lambda[k][i] * grd_lambda[l][j] * D2_tmp[k][l];
      }
    
70
    return ((*val));
71
72
  }

73

74
  int BasisFunction::getNumberOfDofs(int i) const
75
76
77
78
79
  { 
    return (*nDOF)[i];
  }

}