#ifndef __CMODEL_HYSDMODEL_H
#define __CMODEL_HYSDMODEL_H

#ifndef __CMODEL_CONTMODEL_H
#include "base\contmodel.h"
#endif



//------------ built-in, user-defined contact model "CM_HysDamp" -----------
const unsigned long ulModelCM_HysDamp = 5;
class CM_HysDamp : public ContactModel {
  private:
    double kn_load;     // normal stiffness at laoding
    double kn_unload;   // normal stiffness at unloading
    double kn_m;        // mean normal stiffness
    double ks;          // shear stiffness
    double fric;        // frictional coefficient
    double hys_nstr;    // normal contact strength
    double hys_sstr;    // shear contact strength
    unsigned char type_gobj2;     //
    double sp_damp;     // ratio k_load/k_unload <= 1.0, 0.8 default resti. coef = 0.9
    double u_old;       // overlap just before
    double u_zero;      // default overlap when reloading within this contact cycle
    double u_zeroo;     // default overlap when unloading within this contact cycle
    double u_max;       // max. overlap of this contact cycle
    double n_force_old; // n_force just before to check transition + -
    bool   bNtension;   // FDlaw option, with or without tensile force, default bFalse (with tensile)
    bool   bInheritProp;// Inherit property in contact class, default bFalse (NOT inherit)

  public:
    // Creators
    CM_HysDamp(bool bRegister=false);
    ~CM_HysDamp(void) { }

    // Accessors
    EXPORT const char *Name(void) const;
    EXPORT const char **PropNames(void) const;
    EXPORT ContactModel *Clone(PropBlock *pb=0) const;
    EXPORT double  ReturnProp(int n) const;
    EXPORT double  KsEstimate(void) const { return ks; }
    EXPORT double  KnEstimate(void) const { return kn_unload; } // high stiffness
    EXPORT unsigned long   Version(void) const { return 4; }

    // Manipulators
    EXPORT void AcceptProp(int n, double v);
    EXPORT const char *PreCycle(PropBlock &pb);
    EXPORT void FDlaw(FdBlock &fb, char cDim);
    void SetProp(PropBlock &pb);
    void SetKn(void);
    void CheckBonding(FdBlock &fb, char cDim);  
    EXPORT const char *SaveRestore(ModelSaveObject *mso);
};



#endif
