Skip to content

Commit

Permalink
Merge branch 'master' into lmn-stretching-support
Browse files Browse the repository at this point in the history
  • Loading branch information
pbartholomew08 committed Sep 30, 2024
2 parents 28adc0d + 58673d0 commit 62df431
Show file tree
Hide file tree
Showing 215 changed files with 9,298 additions and 16,373 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# We don't want to build openmpi each time this workflow is
# run. Setup caching of OpenMPI after it is built and installed.
# See "Caching dependencies to speed up workflows" on the GH
# actions docs.
- name: Cache OpenMPI
id: cache-openmpi
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: openmpi-4.1.4/installed
key: openmpi-4.1.4
Expand All @@ -42,20 +42,12 @@ jobs:
./configure --prefix=$(pwd)/installed
make all install
- name: Build Incompact3d
- name: Build Xcompact3d
run: |
export PATH=$(pwd)/openmpi-4.1.4/installed/bin/:$PATH
make BUILD=debug
- name: Run TGV case
run: |
cp test/data/Taylor-Green-Vortex/reference_input.i3d input.i3d
export PATH=$(pwd)/openmpi-4.1.4/installed/bin/:$PATH
mpirun -np 2 xcompact3d
- name: Compare output time evolution to reference output
run: |
pip install numpy
python test/compare_TGV_time_evolution.py \
--input time_evol.dat \
--reference test/data/Taylor-Green-Vortex/reference_time_evol.dat
export FC=mpif90
cmake -S . -B build
cmake --build build -j 2
cmake --install build
ctest --test-dir build
35 changes: 35 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "20"
# rust: "1.70"
# golang: "1.20"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
# builder: "dirhtml"
# Fail on all warnings to avoid broken references
# fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
204 changes: 47 additions & 157 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.20)
cmake_policy(SET CMP0074 NEW)

project(xcompact3d LANGUAGES Fortran)
project(Xcompact3d LANGUAGES Fortran)
set(version 5.0)
if (IO_BACKEND MATCHES "adios2")
# Can be useful to also activate CXX, sometimes is needed by packages
enable_language(C CXX)
endif (IO_BACKEND MATCHES "adios2")

set(AUTHOR "Stefano Rolfo;Charles Moulinec")
set(AUTHOR_DETAILS "[email protected];[email protected]")
set(DESCRIPTION "Building xcompact3d using cmake")
set(DESCRIPTION "Building Xcompact3d using cmake")

message(STATUS "building ${PROJECT_NAME}")

Expand All @@ -20,163 +23,50 @@ endif()
INCLUDE(CMakeDependentOption)
INCLUDE(CMakeParseArguments)

# Find the modules included with Xcompact
#SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

# make sure that the default is a RELEASE
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: None Debug Release."
FORCE)
"Choose the type of build, options are: NONE DEV DEBUG RELEASE."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)

set(Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER_ID} )
message(STATUS "COMP ID ${Fortran_COMPILER_NAME}")
message(STATUS "Fortran compiler name ${Fortran_COMPILER_NAME}")
message(STATUS "Fortran compiler version ${CMAKE_Fortran_COMPILER_VERSION}")
if (Fortran_COMPILER_NAME MATCHES "GNU")
# gfortran
message(STATUS "Setting gfortran flags")
set(CMAKE_Fortran_FLAGS "-cpp -funroll-loops -floop-optimize -g -Warray-bounds -fcray-pointer -fbacktrace -ffree-line-length-none")
if (CMAKE_Fortran_COMPILER_VERSION GREATER_EQUAL "10")
message(STATUS "Set New Fortran basic flags")
set(CMAKE_Fortran_FLAGS "-cpp -funroll-loops -floop-optimize -g -Warray-bounds -fcray-pointer -fbacktrace -ffree-line-length-none -fallow-argument-mismatch")
endif (CMAKE_Fortran_COMPILER_VERSION GREATER_EQUAL "10")
set(CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3")
set(CMAKE_Fortran_FLAGS_DEBUG "-DDEBG -O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "Intel")
message(STATUS "Setting ifort flags")
set(CMAKE_Fortran_FLAGS "-fpp -xHost -heaparrays -safe-cray-ptr -g -traceback")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -ipo")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -DDEBG")
#set(CMAKE_Fortran_FLAGS "-cpp xSSE4.2 -axAVX,CORE-AVX-I,CORE-AVX2 -ipo -fp-model fast=2 -mcmodel=large -safe-cray-ptr")
elseif (Fortran_COMPILER_NAME MATCHES "NAG")
message(STATUS "Setting nagfor flags")
set(CMAKE_Fortran_FLAGS "-fpp")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "Cray")
message(STATUS "Setting cray fortran flags")
set(CMAKE_Fortran_FLAGS "-eF -g -N 1023")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
elseif (Fortran_COMPILER_NAME MATCHES "NVHPC")
message(STATUS "Setting NVHPC fortran flags")
set(CMAKE_Fortran_FLAGS "-cpp -Mfree -Kieee -g")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3 -fast")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -DDEBG")
elseif (Fortran_COMPILER_NAME MATCHES "Fujitsu")
message(STATUS "Setting Fujitsu fortran flags")
set (CMAKE_Fortran_FLAGS "-Cpp")
set (CMAKE_Fortran_FLAGS_RELEASE "-O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0")
else (Fortran_COMPILER_NAME MATCHES "GNU")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("No optimized Fortran compiler flags are known, we just try -O2...")
set (CMAKE_Fortran_FLAGS_RELEASE "-O2")
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
endif (Fortran_COMPILER_NAME MATCHES "GNU")

if (CMAKE_BUILD_TYPE MATCHES "DEBUG")
add_definitions("-DDEBG")
endif (CMAKE_BUILD_TYPE MATCHES "DEBUG")


find_package(MPI REQUIRED)
# Stop if there is no MPI_Fortran_Compiler
if (MPI_Fortran_COMPILER)
message(STATUS "MPI_Fortran_COMPILER found: ${MPI_Fortran_COMPILER}")
else (MPI_Fortran_COMPILER)
message(SEND_ERROR "This application cannot compile without MPI")
endif(MPI_Fortran_COMPILER)
# Warning if Include are not found => can be fixed with more recent cmake version
if (MPI_FOUND)
message(STATUS "MPI FOUND: ${MPI_FOUND}")
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
message(STATUS "MPI INCL ALSO FOUND: ${MPI_INCLUDE_PATH}")
else (MPI_FOUND)
message(STATUS "NO MPI include have been found. The executable won't be targeted with MPI include")
message(STATUS "Code will compile but performaces can be compromised")
message(STATUS "Using a CMake vers > 3.10 should solve the problem")
message(STATUS "Alternatively use ccmake to manually set the include if available")
endif (MPI_FOUND)

execute_process(
COMMAND git describe --tag --long --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions("-DVERSION=\"${GIT_VERSION}\"")
option(DOUBLE_PRECISION "Build Xcompact with double precision" ON)
if (DOUBLE_PRECISION)
add_definitions("-DDOUBLE_PREC")
endif()

option(SINGLE_PRECISION_OUTPUT "Build XCompact with output in single precision" OFF)
if (SINGLE_PRECISION_OUTPUT)
add_definitions("-DSAVE_SINGLE")
endif()

# FFT options
set(FFT_Choice "generic" CACHE STRING "FFT for XCompact3d project (generic is the default)")
set_property(CACHE FFT_Choice PROPERTY STRINGS generic fftw3 mkl)

# Look for ADIOS2 library
option(USE_ADIOS2 "Build XCompact with ADIOS2 library" OFF)
if(USE_ADIOS2)
#find_package(ADIOS2 COMPONENTS fortran)
find_package(ADIOS2)
endif()
if(ADIOS2_FOUND)
message(STATUS "ADIOS INCLUDE ${ADIOS2_INCLUDE_DIRS}")
include_directories(${ADIOS2_INCLUDE_DIRS})
add_definitions("-DADIOS2")
else(ADIOS_FOUND)
message(STATUS "ADIOS2 not found")
endif()

# Create a static library for the fft
add_subdirectory(decomp2d)

# Create the Xcompact3d executable
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
if (CMAKE_BUILD_TYPE MATCHES "NONE")
message (STATUS "Selected build type : None")
elseif (CMAKE_BUILD_TYPE MATCHES "RELEASE")
message (STATUS "Selected build type : Release")
elseif (CMAKE_BUILD_TYPE MATCHES "DEBUG")
message (STATUS "Selected build type : Debug")
elseif (CMAKE_BUILD_TYPE MATCHES "DEV")
message (FATAL_ERROR "DEV build is a work in progress and currently not supported by Xcompact3d")
else (CMAKE_BUILD_TYPE MATCHES "NONE")
message (FATAL_ERROR "Invalid build type, options are: NONE DEV DEBUG RELEASE.")
endif (CMAKE_BUILD_TYPE MATCHES "NONE")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_SOURCE_DIR}/cmake/compilers" "${CMAKE_SOURCE_DIR}/cmake/fft")
find_package(DECOMP2D REQUIRED)

# Despite IO is handled by 2DECOMP&FFT we need to set it
set (IO_BACKEND "mpi" CACHE STRING "Default IO backend (mpi (default) or adios2)")
set_property(CACHE IO_BACKEND PROPERTY STRINGS mpi adios2)

include(X3D_MPI)

include(X3D_Compilers)

# Add the sources
add_subdirectory(src)

# Create the Xcompact3d executable
add_subdirectory(post_vtk)

# Create an example dir with all input.i3d example files
option(BUILD_TESTING "Build with tests" ON)
set(test_dir "${PROJECT_BINARY_DIR}/Test")
add_subdirectory(examples)
message(STATUS "Before test main ${test_dir}")
# Add tests
option(BUILD_TESTING "Build with test and use only TGV case" ON)
option(BUILD_TESTING_FULL "Build all tests" OFF)
if (${BUILD_TESTING})
include(CTest)
message(STATUS "MPI INCL ALSO FOUND: ${MPI_INCLUDE_PATH}")
message(STATUS "MPI EXEC: ${MPIEXEC_EXECUTABLE}")
# ABL
add_test(NAME ABL-Convective-old COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_convective_test.i3d WORKING_DIRECTORY ${test_dir}/ABL-Convective-old)
add_test(NAME ABL-Neutral-old COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_neutral_test.i3d WORKING_DIRECTORY ${test_dir}/ABL-Neutral-old)
add_test(NAME ABL-Stable-old COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_stable_test.i3d WORKING_DIRECTORY ${test_dir}/ABL-Stable-old)
add_test(NAME ABL-Neutral COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_neutral_test.i3d WORKING_DIRECTORY ${test_dir}/ABL-Neutral)
# Channel
add_test(NAME Channel-Flow-X COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test_x.i3d WORKING_DIRECTORY ${test_dir}/Channel-Flow-X)
add_test(NAME Channel-Flow-Z COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test_z.i3d WORKING_DIRECTORY ${test_dir}/Channel-Flow-Z)
# Cylinder
if(NOT ${USE_ADIOS2})
add_test(NAME Cylinder COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/Cylinder)
add_test(NAME CylinderMoving COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test_moving.i3d WORKING_DIRECTORY ${test_dir}/CylinderMoving)
endif()
# Lock excahnge
add_test(NAME Lock-exchange COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/Lock-exchange)
# Mixing Layer
add_test(NAME Mixing-layer COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/Mixing-layer)
# TGV
add_test(NAME TGvortex COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/TGV)
# TBL
add_test(NAME TBL COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/TBL)
# Wind Turbines
add_test(NAME Wind-Turbine COMMAND ${MPIEXEC_EXECUTABLE} -n ${MPIEXEC_MAX_NUMPROCS} ${CMAKE_INSTALL_PREFIX}/bin/xcompact3d input_test.i3d WORKING_DIRECTORY ${test_dir}/Wind-Turbine)
endif()
add_subdirectory(examples)
add_subdirectory(tests)
endif (${BUILD_TESTING})

# Add a prettify target
#add_custom_target(format sh ${CMAKE_SOURCE_DIR}/scripts/format.sh
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})


2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Alphabetic order:
Paul Bartholomew (EPCC, UK)
Nikos Bempedelis (ICL, UK)
Georgios (Yorgos) Deskos (NREL, USA)
Jian Fang (STFC, UK)
Cedric Flageul (Poitiers, France)
Ricardo Frantz (Paris, France)
Athanasios Giannenas (ICL, UK)
Gaurav Gupta (IIST, India)
Arash Hamzehloo (ICL, UK)
Sylvain Laizet (ICL, UK)
Eric Lamballais (Poitiers, France)
Expand Down
Loading

0 comments on commit 62df431

Please sign in to comment.