/*
    C++ Mesh Generation Library
    Copyright (c) 2000echet <eric at bechet dot ca>

    This file is part of the C++ Mesh Generation Library.

    See the NOTICE & LICENSE files for conditions.
*/
//---------------------------------------------------------------------------
#ifndef CONSTANT_ISOTROPIC_METRIC_H
#define CONSTANT_ISOTROPIC_METRIC_H
//---------------------------------------------------------------------------



#include <cmath>
#include "mesh_const.h"
#include "metric_field.h"

using namespace std;

/// a constant metric yelding a uniform mesh of size sz (see constructor)
template <class V> class Constant_Isotropic_Metric : public Metric_Field<V>
{

///
  double size;

public :
///
  Constant_Isotropic_Metric ( double sz=1. ) :Metric_Field<V> ( 0 )
  {
    size=sz;
  }

///
  void Set_Size ( double sz )
  {
    size=sz;
  }

///
  virtual void operator () ( V& Ver,Metric_Tensor& MM )
  {

    MM.Set_Isotropic_Size ( size );
  }


///
  virtual double Metric_Distance ( V& V1,V& V2 )
  {
    double d=0,vi;

    for ( int i=0; i<V::Dimension; ++i )
    {
      vi=V2[i]-V1[i];
      d+=vi*vi;
    }

    d=sqrt ( d );
    d/=size;
    return d;
  }
};


#endif // CONSTANT_ISOTROPIC_METRIC_H

 
