~mdrews/maus/my-branch

« back to all changes in this revision

Viewing changes to src/legacy/Interface/Mesh.cc

  • Committer: Durga Rajaram
  • Date: 2013-10-17 14:45:06 UTC
  • mfrom: (659.1.76 rc)
  • Revision ID: durga@fnal.gov-20131017144506-orvzitqqdbj08ohy
Tags: MAUS-v0.7.3
MAUS-v0.7.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
{
24
24
  if(xSize < 2 || ySize < 2) throw(Squeal(Squeal::recoverable, "2D Grid must be at least 2x2 grid", "TwoDGrid::TwoDGrid(...)"));
25
25
  SetConstantSpacing();
 
26
  delete [] x;
 
27
  delete [] y; 
26
28
}
27
29
 
28
30
TwoDGrid::TwoDGrid(std::vector<double> x, std::vector<double> y)  : _x (x), _y(y), _xSize(x.size()), _ySize(y.size()), _maps(), _constantSpacing(false)
127
129
void TwoDGrid::SetConstantSpacing()
128
130
{
129
131
    _constantSpacing = true;
130
 
    for(unsigned int i=0; i<_x.size()-1; i++) if( fabs(1-(_x[i+1]-_x[i])/(_x[1]-_x[0])) > 1e-9 ) _constantSpacing = false;
131
 
    for(unsigned int i=0; i<_y.size()-1; i++) if( fabs(1-(_y[i+1]-_y[i])/(_y[1]-_y[0])) > 1e-9 ) _constantSpacing = false;
 
132
    for (unsigned int i = 0; i < _x.size()-1; i++)
 
133
        if (fabs(1-(_x[i+1]-_x[i])/(_x[1]-_x[0])) > 1e-9)
 
134
            _constantSpacing = false;
 
135
    for (unsigned int i = 0; i < _y.size()-1; i++)
 
136
        if (fabs(1-(_y[i+1]-_y[i])/(_y[1]-_y[0])) > 1e-9)
 
137
            _constantSpacing = false;
132
138
}
133
139
 
134
140
Mesh::Iterator TwoDGrid::Nearest(const double* position) const