BasisFunction.hh 2.6 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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92


#include "BasisFunction.h"

namespace AMDiS {

  template<typename T>
  T BasisFunction::evalUh(const DimVec<double>& lambda,
			       const mtl::dense_vector<T>& uh_loc) const
  {
    T val;
    nullify(val);
    
    for (int i = 0; i < nBasFcts; i++)
      val += uh_loc[i] * (*(*phi)[i])(lambda);

    return val;
  }

  template<typename T>
  typename GradientType<T>::type& BasisFunction::evalGrdUh(const DimVec<double>& lambda,
						      const DimVec<WorldVector<double> >& grd_lambda,
						      const mtl::dense_vector<T>& uh_loc,
						      typename GradientType<T>::type& val) const
  {

    mtl::dense_vector<double> grdTmp1(dim + 1);
    T null;
    nullify(null);
    mtl::dense_vector<T> grdTmp2(dim + 1, null);

    for (int i = 0; i < nBasFcts; i++) {
      (*(*grdPhi)[i])(lambda, grdTmp1);

      for (int j = 0; j < dim + 1; j++)
	grdTmp2[j] += uh_loc[i] * grdTmp1[j];
    }
    nullify(val);

    for (int i = 0; i < dow; i++) {
      for (int j = 0; j < dim + 1; j++)
	val[i] += grd_lambda[j][i] * grdTmp2[j];
    }

    return val;
  }

//   template<typename T>
//   typename D2Type<T>::type& BasisFunction::evalD2Uh(const DimVec<double>& lambda,
// 						     const DimVec<WorldVector<double> >& grd_lambda,
// 						     const mtl::dense_vector<T>& uh_loc,
// 						     D2Type<T>::type& val) const
//   {
//     DimMat<double> D2_b(dim, DEFAULT_VALUE, 0.0);
//     DimMat<T> D2_tmp(dim, DEFAULT_VALUE, 0.0);
// 
//     for (int i = 0; i < nBasFcts; i++) {
//       (*(*d2Phi)[i])(lambda, D2_b);
//       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;
// 	for (int k = 0; k < dim + 1; k++)
// 	  for (int l = 0; l < dim + 1; l++)
// 	    val[i][j] += grd_lambda[k][i] * grd_lambda[l][j] * D2_tmp[k][l];
//       }
// 
//     return val;
//   }
93
}