// chara2d.h
//
// Characteristic tracking in 2-dim 
//
// Jiangguo (James) Liu
// ColoState, Jan.-Jun. 2007


#ifndef Chara2d_H
#define Chara2d_H

#include "AuxMesh2d.h"
#include "PtVec2d.h"
#include "plygn.h"
#include "RealMesh2d.h"

// Characteristic in 2-dim

class Chara2d {
private:
   int maxNumPts, numPts;
   int indFoot, indHead;  // Index for the foot or head
   int footOnBndry, headOnBndry;
   double tfoot, thead;
   PtVec2d foot, head;
   double Deltat, Jacobian;
   double *tm;  // times on the characteristic
   PtVec2d *pt;  // points on the characteristic
public:
   Chara2d() {maxNumPts=0; numPts=0; tm=0; pt=0;}  // Default constructor
   Chara2d(int maxNumPtsChara);  // Another constructor
   Chara2d(const Chara2d &cha);  // Copy constructor
   ~Chara2d() {delete[] tm,pt; tm=0; pt=0;}
   Chara2d &operator=(const Chara2d&);  // Copy assignment
   void resize(int maxNumPtsChara);
   void setFoot(double t, PtVec2d P) {tfoot=t; foot=P;}
   void setHead(double t, PtVec2d P) {thead=t; head=P;}
   void getFoot(double &t, PtVec2d &P) const {t=tfoot; P=foot;}
   void getHead(double &t, PtVec2d &P) const {t=thead; P=head;}
   int isFootOnBndry() const {return footOnBndry;}
   int isHeadOnBndry() const {return headOnBndry;}
   double getDeltat() const {return Deltat;}
   double getJacobian() const {return Jacobian;}
friend void bkwdTrknEuler(Chara2d &cha, 
   const Plygn &realDom, const Plygn &innerDom, 
   const RealMesh2d &realMesh, const AuxMesh2d &auxMesh, 
   PtVec2d (*vel)(PtVec2d), double told, double tnew, 
   double thead, PtVec2d head);
friend void bkwdTrknRK2(Chara2d &cha, 
   const Plygn &realDom, const Plygn &innerDom, 
   const RealMesh2d &realMesh, const AuxMesh2d &auxMesh, 
   PtVec2d (*vel)(PtVec2d), double told, double tnew, 
   double thead, PtVec2d head);
};

#endif  // Chara2d_H
