Skip to content

Commit 316956a

Browse files
authored
Merge pull request #63 from pletzer/floor_error
fixing floor compiler error on linux and mac os x
2 parents 6118874 + 31aaf91 commit 316956a

File tree

7 files changed

+159
-112
lines changed

7 files changed

+159
-112
lines changed

.cirrus.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Global defaults.
1111
#
1212
container:
13-
image: python:3.9
13+
image: python:3.10
1414

1515
env:
1616
# Maximum cache period (in weeks) before forcing a new cache upload.
@@ -74,7 +74,7 @@ linux_task:
7474
- pytest
7575
- mkdir build-cmake
7676
- cd build-cmake
77-
- cmake -DBUILD_FORTRAN=ON -DVTK_INCLUDE_DIR=${ENV_DIR}/include/vtk-9.0 -DVTK_LIBRARY_DIR=${ENV_DIR}/lib ..
77+
- cmake -DBUILD_FORTRAN=ON -DVTK_INCLUDE_DIR=${ENV_DIR}/include/vtk-9.1 -DVTK_LIBRARY_DIR=${ENV_DIR}/lib ..
7878
- make
7979
- ctest
8080

@@ -127,7 +127,7 @@ osx_task:
127127
- pytest
128128
- mkdir build-cmake
129129
- cd build-cmake
130-
- cmake -DBUILD_FORTRAN=OFF -DVTK_INCLUDE_DIR=${ENV_DIR}/include/vtk-9.0 -DVTK_LIBRARY_DIR=${ENV_DIR}/lib ..
130+
- cmake -DBUILD_FORTRAN=OFF -DVTK_INCLUDE_DIR=${ENV_DIR}/include/vtk-9.1 -DVTK_LIBRARY_DIR=${ENV_DIR}/lib ..
131131
- make
132132
- ctest
133133

@@ -158,7 +158,7 @@ win_task:
158158
- conda install -c conda-forge setuptools
159159
- conda install --yes python=%PY_VER%
160160
- conda install --yes pytest tbb cython numpy netcdf4
161-
- conda install --yes -c conda-forge vtk=9.0.3 libnetcdf=4.8.1
161+
- conda install --yes -c conda-forge vtk=9.1.0 libnetcdf=4.8.1
162162
install_script:
163163
- conda list
164164
- pip install --no-deps --editable .
@@ -174,8 +174,8 @@ win_task:
174174
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
175175
# - where cl
176176
# - dir "%CONDA_LIB%\lib
177-
# - dir "%CONDA_LIB%\include\vtk-9.0"
178-
- cmake -G "NMake Makefiles" -DVTK_INCLUDE_DIR="%CONDA_LIB%\include\vtk-9.0" -DVTK_LIBRARY_DIR="%CONDA_LIB%\lib" -DNETCDF_INCLUDE_DIRS="%CONDA_LIB%\include" -DNETCDF_LIBRARIES="%CONDA_LIB%\lib\netcdf.lib" ..
177+
# - dir "%CONDA_LIB%\include\vtk-9.1"
178+
- cmake -G "NMake Makefiles" -DVTK_INCLUDE_DIR="%CONDA_LIB%\include\vtk-9.1" -DVTK_LIBRARY_DIR="%CONDA_LIB%\lib" -DNETCDF_INCLUDE_DIRS="%CONDA_LIB%\include" -DNETCDF_LIBRARIES="%CONDA_LIB%\lib\netcdf.lib" ..
179179
- nmake
180180
- ctest
181181
- cd ../

py310.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: mint-dev
2+
3+
channels:
4+
- conda-forge
5+
6+
dependencies:
7+
- python=3.10
8+
9+
# Setup dependencies.
10+
- cmake
11+
- cython
12+
- setuptools
13+
- tbb-devel
14+
- numpy
15+
- pip
16+
17+
# Core dependencies.
18+
- libnetcdf=4.8.1
19+
- vtk=9.1.0
20+
21+
# Test dependencies.
22+
- pytest
23+
- netcdf4

requirements/py310.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: mint-dev
2+
3+
channels:
4+
- conda-forge
5+
6+
dependencies:
7+
- python=3.10
8+
9+
# Setup dependencies.
10+
- cmake
11+
- cython
12+
- setuptools
13+
- tbb-devel
14+
- numpy
15+
- pip
16+
17+
# Core dependencies.
18+
- libnetcdf=4.8.1
19+
- vtk=9.1.0
20+
21+
# Test dependencies.
22+
- pytest
23+
- netcdf4=1.5.8

requirements/py38.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ dependencies:
1616
# Core dependencies.
1717
- libnetcdf
1818
- numpy
19-
- vtk=9.0.3
19+
- vtk=9.1.0
2020

2121
# Test dependencies.
2222
- pytest
23-
- netcdf4
23+
- netcdf4=1.5.8

requirements/py39.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ dependencies:
1616

1717
# Core dependencies.
1818
- libnetcdf=4.8.1
19-
- vtk=9.0.3
19+
- vtk=9.1.0
2020

2121
# Test dependencies.
2222
- pytest
23-
- netcdf4
23+
- netcdf4=1.5.8

src/mntRegridAxis.cpp

Lines changed: 102 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,102 @@
1-
#include <mntRegridAxis.h>
2-
3-
LIBRARY_API
4-
int mnt_regridaxis_new(RegridAxis_t** self) {
5-
6-
*self = new RegridAxis_t();
7-
8-
(*self)->spline = vtkCardinalSpline::New();
9-
10-
// let the the spline estimate the second derivative at the boundaries
11-
(*self)->spline->SetLeftConstraint(3);
12-
(*self)->spline->SetRightConstraint(3);
13-
14-
return 0;
15-
}
16-
17-
LIBRARY_API
18-
int mnt_regridaxis_del(RegridAxis_t** self) {
19-
20-
// destroy the spline object
21-
(*self)->spline->Delete();
22-
23-
delete *self;
24-
25-
return 0;
26-
}
27-
28-
29-
LIBRARY_API
30-
int mnt_regridaxis_build(RegridAxis_t** self, int numValues, const double srcValues[]) {
31-
32-
(*self)->spline->RemoveAllPoints();
33-
34-
if (numValues < 2) {
35-
// need at least two values (one interval)
36-
return 1;
37-
}
38-
39-
(*self)->numValues = numValues;
40-
(*self)->tLo = 0;
41-
(*self)->tHi = numValues - 1;
42-
43-
// axis is monotonically increasing
44-
(*self)->increasing = true;
45-
if (srcValues[numValues - 1] < srcValues[0]) {
46-
// axis is monotonically decreasing
47-
(*self)->increasing = false;
48-
}
49-
50-
// construct the spline object. Note that the spline object maps the
51-
// axis values to indices. This will allow us to quickly find the
52-
// float index of a target axis value.
53-
int ier = 0;
54-
for (int i = 0; i < numValues - 1; ++i) {
55-
56-
(*self)->spline->AddPoint(srcValues[i], double(i));
57-
58-
if ((*self)->increasing && srcValues[i + 1] < srcValues[i]) {
59-
ier++;
60-
}
61-
else if (!(*self)->increasing && srcValues[i + 1] > srcValues[i]) {
62-
ier++;
63-
}
64-
}
65-
// add last value
66-
(*self)->spline->AddPoint(srcValues[numValues - 1], double(numValues - 1));
67-
68-
// compute the spline coefficients
69-
(*self)->spline->Compute();
70-
71-
return ier;
72-
}
73-
74-
LIBRARY_API
75-
int mnt_regridaxis_getPointWeights(RegridAxis_t** self, double target, int indices[2], double weights[2]) {
76-
77-
double t = (*self)->spline->Evaluate(target);
78-
79-
// low side of the interval
80-
indices[0] = std::max(0, std::min((*self)->numValues - 2, int(floor(t))));
81-
82-
// high side of the interval
83-
indices[1] = indices[0] + 1;
84-
85-
// linear interpolation weights
86-
weights[0] = indices[1] - t;
87-
weights[1] = t - indices[0];
88-
89-
return 0;
90-
}
91-
92-
93-
LIBRARY_API
94-
int mnt_regridaxis_getCellIndexBounds(RegridAxis_t** self, const double targets[2], double indexBounds[2]) {
95-
96-
indexBounds[0] = (*self)->spline->Evaluate(targets[0]);
97-
indexBounds[1] = (*self)->spline->Evaluate(targets[1]);
98-
99-
return 0;
100-
}
101-
1+
#include <mntRegridAxis.h>
2+
#include <cmath>
3+
4+
LIBRARY_API
5+
int mnt_regridaxis_new(RegridAxis_t** self) {
6+
7+
*self = new RegridAxis_t();
8+
9+
(*self)->spline = vtkCardinalSpline::New();
10+
11+
// let the the spline estimate the second derivative at the boundaries
12+
(*self)->spline->SetLeftConstraint(3);
13+
(*self)->spline->SetRightConstraint(3);
14+
15+
return 0;
16+
}
17+
18+
LIBRARY_API
19+
int mnt_regridaxis_del(RegridAxis_t** self) {
20+
21+
// destroy the spline object
22+
(*self)->spline->Delete();
23+
24+
delete *self;
25+
26+
return 0;
27+
}
28+
29+
30+
LIBRARY_API
31+
int mnt_regridaxis_build(RegridAxis_t** self, int numValues, const double srcValues[]) {
32+
33+
(*self)->spline->RemoveAllPoints();
34+
35+
if (numValues < 2) {
36+
// need at least two values (one interval)
37+
return 1;
38+
}
39+
40+
(*self)->numValues = numValues;
41+
(*self)->tLo = 0;
42+
(*self)->tHi = numValues - 1;
43+
44+
// axis is monotonically increasing
45+
(*self)->increasing = true;
46+
if (srcValues[numValues - 1] < srcValues[0]) {
47+
// axis is monotonically decreasing
48+
(*self)->increasing = false;
49+
}
50+
51+
// construct the spline object. Note that the spline object maps the
52+
// axis values to indices. This will allow us to quickly find the
53+
// float index of a target axis value.
54+
int ier = 0;
55+
for (int i = 0; i < numValues - 1; ++i) {
56+
57+
(*self)->spline->AddPoint(srcValues[i], double(i));
58+
59+
if ((*self)->increasing && srcValues[i + 1] < srcValues[i]) {
60+
ier++;
61+
}
62+
else if (!(*self)->increasing && srcValues[i + 1] > srcValues[i]) {
63+
ier++;
64+
}
65+
}
66+
// add last value
67+
(*self)->spline->AddPoint(srcValues[numValues - 1], double(numValues - 1));
68+
69+
// compute the spline coefficients
70+
(*self)->spline->Compute();
71+
72+
return ier;
73+
}
74+
75+
LIBRARY_API
76+
int mnt_regridaxis_getPointWeights(RegridAxis_t** self, double target, int indices[2], double weights[2]) {
77+
78+
double t = (*self)->spline->Evaluate(target);
79+
80+
// low side of the interval
81+
indices[0] = std::max(0, std::min((*self)->numValues - 2, int(floor(t))));
82+
83+
// high side of the interval
84+
indices[1] = indices[0] + 1;
85+
86+
// linear interpolation weights
87+
weights[0] = indices[1] - t;
88+
weights[1] = t - indices[0];
89+
90+
return 0;
91+
}
92+
93+
94+
LIBRARY_API
95+
int mnt_regridaxis_getCellIndexBounds(RegridAxis_t** self, const double targets[2], double indexBounds[2]) {
96+
97+
indexBounds[0] = (*self)->spline->Evaluate(targets[0]);
98+
indexBounds[1] = (*self)->spline->Evaluate(targets[1]);
99+
100+
return 0;
101+
}
102+

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.19.1
1+
1.19.2

0 commit comments

Comments
 (0)