Skip to content

Commit

Permalink
kind of working version of bindings #14
Browse files Browse the repository at this point in the history
  • Loading branch information
fnrizzi committed Jun 2, 2021
1 parent b7c1da4 commit 1807fd4
Show file tree
Hide file tree
Showing 122 changed files with 1,688 additions and 499 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "pybind11"]
path = pybind11
url = https://github.com/Pressio/pybind11.git
61 changes: 35 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@

cmake_minimum_required(VERSION 3.18.0)
project(pressiodemoapps CXX)
set (CMAKE_CXX_STANDARD 11)

#=====================================================================
# we need c++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# test if compiler supports standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++14" COMPILER_SUPPORT_CPP14)
if(NOT COMPILER_SUPPORT_CPP14)
message(FATAL_ERROR "Compiler does not support -std=c++14. This is required.")
endif()

#=====================================================================
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds are not allowed.
Please make a new directory (called a build directory) and run CMake from there.
You may need to remove CMakeCache.txt.")
Please make a new directory (e.g. build directory) and run CMake from there.")
endif()

#=====================================================================
# check build type
# default to release if build type is empty
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "${CMAKE_BUILD_TYPE} is not specified, defaulting to Release.")
set(CMAKE_BUILD_TYPE "Release")
endif()

Expand All @@ -26,27 +36,26 @@ if( NOT cmake_build_type_tolower STREQUAL "debug"
endif()

#=====================================================================
# c++ standard
#=====================================================================
# commands to test if compiler supports standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORT_CPP11)
if(NOT COMPILER_SUPPORT_CPP11)
message(FATAL_ERROR "Compiler does not support -std=c++11. This is required.")
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(PRESSIODEMOAPPS_ENABLE_BINDINGS)
set(PYSRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/pysrc)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tpls/pybind11)

#=====================================================================
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/tpls/eigen/eigen3
${CMAKE_CURRENT_SOURCE_DIR}/tpls/pressio/include)
set(modulename _pressiodemoappsimpl)
pybind11_add_module(${modulename} ${PYSRC_DIR}/main_binder.cc)
target_compile_definitions(${modulename} PRIVATE MODNAME=${modulename})
target_compile_definitions(${modulename} PRIVATE PRESSIODEMOAPPS_ENABLE_BINDINGS)

#=====================================================================
# tests are enabled if PRESSIODEMOAPPS_ENABLE_TESTS = ON
if(PRESSIODEMOAPPS_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
else()

add_definitions(-DPRESSIODEMOAPPS_ENABLE_TPL_EIGEN=${PRESSIODEMOAPPS_ENABLE_TPL_EIGEN})
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/tpls/eigen/eigen3
${CMAKE_CURRENT_SOURCE_DIR}/tpls/pressio/include)

if(PRESSIODEMOAPPS_ENABLE_TESTS)
enable_testing()
add_subdirectory(testsCpp)
endif()
endif()
45 changes: 45 additions & 0 deletions DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
pressio-demoapps: Python bindings
=================================

This package provides Python bindings for the C++ library pressio-demoapps (website_).

.. _website: https://pressio.github.io/pressio-demoapps


Install
-------

You need a C++11-compliant compiler and then do:

.. code-block:: bash
export CXX=<path-to-your-C++-compiler>
pip install pressio-demoapps
You can double check that everything worked fine by doing:

.. code-block:: python
import pressiodemoapps
print(pressiodemoapps.__version__)
Running Demos/Tutorials
-----------------------

After installing the library, you can run the regression tests:

TBD

Documentation
-------------

TBD

Citations
---------

If you use this package, please acknowledge our work-in-progress:

TBD
15 changes: 9 additions & 6 deletions include/advection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@
#include "mesh.hpp"
#include "weno.hpp"
#include "./impl/advection1d/fluxes.hpp"

#include "Eigen/Core"
#include "Eigen/Sparse"
#include "./impl/advection1d/eigen_linear.hpp"
#include "./impl/advection1d/linear_adv_impl.hpp"

namespace pressiodemoapps{

#ifdef PRESSIODEMOAPPS_ENABLE_TPL_EIGEN
template<class scalar_t, class mesh_t>
using PeriodicLinearAdvection1dEigen =
pressiodemoapps::ad::impl::EigenLinearAdv<scalar_t, mesh_t>;
pressiodemoapps::ad::impl::LinearAdvT<
scalar_t, mesh_t,
Eigen::Matrix<scalar_t,-1,1>,
Eigen::Matrix<scalar_t,-1,1>,
Eigen::Matrix<scalar_t,-1,1>
>;
#endif

}

#endif
9 changes: 6 additions & 3 deletions include/euler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
#include "mesh.hpp"
#include "weno.hpp"
#include "./impl/eulerCommon/energy.hpp"

#include "./impl/eulerCommon/fluxes.hpp"

#include "./impl/euler2d/initial_condition.hpp"

#ifdef PRESSIODEMOAPPS_ENABLE_TPL_EIGEN
#include "Eigen/Core"
#include "Eigen/Sparse"
#include "./impl/euler1d/eigen_app.hpp"

#include "./impl/euler2d/initial_condition.hpp"
#include "./impl/euler2d/eigen_app.hpp"
#endif

namespace pressiodemoapps{

#ifdef PRESSIODEMOAPPS_ENABLE_TPL_EIGEN
template<class scalar_t, class mesh_t>
using PeriodicEuler1dEigen =
pressiodemoapps::ee::impl::EigenApp1d<scalar_t, mesh_t, 0>;
Expand All @@ -39,6 +41,7 @@ using Sedov2dEigen =
template<class scalar_t, class mesh_t>
using Riemann2dEigen =
pressiodemoapps::ee::impl::EigenApp2d<scalar_t, mesh_t, 2>;
#endif

}

Expand Down
Loading

0 comments on commit 1807fd4

Please sign in to comment.