Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT} ${LIBROM_FLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} ${LIBROM_FLAGS}" CACHE STRING "" FORCE)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (CMAKE_HOST_APPLE)
# Fix linker flags for OSX to use classic linker on XCode 15.0+:
# https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking
Expand Down Expand Up @@ -121,9 +125,9 @@ endif()

add_subdirectory(lib)

# Use the C++11 standard as an entire feature instead of
# Use the C++17 standard as an entire feature instead of
# enumerating individual compiler features for simplicity
target_compile_features(ROM PRIVATE cxx_std_11)
target_compile_features(ROM PRIVATE cxx_std_17)

if (ENABLE_EXAMPLES)
if (USE_MFEM)
Expand Down Expand Up @@ -190,11 +194,12 @@ if (ENABLE_EXAMPLES)
add_executable(${name} examples/${example_dir}/${name}.cpp)

target_link_libraries(${name}
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
${MPI_C_INCLUDE_DIRS}
${MPI_CXX_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach() # IN LISTS examples
file(COPY examples/data DESTINATION ${CMAKE_BINARY_DIR}/examples)
file(COPY examples/merlin DESTINATION ${CMAKE_BINARY_DIR}/examples)
Expand All @@ -211,11 +216,12 @@ if (ENABLE_EXAMPLES)
add_executable(${name} examples/misc/${name}.cpp)

target_link_libraries(${name}
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
${MPI_C_INCLUDE_DIRS}
${MPI_CXX_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach(name) # IN LISTS misc_exmaple_names

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)
Expand All @@ -231,11 +237,12 @@ if (ENABLE_EXAMPLES)
foreach(name IN LISTS regression_test_names)
add_executable(${name} regression_tests/${name}.cpp)
target_link_libraries(${name}
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
PRIVATE ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
${MPI_C_INCLUDE_DIRS}
${MPI_CXX_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach(name) # IN LISTS regression_test_names
endif()
endif(ENABLE_EXAMPLES)
Expand Down
16 changes: 6 additions & 10 deletions examples/dmd/de_dg_advection_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ double t_final = 10.0;
double dt = 0.01;
double ef = 0.9999;
bool visualization = false;
bool visit = false;
bool use_visit = false;
bool paraview = false;
bool adios2 = false;
bool binary = false;
Expand Down Expand Up @@ -478,7 +478,7 @@ double simulation()
// Create data collection for solution output: either VisItDataCollection for
// ascii data files, or SidreDataCollection for binary data files.
DataCollection *dc = NULL;
if (visit)
if (use_visit)
{
if (binary)
{
Expand Down Expand Up @@ -791,7 +791,7 @@ double simulation()
sout << "solution\n" << pmesh << u_gf << flush;
}

if (visit)
if (use_visit)
{
dc->SetCycle(ti);
dc->SetTime(t);
Expand Down Expand Up @@ -946,15 +946,11 @@ double simulation()
VisItDataCollection dmd_visit_dc("DMD_DG_Advection_Greedy_" +
to_string(f_factor), &pmesh);
dmd_visit_dc.RegisterField("temperature", &u_gf);
if (visit)
if (use_visit)
{
dmd_visit_dc.SetCycle(0);
dmd_visit_dc.SetTime(0.0);
dmd_visit_dc.Save();
}

if (visit)
{
for (int i = 1; i < ts.size(); i++)
{
if (i == ts.size() - 1 || (i % vis_steps) == 0)
Expand Down Expand Up @@ -1148,7 +1144,7 @@ int main(int argc, char *argv[])
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
"--no-visualization",
"Enable or disable GLVis visualization.");
args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit",
args.AddOption(&use_visit, "-visit", "--visit-datafiles", "-no-visit",
"--no-visit-datafiles",
"Save data files for VisIt (visit.llnl.gov) visualization.");
args.AddOption(&paraview, "-paraview", "--paraview-datafiles", "-no-paraview",
Expand Down Expand Up @@ -1271,7 +1267,7 @@ int main(int argc, char *argv[])
else if (build_database)
{
MFEM_VERIFY(rdim != -1, "rdim must be set.");
MFEM_VERIFY(!visit
MFEM_VERIFY(!use_visit
&& !visualization,
"visit and visualization must be turned off during the build_database phase.")
std::ifstream infile(io_dir+"/dg_advection_greedy_parametric_data");
Expand Down
16 changes: 6 additions & 10 deletions examples/dmd/de_parametric_heat_conduction_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ double greedy_relative_diff_tol = 0.01;
int greedy_subset_size = 2;
int greedy_convergence_subset_size = 3;
bool visualization = false;
bool visit = false;
bool use_visit = false;
int vis_steps = 5;
bool adios2 = false;
const char *baseoutputname = "";
Expand Down Expand Up @@ -306,7 +306,7 @@ double simulation()
to_string(radius) + "_" + to_string(alpha) + "_" + to_string(cx) + "_" +
to_string(cy), pmesh);
visit_dc.RegisterField("temperature", &u_gf);
if (!de && !online && visit)
if (!de && !online && use_visit)
{
visit_dc.SetCycle(0);
visit_dc.SetTime(0.0);
Expand Down Expand Up @@ -522,7 +522,7 @@ double simulation()
sout << "solution\n" << *pmesh << u_gf << flush;
}

if (!de && !online && visit)
if (!de && !online && use_visit)
{
visit_dc.SetCycle(ti);
visit_dc.SetTime(t);
Expand Down Expand Up @@ -732,15 +732,11 @@ double simulation()
to_string(radius) + "_" + to_string(alpha) + "_" +
to_string(cx) + "_" + to_string(cy), pmesh);
dmd_visit_dc.RegisterField("temperature", &u_gf);
if (visit)
if (use_visit)
{
dmd_visit_dc.SetCycle(0);
dmd_visit_dc.SetTime(0.0);
dmd_visit_dc.Save();
}

if (visit)
{
for (int i = 1; i < ts.size(); i++)
{
if (i == ts.size() - 1 || (i % vis_steps) == 0)
Expand Down Expand Up @@ -1017,7 +1013,7 @@ int main(int argc, char *argv[])
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
"--no-visualization",
"Enable or disable GLVis visualization.");
args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit",
args.AddOption(&use_visit, "-visit", "--visit-datafiles", "-no-visit",
"--no-visit-datafiles",
"Save data files for VisIt (visit.llnl.gov) visualization.");
args.AddOption(&vis_steps, "-vs", "--visualization-steps",
Expand Down Expand Up @@ -1054,7 +1050,7 @@ int main(int argc, char *argv[])
if (build_database)
{
MFEM_VERIFY(rdim != -1, "rdim must be set.");
MFEM_VERIFY(!visit
MFEM_VERIFY(!use_visit
&& !visualization,
"visit and visualization must be turned off during the build_database phase.")
std::ifstream infile("de_parametric_heat_conduction_greedy_data");
Expand Down
8 changes: 4 additions & 4 deletions examples/prom/de_parametric_maxwell_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool static_cond = false;
bool pa = false;
const char *device_config = "cpu";
bool visualization = false;
bool visit = false;
bool use_visit = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing using namespace std; will likely also do the trick.

I think using namespace std; is considered bad practice, exactly for the reason it causes problems here... I also use it quite often :), just saying..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good compromise might be:using namespace std::cout

According to:
https://www.geeksforgeeks.org/cpp/using-namespace-std-considered-bad-practice/

bool fom = false;
bool offline = false;
bool online = false;
Expand Down Expand Up @@ -388,7 +388,7 @@ double simulation()

// 27. Save data in the VisIt format.
DataCollection *dc = NULL;
if (visit)
if (use_visit)
{
if (offline) dc = new VisItDataCollection("de_maxwell_local", pmesh);
else if (fom) dc = new VisItDataCollection("de_maxwell_local_fom", pmesh);
Expand Down Expand Up @@ -647,7 +647,7 @@ int main(int argc, char *argv[])
"--no-partial-assembly", "Enable Partial Assembly.");
args.AddOption(&device_config, "-d", "--device",
"Device configuration string, see Device::Configure().");
args.AddOption(&visit, "-visit", "--visit-datafiles", "-no-visit",
args.AddOption(&use_visit, "-visit", "--visit-datafiles", "-no-visit",
"--no-visit-datafiles",
"Save data files for VisIt (visit.llnl.gov) visualization.");
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
Expand Down Expand Up @@ -738,7 +738,7 @@ int main(int argc, char *argv[])
MFEM_VERIFY(!offline
&& !online,
"offline and online must be turned off during the build_database phase.");
MFEM_VERIFY(!visit
MFEM_VERIFY(!use_visit
&& !visualization,
"visit and visualization must be turned off during the build_database phase.")
std::ifstream infile("de_parametric_maxwell_greedy_algorithm_data");
Expand Down
3 changes: 2 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ endif()
# but is done here to ease a potential rollback to CMake 2.8 or CMake
# 3.0.
target_link_libraries(ROM
PUBLIC ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran ${HDF5_LIBRARIES}
PUBLIC ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran ${HDF5_LIBRARIES}
${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS}
PRIVATE ${ZLIB_LIBRARIES} ZLIB::ZLIB)

Expand All @@ -141,6 +141,7 @@ target_include_directories(ROM PUBLIC
${PARMETIS_INCLUDES}
${HDF5_C_INCLUDE_DIRS}
${MPI_C_INCLUDE_DIRS}
${MPI_CXX_INCLUDE_DIRS}
${MFEM_C_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

Expand Down
12 changes: 6 additions & 6 deletions unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ set(unit_test_names
foreach(name IN LISTS unit_test_names)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PRIVATE
ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C
ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX
${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES}
MPI::MPI_Fortran)
target_include_directories(${name} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach(name)

set(unit_test_stems
Expand All @@ -53,12 +53,12 @@ set(unit_test_stems
foreach(stem IN LISTS unit_test_stems)
add_executable(test_${stem} test_${stem}.cpp)
target_link_libraries(test_${stem} PRIVATE
ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} MPI::MPI_C
ROM ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C MPI::MPI_CXX
${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES}
MPI::MPI_Fortran GTest::GTest)
target_include_directories(test_${stem} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS})
target_compile_features(test_${stem} PRIVATE cxx_std_11)
${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS} ${MPI_CXX_INCLUDE_DIRS})
target_compile_features(test_${stem} PRIVATE cxx_std_17)
target_compile_definitions(test_${stem} PRIVATE CAROM_HAS_GTEST)

add_test(NAME test_${stem} COMMAND test_${stem})
Expand Down