Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2024 #44

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ jobs:
- name: Run unit tests
run: |
cd build
./unit_tests

OMP_NUM_THREADS=1 ./unit_tests -r junit > unit_tests_report.xml

- name: Code coverage
run: |
cpp-coveralls -r . -b "build/" -i "src/" -i "include/" --exclude "ext/" --gcov-options "\-lp" --verbose
cpp-coveralls -r . -b "build/" -i "src/" -i "include/" --exclude "ext/" --gcov-options "\-lp" --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### Project specific ###
*.con
*.cfg
bin/*
*.su2
Expand Down
40 changes: 10 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option( BUILD_DOC "builds Doxygen and Sphinx documentation" OFF )
option( BUILD_UNITY "enables unity build for faster compile times" ON )
option( BUILD_CODE_COV "enables compiler option required for code coverage analysis" OFF )
option( BUILD_ML "enables build with tensorflow backend access" OFF )
option( BUILD_MPI "enables build with MPI access" OFF )

#################################################

Expand All @@ -31,8 +32,10 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

find_package( OpenMP REQUIRED )

find_package( MPI REQUIRED )
include_directories( ${MPI_INCLUDE_PATH} )
if( BUILD_MPI )
find_package( MPI REQUIRED )
include_directories( ${MPI_INCLUDE_PATH} )
endif()

find_package( LAPACK REQUIRED )
include_directories( ${LAPACK_INCLUDE_DIR} )
Expand All @@ -41,9 +44,6 @@ find_package( BLAS )

find_package( VTK COMPONENTS vtkIOGeometry vtkFiltersCore REQUIRED )

find_package( Python3 COMPONENTS Interpreter Development NumPy REQUIRED )
include_directories( ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS} )

add_compile_definitions( KITRT_PYTHON_PATH="${CMAKE_SOURCE_DIR}/python" )
add_compile_definitions( BLAZE_USE_SHARED_MEMORY_PARALLELIZATION=0 )
message( STATUS "Blaze: Shared memory parallelization disabled" )
Expand All @@ -61,7 +61,11 @@ include_directories( ${CMAKE_SOURCE_DIR}/ext/blaze )
include_directories( ${CMAKE_SOURCE_DIR}/ext/cpptoml/include )
include_directories( ${CMAKE_SOURCE_DIR}/ext/spdlog/include )

set( CORE_LIBRARIES ${Python3_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX -lstdc++fs )
if( BUILD_MPI )
set( CORE_LIBRARIES ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX -lstdc++fs )
else()
set( CORE_LIBRARIES ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX -lstdc++fs )
endif()


#################################################
Expand Down Expand Up @@ -106,30 +110,6 @@ target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELWITHDEBINFO>
target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
#################################################


### BUILD ML ###################################
# Standalone ML Build (legacy)
#if( BUILD_ML )
# # Tensorflow
# include_directories( ${CMAKE_SOURCE_DIR}/ext/cppflow/include/ )
# find_library(TENSORFLOW_LIB tensorflow)
# add_executable( ${CMAKE_PROJECT_NAME} ${SRCS} ${EXT_SRCS} )
#
# # Specify Path for tensorflow models
# add_compile_definitions( TENSORFLOW_MODEL_PATH="${CMAKE_SOURCE_DIR}/tfmodels" )
#
# target_compile_definitions( ${CMAKE_PROJECT_NAME} PUBLIC BUILD_ML )
# target_link_libraries( ${CMAKE_PROJECT_NAME} ${CORE_LIBRARIES} ${TENSORFLOW_LIB})
# set_target_properties( ${CMAKE_PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin" )
#
# target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:DEBUG>:${KITRT_DEBUG_OPTIONS}>" )
# target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:${KITRT_RELWITHDEBINFO_OPTIONS}>" )
# target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
#
#endif()
#################################################


### BUILD UNIT TESTS ############################
if( BUILD_TESTING )
include( CTest )
Expand Down
7 changes: 4 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Copyright 2020 Karlsruhe Institute of Technology - Steinbuch Centre for Computing
Copyright 2024 Steffen Schotthoefer, Pia Stammer, Jonas Kusch.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including the rights to use, copy, modify, merge, publish, the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
It is prohibited to sell copies of the software or use the software in any commerical context.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
123 changes: 123 additions & 0 deletions examples/cascade_lattice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import os
import subprocess


def main():
# Example usage:
quad_order = 19
cl_fine_vals = [0.02, 0.02, 0.01, 0.005]
cl_coarse = 0.05
cl_boundary = 0.2
length = 0.05

for i in range(len(cl_fine_vals)):
cl_fine = cl_fine_vals[i]
modify_and_run_geo_file(
cl_fine=cl_fine, cl_coarse=cl_coarse, cl_boundary=cl_boundary, length=length
)
modify_quad_order(quad_order=quad_order)
new_log_file, log_dir = modify_and_save_log_file(
quad_order, cl_fine, cl_coarse, cl_boundary, length
)
print(f"New log file name: {new_log_file}")
print(f"Log directory: {log_dir}")
run_cpp_program(config_file_path="lattice.cfg")

return 0


def modify_and_run_geo_file(cl_fine, cl_coarse, cl_boundary, length):
# Define the file path
geo_file_path = "meshes/geo_files/lattice_refined.geo"

# Read the contents of the .geo file
with open(geo_file_path, "r") as file:
lines = file.readlines()

# Modify the variables in the first 4 lines
lines[0] = f"cl_fine = {cl_fine};\n"
lines[1] = f"cl_coarse = {cl_coarse};\n"
lines[2] = f"cl_boundary = {cl_boundary};\n"
lines[3] = f"length = {length};\n"

# Save the modified .geo file
with open(geo_file_path, "w") as file:
file.writelines(lines)

# Execute the command
command = f"gmsh {geo_file_path} -2 -format su2 -save_all"
os.system(command)


def modify_quad_order(quad_order):
# Define the file path
cfg_file_path = "lattice.cfg"

# Read the contents of the lattice.cfg file
with open(cfg_file_path, "r") as file:
lines = file.readlines()

# Find the line containing "QUAD_ORDER" and modify it
for i, line in enumerate(lines):
if "QUAD_ORDER" in line:
lines[i] = f"QUAD_ORDER = {quad_order}\n"
break

# Save the modified lattice.cfg file
with open(cfg_file_path, "w") as file:
file.writelines(lines)


def modify_and_save_log_file(quad_order, cl_fine, cl_coarse, cl_boundary, length):
# Define the file path
cfg_file_path = "lattice.cfg"

# Read the contents of the lattice.cfg file
with open(cfg_file_path, "r") as file:
lines = file.readlines()

# Identify the lines containing "LOG_DIR" and "LOG_FILE"
log_dir_line = next(line for line in lines if "LOG_DIR" in line)
log_file_line = next(line for line in lines if "LOG_FILE" in line)
vtk_file_line = next(line for line in lines if "OUTPUT_FILE" in line)

print(log_file_line)
# Extract the current log directory and file name
current_log_dir = log_dir_line.split("=")[1].strip()
current_log_file = log_file_line.split("=")[1].strip()

# Construct the new log file name
new_log_file = f"lattice_quad_order_{quad_order}_cl_fine_{cl_fine}_cl_coarse_{cl_coarse}_cl_boundary_{cl_boundary}_length_{length}"
new_vtk_file = f"lattice_quad_order_{quad_order}_cl_fine_{cl_fine}_cl_coarse_{cl_coarse}_cl_boundary_{cl_boundary}_length_{length}"

# Update the log file name in the lines list
log_file_line_new = f"LOG_FILE = {new_log_file}\n"
vtk_file_line_new = f"OUTPUT_FILE = {new_vtk_file}\n"
lines[lines.index(log_file_line)] = log_file_line_new
lines[lines.index(vtk_file_line)] = vtk_file_line_new

# Save the modified lattice.cfg file
with open(cfg_file_path, "w") as file:
file.writelines(lines)

# Return the new log file name and log directory
return new_log_file, current_log_dir


def run_cpp_program(config_file_path):
# Define the path to the C++ program
cpp_program_path = "../build/KiT-RT"

# Construct the command to run the C++ program with the specified configuration file
command = [cpp_program_path, config_file_path]

try:
# Run the C++ program
subprocess.run(command, check=True)
print("C++ program executed successfully.")
except subprocess.CalledProcessError as e:
print(f"Error running C++ program: {e}")


if __name__ == "__main__":
main()
48 changes: 48 additions & 0 deletions examples/configs/lattice_SN.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lattice Benchmarking File SN %
% Author <Steffen Schotthöfer> %
% Date 08.01.2024 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% ----IO specification ----
%
OUTPUT_DIR = result_lattice
OUTPUT_FILE = lattice_quad_order_19_grid_20
LOG_DIR = result_lattice/logs
LOG_FILE = lattice_quad_order_19_grid_20
MESH_FILE = meshes/testcases/lattice/lattice_rectangular.su2
%
% --- Problem definition ---
%
PROBLEM = LATTICE
TIME_FINAL = 2.8
SPATIAL_DIM = 3
SOURCE_MAGNITUDE = 1.0
%
% ---- Solver specifications ----
%
% Solver type
SOLVER = SN_SOLVER
% CFL number
CFL_NUMBER = 0.95
% Reconstruction order
RECONS_ORDER = 2
%
% ---- Boundary Conditions ----
%
BC_NEUMANN = ( void )
%
% ----- Quadrature Specification ---
%
QUAD_TYPE = LEBEDEV
QUAD_ORDER = 19
%
% ----- Output ----
%
VOLUME_OUTPUT = (MINIMAL)
VOLUME_OUTPUT_FREQUENCY = 0
SCREEN_OUTPUT = (ITER, MASS,RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW, CUR_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION )
SCREEN_OUTPUT_FREQUENCY = 10
HISTORY_OUTPUT = (ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_OUTFLOW, MAX_OUTFLOW, CUR_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION)
HISTORY_OUTPUT_FREQUENCY = 1
Loading
Loading