Skip to content
Merged
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
146 changes: 29 additions & 117 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,133 +110,45 @@ set(CAROM_HAVE_LAPACK ${LAPACK_FOUND})
set(CAROM_HAVE_HDF5 ${HDF5_FOUND})

if (USE_MFEM)
find_library(MFEM mfem "${CMAKE_SOURCE_DIR}/dependencies/mfem" "${MFEM_DIR}/lib")
find_library(HYPRE HYPRE "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/lib" "${HYPRE_DIR}/lib")
find_library(PARMETIS parmetis "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis" "${PARMETIS_DIR}/lib")
find_library(METIS metis "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis" "${METIS_DIR}/lib")
find_path(MFEM_INCLUDES mfem.hpp "${CMAKE_SOURCE_DIR}/dependencies/mfem" "${MFEM_DIR}/include")
find_path(HYPRE_INCLUDES HYPRE.h "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/include" "${HYPRE_DIR}/include")
find_path(PARMETIS_INCLUDES metis.h "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/metis/include" "${PARMETIS_DIR}/metis/include")
# Try to find MFEM installed using cmake
find_package(mfem NAMES MFEM HINTS "${MFEM_DIR}"
"${MFEM_DIR}/lib/cmake/mfem" "${CMAKE_SOURCE_DIR}/dependencies/mfem/lib/cmake/mfem" NO_DEFAULT_PATH QUIET)
if (mfem_FOUND)
message(STATUS "Found mfem config in: ${mfem_DIR} (version ${MFEM_VERSION})")
else()
# Try to find MFEM installed using configure
find_library(MFEM mfem HINTS "${MFEM_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/mfem")
find_library(HYPRE HYPRE HINTS "${HYPRE_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/lib")
find_library(PARMETIS parmetis HINTS "${PARMETIS_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libparmetis")
find_library(METIS metis HINTS "${METIS_DIR}/lib" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/build/lib/libmetis")
find_path(MFEM_INCLUDES mfem.hpp HINTS "${MFEM_DIR}/include" "${CMAKE_SOURCE_DIR}/dependencies/mfem")
find_path(HYPRE_INCLUDES HYPRE.h HINTS "${HYPRE_DIR}/include" "${CMAKE_SOURCE_DIR}/dependencies/hypre/src/hypre/include")
find_path(PARMETIS_INCLUDES metis.h "${PARMETIS_DIR}/metis/include" "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/metis/include")

if (${MFEM} STREQUAL "MFEM-NOTFOUND")
error( "MFEM not found" )
else()
message(STATUS "MFEM library:" ${MFEM})
message(STATUS "MFEM includes:" ${MFEM_INCLUDES})
endif()
endif()
endif()

add_subdirectory(lib)
set(CAROM_LIBS ${MPI_C_LINK_FLAGS} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES} MPI::MPI_C ${MPI_FORTRAN_LINK_FLAGS} ${MPI_FORTRAN_LIBRARIES} MPI::MPI_Fortran)
set(CAROM_INCS ${CMAKE_CURRENT_SOURCE_DIR} ${MPI_C_INCLUDE_DIRS})

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

if (ENABLE_EXAMPLES)
add_subdirectory(examples/misc)
if (USE_MFEM)
set(examples
poisson_global_rom
poisson_local_rom_greedy
dg_advection_global_rom
dg_advection_local_rom_matrix_interp
mixed_nonlinear_diffusion
nonlinear_elasticity_global_rom
linear_elasticity_global_rom
maxwell_global_rom
de_parametric_maxwell_greedy
maxwell_local_rom_greedy
grad_div_global_rom
elliptic_eigenproblem_global_rom
dg_advection
nonlinear_elasticity
heat_conduction
heat_conduction_dmdc
parametric_heat_conduction
de_parametric_heat_conduction_greedy
de_dg_advection_greedy
wave_equation
dg_euler
local_dw_csv
parametric_tw_csv
parametric_dw_csv
parametric_dmdc_heat_conduction)
set(example_directories
prom
prom
prom
prom
prom
prom
prom
prom
prom
prom
prom
prom
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd
dmd)

list(LENGTH examples len1)
math(EXPR len2 "${len1} - 1")

foreach(val RANGE ${len2})
list(GET examples ${val} name)
list(GET example_directories ${val} example_dir)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/${example_dir})
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)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
endforeach() # IN LISTS examples
add_subdirectory(examples/prom)
add_subdirectory(examples/dmd)
file(COPY examples/data DESTINATION ${CMAKE_BINARY_DIR}/examples)
file(COPY examples/merlin DESTINATION ${CMAKE_BINARY_DIR}/examples)
file(COPY examples/dmd/heat_conduction_csv.sh DESTINATION ${CMAKE_BINARY_DIR}/examples/dmd)
file(COPY examples/dmd/heat_conduction_hdf.sh DESTINATION ${CMAKE_BINARY_DIR}/examples/dmd)
endif()

set(misc_example_names
combine_samples)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples/misc)

foreach(name IN LISTS misc_example_names)
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)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
endforeach(name) # IN LISTS misc_exmaple_names

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests)

if (USE_MFEM)
set(regression_test_names
basisComparator
checkError
computeSpeedup
solutionComparator
fileComparator)

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)
target_include_directories(${name}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
${MPI_C_INCLUDE_DIRS})
target_compile_features(${name} PRIVATE cxx_std_11)
endforeach(name) # IN LISTS regression_test_names
add_subdirectory(regression_tests)
endif()
endif(ENABLE_EXAMPLES)

Expand Down
31 changes: 31 additions & 0 deletions examples/dmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
###############################################################################
#
# Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC
# and other libROM project developers. See the top-level COPYRIGHT
# file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
#
###############################################################################

set(examples
dg_advection
nonlinear_elasticity
heat_conduction
heat_conduction_dmdc
parametric_heat_conduction
de_parametric_heat_conduction_greedy
de_dg_advection_greedy
wave_equation
dg_euler
local_dw_csv
parametric_tw_csv
parametric_dw_csv
parametric_dmdc_heat_conduction)

foreach(name IN LISTS examples)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS})
target_include_directories(${name} PRIVATE ${CAROM_INCS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach()
13 changes: 12 additions & 1 deletion examples/dmd/de_dg_advection_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,18 @@
#include "utils/CSVDatabase.h"


using namespace std;
using std::vector;
using std::cout;
using std::endl;
using std::flush;
using std::max;
using std::min;
using std::to_string;
using std::ifstream;
using std::ofstream;
using std::ostringstream;
using std::setfill;
using std::setw;
using namespace mfem;

// Choice for the problem setup. The fluid velocity, initial condition and
Expand Down
13 changes: 12 additions & 1 deletion examples/dmd/de_parametric_heat_conduction_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,18 @@
#define mkdir(dir, mode) _mkdir(dir)
#endif

using namespace std;
using std::vector;
using std::cout;
using std::endl;
using std::flush;
using std::max;
using std::min;
using std::to_string;
using std::ifstream;
using std::ofstream;
using std::ostringstream;
using std::setfill;
using std::setw;
using namespace mfem;

/** After spatial discretization, the conduction model can be written as:
Expand Down
2 changes: 1 addition & 1 deletion examples/dmd/heat_conduction_dmdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ int main(int argc, char *argv[])
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
// with the same code.
Mesh *mesh;
if (mesh_file == "")
if (strcmp(mesh_file, "") == 0 )
{
mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/dmd/parametric_dmdc_heat_conduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ int main(int argc, char *argv[])
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
// with the same code.
Mesh *mesh;
if (mesh_file == "")
if (strcmp(mesh_file, "") == 0 )
{
mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL));
}
Expand Down
9 changes: 9 additions & 0 deletions examples/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(examples
combine_samples)

foreach(name IN LISTS examples)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS})
target_include_directories(${name} PRIVATE ${CAROM_INCS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach()
28 changes: 28 additions & 0 deletions examples/prom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
###############################################################################
#
# Copyright (c) 2013-2024, Lawrence Livermore National Security, LLC
# and other libROM project developers. See the top-level COPYRIGHT
# file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
#
###############################################################################
set(examples
poisson_global_rom
poisson_local_rom_greedy
dg_advection_global_rom
dg_advection_local_rom_matrix_interp
mixed_nonlinear_diffusion
nonlinear_elasticity_global_rom
linear_elasticity_global_rom
maxwell_global_rom
de_parametric_maxwell_greedy
maxwell_local_rom_greedy
elliptic_eigenproblem_global_rom)

foreach(name IN LISTS examples)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} PRIVATE ROM ${CAROM_LIBS})
target_include_directories(${name} PRIVATE ${CAROM_INCS})
target_compile_features(${name} PRIVATE cxx_std_17)
endforeach()
15 changes: 14 additions & 1 deletion examples/prom/de_parametric_maxwell_greedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,20 @@
#define mkdir(dir, mode) _mkdir(dir)
#endif

using namespace std;
using std::vector;
using std::set;
using std::map;
using std::make_pair;
using std::string;
using std::cout;
using std::endl;
using std::flush;
using std::max;
using std::min;
using std::to_string;
using std::ifstream;
using std::ofstream;
using std::ostringstream;
using namespace mfem;

// Exact solution, E, and r.h.s., f. See below for implementation.
Expand Down
2 changes: 1 addition & 1 deletion examples/prom/elliptic_eigenproblem_global_rom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ int main(int argc, char *argv[])
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
// with the same code.
Mesh *mesh;
if (mesh_file == "")
if (strcmp(mesh_file, "") == 0 )
{
mesh = new Mesh(Mesh::MakeCartesian2D(2, 2, Element::QUADRILATERAL));
}
Expand Down
10 changes: 6 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ if (BLAS_LIBRARIES MATCHES ".*mkl.*")
find_package(MKL COMPONENTS BLACS ScaLAPACK)
if (NOT MKL_ScaLAPACK_FOUND)
find_package(ScaLAPACK REQUIRED)
target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES})
target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES} ${MFEM_LIBRARIES})
else()
target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES})
target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES} ${MFEM_LIBRARIES})
target_include_directories(ROM PUBLIC ${MKL_INCLUDE_DIRS})
endif()
else() # BLAS or LAPACK isn't MKL
Expand All @@ -112,7 +112,7 @@ else() # BLAS or LAPACK isn't MKL
set(ENV{PATH} "${CMAKE_SOURCE_DIR}/dependencies/scalapack-2.2.0:$ENV{PATH}")
find_package(ScaLAPACK REQUIRED)
endif()
target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES})
target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES} ${MFEM_LIBRARIES})
endif()

# PUBLIC dependencies are transitive; these dependencies are used in
Expand All @@ -131,7 +131,7 @@ endif()
# 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}
${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS}
${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS} ${MFEM_LIBRARIES}
PRIVATE ${ZLIB_LIBRARIES} ZLIB::ZLIB)

target_include_directories(ROM PUBLIC
Expand All @@ -144,6 +144,8 @@ target_include_directories(ROM PUBLIC
${MFEM_C_INCLUDE_DIRS}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

target_compile_features(ROM PRIVATE cxx_std_17)

# Find headers from the source file list that need to be installed
set(HEADERS "")
foreach(file IN LISTS source_files)
Expand Down
2 changes: 1 addition & 1 deletion lib/algo/greedy/GreedySampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class GreedySampler
/**
* @brief Destructor.
*/
~GreedySampler();
virtual ~GreedySampler();

/**
* @brief Returns the next parameter point for which sampling is required.
Expand Down
3 changes: 2 additions & 1 deletion lib/linalg/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,8 @@ Matrix::gather()
MPI_COMM_WORLD) == MPI_SUCCESS);

delete [] d_mat;
delete [] data_offsets, data_cnts;
delete [] data_offsets;
delete [] data_cnts;
d_mat = d_new_mat;
d_alloc_size = new_size;

Expand Down
3 changes: 2 additions & 1 deletion lib/linalg/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ Vector::gather()
MPI_COMM_WORLD) == MPI_SUCCESS);

delete [] d_vec;
delete [] data_offsets, data_cnts;
delete [] data_offsets;
delete [] data_cnts;
d_vec = d_new_vec;
d_alloc_size = new_size;
d_dim = new_size;
Expand Down
2 changes: 1 addition & 1 deletion lib/linalg/svd/IncrementalSVD.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class IncrementalSVD : public SVD
bool
takeSample(
double* u_in,
bool add_without_increase = false);
bool add_without_increase = false) override;

/**
* @brief Returns the basis vectors for the current time interval as a
Expand Down
Loading