//#####################################################################
// Copyright 2015, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#ifndef __PARTICLE_GRID_WEIGHTS__
#define __PARTICLE_GRID_WEIGHTS__
#include <Core/Vectors/VECTOR.h>
namespace PhysBAM{

template<class T,int d> class SYMMETRIC_MATRIX;

template<class TV>
class PARTICLE_GRID_WEIGHTS
{
    typedef typename TV::SCALAR T;
    typedef VECTOR<int,TV::m> IV;
public:
    struct SCRATCH
    {
        ARRAY<IV> index;
        ARRAY<T> weight;
        VECTOR<ARRAY<TV>,2> gradient;
        TV m3,m4;
    };

    T Dp;
    T Dp_inv;
    int order;

    // Uses this many grid nodes in each direction
    int stencil_width;

    PARTICLE_GRID_WEIGHTS(int threads);
    virtual ~PARTICLE_GRID_WEIGHTS();

    virtual void Compute(int p,SCRATCH& scratch,bool want_gradient,bool want_pseudo_gradient) const=0;
    virtual void Compute(const TV& X,SCRATCH& scratch,bool want_gradient,bool want_pseudo_gradient) const=0;
    virtual void Update(ARRAY_VIEW<const TV> X)=0;
    virtual void Particle_Ranges(ARRAY<RANGE<IV> >& ranges) const=0;
//#####################################################################
};
}
#endif
