//#####################################################################
// Copyright 2002-2006, Ronald Fedkiw, Geoffrey Irving, Andrew Selle.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class BOUNDARY_CUSTOM_FUNCTION
//#####################################################################
#ifndef __BOUNDARY_CUSTOM_FUNCTION__
#define __BOUNDARY_CUSTOM_FUNCTION__

#include <Core/Boundaries/BOUNDARY.h>
#include <functional>
namespace PhysBAM{

template<class TV,class T2>
class BOUNDARY_CUSTOM_FUNCTION:public BOUNDARY<TV,T2>
{
    typedef typename TV::SCALAR T;typedef VECTOR<int,TV::m> IV;
    typedef VECTOR<bool,2> TV_BOOL2;typedef VECTOR<TV_BOOL2,TV::m> TV_SIDES;typedef ARRAYS_ND_BASE<T,IV> T_ARRAYS_BASE;
public:
    typedef BOUNDARY<TV,T2> BASE;
    using BASE::Set_Constant_Extrapolation;using BASE::Constant_Extrapolation;
    using BASE::Find_Ghost_Regions_Cell;using BASE::Boundary;

    std::function<T2(TV)> F;

    BOUNDARY_CUSTOM_FUNCTION(std::function<T2(TV)> F_input) : F(F_input) {}

    ~BOUNDARY_CUSTOM_FUNCTION() = default;

//#####################################################################
    virtual void Fill_Ghost_Cells(const GRID<TV>& grid,const ARRAYS_ND_BASE<T2,IV>& u,ARRAYS_ND_BASE<T2,IV>& u_ghost,const int number_of_ghost_cells=3) const override;
    virtual void Fill_Ghost_Nodes(const GRID<TV>& grid,const ARRAYS_ND_BASE<T2,IV>& u,ARRAYS_ND_BASE<T2,IV>& u_ghost,const int number_of_ghost_cells=3) const override;
    virtual void Fill_Ghost_Faces(const GRID<TV>& grid,const ARRAY<T2,FACE_INDEX<TV::m> >& u,ARRAY<T2,FACE_INDEX<TV::m> >& u_ghost,const int number_of_ghost_cells=3) const override;
    virtual void Fill_Single_Ghost_Region_Node(const GRID<TV>& grid,ARRAYS_ND_BASE<T2,IV>& u_ghost,const RANGE<IV>& region,const int side,const int number_of_ghost_cells=3) const override;
    virtual void Fill_Single_Ghost_Region_Cell(const GRID<TV>& grid,ARRAYS_ND_BASE<T2,IV>& u_ghost,const RANGE<IV>& region,const int side,const int number_of_ghost_cells=3) const override;

//#####################################################################
};
}
#endif
