Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update and refactor mesh generation #10

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ jobs:
curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0

build_py_project_in_conda_env
install_and_run_flake8 "$(get_proj_name)" examples/*.py test/*.py benchmarks/*.py

pytest:
name: Testing (Linux)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
export CONDA_ENVIRONMENT=.test-conda-env-py3.yml
Expand All @@ -44,16 +40,17 @@ jobs:
. ci-support-v0

build_py_project_in_conda_env
pushd contrib/meshgen11_dealii
bash build.sh
popd

test_py_project

pytest_mac:
name: Testing (macOS)
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
export LC_ALL=en_US.UTF-8
Expand All @@ -66,16 +63,17 @@ jobs:
. ci-support-v0

build_py_project_in_conda_env
pushd contrib/meshgen11_dealii
bash build.sh
popd

test_py_project

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
export CONDA_ENVIRONMENT=.test-conda-env-py3.yml
Expand All @@ -84,23 +82,29 @@ jobs:
. ci-support-v0

build_py_project_in_conda_env
pushd contrib/meshgen11_dealii
bash build.sh
popd

build_docs

examples:
name: Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: "Main Script"
run: |
export CONDA_ENVIRONMENT=.test-conda-env-py3.yml

curl -L -O https://tiker.net/ci-support-v0
. ci-support-v0

build_py_project_in_conda_env
pushd contrib/meshgen11_dealii
bash build.sh
popd

run_examples

# vim: sw=2
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

3 changes: 2 additions & 1 deletion .test-conda-env-py3-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ dependencies:
- pluggy
- pocl
- py
- pybind11
- pyevtk
- pyfmmlib
- pyopencl
- pyrsistent
- pytest
- pytest-cov
- python-symengine
- python>=3.8
- python=3
- pyvkfft
- scipy
- symengine
Expand Down
3 changes: 2 additions & 1 deletion .test-conda-env-py3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ dependencies:
- pluggy
- pocl
- py
- pybind11
- pyevtk
- pyfmmlib
- pyopencl
- pyrsistent
- pytest
- pytest-cov
- python-symengine
- python>=3.8
- python=3
- pyvkfft
- scipy
- symengine
Expand Down
87 changes: 29 additions & 58 deletions contrib/meshgen11_dealii/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -22,65 +22,36 @@
##
## ---------------------------------------------------------------------

CMAKE_MINIMUM_REQUIRED(VERSION 3.5.0)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
PROJECT(meshgen11_dealii)
cmake_minimum_required(VERSION 3.15.0)
project(meshgen11_dealii LANGUAGES CXX)

IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
#SET(CMAKE_BUILD_TYPE "RELEASE")
#SET(CMAKE_BUILD_TYPE "RELWITHDEBINFO")
#SET(CMAKE_BUILD_TYPE "MINSIZEREL")
ENDIF()
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection")

# set(DEAL_II_DIR "/home/xywei/apps" CACHE STRING "Deal.II dir")
# deal.II >= 8.4.1
FIND_PACKAGE(deal.II REQUIRED
HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} $ENV{CONDA_PREFIX}
)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

DEAL_II_INITIALIZE_CACHED_VARIABLES()
# deal.II
find_package(deal.II REQUIRED
HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR} $ENV{CONDA_PREFIX})
deal_ii_initialize_cached_variables()

find_package( PythonInterp 3.8 EXACT )
find_package( PythonLibs 3.8 EXACT )
# Python
find_package(Python REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 REQUIRED CONFIG)

add_subdirectory(pybind11)
pybind11_add_module(meshgen11 meshgen.cpp)
set_target_properties(meshgen11 PROPERTIES PREFIX "")
set_target_properties(meshgen11 PROPERTIES OUTPUT_NAME "meshgen")

if(FALSE)
# This script does not work on current Debian testing
DEAL_II_SETUP_TARGET(meshgen11)
else()
SET(_build "RELEASE")
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
IF("${_cmake_build_type}" MATCHES "debug")
SET(_build "DEBUG")
ENDIF()
SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY
INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}"
)
SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY
INCLUDE_DIRECTORIES "/usr/include/"
)
SET_PROPERTY(TARGET meshgen11 APPEND_STRING PROPERTY
COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
)
SET_PROPERTY(TARGET meshgen11 APPEND_STRING PROPERTY
LINK_FLAGS " ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}} $ENV{DEAL_II_LINKER_FLAGS}"
)
SET_PROPERTY(TARGET meshgen11 APPEND PROPERTY
COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
)
GET_PROPERTY(_type TARGET meshgen11 PROPERTY TYPE)
IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY")
TARGET_LINK_LIBRARIES(meshgen11 PRIVATE ${DEAL_II_TARGET_${_build}})
ENDIF()
endif()

ADD_CUSTOM_COMMAND(TARGET meshgen11 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"meshgen.*.so"
"meshgen.so"
COMMENT "Copied meshgen lib to meshgen.so")
set_target_properties(meshgen11 PROPERTIES
OUTPUT_NAME "meshgen"
LINK_FLAGS ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_RELEASE}
COMPILE_DEFINITIONS ${DEAL_II_USER_DEFINITIONS}
INTERPROCEDURAL_OPTIMIZATION ON
VISIBILITY_INLINES_HIDDEN ON)
target_include_directories(meshgen11 PRIVATE ${DEAL_II_INCLUDE_DIRS})
target_link_libraries(meshgen11 PRIVATE ${DEAL_II_TARGET_RELEASE})

add_custom_command(TARGET meshgen11 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"meshgen.*.so"
"meshgen.so"
COMMENT "Copied meshgen lib to meshgen.so")
4 changes: 1 addition & 3 deletions contrib/meshgen11_dealii/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ To build `meshgen11`, you need:
## Usage

The script `build.sh` also copies the built library to voluemential path so that you can use

```
```python
import voluemential.meshgen
```

directly.
22 changes: 10 additions & 12 deletions contrib/meshgen11_dealii/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
##
## The above copyright notice and this permission notice shall be included in
## all copies or substantial portions of the Software.
##
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -25,22 +25,20 @@

set -e

mkdir -p build
cd build
cmake ..
make
cd ..
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --verbose

echo Module built:
echo ${PWD}/build/meshgen.so
echo 'Module built:'
echo "${PWD}/build/meshgen.so"

outfile=$(realpath ../../volumential/meshgen_dealii.so)
if [ -f build/meshgen.so ]; then
cp build/meshgen.so ../../volumential/meshgen_dealii.so
cp build/meshgen.so "${outfile}"
elif [ -f build/meshgen.dylib ]; then
cp build/meshgen.dylib ../../volumential/meshgen_dealii.so
cp build/meshgen.dylib "${outfile}"
else
echo "Something went wrong. Build failed."
exit 1
fi

echo Library copied to volumential path.
echo "Library copied to '${outfile}'."
3 changes: 2 additions & 1 deletion contrib/meshgen11_dealii/meshgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ constexpr double b = 1;
const d::UpdateFlags update_flags =
d::update_quadrature_points | d::update_JxW_values;

void greet() { std::cout << "Hello from meshgen11_dealii." << std::endl; }
void greet() { std::cout << "Hello from mesh generation via deal.II." << std::endl; }

// {{{ utils

Expand Down Expand Up @@ -605,6 +605,7 @@ py::tuple make_uniform_cubic_grid(int q, int level, int dim,
return make_uniform_cubic_grid_details<3>(q, level);
} else {
std::cout << "Dimension must be 1,2 or 3." << std::endl;
return py::tuple();
}
}

Expand Down
1 change: 0 additions & 1 deletion contrib/meshgen11_dealii/pybind11
Submodule pybind11 deleted from f5f661
1 change: 1 addition & 0 deletions examples/laplace2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import pymbolic as pmbl
import pyopencl as cl
import pyopencl.array

from volumential.tools import ScalarFieldExpressionEvaluation as Eval

Expand Down
1 change: 1 addition & 0 deletions examples/laplace3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import pymbolic as pmbl
import pymbolic.functions
import pyopencl as cl
import pyopencl.array

from volumential.tools import ScalarFieldExpressionEvaluation as Eval

Expand Down
Loading
Loading