Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
651ec44
Bump version
valeriabarra Jul 20, 2026
8445521
Update RELEASING notes for MOLE.jl releases
valeriabarra Jul 21, 2026
d6266b2
grid basic struct
jbrzensk Jul 29, 2026
4f5c60f
Bump pillow from 12.1.1 to 12.3.0 in /doc/sphinx
dependabot[bot] Jul 23, 2026
f4cd3dc
Correct Pillow version in requirements.txt
cpaolini Jul 23, 2026
8e71163
makegrid added
jbrzensk Jul 30, 2026
cf3a0a2
ensure subdirs exist
jbrzensk Jul 30, 2026
209807d
validate grid added
jbrzensk Jul 30, 2026
ebd1a2e
Enhance CMake step with debug output
cpaolini Jul 31, 2026
6db0017
MOLE grids, errors and utilities
Tony-Drummond Aug 12, 2026
35735d8
grid basic struct
jbrzensk Jul 29, 2026
598e572
makegrid added
jbrzensk Jul 30, 2026
f153daf
ensure subdirs exist
jbrzensk Jul 30, 2026
192f537
validate grid added
jbrzensk Jul 30, 2026
ba272c1
Enhance CMake step with debug output
cpaolini Jul 31, 2026
7bec474
Merge branch 'dev/MOLE_2.0' into cpp_dev/mole2_0_grid_implementation
Tony-Drummond Aug 12, 2026
e23653c
Including DEBUGING MODE
Tony-Drummond Aug 14, 2026
bb81610
Adding testing and build utilities
Tony-Drummond Aug 14, 2026
b0bbd0c
MOLE grids, errors and utilities
Tony-Drummond Aug 12, 2026
88b3304
Merge remote-tracking branch 'origin/dev/MOLE_2.0' into cpp_dev/mole2…
Tony-Drummond Aug 17, 2026
0f8342f
Update README.md
Tony-Drummond Aug 17, 2026
8f6158a
feat: add gridBuilder, a name-value grid construction API
Jiya-Rathi Aug 18, 2026
dff0e9c
test: add regression tests for gridBuilder
Jiya-Rathi Aug 18, 2026
b9114e0
docs: add gridBuilder examples
Jiya-Rathi Aug 18, 2026
d0ed23b
Bump pillow from 12.1.1 to 12.3.0 in /doc/sphinx
dependabot[bot] Jul 23, 2026
d1c862e
Correct Pillow version in requirements.txt
cpaolini Jul 23, 2026
b74d7b8
Bump pillow from 12.1.1 to 12.3.0 in /doc/sphinx
dependabot[bot] Jul 23, 2026
6804c3c
Correct Pillow version in requirements.txt
cpaolini Jul 23, 2026
b42f606
Correct Pillow version in requirements.txt
cpaolini Jul 23, 2026
6416cb4
updated README.md files + more examples
Tony-Drummond Aug 19, 2026
062dc16
Update MOLE_errors.h
Tony-Drummond Aug 19, 2026
d1f5d9a
updating .gitignore
Tony-Drummond Aug 20, 2026
90d352e
updating .gitignore
Tony-Drummond Aug 20, 2026
710f5bb
Update MOLE_errors.h
Tony-Drummond Aug 20, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/src/mole_C++/*.a
/src/cpp/*.o
/src/cpp/*.a
/cpp/build

# CMake generated files
CMakeCache.txt
Expand Down
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
project(TopLevelProject VERSION 1.0 LANGUAGES CXX)


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Display the detected C++ compiler ID
Expand Down Expand Up @@ -147,10 +147,9 @@ set(LINK_LIBS ${ARMADILLO_LIBRARIES}
${LAPACK_LIBRARY})

# Add subdirectories
add_subdirectory(src/cpp)
add_subdirectory(tests/cpp)
add_subdirectory(tests/matlab_octave)
add_subdirectory(examples/cpp)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(examples)

# Custom target to build everything
add_custom_target(all_build DEPENDS mole_C++ tests_C++ examples_C++ tests_matlab_octave)
Expand Down
170 changes: 170 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
cmake_minimum_required(VERSION 3.10)
project(MOLE
VERSION 2.0.0
DESCRIPTION "Mimetic Operators Library Enhanced (MOLE) - C++ implementation"
LANGUAGES CXX
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

# Display the detected C++ compiler ID
message(STATUS "Detected CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")

# Compiler-specific CXX_FLAGS and linker flags
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CMAKE_CXX_FLAGS "-O3 -Xclang -fopenmp -DARMA_DONT_USE_WRAPPER -DARMA_USE_SUPERLU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp")
message(STATUS "Using AppleClang-specific flags.")
include_directories("/usr/local/opt/libomp/include" "/opt/homebrew/opt/libomp/include")
message(STATUS "Adding Eigen3 include directory for AppleClang.")
set(EIGEN3_INCLUDE_DIR "/opt/homebrew/include/eigen3")
include_directories(${EIGEN3_INCLUDE_DIR})

elseif (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CMAKE_CXX_FLAGS "-O3 -qopenmp -DARMA_DONT_USE_WRAPPER -DARMA_USE_SUPERLU -diag-disable=10430")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "Using non-Clang compiler flags.")
# Get MKLROOT from environment or fallback to default
if(DEFINED ENV{MKLROOT})
set(MKLROOT $ENV{MKLROOT})
else()
set(MKLROOT "/opt/intel/oneapi/mkl/latest")
endif()
# Automatically set Armadillo to link against MKL
set(BLAS_LIBRARIES "${MKLROOT}/lib/intel64/libmkl_rt.so" CACHE STRING "BLAS library path for MKL")
set(LAPACK_LIBRARIES "${MKLROOT}/lib/intel64/libmkl_rt.so" CACHE STRING "LAPACK library path for MKL")
set(ARMA_USE_WRAPPER OFF CACHE BOOL "Disable Armadillo wrapper to directly use MKL")

message(STATUS "Using MKL from: ${MKLROOT}")

else()
set(CMAKE_CXX_FLAGS "-O3 -fopenmp -DARMA_DONT_USE_WRAPPER -DARMA_USE_SUPERLU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "Using non-Clang compiler flags.")
endif()

if(UNIX AND NOT APPLE AND NOT MSVC)
message(STATUS "Checking for Fortran compiler (gfortran)...")
enable_language(Fortran OPTIONAL)
if(NOT CMAKE_Fortran_COMPILER)
message(FATAL_ERROR "gfortran is required but was not found. Please install it using 'sudo apt install gfortran'.")
endif()
endif()


find_package(Eigen3 3.3.7 REQUIRED)
find_library(OpenBLAS_LIBRARIES NAMES openblas blas PATHS "/usr/lib/x86_64-linux-gnu" "/usr/local/opt/" "usr/local/lib" REQUIRED)
find_library(LAPACK_LIBRARY lapack REQUIRED PATHS "/usr/lib" "/usr/lib/x86_64-linux-gnu" "/usr/local/lib" "/usr/local/opt/")

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

# Paths for downloading and building libraries
set(ARMADILLO_VERSION "15.2.2")
set(SUPERLU_VERSION "7.0.1")
set(BUILD_DIR "${CMAKE_BINARY_DIR}/third_party_build")
set(INSTALL_DIR "${CMAKE_BINARY_DIR}/third_party_install")

# SuperLU configuration
set(SUPERLU_TARBALL_URL "https://github.com/xiaoyeli/superlu/archive/refs/tags/v${SUPERLU_VERSION}.tar.gz")
set(SUPERLU_SRC_DIR "${BUILD_DIR}/superlu-${SUPERLU_VERSION}")
set(SUPERLU_BUILD_DIR "${SUPERLU_SRC_DIR}/build")
set(SUPERLU_INSTALL_DIR "${INSTALL_DIR}/superlu-${SUPERLU_VERSION}")

file(DOWNLOAD ${SUPERLU_TARBALL_URL} ${BUILD_DIR}/superlu-${SUPERLU_VERSION}.tar.gz)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf superlu-${SUPERLU_VERSION}.tar.gz WORKING_DIRECTORY ${BUILD_DIR})
# Detect platform and apply the correct sed command
if(APPLE)
execute_process(
COMMAND sed -i "" "s/cmake_minimum_required(VERSION 2.8.12)/cmake_minimum_required(VERSION 3.10)/" CMakeLists.txt
WORKING_DIRECTORY ${SUPERLU_SRC_DIR}
)
else()
execute_process(
COMMAND sed -i "s/cmake_minimum_required(VERSION 2.8.12)/cmake_minimum_required(VERSION 3.10)/" CMakeLists.txt
WORKING_DIRECTORY ${SUPERLU_SRC_DIR}
)
endif()

# Confirm the patch
execute_process(
COMMAND grep "cmake_minimum_required" ${SUPERLU_SRC_DIR}/CMakeLists.txt
OUTPUT_VARIABLE cmake_version_line
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "SuperLU CMakeLists.txt after patch: ${cmake_version_line}")

execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SUPERLU_BUILD_DIR})

execute_process(COMMAND ${CMAKE_COMMAND} ..
-DCMAKE_INSTALL_PREFIX=${SUPERLU_INSTALL_DIR}
-Denable_internal_blaslib=NO
-DTPL_BLAS_LIBRARIES=${OpenBLAS_LIBRARIES}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_C_FLAGS="-fPIC"
-DCMAKE_CXX_FLAGS="-fPIC"
WORKING_DIRECTORY ${SUPERLU_BUILD_DIR})
execute_process(COMMAND make -j4 WORKING_DIRECTORY ${SUPERLU_BUILD_DIR})
execute_process(COMMAND make install WORKING_DIRECTORY ${SUPERLU_BUILD_DIR})

# Armadillo configuration
set(ARMADILLO_TARBALL_URL "https://sourceforge.net/projects/arma/files/armadillo-${ARMADILLO_VERSION}.tar.xz")
set(ARMADILLO_BUILD_DIR "${BUILD_DIR}/armadillo-${ARMADILLO_VERSION}")
set(ARMADILLO_INSTALL_DIR "${INSTALL_DIR}/armadillo-${ARMADILLO_VERSION}")

file(DOWNLOAD ${ARMADILLO_TARBALL_URL} ${BUILD_DIR}/armadillo-${ARMADILLO_VERSION}.tar.xz)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xJf armadillo-${ARMADILLO_VERSION}.tar.xz WORKING_DIRECTORY ${BUILD_DIR})
execute_process(COMMAND ${CMAKE_COMMAND}
-DSuperLU_INCLUDE_DIR=${SUPERLU_INSTALL_DIR}/include
-DSuperLU_LIBRARY=${SUPERLU_INSTALL_DIR}/lib/libsuperlu.a
-DCMAKE_INSTALL_PREFIX=${ARMADILLO_INSTALL_DIR} .
WORKING_DIRECTORY ${ARMADILLO_BUILD_DIR})
execute_process(COMMAND make -j4 WORKING_DIRECTORY ${ARMADILLO_BUILD_DIR})
execute_process(COMMAND make install WORKING_DIRECTORY ${ARMADILLO_BUILD_DIR})

# Update paths for Armadillo and SuperLU
include_directories(${SUPERLU_INSTALL_DIR}/include ${ARMADILLO_INSTALL_DIR}/include)
link_directories(${SUPERLU_INSTALL_DIR}/lib ${ARMADILLO_INSTALL_DIR}/lib)

# Find required libraries
set(CMAKE_PREFIX_PATH ${ARMADILLO_INSTALL_DIR} ${CMAKE_PREFIX_PATH})
set(Armadillo_DIR ${ARMADILLO_INSTALL_DIR}/share/Armadillo)

find_package(Armadillo REQUIRED)
if(NOT Armadillo_FOUND)
message(FATAL_ERROR "Custom Armadillo not found in ${ARMADILLO_INSTALL_DIR}")
else()
message(STATUS "Using Armadillo from ${ARMADILLO_INSTALL_DIR}")
endif()

find_package(Eigen3 3.3.7 REQUIRED)
find_library(OpenBLAS_LIBRARIES NAMES openblas blas PATHS "/usr/lib/x86_64-linux-gnu" "/usr/local/opt/" REQUIRED)
find_library(LAPACK_LIBRARY lapack REQUIRED PATHS "/usr/lib" "/usr/lib/x86_64-linux-gnu" "/usr/local/lib" "/usr/local/opt/")

# Required libraries and link settings
set(LINK_LIBS ${ARMADILLO_LIBRARIES}
${OpenBLAS_LIBRARIES}
${SUPERLU_INSTALL_DIR}/lib/libsuperlu.a
${LAPACK_LIBRARY})

# Add subdirectories
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(examples/grids)

# Custom target to build everything
add_custom_target(all_build DEPENDS mole_C++ tests_C++ examples_C++ tests_matlab_octave)
# ---------------------------------------------------------------
# Summary printed at configure time
# ---------------------------------------------------------------
message(STATUS "")
message(STATUS "MOLE ${PROJECT_VERSION} configuration summary:")
message(STATUS " Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS " Armadillo version: ${ARMADILLO_VERSION_STRING}")
message(STATUS " Build examples: ${MOLE_BUILD_EXAMPLES}")
message(STATUS " Build tests: ${MOLE_BUILD_TESTS}")
message(STATUS "")

52 changes: 52 additions & 0 deletions cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!--
====================================================================
= MOLE 2.0 - C++ =
====================================================================
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (c) 2008-2024 San Diego State University Research
Foundation (SDSURF).
See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for details.
--------------------------------------------------------------------
File created: 06-24-2026
====================================================================
-->

# Top subdirectory for MOLE 2.0 C++ files

Subdirectory and Pathname: **mole/cpp**

## Purpose

Top subdirectory for the MOLE 2.0 C++ implementation.
It contains the top CMakefile.list.

## MOLE C++ 2.0 Directory structure

```text
mole/
├── cpp/
| │── cmake/
| │── doc/
| │── examples
| |── src/
| │ ├── boundaries
| │ └── grids
| │ └── include
| │ └── operators
| │ └── sys
| │ └── utils
| |── tests

:
: __Other MOLE 2.0 and v1.2.0 files, including other language__
: __implementations__
:
├── .gitignore
└── README.md
```

## Other MOLE 2.0 C++ Files in this directory

+ CMakeLists.txt which builds a MOLE 2.0 C++ version of the library
and all its functional modules
+ README.md (this file)
5 changes: 5 additions & 0 deletions cpp/cmake/MOLEConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/MOLETargets.cmake")

check_required_components(MOLE)
45 changes: 45 additions & 0 deletions cpp/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
====================================================================
= MOLE 2.0 - C++ =
====================================================================
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (c) 2008-2024 San Diego State University Research
Foundation (SDSURF).
See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for
details.
--------------------------------------------------------------------
File created: 06-24-2026
====================================================================
-->

# Subdirectory of Use Cases/Examples for the MOLE 2.0 Implementation

Subdirectory and Pathname: **mole/cpp/examples**

## Purpose

This is the top subdirectory for the MOLE 2.0 C++ example
implementations. Examples are organized by the different modules
contained in the MOLE Library

## Structure of the MOLE C++ 2.0 Subdirectory of Examples

```text
mole/
├── cpp/
| │── examples
| │ ├── boundaries
| │ └── grids
| │ └── operators
| │ └── sys
| | └── time_integrators
| │ └── utils
```

## MOLE 2.0 C++ Files and Subdirectories in this subdirectory

+ subdirectory **grids**: contains examples on how to declare and
construct MOLE grids
+ subdirectory **sys**: contains examples on how to use MOLE v2.0
error handling mechanisms
+ file **README.md** this file
35 changes: 35 additions & 0 deletions cpp/examples/grids/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.14)

# ---------------------------------------------------------------
# The files in the CMakeLists.txt file are all examples of the
# the use of the MOLE Library
# ---------------------------------------------------------------
set(MOLE_EXAMPLE_SOURCES
grid1D_basic.cpp # basic 1D grid generation
grid2D_basic.cpp # basic 2D grid generation
err_grid2D_basic.cpp # basic 2D grid generation
gridBuilder1D_basic.cpp # 1D grid through gridBuilder
gridBuilder2D_basic.cpp # 2D grid with periodicity
gridBuilder_arg_order.cpp # attribute order independence
gridBuilder_error_handling.cpp # parse-time error reporting
)

# Builds all the examples listed in MOLE_EXAMPLE_SOURCES
add_custom_target(mole_examples)

foreach(_mole_example_src IN LISTS MOLE_EXAMPLE_SOURCES)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_mole_example_src}")
message(FATAL_ERROR
"MOLE example source listed in examples/CMakeLists.txt "
"is missing: ${_mole_example_src}")
endif()
get_filename_component(_mole_example_name
${_mole_example_src} NAME_WE)
add_executable(${_mole_example_name} ${_mole_example_src})
target_link_libraries(${_mole_example_name} PRIVATE MOLE::mole)
target_compile_options(${_mole_example_name} PRIVATE -Wall -Wextra)
# Group all example binaries under a single "examples" target so
# `cmake --build . --target examples` builds just these, without
# also building the (potentially much larger) test suite.
add_dependencies(mole_examples ${_mole_example_name})
endforeach()
34 changes: 34 additions & 0 deletions cpp/examples/grids/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
====================================================================
= MOLE 2.0 - C++ =
====================================================================
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (c) 2008-2024 San Diego State University Research
Foundation (SDSURF).
See LICENSE file or https://www.gnu.org/licenses/gpl-3.0.html for
details.
--------------------------------------------------------------------
File created: 06-24-2026
====================================================================
-->

# Subdirectory for MOLE 2.0 C++ grid examples

Subdirectory and Pathname: **mole/cpp/examples/grids/**

## Purpose

Subdirectory containing examples of MOLE grid declarations and
generation using MOLE grid classes and the MOLE gridBuilder

## List of Files in This Subdirectory

+ **CMakeLists.txt**: support the building of MOLE 2.0 C++ examples of
MOLE grids
+ **err_grid2D_basic.cpp**: a C++ example of how the MOLE error log
mechanisms works in the context of grids
+ **grid1D_basic.cpp**: a C++ example of a 1D grid declaration and
instantiation (checking for errors)
+ **grid2D_basic.cpp**:a C++ example of a 1D grid declaration and
instantiation (checking for errors)
+ **README.md**: (this file)
Loading
Loading