// SpaFEDTe, a Template based C++ library for creating 
// Discontinuous Finite Element Spaces,
// Copyright (C) 2012 Lorenzo Alessio Botti

/* This library is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Lesser General Public */ 
/* License as published by the Free Software Foundation either */ 
/* version 3.0 of the License, or (at your option) any later version. */

/* This software is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU */
/* Lesser General Public License for more details. */

/* You should have received a copy of the GNU Lesser General Public */
/* License along with this software; if not, a copy of the full */
/* GNU Lesser General Public License can be found at */
/* http://www.gnu.org/licenses/. */

#ifndef __LagrangeNodalMappingBasisFunction_h__
#define __LagrangeNodalMappingBasisFunction_h__

#include "BasisFunction.hpp"
#include "MappingBasisFunction.hpp"
#include "Tuple.hpp"
#include "EnumElemType.hpp"
#include "Quadrature.hpp"
#include "Eigen/Dense"

template<unsigned int Dim, unsigned int DIm>
class LagrangeNodalMappingFunction : public MappingBasisFunction<Dim, DIm>
{
public:
  typedef typename BasisFunction<Dim>::ShapeDerivMatrix ShapeDerivMatrix;
  typedef typename BasisFunction<Dim>::ShapeMatrix ShapeMatrix;

  LagrangeNodalMappingFunction():
    MappingBasisFunction<Dim, DIm>(),
    vandermondeOrder(0),
    vandermondeItemType(INVALID_ELEM)
    {
      ;
    } 
  
  LagrangeNodalMappingFunction(unsigned int order, ElemType itemType):
    MappingBasisFunction<Dim, DIm>(order, itemType),
    vandermondeOrder(0),
    vandermondeItemType(INVALID_ELEM)
    {
      ;
    } 
    
  ~LagrangeNodalMappingFunction() { }

  BasisFunction<Dim>& getVandermondeBasisFunction()
  {
    return vandermondeBasisFunction;
  }

  Eigen::MatrixXd& getVandermondeInvMat()
  {
    return vandermondeInvMatrix;
  }
  
  unsigned int& getVandermondeOrder()
  {
    return vandermondeOrder;
  }
  
  const unsigned int& getVandermondeOrder() const
  {
    return vandermondeOrder;
  }
  
  ElemType& getVandermondeItemType()
  {
    return vandermondeItemType;
  }
  
  const ElemType& getVandermondeItemType() const
  {
    return vandermondeItemType;
  }
  
protected:
  
  BasisFunction<Dim> vandermondeBasisFunction;

  Eigen::MatrixXd vandermondeInvMatrix;
  
  unsigned int vandermondeOrder;

  ElemType vandermondeItemType;

};

#endif
