// GenFem - A high-level finite element library
// Copyright (C) 2010-2026 Eric Bechet
//
// See the LICENSE file for license information and contributions.
// Please report all bugs and problems to <bechet@cadxfem.org>.
//
// Initial design: Frederic Duboeuf (rev.1359)


#ifndef _GEN_SIMPLE_FUNCTION_H_
#define _GEN_SIMPLE_FUNCTION_H_

#include "genTraits.h"

template<class T> class genSimpleFunction
{
public :
  typedef typename TensorialTraits<T>::Scalar Scalar;
  typedef typename TensorialTraits<T>::ScalarType ScalarType;
  typedef typename TensorialTraits<T>::ValType ValType;
  typedef typename TensorialTraits<T>::GradType GradType;
  typedef typename TensorialTraits<T>::HessType HessType;

public :
  virtual ValType operator()(double x, double y, double z) const = 0;
  virtual GradType grad(double x, double y, double z) const = 0;
  virtual HessType hess(double x, double y, double z) const = 0;
};

template<class T> class genSimpleFunctionConstant : public genSimpleFunction<T>
{
public :
  typedef typename TensorialTraits<T>::Scalar Scalar;
  typedef typename TensorialTraits<T>::ScalarType ScalarType;
  typedef typename TensorialTraits<T>::ValType ValType;
  typedef typename TensorialTraits<T>::GradType GradType;
  typedef typename TensorialTraits<T>::HessType HessType;
protected :
  ValType val;

public :
  genSimpleFunctionConstant(ValType val_=ValType()) : val(val_) {}
  virtual ~genSimpleFunctionConstant(){}
  virtual ValType operator()(double x, double y, double z) const { return val; };
  virtual GradType grad(double x, double y, double z) const { return GradType(); };
  virtual HessType hess(double x, double y, double z) const { return HessType(); };
};



#endif // _GEN_SIMPLE_FUNCTION_H_
