// AuxMesh2d.h
//
// Jiangguo (James) Liu
// ColoState, Jan.-Jun. 2007


#ifndef AuxMesh2d_H
#define AuxMesh2d_H

#include "index2.h"
#include "PtVec2d.h"
#include "RealMesh2d.h"

// Auxiliary mesh for 2-dim problems 
// including the info about its connection with the given real mesh, 
// i.e., the look-up table of rectangular boxes vs. elements

class AuxMesh2d {
private:
   double DomA, DomB, DomC, DomD;  // x,y-coordinates for domain corners
   int nx, ny, nr;  // Numbers of x-, y-segments, rectangular boxes
   double Deltax, Deltay;  // if a uniform auxiliary mesh
   double *x, *y;  // x,y-coordinates of nodes
   int *ner, **re;  // Number of elements per box, rect box vs elements
public:
   AuxMesh2d() {x=0; y=0; ner=0; re=0;}  // Default constructor
   AuxMesh2d(const RealMesh2d&);  // Constructor based on a real mesh
   ~AuxMesh2d();  // Destructor body somewhere else
   float avgNumEltsPerRect() const;
   int numEltsWithRect(Index2) const;
   int rectVsElt(Index2, int) const;
   void saveRectVsEltsData() const;  // Default filename "RectVsElts.dat"
   Index2 locInAuxMesh(PtVec2d) const;
};

int locInRealMesh(PtVec2d, const RealMesh2d&, const AuxMesh2d&);

#endif  // AuxMesh2d_H
