Skip to content

Commit

Permalink
Merge pull request #3449 from pybamm-team/i3431-windows-wheels
Browse files Browse the repository at this point in the history
Fix failing windows wheel builds
  • Loading branch information
martinjrobins authored and Saransh-cpp committed Oct 17, 2023
1 parent 211778b commit 320b2e5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(NOT MSVC)
# MSVC does not support variable length arrays (vla)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=vla")
endif()

# casadi seems to compile without the newer versions of std::string
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
Expand Down
2 changes: 1 addition & 1 deletion pybamm/solvers/c_solvers/idaklu/CasadiSolverOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Solution CasadiSolverOpenMP::solve(

// set inputs
auto p_inputs = inputs.unchecked<2>();
for (uint i = 0; i < functions->inputs.size(); i++)
for (int i = 0; i < functions->inputs.size(); i++)
functions->inputs[i] = p_inputs(i, 0);

// set initial conditions
Expand Down
2 changes: 1 addition & 1 deletion pybamm/solvers/c_solvers/idaklu/casadi_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
template<typename T1, typename T2>
void csc_csr(const realtype f[], const T1 c[], const T1 r[], realtype nf[], T2 nc[], T2 nr[], int N, int cols) {
int nn[cols+1];
std::vector<int> nn(cols+1);
std::vector<int> rr(N);
for (int i=0; i<cols+1; i++)
nc[i] = 0;
Expand Down
6 changes: 3 additions & 3 deletions pybamm/solvers/c_solvers/idaklu/casadi_sundials_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int jacobian_casadi(realtype tt, realtype cj, N_Vector yy, N_Vector yp,
jac_colptrs[i] = p_jac_times_cjmass_colptrs[i];
}
} else if (SUNSparseMatrix_SparseType(JJ) == CSR_MAT) {
realtype newjac[SUNSparseMatrix_NNZ(JJ)];
std::vector<realtype> newjac(SUNSparseMatrix_NNZ(JJ));
sunindextype *jac_ptrs = SUNSparseMatrix_IndexPointers(JJ);
sunindextype *jac_vals = SUNSparseMatrix_IndexValues(JJ);

Expand All @@ -229,15 +229,15 @@ int jacobian_casadi(realtype tt, realtype cj, N_Vector yy, N_Vector yp,
p_python_functions->jac_times_cjmass.m_arg[2] =
p_python_functions->inputs.data();
p_python_functions->jac_times_cjmass.m_arg[3] = &cj;
p_python_functions->jac_times_cjmass.m_res[0] = newjac;
p_python_functions->jac_times_cjmass.m_res[0] = newjac.data();
p_python_functions->jac_times_cjmass();

// convert (casadi's) CSC format to CSR
csc_csr<
std::remove_pointer_t<decltype(p_python_functions->jac_times_cjmass_rowvals.data())>,
std::remove_pointer_t<decltype(jac_vals)>
>(
newjac,
newjac.data(),
p_python_functions->jac_times_cjmass_rowvals.data(),
p_python_functions->jac_times_cjmass_colptrs.data(),
jac_data,
Expand Down
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"kind": "git",
"repository": "https://github.com/pybamm-team/sundials-vcpkg-registry.git",
"baseline": "2aaffb6bba7bc0b50cb74ddad636832d673851a1",
"baseline": "af9f5e4bc730bf2361c47f809dcfb733e7951faa",
"packages": ["sundials"]
},
{
Expand Down

0 comments on commit 320b2e5

Please sign in to comment.