Skip to content

Commit

Permalink
New radiation test cases (#42)
Browse files Browse the repository at this point in the history
* added symmetric hohlraum. Changed the way neumann cells work. ALl old test cases are now broken

* created lattice test case and mesh generator

* startet new scalar outputs

* first QOIs work

* finished lattice QOI

* added hohlraum qois

* fixed small bug with openMP

* fix bug with probing moments

* project restructrue

* debugging

* started variation QOIs

* added variation QOI

* startet incorporation of the UM-Bridge framework

* setup um-bridge test case lattice - errror with network connection

* added design parameters for the lattice test case

* refactoring of problem specific QOIs. put to the corresponding problem class

* included pointer to quadrature class to problem. WIll help reduce the memory footprint of the solver

* made all qois and design parameters part of the corresponding problem class

* fixed compiler warning about included map

* fix small bug

* fixed ninja compile bug

* started hohlraum probing qoi

* fixed type conversion bug

* fixed compile problems. Added sampling line hohlraum test case

* added line variance

* added green line scalar output

* segfault somewhere in hohlraum

* resordered meshing scripts. startet refined mesh for lattice

* mesh refinement for lattice

* updated requirements

* fixed computation of the characteristic length in 2d

* mesh io verbose

* mesh io verbose

* added folder for mesh files geo

* cascading file lattice

* repaired lattice geo file

* fixed geo file

* adapted cascade file

* added geo file for rectangular meshes

* segfault introduced

* fixed quad grid

* fixed segfault in hohlraum, linesource and checkerboard

* added singularity container support

* added lattice benchmark

* small change in lattice testcase file

* added solver output

* made progression for transfinite elements in lattice test case variable

* added lattice meshing command

* removed MPI and Python dependencies from KiT-RT

* added MPI singularity def file

* updated geo file

* new example file structure

* changed mesh size to minimal size for example

* small speedup of mesh connectivity

* mesh has now access to config. io writer for connectiivty added

* started to add connectivity loader

* added mesh connectivity reader from file for faster recomputation

* increased cfl number

* update mn and pn solver to new, more memory efficient phhysics implementation

* fixed bug in max absorption computation

* added config files

* updated meshing scripts

* updated meshing scripts

* updated runscript

* fixed outpout of logfiles. part 1

* start debugging logger

* fixed logger filename bug

* added cfg file

* update n80 meshfile to geo progression 0.5

* fixed bug in output verbosity

* added output verbosity

* fixed scatter xs bug

* removed some compiler warnings. fixed test cases for new ghost cell implementation

* fixed several compile warning about unused variables. adapted reference files for validationt test to new boundary conditions WITHOUT mesh connectivity file. There is a BUG in the connectivity reader or writer

* fixed all test cases locally. added unit test for mesh connectivity file reader

* fixed a double defnition bug

* fixed mn test case

* fixed screen output test case

* changed workflow file

* small fix

* small fix

* revert changes to worklow

* revert change in worklof yaml

* fix csv output formatting

* fix output validation test for new formatting

* changed license

* fix

* upped writeout precision

* upped output precifion for logger

* change ??

* loop unrolling sn solver

* added hpc examples sym_hohlraum

* added sym_hohlraum cfg

* changed gitignore

* fix segfault in 2d flux

* temporarily changed mesh resolution

* added quarterhohlraum

* added quarterhohlraum cfg and mesh files

* added quarter hohlraum for high res simulation speedup

* added meshing functionality

* added quarter hohlraum

* reflecting boundary conditions for quarter hohlraum

* qois for quarter hohlraum

* removed cout from main.cpp

* fix unit tests

* started hohlraum design params

* accelerated sn solver by 25% through memory access optimization in Flux update (#45)

* added half lattice benchmark

* added half lattice bench

* updates upwind flux

* fix logger unit test

* Fixed Bug in 2nd order HPC SN solver (#47)

* fix for unit tests?

* started hpc sn solver

* continue mem opt

* continue hpc sn solver

* continue hpc solver

* order 1 solver accellerated'

* lattice qois updated

* clean up of hpc examples

* started 2nd order solver

* added half lattice and 2nd order

* 2nd order solver ready with venkat limiter

* fix output bug

* added 2nd order in time (inefficiently)

* bugfixing 2nd order

* changed initial condiiton to 0

* arrg

* linesource 1st order paralelized

* compartmentalize fvm update and fluxes (10% performance loss)

* fixed lattice

* started 2nd order flux

* restore bs limiter

* fixed 2nd order lattice

* temp comment out hohlraum specific stuff

* fixed hohlraum 2nd order with all QOIS

---------

Co-authored-by: Steffen Schotthöfer <steffen.schotthoefer@kit.edu>

* Memory optimization solver (#46)

* fix for unit tests?

* started hpc sn solver

* continue mem opt

* continue hpc sn solver

* continue hpc solver

* order 1 solver accellerated'

* lattice qois updated

* clean up of hpc examples

* started 2nd order solver

* added half lattice and 2nd order

* 2nd order solver ready with venkat limiter

* fix output bug

* added 2nd order in time (inefficiently)

* bugfixing 2nd order

* changed initial condiiton to 0

---------

Co-authored-by: Steffen Schotthöfer <steffen.schotthoefer@kit.edu>

* fixed small debug verbosity bugs

* fix unit tests

* fix screen output test

* fixed screen output test - accounting for extra time step to fill up to t_f

* fixes csv logger test case

* fixed logger output now?

* another logger fix

* added container builder

* remove debug output

* rename sy hohlruam cfg

* prepared for 2nd order in time

* updated hohlraum qois

* added singularity install script kitrt

* changed flux limiter to venkatakrishnan

* quarter hohlraum now works

* fix segfaults

* fix race condition

* added variable green region to hozhlraum

* variable red absorption region

* fixed bug in boundary condition quarter hohlraum

* fixed vtk memory leak

* updated hohlraum design params

* update options

* comment unused var out

* added lattice qois according to testbed v2

* updated quarter hohlraum test case

* bugfix

* parallel conmat (experimental)

* parallel mesh connectivity gives segfault

* mesh connectivity accelerated - experimental

* accelerated solver startup

* set forced connectivity wirte as an option

* does not write connectivity file anymore when forced connectivity is active

* fixed bug in cell of coord identification

* added moment output for hpc sn solver

* fixed 2nd order solver

* fixed bug in absorption calculation of the hohlraum center capsule

* added total absorption as output field

* fixed hohrlaum absorption coefficient

* Mpi sn solver (#49)

* remove debugging output

* fixed mpi bugs

* fixed bug in logging mechanism

* hohlraum outputs mpi parallelized

* fixed output bug in hohlraum absorption

* fix green domain

* test ball probing moments

* fixed parameter issue with hohlraum

* fixed hohlraum parameters. Consitent with original crocett paper from 2019

* fixed issue when cell length is larger than ball

* fixed indexing bug

* fix reference file for screen output

* remove meshing tests - not needed

---------

Co-authored-by: Steffen Schotthoefer
Co-authored-by: Steffen Schotthoefer
  • Loading branch information
ScSteffen authored Sep 12, 2024
1 parent 6d42526 commit be64104
Show file tree
Hide file tree
Showing 139 changed files with 10,989 additions and 3,698 deletions.
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

0 comments on commit be64104

Please sign in to comment.