- Re-instate the fully unconditional "snap-to-last" behaviour in
uniquify(). Mention that "snap-to-last" is a no-op when second-to-last point is more than <tolerance> apart from the last point. - Assert that the <tolerance> is a non-negative value. - For benefit of Emacs indenting, adjust license block.
This commit is contained in:
parent
6c6b1aa0c8
commit
d1175bc038
@ -13,25 +13,26 @@
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2009 SINTEF ICT, Applied Mathematics.
|
Copyright 2009 SINTEF ICT, Applied Mathematics.
|
||||||
Copyright 2009 Statoil ASA.
|
Copyright 2009 Statoil ASA.
|
||||||
|
|
||||||
This file is part of The Open Reservoir Simulator Project (OpenRS).
|
This file is part of The Open Reservoir Simulator Project (OpenRS).
|
||||||
|
|
||||||
OpenRS is free software: you can redistribute it and/or modify
|
OpenRS is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
OpenRS is distributed in the hope that it will be useful,
|
OpenRS is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
|
along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -79,11 +80,13 @@ static int createSortedList(double *list, int n, int m,
|
|||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------
|
/*-----------------------------------------------------------------
|
||||||
Remove points that are closer than tolerance in list
|
Remove points less than <tolerance> apart in <list> of increasing
|
||||||
of increasing doubles
|
doubles.
|
||||||
*/
|
*/
|
||||||
static int uniquify(int n, double *list, double tolerance)
|
static int uniquify(int n, double *list, double tolerance)
|
||||||
{
|
{
|
||||||
|
assert (!(tolerance < 0.0));
|
||||||
|
|
||||||
if (n<1) return 0;
|
if (n<1) return 0;
|
||||||
int i;
|
int i;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
@ -96,14 +99,19 @@ static int uniquify(int n, double *list, double tolerance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep last value (one way or the other...) */
|
/*
|
||||||
#if 0
|
Preserve outer z-boundary.
|
||||||
if (val + tolerance < list[n-1]){
|
|
||||||
list[pos-1] = list[n-1];
|
This operation is a no-op in the case
|
||||||
}
|
|
||||||
#else
|
list[pos-2] + tolerance < list[n-1].
|
||||||
list[pos-1] = list[n-1];
|
|
||||||
#endif
|
If, however, the second to last point is less than <tolerance>
|
||||||
|
away from the last point (list[n-1]), we remove this
|
||||||
|
second-to-last point as it cannot be distinguished from "final"
|
||||||
|
point.
|
||||||
|
*/
|
||||||
|
list[pos-1] = list[n-1];
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user