// 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 2.1 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/copyleft/lesser.html. */

#ifndef __CollectiveMappingFunction_h__
#define __CollectiveMappingFunction_h__

#include "Quadrature.hpp"

template<class MappingBasisFunctionT>
class CollectiveMappingFunction
{
public:
  typedef MappingBasisFunctionT MappingBasisFunctionType;
  typedef typename MappingBasisFunctionType::PointVector PointVector;
  typedef typename MappingBasisFunctionType::JacVector JacVector;
  typedef typename MappingBasisFunctionType::CoordVector CoordVector;
  typedef typename MappingBasisFunctionType::DistanceVector DistanceVector;
  typedef typename MappingBasisFunctionType::RotationMatrix RotationMatrix;
  typedef typename MappingBasisFunctionType::NormalVector NormalVector;

  CollectiveMappingFunction()
    {
      ;
    } 
  
  ~CollectiveMappingFunction() { }

public:
  const JacVector& getJacobianXweight() const { return m_jacXweight; }

  JacVector& getJacobianXweight() { return m_jacXweight; }
  
  const PointVector& getQpointX() const { return m_QpointX; }

  PointVector& getQpointX() { return m_QpointX; }
  
  const NormalVector& getNormalVec() const { return m_normalVec; }

  NormalVector& getNormalVec() { return m_normalVec; }

  void resizeAllCollective(const unsigned int qpoints)
  {
    this->m_QpointX.resize(qpoints,Eigen::NoChange);
    this->m_jacXweight.resize(qpoints);
    if (MappingBasisFunctionType::RefSpaceDim != MappingBasisFunctionType::PhySpaceDIm)
      this->m_normalVec.resize(qpoints);
  }
  
  void resizeQpointsXCollective(const unsigned int qpoints)
  {
    this->m_QpointX.resize(qpoints,Eigen::NoChange);
  }
  
  MappingBasisFunctionType& getSubMappingFunction()
  {
    return mappingFunction;
  }
  
  const MappingBasisFunctionType& getSubMappingFunction() const
  {
    return mappingFunction;
  }
  
private:
  MappingBasisFunctionType mappingFunction;
  
  JacVector m_jacXweight;
  
  PointVector m_QpointX;
  
  NormalVector m_normalVec;
};

#endif
