// @HEADER
// ***********************************************************************
//
//           Panzer: A partial differential equation assembly
//       engine for strongly coupled complex multiphysics systems
//                 Copyright (2011) Sandia Corporation
//
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
// the U.S. Government retains certain rights in this software.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
// Eric C. Cyr (eccyr@sandia.gov)
// ***********************************************************************
// @HEADER

#ifndef __Panzer_OrientationContainer_hpp__
#define __Panzer_OrientationContainer_hpp__

#include "Panzer_OrientationContainerBase.hpp"

namespace panzer {

// forward declaration
class GlobalIndexer;

/** This class is used to access orientations and 
  * provides a degree of seperation between the
  * BasisValues objects and the global indexer (which
  * computes and stores the orientation). The particular
  * thing that this is does is avoids the need for the
  * WorksetContainer/Factory to know anything about
  * the local or global ordinal types.
  */
template <typename Scalar,typename Array,typename LocalOrdinal,typename GlobalOrdinal>
class OrientationContainer : public OrientationContainerBase<Scalar,Array> {
  Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
  std::string fieldName_;

public:
 
  /** Initialize this container with a particular global indexer.
    */
  OrientationContainer(const Teuchos::RCP<const panzer::GlobalIndexer> & globalIndexer,
                       const std::string & fieldName);

  virtual ~OrientationContainer() {}

  /** Get the orientations for a number of cell local ids. This will
    * be dependent on a particular basis.
    *
    * \param[in] cell_local_ids Cells to build orientations for.
    * \param[in] orientations Array of orientations (previously allocated)
    *                         to be filled with the orientations of a
    *                         particular basis.
    */
  virtual void getOrientations(const std::string & blockId,
                               const std::vector<std::size_t> & cell_local_ids,
                               Array & orientations) const;

};

/** Build an orientation container from a global indexer and a field.
  * Underneath this does several dynamic casts to determine the type of GlobalIndexer
  * object that has been passed in.
  */
template <typename Scalar,typename Array>
Teuchos::RCP<const panzer::OrientationContainerBase<Scalar,Array> > 
buildOrientationContainer(const Teuchos::RCP<const panzer::GlobalIndexer> & globalIndexer,
                          const std::string & fieldName);

}

#include "Panzer_OrientationContainer_impl.hpp"

#endif
