//#####################################################################
// Copyright 2021, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#ifndef __LINEAR_INTERPOLATION__
#define __LINEAR_INTERPOLATION__

#include <Core/Interpolation/GENERAL_INTERPOLATION_CELL.h>
#include <Core/Interpolation/GENERAL_INTERPOLATION_FACE.h>
#include <Core/Interpolation/GENERAL_INTERPOLATION_NODE.h>
#include <Core/Interpolation/INTERPOLATION_UNIFORM_FORWARD.h>
namespace PhysBAM{

// interpolating polynomial
struct LINEAR_INTERPOLATION_STENCIL
{
    constexpr static int stencil_size=2;
    template<int a,int d,class T> static VECTOR<VECTOR<T,2>,1> Value(T t){return {{1-t,t}};}
    template<int a,int d,class T> static VECTOR<VECTOR<T,2>,1> Diff(T t){return {{-1,1}};}
    template<int a,int d,class T> static VECTOR<VECTOR<T,2>,1> Hess(T t){return {};}
};

template<class TV,class T2>
using LINEAR_INTERPOLATION_NODE=GENERAL_INTERPOLATION_NODE<TV,T2,LINEAR_INTERPOLATION_STENCIL>;

template<class TV,class T2>
using LINEAR_INTERPOLATION_CELL=GENERAL_INTERPOLATION_CELL<TV,T2,LINEAR_INTERPOLATION_STENCIL>;

template<class TV,class T2,class T_FACE_ARRAY=ARRAY<T2,FACE_INDEX<TV::m> > >
using LINEAR_INTERPOLATION_FACE=GENERAL_INTERPOLATION_FACE<TV,T2,LINEAR_INTERPOLATION_STENCIL,false,T_FACE_ARRAY>;

template<class TV,class T2>
using LINEAR_INTERPOLATION_NODE_CONST_EXTRAP=GENERAL_INTERPOLATION_NODE<TV,T2,LINEAR_INTERPOLATION_STENCIL,true>;

template<class TV,class T2,class T_FACE_ARRAY>
struct LINEAR_INTERPOLATION_ALL:LINEAR_INTERPOLATION_NODE<TV,T2>,LINEAR_INTERPOLATION_CELL<TV,T2>,LINEAR_INTERPOLATION_FACE<TV,T2,T_FACE_ARRAY>
{
};
}
#endif
