Skip to content

Commit 14731a6

Browse files
This is the first merge from main into MPI branch
Merge branch 'main' into local-MPI
2 parents 3d0f31a + ab856e1 commit 14731a6

578 files changed

Lines changed: 118401 additions & 27936 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/scripts/sync-wiki.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import re
5+
import yaml
6+
import sys
7+
8+
# Constants
9+
REPO_URL = "https://github.com/PhasicFlow/phasicFlow"
10+
REPO_PATH = os.path.join(os.environ.get("GITHUB_WORKSPACE", ""), "repo")
11+
WIKI_PATH = os.path.join(os.environ.get("GITHUB_WORKSPACE", ""), "wiki")
12+
MAPPING_FILE = os.path.join(REPO_PATH, "doc/mdDocs/markdownList.yml")
13+
14+
def load_mapping():
15+
"""Load the markdown to wiki page mapping file."""
16+
try:
17+
with open(MAPPING_FILE, 'r') as f:
18+
data = yaml.safe_load(f)
19+
return data.get('mappings', [])
20+
except Exception as e:
21+
print(f"Error loading mapping file: {e}")
22+
return []
23+
24+
def convert_relative_links(content, source_path):
25+
"""Convert relative links in markdown content to absolute URLs."""
26+
# Find markdown links with regex pattern [text](url)
27+
md_pattern = r'\[([^\]]+)\]\(([^)]+)\)'
28+
29+
# Find HTML img tags
30+
img_pattern = r'<img\s+src=[\'"]([^\'"]+)[\'"]'
31+
32+
def replace_link(match):
33+
link_text = match.group(1)
34+
link_url = match.group(2)
35+
36+
# Skip if already absolute URL or anchor
37+
if link_url.startswith(('http://', 'https://', '#', 'mailto:')):
38+
return match.group(0)
39+
40+
# Get the directory of the source file
41+
source_dir = os.path.dirname(source_path)
42+
43+
# Create absolute path from repository root
44+
if link_url.startswith('/'):
45+
# If link starts with /, it's already relative to repo root
46+
abs_path = link_url
47+
else:
48+
# Otherwise, it's relative to the file location
49+
abs_path = os.path.normpath(os.path.join(source_dir, link_url))
50+
if not abs_path.startswith('/'):
51+
abs_path = '/' + abs_path
52+
53+
# Convert to GitHub URL
54+
github_url = f"{REPO_URL}/blob/main{abs_path}"
55+
return f"[{link_text}]({github_url})"
56+
57+
def replace_img_src(match):
58+
img_src = match.group(1)
59+
60+
# Skip if already absolute URL
61+
if img_src.startswith(('http://', 'https://')):
62+
return match.group(0)
63+
64+
# Get the directory of the source file
65+
source_dir = os.path.dirname(source_path)
66+
67+
# Create absolute path from repository root
68+
if img_src.startswith('/'):
69+
# If link starts with /, it's already relative to repo root
70+
abs_path = img_src
71+
else:
72+
# Otherwise, it's relative to the file location
73+
abs_path = os.path.normpath(os.path.join(source_dir, img_src))
74+
if not abs_path.startswith('/'):
75+
abs_path = '/' + abs_path
76+
77+
# Convert to GitHub URL (use raw URL for images)
78+
github_url = f"{REPO_URL}/raw/main{abs_path}"
79+
return f'<img src="{github_url}"'
80+
81+
# Replace all markdown links
82+
content = re.sub(md_pattern, replace_link, content)
83+
84+
# Replace all img src tags
85+
content = re.sub(img_pattern, replace_img_src, content)
86+
87+
return content
88+
89+
def process_file(source_file, target_wiki_page):
90+
"""Process a markdown file and copy its contents to a wiki page."""
91+
source_path = os.path.join(REPO_PATH, source_file)
92+
target_path = os.path.join(WIKI_PATH, f"{target_wiki_page}.md")
93+
94+
print(f"Processing {source_path} -> {target_path}")
95+
96+
try:
97+
# Check if source exists
98+
if not os.path.exists(source_path):
99+
print(f"Source file not found: {source_path}")
100+
return False
101+
102+
# Read source content
103+
with open(source_path, 'r') as f:
104+
content = f.read()
105+
106+
# Convert relative links
107+
content = convert_relative_links(content, source_file)
108+
109+
# Write to wiki page
110+
with open(target_path, 'w') as f:
111+
f.write(content)
112+
113+
return True
114+
115+
except Exception as e:
116+
print(f"Error processing {source_file}: {e}")
117+
return False
118+
119+
def main():
120+
# Check if wiki directory exists
121+
if not os.path.exists(WIKI_PATH):
122+
print(f"Wiki path not found: {WIKI_PATH}")
123+
sys.exit(1)
124+
125+
# Load mapping
126+
mappings = load_mapping()
127+
if not mappings:
128+
print("No mappings found in the mapping file")
129+
sys.exit(1)
130+
131+
print(f"Found {len(mappings)} mappings to process")
132+
133+
# Process each mapping
134+
success_count = 0
135+
for mapping in mappings:
136+
source = mapping.get('source')
137+
target = mapping.get('target')
138+
139+
if not source or not target:
140+
print(f"Invalid mapping: {mapping}")
141+
continue
142+
143+
if process_file(source, target):
144+
success_count += 1
145+
146+
print(f"Successfully processed {success_count} of {len(mappings)} files")
147+
148+
# Exit with error if any file failed
149+
if success_count < len(mappings):
150+
sys.exit(1)
151+
152+
if __name__ == "__main__":
153+
main()

.github/workflows/sync-wiki.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Sync-Wiki
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**/*.md"
9+
- ".github/workflows/sync-wiki.yml"
10+
- "doc/mdDocs/markdownList.yml"
11+
- ".github/scripts/sync-wiki.py"
12+
workflow_dispatch:
13+
14+
jobs:
15+
sync-wiki:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Repository
19+
uses: actions/checkout@v3
20+
with:
21+
path: repo
22+
- name: Checkout Wiki
23+
uses: actions/checkout@v3
24+
with:
25+
repository: ${{ github.repository }}.wiki
26+
path: wiki
27+
continue-on-error: true
28+
- name: Create Wiki Directory if Not Exists
29+
run: |
30+
if [ ! -d "wiki" ]; then
31+
mkdir -p wiki
32+
cd wiki
33+
git init
34+
git config user.name "${{ github.actor }}"
35+
git config user.email "${{ github.actor }}@users.noreply.github.com"
36+
git remote add origin "https://github.com/${{ github.repository }}.wiki.git"
37+
fi
38+
- name: Set up Python
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: '3.10'
42+
- name: Install dependencies
43+
run: pip install pyyaml
44+
- name: Sync markdown files to Wiki
45+
run: |
46+
python $GITHUB_WORKSPACE/repo/.github/scripts/sync-wiki.py
47+
env:
48+
GITHUB_REPOSITORY: ${{ github.repository }}
49+
- name: Push changes to wiki
50+
run: |
51+
cd wiki
52+
git config user.name "${{ github.actor }}"
53+
git config user.email "${{ github.actor }}@users.noreply.github.com"
54+
git add .
55+
if git status --porcelain | grep .; then
56+
git commit -m "Auto sync wiki from main repository"
57+
git push --set-upstream https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.wiki.git master -f
58+
else
59+
echo "No changes to commit"
60+
fi

CMakeLists.txt

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,26 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
33
# set the project name and version
44
project(phasicFlow VERSION 1.0 )
55

6-
set(CMAKE_CXX_STANDARD 17 CACHE STRING "" FORCE)
6+
set(CMAKE_CXX_STANDARD 20 CACHE STRING "" FORCE)
77
set(CMAKE_CXX_STANDARD_REQUIRED True)
88
set(CMAKE_INSTALL_PREFIX ${phasicFlow_SOURCE_DIR} CACHE PATH "Install path of phasicFlow" FORCE)
9-
set(CMAKE_BUILD_TYPE Debug CACHE STRING "build type" FORCE)
9+
set(CMAKE_BUILD_TYPE Release CACHE STRING "build type")
1010
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build using shared libraries" FORCE)
1111
mark_as_advanced(FORCE var BUILD_SHARED_LIBS)
1212

13-
message(STATUS ${CMAKE_INSTALL_PREFIX})
13+
message(STATUS "Install prefix is:" ${CMAKE_INSTALL_PREFIX})
1414

1515
include(cmake/globals.cmake)
1616

17-
#Kokkos directory to be included
18-
set(Kokkos_Source_DIR)
19-
20-
if(DEFINED ENV{Kokkos_DIR})
21-
set(Kokkos_Source_DIR $ENV{Kokkos_DIR})
22-
else()
23-
set(Kokkos_Source_DIR $ENV{HOME}/Kokkos/kokkos)
24-
endif()
25-
message(STATUS "Kokkos source directory is ${Kokkos_Source_DIR}")
26-
add_subdirectory(${Kokkos_Source_DIR} ${phasicFlow_BINARY_DIR}/kokkos)
27-
Kokkos_cmake_settings()
28-
29-
3017
option(pFlow_STD_Parallel_Alg "Use TTB std parallel algorithms" ON)
3118
option(pFlow_Build_Serial "Build phasicFlow and backends for serial execution" OFF)
3219
option(pFlow_Build_OpenMP "Build phasicFlow and backends for OpenMP execution" OFF)
3320
option(pFlow_Build_Cuda "Build phasicFlow and backends for Cuda execution" OFF)
3421
option(pFlow_Build_Double "Build phasicFlow with double precision floating-oint variables" ON)
3522
option(pFlow_Build_MPI "Build for MPI parallelization. This will enable multi-gpu run, CPU run on clusters (distributed memory machine). Use this combination Cuda+MPI, OpenMP + MPI or Serial+MPI " OFF)
3623

24+
#for installing the required packages
25+
include(cmake/preReq.cmake)
3726

3827
if(pFlow_Build_Serial)
3928
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Serial execution" FORCE)
@@ -46,7 +35,8 @@ elseif(pFlow_Build_OpenMP )
4635
set(Kokkos_ENABLE_OPENMP ON CACHE BOOL "OpenMP execution" FORCE)
4736
set(Kokkos_ENABLE_CUDA OFF CACHE BOOL "Cuda execution" FORCE)
4837
set(Kokkos_ENABLE_CUDA_LAMBDA OFF CACHE BOOL "Cuda execution" FORCE)
49-
set(Kokkos_DEFAULT_HOST_PARALLEL_EXECUTION_SPACE SERIAL CACHE STRING "" FORCE)
38+
set(Kokkos_DEFAULT_HOST_PARALLEL_EXECUTION_SPACE Serial CACHE STRING "" FORCE)
39+
set(Kokkos_DEFAULT_DEVICE_PARALLEL_EXECUTION_SPACE OpenMP CACHE STRING "" FORCE)
5040
set(Kokkos_ENABLE_CUDA_CONSTEXPR OFF CACHE BOOL "Enable constexpr on cuda code" FORCE)
5141
elseif(pFlow_Build_Cuda)
5242
set(Kokkos_ENABLE_SERIAL ON CACHE BOOL "Serial execution" FORCE)
@@ -65,18 +55,17 @@ include(cmake/makeExecutableGlobals.cmake)
6555

6656
configure_file(phasicFlowConfig.H.in phasicFlowConfig.H)
6757
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
58+
6859
#add a global include directory
6960
include_directories(src/setHelpers src/demComponent "${PROJECT_BINARY_DIR}")
7061

71-
7262
add_subdirectory(src)
7363

7464
add_subdirectory(solvers)
7565

7666
add_subdirectory(utilities)
7767

78-
#add_subdirectory(DEMSystems)
79-
add_subdirectory(testIO)
68+
add_subdirectory(DEMSystems)
8069

8170
install(FILES "${PROJECT_BINARY_DIR}/phasicFlowConfig.H"
8271
DESTINATION include)

DEMSystems/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11

22
set(SourceFiles
3+
domainDistribute/domainDistribute.cpp
34
DEMSystem/DEMSystem.cpp
4-
sphereDEMSystem/sphereDEMSystem.cpp
55
sphereDEMSystem/sphereFluidParticles.cpp
6-
domainDistribute/domainDistribute.cpp
6+
sphereDEMSystem/sphereDEMSystem.cpp
7+
grainDEMSystem/grainFluidParticles.cpp
8+
grainDEMSystem/grainDEMSystem.cpp
79
)
810

911
set(link_libs Kokkos::kokkos phasicFlow Particles Geometry Property Interaction Interaction Utilities)

DEMSystems/DEMSystem/DEMSystem.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ pFlow::DEMSystem::DEMSystem(
3333
ControlDict_()
3434
{
3535

36-
REPORT(0)<<"Initializing host/device execution spaces . . . \n";
37-
REPORT(1)<<"Host execution space is "<< greenText(DefaultHostExecutionSpace::name())<<endREPORT;
38-
REPORT(1)<<"Device execution space is "<<greenText(DefaultExecutionSpace::name())<<endREPORT;
36+
REPORT(0)<<"Initializing host/device execution spaces . . . \n";
37+
REPORT(1)<<"Host execution space is "<< Green_Text(DefaultHostExecutionSpace::name())<<END_REPORT;
38+
REPORT(1)<<"Device execution space is "<<Green_Text(DefaultExecutionSpace::name())<<END_REPORT;
3939

4040
// initialize Kokkos
4141
Kokkos::initialize( argc, argv );
4242

43-
REPORT(0)<<"\nCreating Control repository . . ."<<endREPORT;
43+
REPORT(0)<<"\nCreating Control repository . . ."<<END_REPORT;
4444
Control_ = makeUnique<systemControl>(
4545
ControlDict_.startTime(),
4646
ControlDict_.endTime(),
@@ -87,4 +87,3 @@ pFlow::uniquePtr<pFlow::DEMSystem>
8787

8888
return nullptr;
8989
}
90-

0 commit comments

Comments
 (0)