Skip to content
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
42 changes: 42 additions & 0 deletions .github/workflows/regression.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Regression Tests

on:
schedule:
- cron: "0 0 * * *"
push:
branches: [main]
workflow_dispatch:
pull_request:
branches:
- main

jobs:
run-tests:
runs-on: [self-hosted]
strategy:
fail-fast: false
steps:
- name: checkout testapp
uses: actions/checkout@v4
- name: checkout opensn
uses: actions/checkout@v4
with:
repository: Open-Sn/opensn
path: opensn
- name: install opensn
shell: bash
run: |
module load opensn/clang/17 python3/3.12.3
cd opensn && mkdir build && mkdir install && cd build
cmake -DOPENSN_WITH_PYTHON=True -DCMAKE_INSTALL_PREFIX=../install .. && make -j && make install
- name: compile app
shell: bash
run: |
module load opensn/clang/17 python3/3.12.3
cd OpenSnApp && mkdir build && cd build
cmake -DCMAKE_PREFIX_PATH=../../opensn/install .. && make -j
- name: test examples
shell: bash
run: |
module load opensn/clang/17 python3/3.12.3
cd tests && ../build/test_app_exec -i test.py
89 changes: 89 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.git
cmake-build-debug/
cmake-build-debug
.idea
bin
build*/
doc/documentation
doc/HTMLdocs
doc/whitepages

# root Makefile is generated by CMake automatically
Makefile

resources/Dependencies/lua-5.3.5/
resources/Dependencies/ncurses/
resources/Dependencies/readline/
resources/Dependencies/triangle/
resources/Dependencies/glew-2.1.0/

# Latex compile files
*.aux
*.lof
*.log
*.lot
*.synctex.gz
*.toc
*.pdf

# All vtk mesh files
/*.vtu
/*.pvtu
test/**/*.pvtu
test/**/*.vtu
test/modules/linear_boltzmann_solvers/dsa/SimTest_92b_DSA_PWLC.pvtu
test/modules/linear_boltzmann_solvers/dsa/SimTest_92b_DSA_PWLC_0.vtu
test/**/*.csv

tests/BigTests/*/solutions/

# All exodus files
/*.e

resources/Dependencies/.DS_Store

resources/.DS_Store

# python files
.DS_Store
._.DS_Store
*.pyc
*.pmesh
__pycache__
**/__pycache__

*-private.sh

#Documentation
doc/generated_files

#visual studio code files
.vscode/

test/**/out/
tutorials/**/out/

#Scratch directory
scratch/

#general data files
*.data
tests/BigTests/c5g7/Test1/solutions/
**/*.cmesh

# Python generated libraries
pyopensn/libopensn*.so*
pyopensn/libopensn*.dylib
pyopensn/__init__.cpython*
pyopensn.egg-info

# Files generated by ply package
doc/scripts/parser.out
doc/scripts/parsetab.py

doc/**/*.pvtu
doc/**/*.vtu

tutorials/**/*.pvtu
tutorials/**/*.vtu
tutorials/**/*.py
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.14)
project(MyOpenSnApp LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)

find_package(MPI REQUIRED)
find_package(VTK REQUIRED COMPONENTS
CommonCore
CommonDataModel
IOLegacy
IOCore
IOXML
ParallelCore
IOParallelXML
FiltersCore
IOEnSight
IOExodus
)
find_package(OpenSn REQUIRED)

# Optional: find pybind11
find_package(pybind11 REQUIRED)

find_package(caliper REQUIRED)

find_package(Python REQUIRED COMPONENTS Interpreter Development)

# Python module
add_library(testapp MODULE
src/test.cc
src/testapp_py.cc
)

execute_process(
COMMAND python3 -m pybind11 --includes
OUTPUT_VARIABLE PYBIND11_INCLUDE_FLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "-I" "" PYBIND11_INCLUDE_DIRS "${PYBIND11_INCLUDE_FLAGS}")
separate_arguments(PYBIND11_INCLUDE_DIRS)

target_include_directories(testapp PRIVATE ${OPENSN_INCLUDE_DIR} ${PYBIND11_INCLUDE_DIRS})
target_link_libraries(testapp PRIVATE opensn::libopensn MPI::MPI_C caliper pybind11::module Python::Python)

set_target_properties(testapp PROPERTIES
PREFIX "" # remove "lib" prefix
OUTPUT_NAME "testapp" # Python import name
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/python
)

# Optional executable
add_executable(test_app_exec src/main.cc src/test.cc)
target_include_directories(test_app_exec PRIVATE ${OPENSN_INCLUDE_DIR} ${PYBIND11_INCLUDE_DIRS})
target_link_libraries(test_app_exec PRIVATE opensn::libopensn MPI::MPI_C caliper pybind11::module Python::Python)
11 changes: 11 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "test.h"
#include "opensn/python/lib/py_app.h"
#include "opensn/mpicpp-lite/mpicpp-lite.h"

int main(int argc, char** argv)
{
mpi::Environment env(argc, argv);
py::scoped_interpreter guard{};
auto app = TestApp::Create({});
return 0;
}
28 changes: 28 additions & 0 deletions src/test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "test.h"
#include "opensn/framework/logging/log.h"
#include "opensn/framework/object_factory.h"

using namespace opensn;

OpenSnRegisterObject(TestApp);

InputParameters
TestApp::GetInputParameters()
{
InputParameters params;
params.SetGeneralDescription("A dummy application for testing.");
params.AddOptionalParameter("name", "test_app", "A name for the application.");
return params;
}

TestApp::TestApp(const InputParameters& params) : name_(params.GetParamValue<std::string>("name"))
{
opensn::log.Log() << "TestApp named " << name_ << " created.";
}

std::shared_ptr<TestApp>
TestApp::Create(const ParameterBlock& params)
{
auto& factory = opensn::ObjectFactory::GetInstance();
return factory.Create<TestApp>("TestApp", params);
}
15 changes: 15 additions & 0 deletions src/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once
#include "opensn/framework/object.h"

class TestApp : public opensn::Object
{
public:
explicit TestApp(const opensn::InputParameters& params);

private:
const std::string name_;

public:
static opensn::InputParameters GetInputParameters();
static std::shared_ptr<TestApp> Create(const opensn::ParameterBlock& params);
};
12 changes: 12 additions & 0 deletions src/testapp_py.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <pybind11/pybind11.h>
#include "test.h"

namespace py = pybind11;

PYBIND11_MODULE(myapp, m)
{
m.doc() = "Python bindings for my OpenSn-based TestApp";

py::class_<TestApp, std::shared_ptr<TestApp>>(m, "TestApp")
.def_static("Create", &TestApp::Create);
}
8 changes: 8 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# test.py
import sys
sys.path.insert(0, "build/python") # where CMake drops the .so

import myapp

app = myapp.TestApp.Create()
print("Successfully created:", app)