Skip to content
Snippets Groups Projects
BasisFunction.hh 2.16 KiB
//
// 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.


#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;
//   }
}