// -*- C++ -*-
// $RCSfile: orthoexmaterial.C,v $
// $Revision: 1.5 $
// $Author: langer $
// $Date: 2000/10/30 19:23:28 $

/* This software was produced by NIST, an agency of the U.S. government,
 * and by statute is not subject to copyright in the United States.
 * Recipients of this software assume all responsibilities associated
 * with its operation, modification and maintenance. However, to
 * facilitate maintenance we ask that before distributing modifed
 * versions of this software, you first contact the authors at
 * oof_manager@ctcms.nist.gov. 
 */

#include "materialcmd.h"
#include "orthoexmaterial.h"
#include "readbinary.h"

CharString OrthoExMaterial::type("eds_el");
MaterialTypeRegistration
    OrthoExMaterial::reg("eds_el", new MaterialCmd<OrthoExMaterial>, 7.0);

float OrthoExMaterial::young_dflt(1.0);
float OrthoExMaterial::poisson_dflt(0.33);
float OrthoExMaterial::a1_dflt(0.0);
float OrthoExMaterial::a2_dflt(0.0);
float OrthoExMaterial::a3_dflt(0.0);
#ifdef THERMAL
float OrthoExMaterial::k1_dflt(0.0);
float OrthoExMaterial::k2_dflt(0.0);
float OrthoExMaterial::k3_dflt(0.0);
#endif // THERMAL
EulerAngle OrthoExMaterial::orientation_dflt;

void OrthoExMaterial::output(FILE* fp_goof,  unsigned char &flag,
			 int n1, int n2, int n3) const
{
    MaterialT::output(fp_goof, flag, n1, n2, n3);
    writebinary(fp_goof, float(orientation.alpha()));
    writebinary(fp_goof, float(orientation.beta()));
    writebinary(fp_goof, float(orientation.gamma()));
    writebinary(fp_goof, flag);
    writebinary(fp_goof, poisson);
    writebinary(fp_goof, young);
    writebinary(fp_goof, a1);
    writebinary(fp_goof, a2);
    writebinary(fp_goof, a3);
#ifdef THERMAL
    writebinary(fp_goof, k1);
    writebinary(fp_goof, k2);
    writebinary(fp_goof, k3);
#endif // THERMAL
}

void OrthoExMaterial::output(FILE* fp_goof,  unsigned char &flag,
			 int n1, int n2, int n3,
			   int same_element) const
{
    MaterialT::output(fp_goof, flag, n1, n2, n3, same_element);
    writebinary(fp_goof, float(orientation.alpha()));
    writebinary(fp_goof, float(orientation.beta()));
    writebinary(fp_goof, float(orientation.gamma()));
    writebinary(fp_goof, flag);
    writebinary(fp_goof, same_element);
    writebinary(fp_goof, poisson);
    writebinary(fp_goof, young);
    writebinary(fp_goof, a1);
    writebinary(fp_goof, a2);
    writebinary(fp_goof, a3);
#ifdef THERMAL
    writebinary(fp_goof, k1);
    writebinary(fp_goof, k2);
    writebinary(fp_goof, k3);
#endif // THERMAL
}

int OrthoExMaterial::compare(const Material *other) const {
  if(!MaterialT::compare(other)) return 0;
  OrthoExMaterial *m2 = (OrthoExMaterial*) other;
  if(poisson != m2->poisson) return 0;
  if(young != m2->young) return 0;
  if(a1 != m2->a1) return 0;
  if(a2 != m2->a2) return 0;
  if(a3 != m2->a3) return 0;
#ifdef THERMAL
  if(k1 != m2->k1) return 0;
  if(k2 != m2->k2) return 0;
  if(k3 != m2->k3) return 0;
#endif // THERMAL
  if(!(orientation == m2->orientation)) return 0;
  return 1;
}
