@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)
2
2
3
3
project (Microphysics
4
4
VERSION 1.0.0
5
- DESCRIPTION "building primordial_chemistry network in Microphysics with CMake"
5
+ DESCRIPTION "building primordial_chemistry or metal_chemistry networks in Microphysics with CMake"
6
6
LANGUAGES CXX C)
7
7
8
8
#----------------------------------------------------------------------------------------------------------------------
@@ -23,11 +23,11 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
23
23
set (integrationparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /integration/_parameters" )
24
24
set (unittestparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /unit_test/_parameters" )
25
25
26
- set (networkpropfile "${output_dir} /network_properties.H" )
27
26
28
27
if (${network_name} STREQUAL "gamma_law" )
29
28
set (EOSparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /EOS/gamma_law/_parameters" )
30
29
30
+ set (networkpropfile "${output_dir} /network_properties.H" )
31
31
set (networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/gammalaw.net" )
32
32
set (networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/" )
33
33
set (networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/network_header.template" )
@@ -44,6 +44,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
44
44
set (gamma_law_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /interfaces/eos_data.cpp
45
45
${CMAKE_CURRENT_FUNCTION_LIST_DIR} /interfaces/network_initialization.cpp
46
46
${output_dir} /extern_parameters.cpp PARENT_SCOPE)
47
+ execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/write_network.py" --header_template "${networkheadertemplatefile} " --header_output "${networkpropfile} " -s "${networkfile} " WORKING_DIRECTORY ${output_dir} /)
47
48
48
49
elseif (${network_name} STREQUAL "primordial_chem" )
49
50
#need these to write extern_parameters.H
@@ -52,6 +53,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
52
53
set (networkpcparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/primordial_chem/_parameters" )
53
54
54
55
#similarly, we want network_properties.H
56
+ set (networkpropfile "${output_dir} /network_properties.H" )
55
57
set (networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/primordial_chem/pynucastro.net" )
56
58
set (networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/primordial_chem/" )
57
59
set (networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/network_header.template" )
@@ -71,7 +73,7 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
71
73
#so, if any of the _parameter files are changed, one needs to re-run 'cmake'
72
74
#to generate updated header files
73
75
74
- if (BUILD_UNIT_TEST )
76
+ if (BUILD_UNIT_TEST_PC )
75
77
execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /util/build_scripts/write_probin.py" --pa "${paramfile} ${EOSparamfile}
76
78
${networkpcparamfile} ${networkparamfile} ${VODEparamfile} ${integrationparamfile} ${unittestparamfile} " --use_namespace WORKING_DIRECTORY ${output_dir} /)
77
79
else ()
@@ -88,13 +90,61 @@ function(setup_target_for_microphysics_compilation network_name output_dir)
88
90
89
91
#below for NAUX
90
92
execute_process (COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PYTHONPATH} :${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null" python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/get_naux.py" --net "${networkdir} " --microphysics_path "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /" WORKING_DIRECTORY ${output_dir} /)
93
+ execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/write_network.py" --header_template "${networkheadertemplatefile} " --header_output "${networkpropfile} " -s "${networkfile} " WORKING_DIRECTORY ${output_dir} /)
94
+
95
+ elseif (${network_name} STREQUAL "metal_chem" )
96
+ #need these to write extern_parameters.H
97
+ set (paramfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /unit_test/burn_cell_metal_chem/_parameters" )
98
+ set (EOSparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /EOS/metal_chem/_parameters" )
99
+ set (networkmcparamfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/metal_chem/_parameters" )
100
+
101
+ #similarly, we want network_properties.H
102
+ set (networkpropfile "${output_dir} /network_properties.H" )
103
+ set (networkfile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/metal_chem/pynucastro.net" )
104
+ set (networkdir "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/metal_chem/" )
105
+ set (networkheadertemplatefile "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/network_header.template" )
106
+
107
+ #DO NOT change the order of the directories below!
108
+ set (metal_chem_dirs ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /util ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /util/gcem/include
109
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /integration/VODE ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /integration/utils
110
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /integration ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /interfaces
111
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /EOS ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /EOS/metal_chem
112
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/metal_chem ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks
113
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /constants
114
+ PARENT_SCOPE)
115
+
116
+ #we need to have extern_parameters.cpp be available at configure time
117
+ #the script write_probin.py writes this .cpp file so we call it here
118
+ #note, execute_process only works on 'cmake' and not 'make'
119
+ #so, if any of the _parameter files are changed, one needs to re-run 'cmake'
120
+ #to generate updated header files
121
+
122
+ if (BUILD_UNIT_TEST_MC)
123
+ execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /util/build_scripts/write_probin.py" --pa "${paramfile} ${EOSparamfile}
124
+ ${networkmcparamfile} ${networkparamfile} ${VODEparamfile} ${integrationparamfile} ${unittestparamfile} " --use_namespace WORKING_DIRECTORY ${output_dir} /)
125
+ else ()
126
+ #do not need paramfile and unittestparamfile
127
+ execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /util/build_scripts/write_probin.py" --pa "${EOSparamfile} ${networkmcparamfile}
128
+ ${networkparamfile} ${VODEparamfile} ${integrationparamfile} " --use_namespace WORKING_DIRECTORY ${output_dir} /)
129
+ endif ()
130
+
131
+ #unlike primordial chem, we also include actual_network_data.cpp here because it is in there that we read in the Semenov opacity table
132
+ set (metal_chem_sources ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /interfaces/eos_data.cpp
133
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /interfaces/network_initialization.cpp
134
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /EOS/metal_chem/actual_eos_data.cpp
135
+ ${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/metal_chem/actual_network_data.cpp
136
+ ${output_dir} /extern_parameters.cpp PARENT_SCOPE)
137
+
138
+
139
+ #below for NAUX
140
+ execute_process (COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${PYTHONPATH} :${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null" python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/get_naux.py" --net "${networkdir} " --microphysics_path "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /" WORKING_DIRECTORY ${output_dir} /)
141
+ execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/write_network.py" --header_template "${networkheadertemplatefile} " --header_output "${networkpropfile} " -s "${networkfile} " WORKING_DIRECTORY ${output_dir} /)
91
142
92
143
else ()
93
- message (FATAL_ERROR "Given network_name " ${network_name} " currently not supported. Use either 'gamma_law' or 'primordial_chem' " )
144
+ message (FATAL_ERROR "Given network_name " ${network_name} " currently not supported. Use either 'gamma_law' or 'primordial_chem' or 'metal_chem' " )
94
145
95
146
endif ()
96
147
97
- execute_process (COMMAND python3 "${CMAKE_CURRENT_FUNCTION_LIST_DIR} /networks/general_null/write_network.py" --header_template "${networkheadertemplatefile} " --header_output "${networkpropfile} " -s "${networkfile} " WORKING_DIRECTORY ${output_dir} /)
98
148
99
149
endfunction ()
100
150
@@ -126,8 +176,9 @@ endif()
126
176
127
177
#set a cache variable that controls whether
128
178
#we want to build the unit test or not
129
- set (BUILD_UNIT_TEST false CACHE BOOL "Do you want to build the unit test? (true/false)" )
130
- message ("Building unit test -- ${BUILD_UNIT_TEST} " )
179
+ set (BUILD_UNIT_TEST_PC false CACHE BOOL "Do you want to build the primordial chem unit test? (true/false)" )
180
+
181
+ set (BUILD_UNIT_TEST_MC false CACHE BOOL "Do you want to build the metal chem unit test? (true/false)" )
131
182
132
183
add_compile_options (-Werror -Wall -Wextra)
133
184
@@ -140,19 +191,28 @@ add_compile_options(-Werror -Wall -Wextra)
140
191
#this will generate a warning but it will build successfully
141
192
#do not need unit_test paramfiles when unit_test is not built
142
193
143
- if (BUILD_UNIT_TEST)
144
- setup_target_for_microphysics_compilation("primordial_chem" ${CMAKE_BINARY_DIR} )
194
+ if (BUILD_UNIT_TEST_PC AND BUILD_UNIT_TEST_MC)
195
+ message (FATAL_ERROR "Cannot build both primordial chem and metal chem tests at the same time!" )
196
+ endif ()
145
197
198
+ if (BUILD_UNIT_TEST_PC)
199
+ #Build primordial chem unit test
200
+ setup_target_for_microphysics_compilation("primordial_chem" ${CMAKE_BINARY_DIR} )
146
201
include_directories (${primordial_chem_dirs} )
147
202
148
- #adding unit_test as subdirectories
203
+ #adding unit_tests as subdirectories
149
204
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /unit_test)
150
- message ("Building primordial chem unit test" )
151
205
152
- else ()
206
+ elseif (BUILD_UNIT_TEST_MC)
207
+ #Build metal chem unit test
208
+ setup_target_for_microphysics_compilation("metal_chem" ${CMAKE_BINARY_DIR} )
209
+ include_directories (${metal_chem_dirs} )
210
+
211
+ #adding unit_tests as subdirectories
212
+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /unit_test)
153
213
154
214
message ("Not building primordial chem unit test" )
155
215
endif ()
156
216
157
-
217
+ #Sample command: cmake .. -DBUILD_UNIT_TEST_MC=True -DBUILD_AMReX=True -DAMReX_SPACEDIM=1
158
218
0 commit comments