/*************************************************************************
 *                                                                       *
 * Vega FEM Simulation Library Version 4.0                               *
 *                                                                       *
 * "isotropic hyperelastic FEM" library , Copyright (C) 2018 USC         *
 * All rights reserved.                                                  *
 *                                                                       *
 * Code authors: Jernej Barbic, Fun Shing Sin                            *
 * http://www.jernejbarbic.com/vega                                      *
 *                                                                       *
 * Research: Jernej Barbic, Hongyi Xu, Yijing Li,                        *
 *           Danyong Zhao, Bohan Wang,                                   *
 *           Fun Shing Sin, Daniel Schroeder,                            *
 *           Doug L. James, Jovan Popovic                                *
 *                                                                       *
 * Funding: National Science Foundation, Link Foundation,                *
 *          Singapore-MIT GAMBIT Game Lab,                               *
 *          Zumberge Research and Innovation Fund at USC,                *
 *          Sloan Foundation, Okawa Foundation,                          *
 *          USC Annenberg Foundation                                     *
 *                                                                       *
 * This library is free software; you can redistribute it and/or         *
 * modify it under the terms of the BSD-style license that is            *
 * included with this library in the file LICENSE.txt                    *
 *                                                                       *
 * This library is distributed in the hope that it will be useful,       *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file     *
 * LICENSE.TXT for more details.                                         *
 *                                                                       *
 *************************************************************************/

#ifndef _HOMOGENEOUSISOTROPICSTVKMATERIAL_H_
#define _HOMOGENEOUSISOTROPICSTVKMATERIAL_H_

#include "isotropicMaterialWithCompressionResistance.h"
#include "tetMesh.h"

namespace vega 
{

/*
   Homogeneous StVK material. Material properties are constant throughout the mesh.
 
   The implemented St.Venant-Kirchhoff material is described in:
   BONET J., WOOD R. D.: Nonlinear Continuum Mechanics
   for Finite Element Analysis, 2nd Ed. Cambridge University
   Press, 2008, page 158
*/

class HomogeneousStVKIsotropicMaterial : public IsotropicMaterialWithCompressionResistance
{
public:
  HomogeneousStVKIsotropicMaterial(double E, double nu, int enableCompressionResistance=0, double compressionResistance=0.0);
  virtual ~HomogeneousStVKIsotropicMaterial();

  void SetYoungModulusAndPoissonRatio(double E, double nu); 
  void SetLameCoefficients(double lambda, double mu); 

  virtual double ComputeEnergy(int elementIndex, double * invariants);
  virtual void ComputeEnergyGradient(int elementIndex, double * invariants, double * gradient); // invariants and gradient are 3-vectors
  virtual void ComputeEnergyHessian(int elementIndex, double * invariants, double * hessian); // invariants is a 3-vector, hessian is a 3x3 symmetric matrix, unrolled into a 6-vector, in the following order: (11, 12, 13, 22, 23, 33).

protected:
  double E, nu;
  double lambdaLame, muLame; // Lam\'e coefficients, not "lame" :)

  double compressionResistance;
  double EdivNuFactor;
  virtual double GetCompressionResistanceFactor(int elementIndex);
};

} // namespace vega

#endif

