Skip to content

Commit 9fb8abb

Browse files
Merge branch 'main' of github.com:PhasicFlow/phasicFlow
2 parents a05225c + 90a8fff commit 9fb8abb

3 files changed

Lines changed: 65 additions & 28 deletions

File tree

cmake/bashrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export pFlow_SRC_DIR="$pFlow_PROJECT_DIR/src"
1919

2020
export Kokkos_DIR="$kokkosDir"
2121

22-
export Zoltan_DIR="$projectDir/Zoltan"
22+
#export Zoltan_DIR="$projectDir/Zoltan"
2323

2424
# Cleanup variables (done as final statement for a clean exit code)
2525
unset projectDir

cmake/zoltanInstallCheck.cmake

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Macro to check for Zoltan installation and build it if needed
2+
# Usage: zoltan_find_or_build(ZOLTAN_DIR)
3+
# Returns: ZOLTAN_INCLUDE_DIR, ZOLTAN_LIBRARY
4+
5+
macro(zoltan_find_or_build ZOLTAN_DIR)
6+
# Set the Zoltan directory
7+
set(ZOLTAN_PREFIX "${ZOLTAN_DIR}" CACHE STRING "Zoltan install directory")
8+
message(STATUS "Zoltan install directory is ${ZOLTAN_PREFIX}")
9+
10+
# Check if the Zoltan library is already built
11+
find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include")
12+
message(STATUS "Zoltan include path: ${ZOLTAN_INCLUDE_DIR}")
13+
14+
find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib")
15+
message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}")
16+
17+
# Check if Zoltan library exists, if not compile it using buildlib script
18+
if(NOT ZOLTAN_LIBRARY)
19+
message(STATUS "Zoltan library not found. Compiling from source using buildlib script...")
20+
21+
# Execute the buildlib bash script
22+
execute_process(
23+
COMMAND bash ${ZOLTAN_PREFIX}/buildlib
24+
WORKING_DIRECTORY ${ZOLTAN_PREFIX}
25+
RESULT_VARIABLE ZOLTAN_BUILD_RESULT
26+
OUTPUT_VARIABLE ZOLTAN_BUILD_OUTPUT
27+
ERROR_VARIABLE ZOLTAN_BUILD_ERROR
28+
)
29+
30+
if(NOT ZOLTAN_BUILD_RESULT EQUAL 0)
31+
message(FATAL_ERROR "Failed to build Zoltan library using buildlib script. Error: ${ZOLTAN_BUILD_ERROR}")
32+
endif()
33+
34+
# Try to find the library again after building
35+
find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib" NO_DEFAULT_PATH)
36+
find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include" NO_DEFAULT_PATH)
37+
38+
if(NOT ZOLTAN_LIBRARY)
39+
message(FATAL_ERROR "Failed to locate Zoltan library after building")
40+
endif()
41+
42+
message(STATUS "Successfully built Zoltan library at ${ZOLTAN_LIBRARY}")
43+
endif()
44+
endmacro()

src/phasicFlow/CMakeLists.txt

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
list(APPEND SourceFiles
32
types/basicTypes/bTypesFunctions.cpp
43
types/basicTypes/Logical.cpp
@@ -119,44 +118,38 @@ set(link_libs)
119118
set(link_libs Kokkos::kokkos tbb)
120119

121120

122-
121+
# for MPI parallelization
123122
if(pFlow_Build_MPI)
124123

125-
set(Zoltan_Install_DIR)
126-
if(DEFINED ENV{Zoltan_DIR})
127-
set(Zoltan_Install_DIR $ENV{Zoltan_DIR})
128-
else()
129-
set(Zoltan_Install_DIR $ENV{HOME}/PhasicFlow/Zoltan)
130-
endif()
131-
message(STATUS "Zoltan install directory is ${Zoltan_Install_DIR}")
132-
133-
set(ZOLTAN_PREFIX "${Zoltan_Install_DIR}" CACHE STRING "Zoltan install directory")
134-
135-
find_path(ZOLTAN_INCLUDE_DIR zoltan.h PATHS "${ZOLTAN_PREFIX}/include")
136-
137-
message(STATUS "Zoltan include path: ${ZOLTAN_INCLUDE_DIR}")
138-
139-
find_library(ZOLTAN_LIBRARY zoltan PATHS "${ZOLTAN_PREFIX}/lib")
140-
message(STATUS "Zoltan lib path: ${ZOLTAN_LIBRARY}")
124+
# Include the Zoltan installation check macro
125+
include(${CMAKE_SOURCE_DIR}/cmake/zoltanInstallCheck.cmake)
126+
127+
# set the Zoltan Directory and check/build if needed
128+
set(Zoltan_Install_DIR ${CMAKE_SOURCE_DIR}/thirdParty/Zoltan)
129+
130+
# Call the macro to find or build Zoltan
131+
zoltan_find_or_build(${Zoltan_Install_DIR})
141132

142133
list(APPEND SourceFiles
143-
MPIParallelization/domain/partitioning/partitioning.cpp
144-
MPIParallelization/domain/partitioning/rcb1DPartitioning.cpp
145-
MPIParallelization/domain/MPISimulationDomain.cpp
146-
MPIParallelization/dataIOMPI/dataIOMPIs.cpp
147-
MPIParallelization/MPI/procCommunication.cpp
148-
MPIParallelization/MPI/scatteredMasterDistributeChar.cpp
149-
MPIParallelization/pointStructure/boundaries/boundaryProcessor.cpp
150-
MPIParallelization/pointField/processorBoundaryFields.cpp
134+
MPIParallelization/domain/partitioning/partitioning.cpp
135+
MPIParallelization/domain/partitioning/rcb1DPartitioning.cpp
136+
MPIParallelization/domain/MPISimulationDomain.cpp
137+
MPIParallelization/dataIOMPI/dataIOMPIs.cpp
138+
MPIParallelization/MPI/procCommunication.cpp
139+
MPIParallelization/MPI/scatteredMasterDistributeChar.cpp
140+
MPIParallelization/pointStructure/boundaries/boundaryProcessor.cpp
141+
MPIParallelization/pointField/processorBoundaryFields.cpp
151142
)
152143

153144
list(APPEND link_libs MPI::MPI_CXX ${ZOLTAN_LIBRARY} -lm )
154145
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
155146
target_include_directories(phasicFlow PUBLIC ./globals ${ZOLTAN_INCLUDE_DIR})
156147

157148
else()
158-
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
149+
150+
pFlow_add_library_install(phasicFlow SourceFiles link_libs)
159151
target_include_directories(phasicFlow PUBLIC ./globals)
152+
160153
endif()
161154

162155

0 commit comments

Comments
 (0)