//#####################################################################
// Copyright 2003-2007, Ron Fedkiw, Geoffrey Irving, Igor Neverov, Andrew Selle, Eftychios Sifakis, Russell Howes, Joseph Teran.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#include <Deformables/Constitutive_Models/GENERAL_CONSTITUTIVE_MODEL.h>
#include <Core/Diff_Tools/Diff_Test.h>
#include <Core/Log/DEBUG_UTILITIES.h>
#include <Core/Matrices/MATRIX.h>
#include <Core/Random_Numbers/RANDOM_NUMBERS.h>
#include <Deformables/Constitutive_Models/GENERAL_STRESS_DERIVATIVE.h>
using namespace PhysBAM;
//#####################################################################
// Destructor
//#####################################################################
template<class T,int d> GENERAL_CONSTITUTIVE_MODEL<T,d>::
~GENERAL_CONSTITUTIVE_MODEL()
{
}
//#####################################################################
// Function Test
//#####################################################################
template<class T,int d> void GENERAL_CONSTITUTIVE_MODEL<T,d>::
Test(const MATRIX<T,d>& F) const
{
    T eps=1e-6;
    MATRIX<T,d> FF[2]={F},dF;
    RANDOM_NUMBERS<T> rand;
    rand.Set_Seed(123);
    rand.Fill_Uniform(dF,-eps,eps);
    FF[1]=FF[0]+dF;
    for(int i=0;i<2;i++)
    {
        T psi=Energy_Density(FF[i]);
        auto P=Stress(FF[i]);
        GENERAL_STRESS_DERIVATIVE<TV> gsd;
        Stress_Derivative(FF[i],gsd);
        auto dP=gsd.Differential(dF);
        Diff_Test(i,"P",psi,FF[i],P);
        Diff_Times_Test(i,"dP",P,dP,FF[i]);
    }
}
namespace PhysBAM{
template class GENERAL_CONSTITUTIVE_MODEL<float,1>;
template class GENERAL_CONSTITUTIVE_MODEL<float,2>;
template class GENERAL_CONSTITUTIVE_MODEL<float,3>;
template class GENERAL_CONSTITUTIVE_MODEL<double,1>;
template class GENERAL_CONSTITUTIVE_MODEL<double,2>;
template class GENERAL_CONSTITUTIVE_MODEL<double,3>;
}
