diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a3aa0978 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,85 @@ +cmake_minimum_required(VERSION 3.22 FATAL_ERROR) + +# set the project name and version +project(phasicFlow VERSION 0.1 ) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) +set(CMAKE_INSTALL_PREFIX ${phasicFlow_SOURCE_DIR} CACHE PATH "Install path of phasicFlow" FORCE) + +message(STATUS ${CMAKE_INSTALL_PREFIX}) + +mark_as_advanced(FORCE var Kokkos_ENABLE_CUDA_LAMBDA) +mark_as_advanced(FORCE var Kokkos_ENABLE_OPENMP) +mark_as_advanced(FORCE var Kokkos_ENABLE_SERIAL) +mark_as_advanced(FORCE var Kokkos_ENABLE_CUDA_LAMBDA) + +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +option(USE_STD_PARALLEL_ALG "Use TTB std parallel algorithms" ON) +option(pFlow_Build_Serial "Build phasicFlow and backends for serial execution" ON) +option(pFlow_Build_OpenMP "Build phasicFlow and backends for OpenMP execution" OFF) +option(pFlow_Build_Cuda "Build phasicFlow and backends for Cuda execution" OFF) + +if(dFlow_Build_Serial) + set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Serial execution" FORCE) + set(Kokkos_ENABLE_OPENMP OFF CACHE BOOL "OpenMP execution" FORCE) + set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "Cuda execution" FORCE) + set(Kokkos_ENABLE_CUDA_LAMBDA OFF CACHE BOOL "Cuda execution" FORCE) +elseif(dFlow_Build_OpenMP ) + set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Serial execution" FORCE) + set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "OpenMP execution" FORCE) + set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "Cuda execution" FORCE) + set(Kokkos_ENABLE_CUDA_LAMBDA OFF CACHE BOOL "Cuda execution" FORCE) +elseif(dFlow_Build_Cuda) + set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Serial execution" FORCE) + set(Kokkos_ENABLE_OPENMP OFF CACHE BOOL "OpenMP execution" FORCE) + set(Kokkos_ENABLE_CUDA ON CACHE BOOL "Cuda execution" FORCE) + set(Kokkos_ENABLE_CUDA_LAMBDA ON CACHE BOOL "Cuda execution" FORCE) +endif() + + + +include(cmake/globals.cmake) +message(STATUS "Valid file extensions are ${validFiles}") + +include(cmake/makeLibraryGlobals.cmake) +include(cmake/makeExecutableGlobals.cmake) + +configure_file(phasicFlowConfig.H.in phasicFlowConfig.H) + +#add a global include directory +include_directories(src/setHelpers src/demComponent "${PROJECT_BINARY_DIR}") + +#main subdirectories of the code +set(Kokkos_Source_DIR) + +if(DEFINED ENV{Kokkos_DIR}) + set(Kokkos_Source_DIR $ENV{Kokkos_DIR}) +# add_subdirectory($ENV{Kokkos_DIR} ${phasicFlow_BINARY_DIR}/kokkos) +# message(STATUS "Kokkos directory is $ENV{Kokkos_DIR}") +else() +# add_subdirectory($ENV{HOME}/Kokkos/kokkos ${phasicFlow_BINARY_DIR}/kokkos) + set(Kokkos_Source_DIR $ENV{HOME}/Kokkos/kokkos) +endif() + +message(STATUS "Kokkos source directory is ${Kokkos_Source_DIR}") +add_subdirectory(${Kokkos_Source_DIR} ${phasicFlow_BINARY_DIR}/kokkos) + +add_subdirectory(src) + +#add_subdirectory(solvers) + +#add_subdirectory(utilities) + +#add_subdirectory(test) + + +install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H" + DESTINATION include +) + +include(InstallRequiredSystemLibraries) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR "${phasicFlow_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${phasicFlow_VERSION_MINOR}") +include(CPack) diff --git a/LICENSE b/LICENSE index f288702d..c07e179f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) CEMF (https://cemf.ir/) Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. diff --git a/cmake/bashrc b/cmake/bashrc new file mode 100644 index 00000000..8e923ee9 --- /dev/null +++ b/cmake/bashrc @@ -0,0 +1,31 @@ + +export pFlow_PROJECT_VERSION=v0.1 + +export pFlow_PROJECT=phasicFlow-$pFlow_PROJECT_VERSION + + +projectDir="$HOME/PhasicFlow" +kokkosDir="$HOME/Kokkos/kokkos" + +export pFlow_PROJECT_DIR="$projectDir/$pFlow_PROJECT" + +# [WM_PROJECT_USER_DIR] - Location of user files +export pFlow_PROJECT_USER_DIR="$projectDir/$USER-$pFlow_PROJECT_VERSION" + +export pFlow_LIB_DIR="$pFlow_PROJECT_DIR/lib" + +export pFlow_BIN_DIR="$pFlow_PROJECT_DIR/bin" + +export pFlow_SRC_DIR="$pFlow_PROJECT_DIR/src" + +export Kokkos_DIR="$kokkosDir" + +# Cleanup variables (done as final statement for a clean exit code) +unset projectDir + +export PATH="$pFlow_BIN_DIR:$PATH" + +export LD_LIBRARY_PATH="$pFlow_LIB_DIR:$LD_LIBRARY_PATH" + + +#------------------------------------------------------------------------------ diff --git a/cmake/globals.cmake b/cmake/globals.cmake new file mode 100644 index 00000000..b3158dd8 --- /dev/null +++ b/cmake/globals.cmake @@ -0,0 +1,4 @@ + +set(validFiles) +list(APPEND validFiles *.C *.cpp *.cxx *.c *.cu *.H *.hpp *.hxx *.h *.cuh) + diff --git a/cmake/makeExecutableGlobals.cmake b/cmake/makeExecutableGlobals.cmake new file mode 100644 index 00000000..5aef5261 --- /dev/null +++ b/cmake/makeExecutableGlobals.cmake @@ -0,0 +1,43 @@ +#add a library to dFlow with source files and target_link_libs (thouse under the main CMakeLists.txt) +macro(pFlow_make_executable_install target_name source_files target_link_libs) + +# add library +add_executable(${target_name} ${${source_files}}) + +target_link_libraries(${target_name} PUBLIC ${${target_link_libs}}) + +#get all valid the source files under the current folder +file(GLOB_RECURSE allValidFilePaths RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${validFiles}) + +set(validFilePathsExcSRCs ${allValidFilePaths}) +list(REMOVE_ITEM validFilePathsExcSRCs ${${source_files}}) +set(includeDirs) +set(includeFiles ${validFilePathsExcSRCs}) + +# get the directory names +foreach(file_path ${validFilePathsExcSRCs}) + GET_FILENAME_COMPONENT(dir_path ${file_path} DIRECTORY) + list(APPEND includeDirs ${dir_path}) +endforeach() + +#remove duplicates +list(REMOVE_DUPLICATES includeDirs) + +target_include_directories(${target_name} + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${includeDirs} + ) + +message(STATUS "\nCreating make file for executable ${target_name}") +message(STATUS " ${target_name} link libraries are: ${${target_link_libs}}") +message(STATUS " ${target_name} source files are: ${source_files}") +message(STATUS " ${target_name} include dirs are: ${includeDirs}\n") + + +install(TARGETS ${target_name} DESTINATION bin) + + +endmacro() + + diff --git a/cmake/makeLibraryGlobals.cmake b/cmake/makeLibraryGlobals.cmake new file mode 100644 index 00000000..26d567c7 --- /dev/null +++ b/cmake/makeLibraryGlobals.cmake @@ -0,0 +1,52 @@ +#add a library to dFlow with source files and target_link_libs (thouse under the main CMakeLists.txt) +macro(pFlow_add_library_install target_name src_files target_link_libs) + +set(source_files ${${src_files}}) + +# add library +add_library(${target_name} ${source_files}) + +set_target_properties(${target_name} PROPERTIES + POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} + ) + +target_link_libraries(${target_name} PUBLIC ${${target_link_libs}}) + +#get all valid the source files under the current folder +file(GLOB_RECURSE allValidFilePaths RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${validFiles}) + +set(validFilePathsExcSRCs ${allValidFilePaths}) +foreach(file ${source_files}) + list(REMOVE_ITEM validFilePathsExcSRCs ${file}) +endforeach() + +set(includeDirs) +set(includeFiles ${validFilePathsExcSRCs}) + +# get the directory names +foreach(file_path ${validFilePathsExcSRCs}) + GET_FILENAME_COMPONENT(dir_path ${file_path} DIRECTORY) + list(APPEND includeDirs ${dir_path}) +endforeach() + +#remove duplicates +list(REMOVE_DUPLICATES includeDirs) + + +target_include_directories(${target_name} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${includeDirs} + ) + +message(STATUS "\nCreating make file for library ${target_name}") +message(STATUS " ${target_name} link libraries are: ${${target_link_libs}}") +message(STATUS " ${target_name} source files are: ${source_files}") +message(STATUS " ${target_name} include dirs are: ${includeDirs}\n") + +install(TARGETS ${target_name} DESTINATION lib) +install(FILES ${includeFiles} DESTINATION include/${target_name}) + +endmacro() + + diff --git a/phasicFlowConfig.H.in b/phasicFlowConfig.H.in new file mode 100644 index 00000000..b4445bf0 --- /dev/null +++ b/phasicFlowConfig.H.in @@ -0,0 +1,8 @@ +// the configured options and settings for Tutorial +#define phasicFlow_VERSION_MAJOR @phasicFlow_VERSION_MAJOR@ +#define phasicFlow_VERSION_MINOR @phasicFlow_VERSION_MINOR@ +#cmakedefine BUILD_SHARED_LIBS +#cmakedefine pFlow_Build_Serial +#cmakedefine pFlow_Build_OpenMP +#cmakedefine pFlow_Build_Cuda +#cmakedefine USE_STD_PARALLEL_ALG \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..ff2582b5 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,15 @@ + +add_subdirectory(phasicFlow) + +#add_subdirectory(Integration) + +#add_subdirectory(Property) + +#add_subdirectory(Particles) + +#add_subdirectory(Interaction) + +#add_subdirectory(MotionModel) + +#add_subdirectory(Geometry) + diff --git a/src/phasicFlow/CMakeLists.txt b/src/phasicFlow/CMakeLists.txt new file mode 100644 index 00000000..a5420f70 --- /dev/null +++ b/src/phasicFlow/CMakeLists.txt @@ -0,0 +1,79 @@ + +list(APPEND SourceFiles +types/basicTypes/bTypesFunctions.C +types/basicTypes/Logical.C +types/types.C + +globals/error.C + +streams/token/tokenIO.C +streams/token/token.C +streams/iStream/IOstream.C +streams/iStream/iIstream.C +streams/iStream/iOstream.C +streams/Stream/Istream.C +streams/Stream/Ostream.C +streams/Fstream/iFstream.C +streams/Fstream/oFstream.C +streams/Fstream/fileStream.C +streams/TStream/iTstream.C +streams/TStream/oTstream.C +streams/streams.C + +dictionary/dictionary.C +dictionary/entry/iEntry.C +dictionary/entry/dataEntry.C +dictionary/twoPartEntry/twoPartEntry.C + +fileSystem/fileSystem.C + +commandLine/commandLine.C + +random/randomReal/randomReal.C +random/randomReal/randomReals.C + +Timer/Timer.C +Timer/Timers.C + +repository/Time/Time.C +repository/Time/timeControl.C +repository/systemControl/systemControl.C +repository/repository/repository.C +repository/IOobject/objectFile.C +repository/IOobject/IOobject.C +repository/IOobject/IOfileHeader.C + +structuredData/box/box.C +structuredData/iBox/iBoxs.C +structuredData/line/line.C +structuredData/pointStructure/pointStructure.C +structuredData/pointStructure/selectors/pStructSelector/pStructSelector.C +structuredData/pointStructure/selectors/boxAll/boxAll.C +structuredData/pointStructure/selectors/rangeAll/rangeAll.C +structuredData/trisurfaceStructure/triSurface.C +structuredData/trisurfaceStructure/multiTriSurface.C +structuredData/trisurfaceStructure/stlFile.C +structuredData/peakableRegion/sphereRegion/sphereRegion.C +structuredData/peakableRegion/boxRegion/boxRegion.C +structuredData/peakableRegion/peakableRegion/peakableRegion.C +structuredData/peakableRegion/peakableRegions.C + +containers/Vector/Vectors.C +containers/Field/Fields.C +containers/symArrayHD/symArrays.C +containers/triSurfaceField/triSurfaceFields.C +containers/bitsetHD/bitsetHDs.C +containers/indexContainer/indexContainer.C + +setFieldList/setFieldList.C +setFieldList/setFieldEntry.C + +eventSubscriber/eventSubscriber.C +eventSubscriber/eventObserver.C) + +set(link_libs Kokkos::kokkos tbb) + +pFlow_add_library_install(phasicFlow SourceFiles link_libs) + +target_include_directories(phasicFlow PUBLIC ./Kokkos ./algorithms ./globals) + diff --git a/src/phasicFlow/types/basicTypes/bTypes.H b/src/phasicFlow/types/basicTypes/bTypes.H new file mode 100755 index 00000000..8ed4a398 --- /dev/null +++ b/src/phasicFlow/types/basicTypes/bTypes.H @@ -0,0 +1,33 @@ +/*------------------------------- phasicFlow --------------------------------- + O C enter of + O O E ngineering and + O O M ultiscale modeling of + OOOOOOO F luid flow +------------------------------------------------------------------------------ + Copyright (C): www.cemf.ir + email: hamid.r.norouzi AT gmail.com +------------------------------------------------------------------------------ +Licence: + This file is part of phasicFlow code. It is a free software for simulating + granular and multiphase flows. You can redistribute it and/or modify it under + the terms of GNU General Public License v3 or any other later versions. + + phasicFlow is distributed to help others in their research in the field of + granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +-----------------------------------------------------------------------------*/ + + +#ifndef __bTypes_H__ +#define __bTypes_H__ + +#include "builtinTypes.H" +#include "bTypesFunctions.H" +#include "Logical.H" +#include "math.H" + + + + +#endif diff --git a/src/phasicFlow/types/basicTypes/builtinTypes.H b/src/phasicFlow/types/basicTypes/builtinTypes.H index 19d38e60..d4d418d1 100755 --- a/src/phasicFlow/types/basicTypes/builtinTypes.H +++ b/src/phasicFlow/types/basicTypes/builtinTypes.H @@ -42,13 +42,15 @@ using int16 = short int; using int32 = int; -using int64 = long long int; +using int64 = long long int; -using uint32 = unsigned int; +using uint16 = unsigned short int ; -using label = std::size_t; +using uint32 = unsigned int; -using word = std:string; +using label = std::size_t; + +using word = std::string; } // end of pFlow