diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a566e72b5..e38dce3e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - uses: ./.github/workflows/checkout_repo - name: Build libROM run: | + mkdir ${GITHUB_WORKSPACE}/build cd ${GITHUB_WORKSPACE}/build export CC=mpicc export CXX=mpicxx @@ -40,6 +41,7 @@ jobs: - name: Build libROM run: | export FC=/usr/local/bin/gfortran-10 + mkdir ${GITHUB_WORKSPACE}/build cd ${GITHUB_WORKSPACE}/build cmake -DCMAKE_BUILD_TYPE=Debug .. make diff --git a/.github/workflows/run_tests/action.yml b/.github/workflows/run_tests/action.yml index 94a068002..d3dbdf81f 100644 --- a/.github/workflows/run_tests/action.yml +++ b/.github/workflows/run_tests/action.yml @@ -15,7 +15,7 @@ runs: mpirun -n 3 --oversubscribe tests/test_RandomizedSVD ./tests/test_DMD mpirun -n 3 --oversubscribe tests/test_DMD - ./tests/test_GreedyParameterPointPreDefinedSampler - mpirun -n 3 --oversubscribe tests/test_GreedyParameterPointPreDefinedSampler + ./tests/test_GreedyCustomSampler + mpirun -n 3 --oversubscribe tests/test_GreedyCustomSampler shell: bash diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 6211b36fc..000000000 --- a/AUTHORS +++ /dev/null @@ -1,18 +0,0 @@ -# libROM authors - -Bill Arrighi -Geoff Oxberry -Youngsoo Choi -Dylan Matthew Copeland -Kevin Huynh - -# Algorithm developers - -Kyle Chand -Geoff Oxberry -Bill Arrighi -Tanya Kostova-Vassilevska -Robert W. Anderson -Youngsoo Choi -Dylan Matthew Copeland -Kevin Huynh diff --git a/CMakeLists.txt b/CMakeLists.txt index cf4de8d14..31625bb68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,16 +8,6 @@ # ############################################################################### -# Debugging tip: If using the GNU Make generator (the default), build -# with `make VERBOSE=1` to see flags being used by GNU Make. This -# output helps in trying to diagnose configuration errors. The -# equivalent for the Ninja generator is `ninja -v`. Also note that -# because this project "uses Fortran" -- a Fortran compiler is -# required to infer Fortran name-mangling conventions -- KitWare's -# "ninja-fortran" is needed to run the resulting Ninja files. This -# software can be installed, e.g., via Spack (`spack install -# ninja-fortran`). - # Require CMake version 3.12 or later to expose modern features of # CMake for maintainability. With additional work, it is possible to # rewrite the build system generator for CMake 3.10+, 3.8+, 3.1+, @@ -46,9 +36,6 @@ list(APPEND CMAKE_MODULE_PATH ${libROM_CMAKE_MODULE_PATH}) option(USE_MFEM "Build libROM with MFEM" OFF) option(BUILD_STATIC "Build libROM as a static library" OFF) -include(FortranCInterface) -FortranCInterface_HEADER(${CMAKE_SOURCE_DIR}/FCMangle.h - MACRO_NAMESPACE "CAROM_FC_") ## Set a bunch of variables to generate a configure header # Enable assertion checking if debug symbols generated if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR @@ -106,63 +93,6 @@ if(HDF5_FOUND) set(CAROM_HAVE_HDF5 1) endif(HDF5_FOUND) -configure_file(${CMAKE_SOURCE_DIR}/CAROM_config.h.in - ${CMAKE_SOURCE_DIR}/CAROM_config.h @ONLY) - -# While it is tempting to use file globbing here, file globbing is -# considered a "modern CMake anti-pattern" because "CMake is not a -# build system -- it is a build system _generator_". Instead, use -# some file name "stems" for generating file names. This construction -# is useful when files may be moved to different directories. -set(module_list - Matrix - Vector - BasisGenerator - BasisReader - BasisWriter - SVD - IncrementalSVD - IncrementalSVDFastUpdate - IncrementalSVDStandard - StaticSVD - RandomizedSVD - GreedyParameterPointSampler - GreedyParameterPointRandomSampler - GreedyParameterPointPreDefinedSampler - Interpolator - MatrixInterpolator - VectorInterpolator - Database - HDFDatabase - Utilities - ParallelBuffer - DMD - DEIM - QDEIM - GNAT - STSampling) -set(source_files) -foreach(module IN LISTS module_list) - list(APPEND source_files ${module}.C) -endforeach(module) # IN LISTS module_list - -list(APPEND source_files - Options.h) - -if (USE_MFEM) - list(APPEND source_files - SampleMesh.hpp) -endif() - -list(APPEND source_files - scalapack_c_wrapper.c - scalapack_f_wrapper.f90) -if (BUILD_STATIC) - add_library(ROM ${source_files}) -else() - add_library(ROM SHARED ${source_files}) -endif() - # List minimum version requirements for dependencies where possible to make # packaging easier later. find_package(HDF5 1.8.0 REQUIRED) @@ -170,23 +100,6 @@ find_package(HDF5 1.8.0 REQUIRED) find_package(BLAS 3.4.0 REQUIRED) find_package(LAPACK 3.4.0 REQUIRED) -# If MKL libraries not found, search for reference ScaLAPACK. If MKL -# libraries found, search for MKL ScaLAPACK; if MKL ScaLAPACK not -# found, search for reference ScaLAPACK. It seems that only -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}) - else() - target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES}) - target_include_directories(ROM PUBLIC ${MKL_INCLUDE_DIRS}) - endif() -else() # BLAS or LAPACK isn't MKL - find_package(ScaLAPACK REQUIRED) - target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES}) -endif() - # In FindMPI.cmake, "CXX" refers to "the MPI C API [being] usable from C++" find_package(MPI 1.2 REQUIRED) @@ -206,34 +119,7 @@ if (USE_MFEM) find_path(PARMETIS_INCLUDES metis.h "${CMAKE_SOURCE_DIR}/dependencies/parmetis-4.0.3/metis/include") endif() -# PUBLIC dependencies are transitive; these dependencies are used in -# the API headers *and* in their implementations -# -# INTERFACE dependencies are used in the API headers, but not in the -# API implementation (e.g., API forwards objects to another library -# without dereferencing those objects -- only pointers are used) -# -# PRIVATE dependencies are used in the API implementation, but not in -# the headers -# -# Using both the MPI::MPI_C target and the two MPI_C "flag variables -# (i.e., "MPI_C_LINK_FLAGS, MPI_C_LIBRARIES) is probably redundant, -# 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} - ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS} - PRIVATE ${ZLIB_LIBRARIES} ZLIB::ZLIB) - -target_include_directories(ROM PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${MFEM_INCLUDES} - ${HYPRE_INCLUDES} - ${PARMETIS_INCLUDES} - ${HDF5_C_INCLUDE_DIRS} - ${MPI_C_INCLUDE_DIRS} - ${MFEM_C_INCLUDE_DIRS} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +add_subdirectory(lib) # Use the C++11 standard as an entire feature instead of # enumerating individual compiler features for simplicity @@ -281,6 +167,7 @@ endif() set(regression_test_names smoke_test + test_include uneven_dist weak_scaling random_test @@ -312,7 +199,7 @@ if(GTEST_FOUND) StaticSVD RandomizedSVD IncrementalSVD - GreedyParameterPointPreDefinedSampler) + GreedyCustomSampler) foreach(stem IN LISTS unit_test_stems) add_executable(test_${stem} tests/test_${stem}.C) target_link_libraries(test_${stem} PRIVATE ROM diff --git a/README.md b/README.md index 950556ca6..306a27696 100644 --- a/README.md +++ b/README.md @@ -16,40 +16,6 @@ non-intrusive black-box approaches. - Sparse identification of nonlinear dynamics (SINDy) -# Authors -Robert W. Anderson (LLNL), -William Arrighi (LLNL), -Siu Wun Cheung (LLNL), -Youngsoo Choi (LLNL), -Dylan Copeland (LLNL), -Kevin Huynh (LLNL), -Jessica Lauzon (Stanford), -Sean McBane (UT Austin), -Geoffrey Oxberry (LLNL). - -# License - -libROM is distributed under the terms of both the MIT license and the -Apache License (Version 2.0). Users may choose either license at their -option. - -All new contributions must be made under both the MIT and Apache-2.0 licenses. - -See -[LICENSE-MIT](https://github.com/LLNL/libROM/blob/master/LICENSE-MIT), -[LICENSE-APACHE](https://github.com/LLNL/libROM/blob/master/LICENSE-APACHE), -[COPYRIGHT](https://github.com/LLNL/libROM/blob/master/COPYRIGHT), and -[NOTICE](https://github.com/LLNL/libROM/blob/master/NOTICE) for -details. - -Up to commit 299876e0a0304f25db56f1f9e2eb2c61ef199048, libROM was -previously released under the terms of the BSD-3 license. - -SPDX_License-Identifier: (Apache-2.0 OR MIT) - -LLNL-CODE-686965 (up to commit 299876e0a0304f25db56f1f9e2eb2c61ef199048) -LLNL-CODE-766763 - # Installation To compile libROM with default build settings (Mac and LLNL LC Machines): @@ -83,3 +49,40 @@ To install libROM with MFEM using spack. ```sh spack install librom +mfem ``` + +# License + +libROM is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). Users may choose either license at their +option. + +All new contributions must be made under both the MIT and Apache-2.0 licenses. + +See +[LICENSE-MIT](https://github.com/LLNL/libROM/blob/master/LICENSE-MIT), +[LICENSE-APACHE](https://github.com/LLNL/libROM/blob/master/LICENSE-APACHE), +[COPYRIGHT](https://github.com/LLNL/libROM/blob/master/COPYRIGHT), and +[NOTICE](https://github.com/LLNL/libROM/blob/master/NOTICE) for +details. + +Up to commit 299876e0a0304f25db56f1f9e2eb2c61ef199048, libROM was +previously released under the terms of the BSD-3 license. + +SPDX_License-Identifier: (Apache-2.0 OR MIT) + +LLNL-CODE-686965 (up to commit 299876e0a0304f25db56f1f9e2eb2c61ef199048) +LLNL-CODE-766763 + + +# Authors +- Robert W. Anderson (LLNL) +- William Arrighi (LLNL) +- Kyle Chand (LLNL) +- Siu Wun Cheung (LLNL) +- Youngsoo Choi (LLNL) +- Dylan Copeland (LLNL) +- Kevin Huynh (LLNL) +- Tanya Kostova-Vassilevska (LLNL) +- Jessica Lauzon (Stanford) +- Sean McBane (UT Austin) +- Geoffrey Oxberry (LLNL) diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/libROM_Design_and_Theory.pdf b/docs/libROM_Design_and_Theory.pdf similarity index 100% rename from libROM_Design_and_Theory.pdf rename to docs/libROM_Design_and_Theory.pdf diff --git a/examples/dmd/dg_advection.cpp b/examples/dmd/dg_advection.cpp index ed46a3dec..b23d1498e 100644 --- a/examples/dmd/dg_advection.cpp +++ b/examples/dmd/dg_advection.cpp @@ -35,8 +35,8 @@ // are also illustrated. #include "mfem.hpp" -#include "DMD.h" -#include "Vector.h" +#include "algo/DMD.h" +#include "linalg/Vector.h" #include #include #include diff --git a/examples/dmd/dg_euler.cpp b/examples/dmd/dg_euler.cpp index 0861c0e50..689b0f97d 100644 --- a/examples/dmd/dg_euler.cpp +++ b/examples/dmd/dg_euler.cpp @@ -43,8 +43,8 @@ // example. #include "mfem.hpp" -#include "DMD.h" -#include "Vector.h" +#include "algo/DMD.h" +#include "linalg/Vector.h" #include #include #include diff --git a/examples/dmd/heat_conduction.cpp b/examples/dmd/heat_conduction.cpp index e86ca1743..b64a0060e 100644 --- a/examples/dmd/heat_conduction.cpp +++ b/examples/dmd/heat_conduction.cpp @@ -28,8 +28,8 @@ // with ADIOS2 (adios2.readthedocs.io) is also illustrated. #include "mfem.hpp" -#include "DMD.h" -#include "Vector.h" +#include "algo/DMD.h" +#include "linalg/Vector.h" #include #include #include diff --git a/examples/dmd/nonlinear_elasticity.cpp b/examples/dmd/nonlinear_elasticity.cpp index 8c40192b7..9e850361a 100644 --- a/examples/dmd/nonlinear_elasticity.cpp +++ b/examples/dmd/nonlinear_elasticity.cpp @@ -36,8 +36,8 @@ // requirement for high-order implicit (SDIRK) time integration. #include "mfem.hpp" -#include "DMD.h" -#include "Vector.h" +#include "algo/DMD.h" +#include "linalg/Vector.h" #include #include #include diff --git a/matlab/deim.m b/examples/matlab/deim.m similarity index 100% rename from matlab/deim.m rename to examples/matlab/deim.m diff --git a/matlab/dmd.m b/examples/matlab/dmd.m similarity index 100% rename from matlab/dmd.m rename to examples/matlab/dmd.m diff --git a/matlab/gnat.m b/examples/matlab/gnat.m similarity index 100% rename from matlab/gnat.m rename to examples/matlab/gnat.m diff --git a/matlab/qdeim.m b/examples/matlab/qdeim.m similarity index 100% rename from matlab/qdeim.m rename to examples/matlab/qdeim.m diff --git a/matlab/randomized_svd.m b/examples/matlab/randomized_svd.m similarity index 100% rename from matlab/randomized_svd.m rename to examples/matlab/randomized_svd.m diff --git a/matlab/second_diff.m b/examples/matlab/second_diff.m similarity index 100% rename from matlab/second_diff.m rename to examples/matlab/second_diff.m diff --git a/examples/prom/dg_advection_global_rom.cpp b/examples/prom/dg_advection_global_rom.cpp index 789e59561..142e3a851 100644 --- a/examples/prom/dg_advection_global_rom.cpp +++ b/examples/prom/dg_advection_global_rom.cpp @@ -44,9 +44,9 @@ // are also illustrated. #include "mfem.hpp" -#include "Vector.h" -#include "BasisGenerator.h" -#include "BasisReader.h" +#include "linalg/Vector.h" +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" #include #include #include diff --git a/examples/prom/dg_advection_local_rom_matrix_interp.cpp b/examples/prom/dg_advection_local_rom_matrix_interp.cpp index 9b88d6781..b375d0f92 100644 --- a/examples/prom/dg_advection_local_rom_matrix_interp.cpp +++ b/examples/prom/dg_advection_local_rom_matrix_interp.cpp @@ -51,11 +51,11 @@ // are also illustrated. #include "mfem.hpp" -#include "Vector.h" -#include "MatrixInterpolator.h" -#include "VectorInterpolator.h" -#include "BasisGenerator.h" -#include "BasisReader.h" +#include "linalg/Vector.h" +#include "algo/manifold_interp/MatrixInterpolator.h" +#include "algo/manifold_interp/VectorInterpolator.h" +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" #include #include #include @@ -383,12 +383,12 @@ int main(int argc, char *argv[]) "Enable or disable matrix interpolation during the online phase."); args.AddOption(&interp_prep, "-interp_prep", "--interp_prep", "-no-interp_prep", "--no-interp_prep", "Enable or disable matrix interpolation preparation during the online phase."); - args.AddOption(&ef, "-ef", "--energy_fraction", - "Energy fraction."); args.AddOption(&rbf_type, "-rt", "--rbf_type", "RBF type ('G' == gaussian, 'MQ'== multiquadric, 'IQ' == inverse quadratic, 'IMQ' == inverse multiquadric)."); args.AddOption(&rbf_width, "-rw", "--rbf_width", "RBF inverse width."); + args.AddOption(&ef, "-ef", "--energy_fraction", + "Energy fraction."); args.AddOption(&rdim, "-rdim", "--rdim", "Reduced dimension."); args.Parse(); diff --git a/examples/prom/mixed_nonlinear_diffusion.cpp b/examples/prom/mixed_nonlinear_diffusion.cpp index 1a7ad7a91..4ab6cd0ed 100644 --- a/examples/prom/mixed_nonlinear_diffusion.cpp +++ b/examples/prom/mixed_nonlinear_diffusion.cpp @@ -42,10 +42,10 @@ #include #include -#include "BasisGenerator.h" -#include "BasisReader.h" -#include "DEIM.h" -#include "SampleMesh.hpp" +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" +#include "hyperreduction/DEIM.h" +#include "mfem/SampleMesh.hpp" typedef enum {ANALYTIC, INIT_STEP} PROBLEM; diff --git a/examples/prom/poisson_global_rom.cpp b/examples/prom/poisson_global_rom.cpp index 926a4db4e..1934a2731 100644 --- a/examples/prom/poisson_global_rom.cpp +++ b/examples/prom/poisson_global_rom.cpp @@ -29,8 +29,8 @@ #include "mfem.hpp" #include #include -#include "BasisGenerator.h" -#include "BasisReader.h" +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" using namespace std; using namespace mfem; diff --git a/examples/prom/poisson_local_rom_greedy.cpp b/examples/prom/poisson_local_rom_greedy.cpp index 8768d81f3..4d93d7cba 100644 --- a/examples/prom/poisson_local_rom_greedy.cpp +++ b/examples/prom/poisson_local_rom_greedy.cpp @@ -26,9 +26,9 @@ #include #include #include -#include "GreedyParameterPointRandomSampler.h" -#include "BasisGenerator.h" -#include "BasisReader.h" +#include "algo/greedy/GreedyRandomSampler.h" +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" using namespace std; using namespace mfem; @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) if (fom) MFEM_VERIFY(fom && !build_database && !use_database && !offline && !online, "everything must be turned off if fom is used."); - CAROM::GreedyParameterPointSampler* greedy_sampler = NULL; + CAROM::GreedySampler* greedy_sampler = NULL; MFEM_VERIFY(!build_database || !use_database, "both build_database and use_database can not be used at the same time."); // 3. Set up the ROM database for the greedy algorithm to run. @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) return 0; } infile.close(); - greedy_sampler = new CAROM::GreedyParameterPointRandomSampler(greedy_param_space_min, greedy_param_space_max, + greedy_sampler = new CAROM::GreedyRandomSampler(greedy_param_space_min, greedy_param_space_max, greedy_param_space_size, false, greedy_relative_error_tol, 1.05, 2.0, greedy_subset_size, greedy_convergence_subset_size, true, "poisson_local_rom_greedy_algorithm_log.txt"); diff --git a/CAROM_config.h.in b/lib/CAROM_config.h.in similarity index 100% rename from CAROM_config.h.in rename to lib/CAROM_config.h.in diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 000000000..47932ed75 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,117 @@ +############################################################################### +# +# Copyright (c) 2013-2021, 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) +# +############################################################################### + +include(FortranCInterface) +FortranCInterface_HEADER(${CMAKE_CURRENT_SOURCE_DIR}/FCMangle.h + MACRO_NAMESPACE "CAROM_FC_") + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CAROM_config.h.in + ${CMAKE_CURRENT_SOURCE_DIR}/CAROM_config.h @ONLY) + +# While it is tempting to use file globbing here, file globbing is +# considered a "modern CMake anti-pattern" because "CMake is not a +# build system -- it is a build system _generator_". Instead, use +# some file name "stems" for generating file names. This construction +# is useful when files may be moved to different directories. +set(module_list + linalg/BasisGenerator + linalg/BasisReader + linalg/BasisWriter + linalg/Matrix + linalg/Vector + linalg/svd/IncrementalSVD + linalg/svd/IncrementalSVDFastUpdate + linalg/svd/IncrementalSVDStandard + linalg/svd/RandomizedSVD + linalg/svd/SVD + linalg/svd/StaticSVD + algo/DMD + algo/greedy/GreedyCustomSampler + algo/greedy/GreedyRandomSampler + algo/greedy/GreedySampler + algo/manifold_interp/Interpolator + algo/manifold_interp/MatrixInterpolator + algo/manifold_interp/VectorInterpolator + hyperreduction/DEIM + hyperreduction/GNAT + hyperreduction/QDEIM + hyperreduction/STSampling + utils/Database + utils/HDFDatabase + utils/Utilities + utils/ParallelBuffer) +set(source_files) +foreach(module IN LISTS module_list) + list(APPEND source_files ${module}.C) +endforeach(module) # IN LISTS module_list + +list(APPEND source_files + linalg/Options.h + librom.h) + +if (USE_MFEM) + list(APPEND source_files + mfem/SampleMesh.hpp) +endif() + +list(APPEND source_files + linalg/scalapack_c_wrapper.c + linalg/scalapack_f_wrapper.f90) +if (BUILD_STATIC) + add_library(ROM ${source_files}) +else() + add_library(ROM SHARED ${source_files}) +endif() + +# If MKL libraries not found, search for reference ScaLAPACK. If MKL +# libraries found, search for MKL ScaLAPACK; if MKL ScaLAPACK not +# found, search for reference ScaLAPACK. It seems that only +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}) + else() + target_link_libraries(ROM PUBLIC ${MKL_ScaLAPACK_LIBRARY} ${MKL_BLACS_LIBRARY} ${MKL_LIBRARIES}) + target_include_directories(ROM PUBLIC ${MKL_INCLUDE_DIRS}) + endif() +else() # BLAS or LAPACK isn't MKL + find_package(ScaLAPACK REQUIRED) + target_link_libraries(ROM PUBLIC ${ScaLAPACK_LIBRARIES}) +endif() + +# PUBLIC dependencies are transitive; these dependencies are used in +# the API headers *and* in their implementations +# +# INTERFACE dependencies are used in the API headers, but not in the +# API implementation (e.g., API forwards objects to another library +# without dereferencing those objects -- only pointers are used) +# +# PRIVATE dependencies are used in the API implementation, but not in +# the headers +# +# Using both the MPI::MPI_C target and the two MPI_C "flag variables +# (i.e., "MPI_C_LINK_FLAGS, MPI_C_LIBRARIES) is probably redundant, +# 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} + ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MFEM} ${HYPRE} ${PARMETIS} ${METIS} + PRIVATE ${ZLIB_LIBRARIES} ZLIB::ZLIB) + +target_include_directories(ROM PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${MFEM_INCLUDES} + ${HYPRE_INCLUDES} + ${PARMETIS_INCLUDES} + ${HDF5_C_INCLUDE_DIRS} + ${MPI_C_INCLUDE_DIRS} + ${MFEM_C_INCLUDE_DIRS} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/DMD.C b/lib/algo/DMD.C similarity index 99% rename from DMD.C rename to lib/algo/DMD.C index 8966c1491..b67220baa 100644 --- a/DMD.C +++ b/lib/algo/DMD.C @@ -12,9 +12,9 @@ #include "DMD.h" -#include "Matrix.h" -#include "Vector.h" -#include "scalapack_wrapper.h" +#include "linalg/Matrix.h" +#include "linalg/Vector.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" /* Use C++11 built-in shared pointers if available; else fallback to Boost. */ @@ -24,8 +24,6 @@ #include #endif -#include "scalapack_wrapper.h" - /* Use automatically detected Fortran name-mangling scheme */ #define zgetrf CAROM_FC_GLOBAL(zgetrf, ZGETRF) #define zgetri CAROM_FC_GLOBAL(zgetri, ZGETRI) diff --git a/DMD.h b/lib/algo/DMD.h similarity index 100% rename from DMD.h rename to lib/algo/DMD.h diff --git a/GreedyParameterPointPreDefinedSampler.C b/lib/algo/greedy/GreedyCustomSampler.C similarity index 83% rename from GreedyParameterPointPreDefinedSampler.C rename to lib/algo/greedy/GreedyCustomSampler.C index 278c46c6f..1e036b805 100644 --- a/GreedyParameterPointPreDefinedSampler.C +++ b/lib/algo/greedy/GreedyCustomSampler.C @@ -11,7 +11,7 @@ // Description: This class greedily selects parameter points // for the construction of a ROM database. -#include "GreedyParameterPointPreDefinedSampler.h" +#include "GreedyCustomSampler.h" #include #include #include @@ -19,7 +19,7 @@ namespace CAROM { -GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( +GreedyCustomSampler::GreedyCustomSampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -32,7 +32,7 @@ GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( bool use_centroid, int random_seed, bool debug_algorithm) : - GreedyParameterPointSampler( + GreedySampler( parameter_points, check_local_rom, relative_error_tolerance, @@ -57,7 +57,7 @@ GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( } } -GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( +GreedyCustomSampler::GreedyCustomSampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -70,7 +70,7 @@ GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( bool use_centroid, int random_seed, bool debug_algorithm) : - GreedyParameterPointSampler( + GreedySampler( parameter_points, check_local_rom, relative_error_tolerance, @@ -95,16 +95,16 @@ GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( } } -GreedyParameterPointPreDefinedSampler::GreedyParameterPointPreDefinedSampler( +GreedyCustomSampler::GreedyCustomSampler( std::string base_file_name, std::string output_log_path) : - GreedyParameterPointSampler( + GreedySampler( base_file_name, output_log_path ) {} void -GreedyParameterPointPreDefinedSampler::constructParameterPoints() +GreedyCustomSampler::constructParameterPoints() { d_min_param_point = d_parameter_points[0]; d_max_param_point = d_parameter_points[0]; @@ -122,12 +122,12 @@ GreedyParameterPointPreDefinedSampler::constructParameterPoints() } void -GreedyParameterPointPreDefinedSampler::getNextParameterPointAfterConvergenceFailure() +GreedyCustomSampler::getNextParameterPointAfterConvergenceFailure() { d_next_point_to_sample = getNearestNonSampledPoint(d_convergence_points[d_counter]); } -GreedyParameterPointPreDefinedSampler::~GreedyParameterPointPreDefinedSampler() +GreedyCustomSampler::~GreedyCustomSampler() { } diff --git a/GreedyParameterPointPreDefinedSampler.h b/lib/algo/greedy/GreedyCustomSampler.h similarity index 91% rename from GreedyParameterPointPreDefinedSampler.h rename to lib/algo/greedy/GreedyCustomSampler.h index 6f6e593dd..c17995920 100644 --- a/GreedyParameterPointPreDefinedSampler.h +++ b/lib/algo/greedy/GreedyCustomSampler.h @@ -11,19 +11,19 @@ // Description: The concrete implementation of the Choi et. al's greedy algorithm // using pre-defined parameter points. -#ifndef included_GreedyParameterPointPreDefinedSampler_h -#define included_GreedyParameterPointPreDefinedSampler_h +#ifndef included_GreedyCustomSampler_h +#define included_GreedyCustomSampler_h -#include "GreedyParameterPointSampler.h" +#include "GreedySampler.h" namespace CAROM { /** - * Class GreedyParameterPointRandomSampler implements a variant of + * Class GreedyRandomSampler implements a variant of * Choi et. al's greedy algorithm using pre-defined * parameter points. */ -class GreedyParameterPointPreDefinedSampler : public GreedyParameterPointSampler +class GreedyCustomSampler : public GreedySampler { public: /** @@ -50,7 +50,7 @@ class GreedyParameterPointPreDefinedSampler : public GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointPreDefinedSampler( + GreedyCustomSampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -88,7 +88,7 @@ class GreedyParameterPointPreDefinedSampler : public GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointPreDefinedSampler( + GreedyCustomSampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -110,14 +110,14 @@ class GreedyParameterPointPreDefinedSampler : public GreedyParameterPointSampler * @param[in] output_log_path The path to the output log file. If not used, outputs to stdout. */ - GreedyParameterPointPreDefinedSampler( + GreedyCustomSampler( std::string base_file_name, std::string output_log_path = ""); /** * @brief Destructor. */ - ~GreedyParameterPointPreDefinedSampler(); + ~GreedyCustomSampler(); protected: diff --git a/GreedyParameterPointRandomSampler.C b/lib/algo/greedy/GreedyRandomSampler.C similarity index 87% rename from GreedyParameterPointRandomSampler.C rename to lib/algo/greedy/GreedyRandomSampler.C index 01051b046..0bd08c4bd 100644 --- a/GreedyParameterPointRandomSampler.C +++ b/lib/algo/greedy/GreedyRandomSampler.C @@ -11,8 +11,8 @@ // Description: This class greedily selects parameter points // for the construction of a ROM database. -#include "GreedyParameterPointRandomSampler.h" -#include "HDFDatabase.h" +#include "GreedyRandomSampler.h" +#include "utils/HDFDatabase.h" #include "mpi.h" #include #include @@ -21,7 +21,7 @@ namespace CAROM { -GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( +GreedyRandomSampler::GreedyRandomSampler( double param_space_min, double param_space_max, int num_parameter_points, @@ -37,7 +37,7 @@ GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( bool use_centroid, int random_seed, bool debug_algorithm) : - GreedyParameterPointSampler( + GreedySampler( param_space_min, param_space_max, num_parameter_points, @@ -74,7 +74,7 @@ GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( } } -GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( +GreedyRandomSampler::GreedyRandomSampler( Vector param_space_min, Vector param_space_max, int num_parameter_points, @@ -90,7 +90,7 @@ GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( bool use_centroid, int random_seed, bool debug_algorithm) : - GreedyParameterPointSampler( + GreedySampler( param_space_min, param_space_max, num_parameter_points, @@ -127,16 +127,16 @@ GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( } } -GreedyParameterPointRandomSampler::GreedyParameterPointRandomSampler( +GreedyRandomSampler::GreedyRandomSampler( std::string base_file_name, std::string output_log_path) : - GreedyParameterPointSampler( + GreedySampler( base_file_name, output_log_path ) {} void -GreedyParameterPointRandomSampler::constructParameterPoints() +GreedyRandomSampler::constructParameterPoints() { checkParameterPointInput(); @@ -188,9 +188,9 @@ GreedyParameterPointRandomSampler::constructParameterPoints() } void -GreedyParameterPointRandomSampler::load(std::string base_file_name) +GreedyRandomSampler::load(std::string base_file_name) { - GreedyParameterPointSampler::load(base_file_name); + GreedySampler::load(base_file_name); char tmp[100]; std::string full_file_name = base_file_name; @@ -209,9 +209,9 @@ GreedyParameterPointRandomSampler::load(std::string base_file_name) } void -GreedyParameterPointRandomSampler::save(std::string base_file_name) +GreedyRandomSampler::save(std::string base_file_name) { - GreedyParameterPointSampler::save(base_file_name); + GreedySampler::save(base_file_name); if (d_rank == 0) { @@ -231,7 +231,7 @@ GreedyParameterPointRandomSampler::save(std::string base_file_name) } void -GreedyParameterPointRandomSampler::getNextParameterPointAfterConvergenceFailure() +GreedyRandomSampler::getNextParameterPointAfterConvergenceFailure() { d_parameter_points.push_back(d_convergence_points[d_counter]); d_parameter_point_errors.push_back(d_max_error); @@ -240,7 +240,7 @@ GreedyParameterPointRandomSampler::getNextParameterPointAfterConvergenceFailure( d_next_point_to_sample = d_parameter_points.size() - 1; } -GreedyParameterPointRandomSampler::~GreedyParameterPointRandomSampler() +GreedyRandomSampler::~GreedyRandomSampler() { } diff --git a/GreedyParameterPointRandomSampler.h b/lib/algo/greedy/GreedyRandomSampler.h similarity index 93% rename from GreedyParameterPointRandomSampler.h rename to lib/algo/greedy/GreedyRandomSampler.h index 63329d566..cd8037d92 100644 --- a/GreedyParameterPointRandomSampler.h +++ b/lib/algo/greedy/GreedyRandomSampler.h @@ -11,19 +11,19 @@ // Description: The concrete implementation of the Choi et. al's greedy algorithm // using random sampling or latin-hypercube sampling. -#ifndef included_GreedyParameterPointRandomSampler_h -#define included_GreedyParameterPointRandomSampler_h +#ifndef included_GreedyRandomSampler_h +#define included_GreedyRandomSampler_h -#include "GreedyParameterPointSampler.h" +#include "GreedySampler.h" namespace CAROM { /** - * Class GreedyParameterPointRandomSampler implements a variant of + * Class GreedyRandomSampler implements a variant of * Choi et. al's greedy algorithm using random sampling or * latin-hypercube sampling. */ -class GreedyParameterPointRandomSampler : public GreedyParameterPointSampler +class GreedyRandomSampler : public GreedySampler { public: /** @@ -56,7 +56,7 @@ class GreedyParameterPointRandomSampler : public GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointRandomSampler( + GreedyRandomSampler( Vector param_space_min, Vector param_space_max, int num_parameter_points, @@ -103,7 +103,7 @@ class GreedyParameterPointRandomSampler : public GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointRandomSampler( + GreedyRandomSampler( double param_space_min, double param_space_max, int num_parameter_points, @@ -128,7 +128,7 @@ class GreedyParameterPointRandomSampler : public GreedyParameterPointSampler * @param[in] output_log_path The path to the output log file. If not used, outputs to stdout. */ - GreedyParameterPointRandomSampler( + GreedyRandomSampler( std::string base_file_name, std::string output_log_path = ""); @@ -144,7 +144,7 @@ class GreedyParameterPointRandomSampler : public GreedyParameterPointSampler /** * @brief Destructor. */ - ~GreedyParameterPointRandomSampler(); + ~GreedyRandomSampler(); protected: diff --git a/GreedyParameterPointSampler.C b/lib/algo/greedy/GreedySampler.C similarity index 95% rename from GreedyParameterPointSampler.C rename to lib/algo/greedy/GreedySampler.C index 0d4f5c9d1..a2fcc18ff 100644 --- a/GreedyParameterPointSampler.C +++ b/lib/algo/greedy/GreedySampler.C @@ -11,8 +11,8 @@ // Description: This class greedily selects parameter points // for the construction of a ROM database. -#include "GreedyParameterPointSampler.h" -#include "HDFDatabase.h" +#include "GreedySampler.h" +#include "utils/HDFDatabase.h" #include "mpi.h" #include #include @@ -97,7 +97,7 @@ getNearestPointIndex(std::vector param_points, double point) return closest_point_index; } -GreedyParameterPointSampler::GreedyParameterPointSampler( +GreedySampler::GreedySampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -120,7 +120,7 @@ GreedyParameterPointSampler::GreedyParameterPointSampler( subset_size, convergence_subset_size, output_log_path, use_centroid, random_seed, debug_algorithm); } -GreedyParameterPointSampler::GreedyParameterPointSampler( +GreedySampler::GreedySampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -151,7 +151,7 @@ GreedyParameterPointSampler::GreedyParameterPointSampler( subset_size, convergence_subset_size, output_log_path, use_centroid, random_seed, debug_algorithm); } -GreedyParameterPointSampler::GreedyParameterPointSampler( +GreedySampler::GreedySampler( Vector param_space_min, Vector param_space_max, int num_parameter_points, @@ -176,7 +176,7 @@ GreedyParameterPointSampler::GreedyParameterPointSampler( convergence_subset_size, output_log_path, use_centroid, random_seed, debug_algorithm); } -GreedyParameterPointSampler::GreedyParameterPointSampler( +GreedySampler::GreedySampler( double param_space_min, double param_space_max, int num_parameter_points, @@ -206,7 +206,7 @@ GreedyParameterPointSampler::GreedyParameterPointSampler( convergence_subset_size, output_log_path, use_centroid, random_seed, debug_algorithm); } -GreedyParameterPointSampler::GreedyParameterPointSampler( +GreedySampler::GreedySampler( std::string base_file_name, std::string output_log_path) { @@ -227,7 +227,7 @@ GreedyParameterPointSampler::GreedyParameterPointSampler( } void -GreedyParameterPointSampler::addDatabaseFromFile( +GreedySampler::addDatabaseFromFile( std::string const& warm_start_file_name) { char tmp[100]; @@ -264,7 +264,7 @@ GreedyParameterPointSampler::addDatabaseFromFile( } void -GreedyParameterPointSampler::load( +GreedySampler::load( std::string base_file_name) { char tmp[100]; @@ -389,7 +389,7 @@ GreedyParameterPointSampler::load( } void -GreedyParameterPointSampler::checkParameterPointInput() +GreedySampler::checkParameterPointInput() { CAROM_VERIFY(d_min_param_point.dim() == d_max_param_point.dim()); CAROM_VERIFY(d_num_parameter_points >= 1); @@ -437,7 +437,7 @@ GreedyParameterPointSampler::checkParameterPointInput() } void -GreedyParameterPointSampler::constructObject( +GreedySampler::constructObject( bool check_local_rom, double relative_error_tolerance, double alpha, @@ -504,7 +504,7 @@ GreedyParameterPointSampler::constructObject( } void -GreedyParameterPointSampler::initializeParameterPoints() +GreedySampler::initializeParameterPoints() { CAROM_VERIFY(d_parameter_points.size() > 0); CAROM_VERIFY(d_subset_size <= d_parameter_points.size()); @@ -524,7 +524,7 @@ GreedyParameterPointSampler::initializeParameterPoints() } std::shared_ptr -GreedyParameterPointSampler::getNextParameterPoint() +GreedySampler::getNextParameterPoint() { if (isComplete()) { @@ -578,7 +578,7 @@ GreedyParameterPointSampler::getNextParameterPoint() } struct GreedyErrorIndicatorPoint -GreedyParameterPointSampler::getNextPointRequiringRelativeError() +GreedySampler::getNextPointRequiringRelativeError() { if (isComplete()) { @@ -605,7 +605,7 @@ GreedyParameterPointSampler::getNextPointRequiringRelativeError() } struct GreedyErrorIndicatorPoint -GreedyParameterPointSampler::getNextPointRequiringErrorIndicator() +GreedySampler::getNextPointRequiringErrorIndicator() { if (isComplete()) { @@ -627,7 +627,7 @@ GreedyParameterPointSampler::getNextPointRequiringErrorIndicator() } struct GreedyErrorIndicatorPoint -GreedyParameterPointSampler::getNextSubsetPointRequiringErrorIndicator() +GreedySampler::getNextSubsetPointRequiringErrorIndicator() { if (d_point_requiring_error_indicator_computed) { @@ -734,7 +734,7 @@ GreedyParameterPointSampler::getNextSubsetPointRequiringErrorIndicator() } struct GreedyErrorIndicatorPoint -GreedyParameterPointSampler::getNextConvergencePointRequiringErrorIndicator() +GreedySampler::getNextConvergencePointRequiringErrorIndicator() { if (d_point_requiring_error_indicator_computed) { @@ -769,7 +769,7 @@ GreedyParameterPointSampler::getNextConvergencePointRequiringErrorIndicator() } void -GreedyParameterPointSampler::printSamplingType(std::string sampling_type) +GreedySampler::printSamplingType(std::string sampling_type) { if (d_rank == 0) { @@ -780,7 +780,7 @@ GreedyParameterPointSampler::printSamplingType(std::string sampling_type) } void -GreedyParameterPointSampler::printConvergenceAchieved() +GreedySampler::printConvergenceAchieved() { if (d_rank == 0) { @@ -808,7 +808,7 @@ GreedyParameterPointSampler::printConvergenceAchieved() } void -GreedyParameterPointSampler::setPointRelativeError(double error) +GreedySampler::setPointRelativeError(double error) { CAROM_VERIFY(error >= 0); CAROM_VERIFY(d_next_parameter_point_computed); @@ -912,7 +912,7 @@ GreedyParameterPointSampler::setPointRelativeError(double error) } void -GreedyParameterPointSampler::setPointErrorIndicator(double error, int vec_size) +GreedySampler::setPointErrorIndicator(double error, int vec_size) { CAROM_VERIFY(error >= 0); CAROM_VERIFY(d_point_requiring_error_indicator_computed); @@ -950,7 +950,7 @@ GreedyParameterPointSampler::setPointErrorIndicator(double error, int vec_size) } void -GreedyParameterPointSampler::printErrorIndicator(Vector errorIndicatorPoint, double proc_errors) +GreedySampler::printErrorIndicator(Vector errorIndicatorPoint, double proc_errors) { if (d_rank == 0) { @@ -967,7 +967,7 @@ GreedyParameterPointSampler::printErrorIndicator(Vector errorIndicatorPoint, dou } void -GreedyParameterPointSampler::agnosticPrint(std::string str) +GreedySampler::agnosticPrint(std::string str) { if (d_output_log_path == "") { @@ -983,7 +983,7 @@ GreedyParameterPointSampler::agnosticPrint(std::string str) } void -GreedyParameterPointSampler::printErrorIndicatorToleranceNotMet() +GreedySampler::printErrorIndicatorToleranceNotMet() { if (d_rank == 0) { @@ -994,7 +994,7 @@ GreedyParameterPointSampler::printErrorIndicatorToleranceNotMet() } void -GreedyParameterPointSampler::setSubsetErrorIndicator(double proc_errors) +GreedySampler::setSubsetErrorIndicator(double proc_errors) { if (d_check_local_rom || d_parameter_sampled_indices.size() == 1) { @@ -1077,7 +1077,7 @@ GreedyParameterPointSampler::setSubsetErrorIndicator(double proc_errors) } void -GreedyParameterPointSampler::setConvergenceErrorIndicator(double proc_errors) +GreedySampler::setConvergenceErrorIndicator(double proc_errors) { printErrorIndicator(d_convergence_points[d_counter], proc_errors); @@ -1113,14 +1113,14 @@ GreedyParameterPointSampler::setConvergenceErrorIndicator(double proc_errors) } void -GreedyParameterPointSampler::generateConvergenceSubset() +GreedySampler::generateConvergenceSubset() { d_convergence_points.clear(); d_convergence_points = generateRandomPoints(d_convergence_subset_size); } void -GreedyParameterPointSampler::startConvergence() +GreedySampler::startConvergence() { d_convergence_started = true; d_max_error = 0; @@ -1141,7 +1141,7 @@ GreedyParameterPointSampler::startConvergence() } std::vector -GreedyParameterPointSampler::generateRandomPoints(int num_points) +GreedySampler::generateRandomPoints(int num_points) { std::vector random_points; @@ -1164,7 +1164,7 @@ GreedyParameterPointSampler::generateRandomPoints(int num_points) } std::shared_ptr -GreedyParameterPointSampler::getNearestROM(Vector point) +GreedySampler::getNearestROM(Vector point) { CAROM_VERIFY(point.dim() == d_parameter_points[0].dim()); @@ -1193,7 +1193,7 @@ GreedyParameterPointSampler::getNearestROM(Vector point) } int -GreedyParameterPointSampler::getNearestNonSampledPoint(Vector point) +GreedySampler::getNearestNonSampledPoint(Vector point) { double closest_dist_to_points = INT_MAX; int closest_point_index = -1; @@ -1218,7 +1218,7 @@ GreedyParameterPointSampler::getNearestNonSampledPoint(Vector point) } int -GreedyParameterPointSampler::getNearestROMIndexToParameterPoint(int index, bool ignore_self) +GreedySampler::getNearestROMIndexToParameterPoint(int index, bool ignore_self) { CAROM_VERIFY(index >= 0 && index < d_parameter_points.size()); @@ -1251,13 +1251,13 @@ GreedyParameterPointSampler::getNearestROMIndexToParameterPoint(int index, bool } std::vector -GreedyParameterPointSampler::getParameterPointDomain() +GreedySampler::getParameterPointDomain() { return d_parameter_points; } std::vector -GreedyParameterPointSampler::getSampledParameterPoints() +GreedySampler::getSampledParameterPoints() { std::vector sampled_points; for (auto itr = d_parameter_sampled_indices.begin(); itr != d_parameter_sampled_indices.end(); ++itr) { @@ -1267,7 +1267,7 @@ GreedyParameterPointSampler::getSampledParameterPoints() } void -GreedyParameterPointSampler::save(std::string base_file_name) +GreedySampler::save(std::string base_file_name) { CAROM_ASSERT(!base_file_name.empty()); @@ -1369,7 +1369,7 @@ GreedyParameterPointSampler::save(std::string base_file_name) } bool -GreedyParameterPointSampler::isComplete() +GreedySampler::isComplete() { if (!d_procedure_completed && d_parameter_sampled_indices.size() == d_num_parameter_points) { @@ -1384,7 +1384,7 @@ GreedyParameterPointSampler::isComplete() return d_procedure_completed; } -GreedyParameterPointSampler::~GreedyParameterPointSampler() +GreedySampler::~GreedySampler() { } diff --git a/GreedyParameterPointSampler.h b/lib/algo/greedy/GreedySampler.h similarity index 97% rename from GreedyParameterPointSampler.h rename to lib/algo/greedy/GreedySampler.h index e01684276..03d11a669 100644 --- a/GreedyParameterPointSampler.h +++ b/lib/algo/greedy/GreedySampler.h @@ -15,23 +15,23 @@ // of linear reduced-order models": https://arxiv.org/abs/1506.07849 // // The greedy algorithm workflow is as follows: -// 1. Construct the GreedyParameterPointSampler by giving it a +// 1. Construct the GreedySampler by giving it a // domain of parameter points. // 2. Request a parameter point to create a local ROM at. // 3. Request a parameter point to compute an error error indicator // for using the nearest local ROM. -// 4. Give the computed error indicator to the GreedyParameterPointSampler. -// 5. Repeat steps 3 and 4 until the GreedyParameterPointSampler +// 4. Give the computed error indicator to the GreedySampler. +// 5. Repeat steps 3 and 4 until the GreedySampler // no longer requires more error indicators to be computed. -// 6. Repeat steps 2 to 5 until the GreedyParameterPointSampler +// 6. Repeat steps 2 to 5 until the GreedySampler // no longer requires more local ROMs to be created. // 7. The ROM database is now complete, meeting the error tolerance // for all parameter points within the domain. -#ifndef included_GreedyParameterPointSampler_h -#define included_GreedyParameterPointSampler_h +#ifndef included_GreedySampler_h +#define included_GreedySampler_h -#include "Vector.h" +#include "linalg/Vector.h" #include #include #include @@ -66,12 +66,12 @@ struct GreedyErrorIndicatorPoint { }; /** - * Class GreedyParameterPointSampler is a class defining the interface of a + * Class GreedySampler is a class defining the interface of a * greedy algorithm that given a domain of parameter points, iteratively * returns the next best parameter point to sample in order to create * a ROM database efficiently. */ -class GreedyParameterPointSampler +class GreedySampler { public: /** @@ -99,7 +99,7 @@ class GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointSampler( + GreedySampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -137,7 +137,7 @@ class GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointSampler( + GreedySampler( std::vector parameter_points, bool check_local_rom, double relative_error_tolerance, @@ -179,7 +179,7 @@ class GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointSampler( + GreedySampler( Vector param_space_min, Vector param_space_max, int num_parameter_points, @@ -223,7 +223,7 @@ class GreedyParameterPointSampler * @param[in] debug_algorithm Whether to turn off all randomness for * debugging purposes. */ - GreedyParameterPointSampler( + GreedySampler( double param_space_min, double param_space_max, int num_parameter_points, @@ -247,14 +247,14 @@ class GreedyParameterPointSampler * @param[in] output_log_path The path to the output log file. If not used, * outputs to stdout. */ - GreedyParameterPointSampler( + GreedySampler( std::string base_file_name, std::string output_log_path = ""); /** * @brief Destructor. */ - ~GreedyParameterPointSampler(); + ~GreedySampler(); /** * @brief Returns the next parameter point for which sampling is required. @@ -391,7 +391,7 @@ class GreedyParameterPointSampler void checkParameterPointInput(); /** - * @brief Construct the GreedyParameterPointSampler object. + * @brief Construct the GreedySampler object. */ void constructObject( bool check_local_rom, diff --git a/Interpolator.C b/lib/algo/manifold_interp/Interpolator.C similarity index 98% rename from Interpolator.C rename to lib/algo/manifold_interp/Interpolator.C index 51d35c4cd..6baa2c559 100644 --- a/Interpolator.C +++ b/lib/algo/manifold_interp/Interpolator.C @@ -14,8 +14,8 @@ #include #include -#include "Matrix.h" -#include "scalapack_wrapper.h" +#include "linalg/Matrix.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" /* Use C++11 built-in shared pointers if available; else fallback to Boost. */ diff --git a/Interpolator.h b/lib/algo/manifold_interp/Interpolator.h similarity index 100% rename from Interpolator.h rename to lib/algo/manifold_interp/Interpolator.h diff --git a/MatrixInterpolator.C b/lib/algo/manifold_interp/MatrixInterpolator.C similarity index 99% rename from MatrixInterpolator.C rename to lib/algo/manifold_interp/MatrixInterpolator.C index bdf83ba54..4329e6cd6 100644 --- a/MatrixInterpolator.C +++ b/lib/algo/manifold_interp/MatrixInterpolator.C @@ -14,8 +14,8 @@ #include #include -#include "Matrix.h" -#include "scalapack_wrapper.h" +#include "linalg/Matrix.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" /* Use C++11 built-in shared pointers if available; else fallback to Boost. */ diff --git a/MatrixInterpolator.h b/lib/algo/manifold_interp/MatrixInterpolator.h similarity index 100% rename from MatrixInterpolator.h rename to lib/algo/manifold_interp/MatrixInterpolator.h diff --git a/VectorInterpolator.C b/lib/algo/manifold_interp/VectorInterpolator.C similarity index 98% rename from VectorInterpolator.C rename to lib/algo/manifold_interp/VectorInterpolator.C index 5ebce2bc3..6ace2c4ef 100644 --- a/VectorInterpolator.C +++ b/lib/algo/manifold_interp/VectorInterpolator.C @@ -14,9 +14,9 @@ #include #include -#include "Matrix.h" -#include "Vector.h" -#include "scalapack_wrapper.h" +#include "linalg/Matrix.h" +#include "linalg/Vector.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" /* Use C++11 built-in shared pointers if available; else fallback to Boost. */ diff --git a/VectorInterpolator.h b/lib/algo/manifold_interp/VectorInterpolator.h similarity index 100% rename from VectorInterpolator.h rename to lib/algo/manifold_interp/VectorInterpolator.h diff --git a/DEIM.C b/lib/hyperreduction/DEIM.C similarity index 99% rename from DEIM.C rename to lib/hyperreduction/DEIM.C index 680b20b7d..829724a8d 100644 --- a/DEIM.C +++ b/lib/hyperreduction/DEIM.C @@ -11,7 +11,7 @@ // Description: Interface to the DEIM algorithm to determine the rows of the // rhs to be sampled for the interpolation of the rhs. -#include "Matrix.h" +#include "linalg/Matrix.h" #include "mpi.h" #include #include diff --git a/DEIM.h b/lib/hyperreduction/DEIM.h similarity index 100% rename from DEIM.h rename to lib/hyperreduction/DEIM.h diff --git a/GNAT.C b/lib/hyperreduction/GNAT.C similarity index 99% rename from GNAT.C rename to lib/hyperreduction/GNAT.C index c85b63bc4..c817a5f55 100644 --- a/GNAT.C +++ b/lib/hyperreduction/GNAT.C @@ -11,7 +11,7 @@ // Description: Interface to the DEIM algorithm to determine the rows of the // rhs to be sampled for the interpolation of the rhs. -#include "Matrix.h" +#include "linalg/Matrix.h" #include "mpi.h" #include #include diff --git a/QDEIM.C b/lib/hyperreduction/QDEIM.C similarity index 99% rename from QDEIM.C rename to lib/hyperreduction/QDEIM.C index 206549d38..46564ffb9 100644 --- a/QDEIM.C +++ b/lib/hyperreduction/QDEIM.C @@ -11,7 +11,7 @@ // Description: Interface to the QDEIM algorithm to determine the rows of the // rhs to be sampled for the interpolation of the rhs. -#include "Matrix.h" +#include "linalg/Matrix.h" #include "mpi.h" #include diff --git a/QDEIM.h b/lib/hyperreduction/QDEIM.h similarity index 100% rename from QDEIM.h rename to lib/hyperreduction/QDEIM.h diff --git a/STSampling.C b/lib/hyperreduction/STSampling.C similarity index 99% rename from STSampling.C rename to lib/hyperreduction/STSampling.C index 81ba01b83..8fb8ca3a1 100644 --- a/STSampling.C +++ b/lib/hyperreduction/STSampling.C @@ -8,7 +8,7 @@ * *****************************************************************************/ -#include "Matrix.h" +#include "linalg/Matrix.h" #include "mpi.h" #include #include diff --git a/STSampling.h b/lib/hyperreduction/STSampling.h similarity index 100% rename from STSampling.h rename to lib/hyperreduction/STSampling.h diff --git a/lib/librom.h b/lib/librom.h new file mode 100644 index 000000000..ae62b168e --- /dev/null +++ b/lib/librom.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * + * Copyright (c) 2013-2021, 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) + * + *****************************************************************************/ + +#ifndef included_librom_h +#define included_librom_h + +#include "linalg/BasisGenerator.h" +#include "linalg/BasisReader.h" +#include "linalg/Options.h" +#include "linalg/Matrix.h" +#include "linalg/Vector.h" +#include "algo/DMD.h" +#include "algo/greedy/GreedyCustomSampler.h" +#include "algo/greedy/GreedyRandomSampler.h" +#include "algo/manifold_interp/MatrixInterpolator.h" +#include "algo/manifold_interp/VectorInterpolator.h" +#include "hyperreduction/DEIM.h" +#include "hyperreduction/QDEIM.h" +#include "hyperreduction/STSampling.h" +#ifdef USEMFEM +#include "mfem/SampleMesh.hpp" +#endif + +#endif diff --git a/BasisGenerator.C b/lib/linalg/BasisGenerator.C similarity index 98% rename from BasisGenerator.C rename to lib/linalg/BasisGenerator.C index 073962657..6ac4b9248 100644 --- a/BasisGenerator.C +++ b/lib/linalg/BasisGenerator.C @@ -15,10 +15,10 @@ // vector generation. #include "BasisGenerator.h" -#include "StaticSVD.h" -#include "RandomizedSVD.h" -#include "IncrementalSVDStandard.h" -#include "IncrementalSVDFastUpdate.h" +#include "svd/StaticSVD.h" +#include "svd/RandomizedSVD.h" +#include "svd/IncrementalSVDStandard.h" +#include "svd/IncrementalSVDFastUpdate.h" namespace CAROM { diff --git a/BasisGenerator.h b/lib/linalg/BasisGenerator.h similarity index 99% rename from BasisGenerator.h rename to lib/linalg/BasisGenerator.h index a728fba64..728f90d00 100644 --- a/BasisGenerator.h +++ b/lib/linalg/BasisGenerator.h @@ -18,7 +18,7 @@ #include "BasisWriter.h" #include "BasisReader.h" #include "Options.h" -#include "SVD.h" +#include "svd/SVD.h" #include "mpi.h" diff --git a/BasisReader.C b/lib/linalg/BasisReader.C similarity index 99% rename from BasisReader.C rename to lib/linalg/BasisReader.C index 6d984a154..479ce2da8 100644 --- a/BasisReader.C +++ b/lib/linalg/BasisReader.C @@ -11,7 +11,7 @@ // Description: A class that reads basis vectors from a file. #include "BasisReader.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "Matrix.h" #include "Vector.h" #include "mpi.h" diff --git a/BasisReader.h b/lib/linalg/BasisReader.h similarity index 99% rename from BasisReader.h rename to lib/linalg/BasisReader.h index cf8e90978..b339948e6 100644 --- a/BasisReader.h +++ b/lib/linalg/BasisReader.h @@ -13,8 +13,8 @@ #ifndef included_BasisReader_h #define included_BasisReader_h -#include "Utilities.h" -#include "Database.h" +#include "utils/Utilities.h" +#include "utils/Database.h" #include #include diff --git a/BasisWriter.C b/lib/linalg/BasisWriter.C similarity index 98% rename from BasisWriter.C rename to lib/linalg/BasisWriter.C index 9c8e8a692..6e9016ce6 100644 --- a/BasisWriter.C +++ b/lib/linalg/BasisWriter.C @@ -11,11 +11,11 @@ // Description: A class that writes basis vectors to a file. #include "BasisWriter.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "Matrix.h" #include "Vector.h" #include "BasisGenerator.h" -#include "Utilities.h" +#include "utils/Utilities.h" #include "mpi.h" diff --git a/BasisWriter.h b/lib/linalg/BasisWriter.h similarity index 98% rename from BasisWriter.h rename to lib/linalg/BasisWriter.h index 66365fa0c..0ee2e2d5e 100644 --- a/BasisWriter.h +++ b/lib/linalg/BasisWriter.h @@ -13,7 +13,7 @@ #ifndef included_BasisWriter_h #define included_BasisWriter_h -#include "Database.h" +#include "utils/Database.h" #include namespace CAROM { diff --git a/Matrix.C b/lib/linalg/Matrix.C similarity index 99% rename from Matrix.C rename to lib/linalg/Matrix.C index 159f5c5e9..a92573e1b 100644 --- a/Matrix.C +++ b/lib/linalg/Matrix.C @@ -13,7 +13,7 @@ // distributed Matrix has its rows distributed across processors. #include "Matrix.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "mpi.h" #include diff --git a/Matrix.h b/lib/linalg/Matrix.h similarity index 100% rename from Matrix.h rename to lib/linalg/Matrix.h diff --git a/Options.h b/lib/linalg/Options.h similarity index 100% rename from Options.h rename to lib/linalg/Options.h diff --git a/Vector.C b/lib/linalg/Vector.C similarity index 99% rename from Vector.C rename to lib/linalg/Vector.C index 2ff8c76e2..595e33c1e 100644 --- a/Vector.C +++ b/lib/linalg/Vector.C @@ -13,7 +13,7 @@ // distributed Vector has its rows distributed across processors. #include "Vector.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "mpi.h" diff --git a/Vector.h b/lib/linalg/Vector.h similarity index 99% rename from Vector.h rename to lib/linalg/Vector.h index 9a467720d..ee13daafe 100644 --- a/Vector.h +++ b/lib/linalg/Vector.h @@ -15,7 +15,7 @@ #ifndef included_Vector_h #define included_Vector_h -#include "Utilities.h" +#include "utils/Utilities.h" #include #include diff --git a/scalapack_c_wrapper.c b/lib/linalg/scalapack_c_wrapper.c similarity index 100% rename from scalapack_c_wrapper.c rename to lib/linalg/scalapack_c_wrapper.c diff --git a/scalapack_f_wrapper.f90 b/lib/linalg/scalapack_f_wrapper.f90 similarity index 100% rename from scalapack_f_wrapper.f90 rename to lib/linalg/scalapack_f_wrapper.f90 diff --git a/scalapack_wrapper.h b/lib/linalg/scalapack_wrapper.h similarity index 100% rename from scalapack_wrapper.h rename to lib/linalg/scalapack_wrapper.h diff --git a/IncrementalSVD.C b/lib/linalg/svd/IncrementalSVD.C similarity index 99% rename from IncrementalSVD.C rename to lib/linalg/svd/IncrementalSVD.C index e243c840e..583cd4c8f 100644 --- a/IncrementalSVD.C +++ b/lib/linalg/svd/IncrementalSVD.C @@ -12,7 +12,7 @@ // interface. #include "IncrementalSVD.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "mpi.h" diff --git a/IncrementalSVD.h b/lib/linalg/svd/IncrementalSVD.h similarity index 99% rename from IncrementalSVD.h rename to lib/linalg/svd/IncrementalSVD.h index a6c751319..579c1c784 100644 --- a/IncrementalSVD.h +++ b/lib/linalg/svd/IncrementalSVD.h @@ -15,8 +15,8 @@ #define included_IncrementalSVD_h #include "SVD.h" -#include "Options.h" -#include "Database.h" +#include "linalg/Options.h" +#include "utils/Database.h" namespace CAROM { diff --git a/IncrementalSVDFastUpdate.C b/lib/linalg/svd/IncrementalSVDFastUpdate.C similarity index 99% rename from IncrementalSVDFastUpdate.C rename to lib/linalg/svd/IncrementalSVDFastUpdate.C index 9dc7f345b..8b9efd5ca 100644 --- a/IncrementalSVDFastUpdate.C +++ b/lib/linalg/svd/IncrementalSVDFastUpdate.C @@ -12,7 +12,7 @@ // using Matthew Brand's "fast update" method. #include "IncrementalSVDFastUpdate.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "mpi.h" diff --git a/IncrementalSVDFastUpdate.h b/lib/linalg/svd/IncrementalSVDFastUpdate.h similarity index 99% rename from IncrementalSVDFastUpdate.h rename to lib/linalg/svd/IncrementalSVDFastUpdate.h index 230896cef..b2ef2a566 100644 --- a/IncrementalSVDFastUpdate.h +++ b/lib/linalg/svd/IncrementalSVDFastUpdate.h @@ -15,7 +15,7 @@ #define included_IncrementalSVDFastUpdate_h #include "IncrementalSVD.h" -#include "Options.h" +#include "linalg/Options.h" namespace CAROM { diff --git a/IncrementalSVDStandard.C b/lib/linalg/svd/IncrementalSVDStandard.C similarity index 99% rename from IncrementalSVDStandard.C rename to lib/linalg/svd/IncrementalSVDStandard.C index 80ba4597d..fa69d34c1 100644 --- a/IncrementalSVDStandard.C +++ b/lib/linalg/svd/IncrementalSVDStandard.C @@ -13,7 +13,7 @@ // the "fast update" method. #include "IncrementalSVDStandard.h" -#include "HDFDatabase.h" +#include "utils/HDFDatabase.h" #include "mpi.h" diff --git a/IncrementalSVDStandard.h b/lib/linalg/svd/IncrementalSVDStandard.h similarity index 99% rename from IncrementalSVDStandard.h rename to lib/linalg/svd/IncrementalSVDStandard.h index 0b5a53322..a28571466 100644 --- a/IncrementalSVDStandard.h +++ b/lib/linalg/svd/IncrementalSVDStandard.h @@ -16,7 +16,7 @@ #define included_IncrementalSVDStandard_h #include "IncrementalSVD.h" -#include "Options.h" +#include "linalg/Options.h" namespace CAROM { diff --git a/RandomizedSVD.C b/lib/linalg/svd/RandomizedSVD.C similarity index 99% rename from RandomizedSVD.C rename to lib/linalg/svd/RandomizedSVD.C index 9a0cefa75..d07940eb1 100644 --- a/RandomizedSVD.C +++ b/lib/linalg/svd/RandomizedSVD.C @@ -14,7 +14,7 @@ #include "RandomizedSVD.h" #include "mpi.h" -#include "scalapack_wrapper.h" +#include "linalg/scalapack_wrapper.h" #include #include diff --git a/RandomizedSVD.h b/lib/linalg/svd/RandomizedSVD.h similarity index 96% rename from RandomizedSVD.h rename to lib/linalg/svd/RandomizedSVD.h index d9f53d188..340ac4e57 100644 --- a/RandomizedSVD.h +++ b/lib/linalg/svd/RandomizedSVD.h @@ -15,8 +15,8 @@ #define included_RandomizedSVD_h #include "StaticSVD.h" -#include "Options.h" -#include "scalapack_wrapper.h" +#include "linalg/Options.h" +#include "linalg/scalapack_wrapper.h" #include #include diff --git a/SVD.C b/lib/linalg/svd/SVD.C similarity index 100% rename from SVD.C rename to lib/linalg/svd/SVD.C diff --git a/SVD.h b/lib/linalg/svd/SVD.h similarity index 99% rename from SVD.h rename to lib/linalg/svd/SVD.h index 17aff2bf7..d9d745b10 100644 --- a/SVD.h +++ b/lib/linalg/svd/SVD.h @@ -14,8 +14,8 @@ #ifndef included_SVD_h #define included_SVD_h -#include "Matrix.h" -#include "Options.h" +#include "linalg/Matrix.h" +#include "linalg/Options.h" #include namespace CAROM { diff --git a/StaticSVD.C b/lib/linalg/svd/StaticSVD.C similarity index 99% rename from StaticSVD.C rename to lib/linalg/svd/StaticSVD.C index 3930d2588..fa978c552 100644 --- a/StaticSVD.C +++ b/lib/linalg/svd/StaticSVD.C @@ -14,7 +14,7 @@ #include "StaticSVD.h" #include "mpi.h" -#include "scalapack_wrapper.h" +#include "linalg/scalapack_wrapper.h" #include diff --git a/StaticSVD.h b/lib/linalg/svd/StaticSVD.h similarity index 98% rename from StaticSVD.h rename to lib/linalg/svd/StaticSVD.h index 45efb3b1c..7a5c333bd 100644 --- a/StaticSVD.h +++ b/lib/linalg/svd/StaticSVD.h @@ -15,8 +15,8 @@ #define included_StaticSVD_h #include "SVD.h" -#include "Options.h" -#include "scalapack_wrapper.h" +#include "linalg/Options.h" +#include "linalg/scalapack_wrapper.h" #include #include diff --git a/SampleMesh.hpp b/lib/mfem/SampleMesh.hpp similarity index 100% rename from SampleMesh.hpp rename to lib/mfem/SampleMesh.hpp diff --git a/Database.C b/lib/utils/Database.C similarity index 100% rename from Database.C rename to lib/utils/Database.C diff --git a/Database.h b/lib/utils/Database.h similarity index 100% rename from Database.h rename to lib/utils/Database.h diff --git a/HDFDatabase.C b/lib/utils/HDFDatabase.C similarity index 100% rename from HDFDatabase.C rename to lib/utils/HDFDatabase.C diff --git a/HDFDatabase.h b/lib/utils/HDFDatabase.h similarity index 100% rename from HDFDatabase.h rename to lib/utils/HDFDatabase.h diff --git a/ParallelBuffer.C b/lib/utils/ParallelBuffer.C similarity index 100% rename from ParallelBuffer.C rename to lib/utils/ParallelBuffer.C diff --git a/ParallelBuffer.h b/lib/utils/ParallelBuffer.h similarity index 100% rename from ParallelBuffer.h rename to lib/utils/ParallelBuffer.h diff --git a/Utilities.C b/lib/utils/Utilities.C similarity index 100% rename from Utilities.C rename to lib/utils/Utilities.C diff --git a/Utilities.h b/lib/utils/Utilities.h similarity index 100% rename from Utilities.h rename to lib/utils/Utilities.h diff --git a/scripts/compile.sh b/scripts/compile.sh index db88966bc..8b6f63029 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -55,9 +55,10 @@ if [[ $USE_MFEM == "On" ]]; then fi if [[ $ARDRA == "true" ]]; then - mkdir ${REPO_PREFIX}/buildArdra + mkdir -p ${REPO_PREFIX}/buildArdra pushd ${REPO_PREFIX}/buildArdra else + mkdir -p ${REPO_PREFIX}/build pushd ${REPO_PREFIX}/build fi rm -rf * diff --git a/BASELINES/random_100proc.out b/tests/baselines/random/random_100proc.out similarity index 100% rename from BASELINES/random_100proc.out rename to tests/baselines/random/random_100proc.out diff --git a/BASELINES/random_10proc.out b/tests/baselines/random/random_10proc.out similarity index 100% rename from BASELINES/random_10proc.out rename to tests/baselines/random/random_10proc.out diff --git a/BASELINES/random_1proc.out b/tests/baselines/random/random_1proc.out similarity index 100% rename from BASELINES/random_1proc.out rename to tests/baselines/random/random_1proc.out diff --git a/BASELINES/random_20proc.out b/tests/baselines/random/random_20proc.out similarity index 100% rename from BASELINES/random_20proc.out rename to tests/baselines/random/random_20proc.out diff --git a/BASELINES/random_25proc.out b/tests/baselines/random/random_25proc.out similarity index 100% rename from BASELINES/random_25proc.out rename to tests/baselines/random/random_25proc.out diff --git a/BASELINES/random_2proc.out b/tests/baselines/random/random_2proc.out similarity index 100% rename from BASELINES/random_2proc.out rename to tests/baselines/random/random_2proc.out diff --git a/BASELINES/random_4proc.out b/tests/baselines/random/random_4proc.out similarity index 100% rename from BASELINES/random_4proc.out rename to tests/baselines/random/random_4proc.out diff --git a/BASELINES/random_50proc.out b/tests/baselines/random/random_50proc.out similarity index 100% rename from BASELINES/random_50proc.out rename to tests/baselines/random/random_50proc.out diff --git a/BASELINES/random_5proc.out b/tests/baselines/random/random_5proc.out similarity index 100% rename from BASELINES/random_5proc.out rename to tests/baselines/random/random_5proc.out diff --git a/BASELINES/smoke_1proc.out b/tests/baselines/smoke/smoke_1proc.out similarity index 100% rename from BASELINES/smoke_1proc.out rename to tests/baselines/smoke/smoke_1proc.out diff --git a/BASELINES/smoke_2proc.out b/tests/baselines/smoke/smoke_2proc.out similarity index 100% rename from BASELINES/smoke_2proc.out rename to tests/baselines/smoke/smoke_2proc.out diff --git a/BASELINES/smoke_3proc.out b/tests/baselines/smoke/smoke_3proc.out similarity index 100% rename from BASELINES/smoke_3proc.out rename to tests/baselines/smoke/smoke_3proc.out diff --git a/BASELINES/smoke_6proc.out b/tests/baselines/smoke/smoke_6proc.out similarity index 100% rename from BASELINES/smoke_6proc.out rename to tests/baselines/smoke/smoke_6proc.out diff --git a/BASELINES/uneven_1proc.out b/tests/baselines/uneven/uneven_1proc.out similarity index 100% rename from BASELINES/uneven_1proc.out rename to tests/baselines/uneven/uneven_1proc.out diff --git a/BASELINES/uneven_2proc.out b/tests/baselines/uneven/uneven_2proc.out similarity index 100% rename from BASELINES/uneven_2proc.out rename to tests/baselines/uneven/uneven_2proc.out diff --git a/BASELINES/uneven_3proc.out b/tests/baselines/uneven/uneven_3proc.out similarity index 100% rename from BASELINES/uneven_3proc.out rename to tests/baselines/uneven/uneven_3proc.out diff --git a/BASELINES/uneven_4proc.out b/tests/baselines/uneven/uneven_4proc.out similarity index 100% rename from BASELINES/uneven_4proc.out rename to tests/baselines/uneven/uneven_4proc.out diff --git a/BASELINES/uneven_5proc.out b/tests/baselines/uneven/uneven_5proc.out similarity index 100% rename from BASELINES/uneven_5proc.out rename to tests/baselines/uneven/uneven_5proc.out diff --git a/BASELINES/uneven_6proc.out b/tests/baselines/uneven/uneven_6proc.out similarity index 100% rename from BASELINES/uneven_6proc.out rename to tests/baselines/uneven/uneven_6proc.out diff --git a/tests/load_samples.C b/tests/load_samples.C index f6b8df27d..928edfab8 100644 --- a/tests/load_samples.C +++ b/tests/load_samples.C @@ -13,8 +13,8 @@ // run in serial. Assumes this file is located in libROM/build. // If not, please adjust file address of sample data below. -#include "../BasisGenerator.h" -#include "../scalapack_wrapper.h" +#include "linalg/BasisGenerator.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" #include diff --git a/tests/random_test.C b/tests/random_test.C index d641fbd3a..6f6e91ff9 100644 --- a/tests/random_test.C +++ b/tests/random_test.C @@ -14,7 +14,7 @@ // same for all processor decompositions when // dim * number of processors is constant. -#include "../BasisGenerator.h" +#include "linalg/BasisGenerator.h" #include "mpi.h" diff --git a/tests/smoke_static.C b/tests/smoke_static.C index 16ef340a8..f36ff3d14 100644 --- a/tests/smoke_static.C +++ b/tests/smoke_static.C @@ -11,8 +11,8 @@ // Description: Simple test of the incremental fast update algorithm and // incremental sampler. -#include "../BasisGenerator.h" -#include "../scalapack_wrapper.h" +#include "linalg/BasisGenerator.h" +#include "linalg/scalapack_wrapper.h" #include "mpi.h" #include diff --git a/tests/smoke_test.C b/tests/smoke_test.C index 5a2a9d390..b90fea439 100644 --- a/tests/smoke_test.C +++ b/tests/smoke_test.C @@ -11,7 +11,7 @@ // Description: Simple test of the incremental fast update algorithm and // incremental sampler. -#include "../BasisGenerator.h" +#include "linalg/BasisGenerator.h" #include "mpi.h" diff --git a/tests/test_DEIM.C b/tests/test_DEIM.C index 5fb1efc7c..9549a2885 100644 --- a/tests/test_DEIM.C +++ b/tests/test_DEIM.C @@ -16,8 +16,8 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../DEIM.h" -#include "../Matrix.h" +#include "hyperreduction/DEIM.h" +#include "linalg/Matrix.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_DMD.C b/tests/test_DMD.C index c0c56cbe3..371d01110 100644 --- a/tests/test_DMD.C +++ b/tests/test_DMD.C @@ -18,8 +18,8 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../DMD.h" -#include "../Vector.h" +#include "algo/DMD.h" +#include "linalg/Vector.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_GNAT.C b/tests/test_GNAT.C index 638143f77..16301f2e0 100644 --- a/tests/test_GNAT.C +++ b/tests/test_GNAT.C @@ -16,8 +16,8 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../DEIM.h" -#include "../Matrix.h" +#include "hyperreduction/DEIM.h" +#include "linalg/Matrix.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_GreedyParameterPointPreDefinedSampler.C b/tests/test_GreedyCustomSampler.C similarity index 89% rename from tests/test_GreedyParameterPointPreDefinedSampler.C rename to tests/test_GreedyCustomSampler.C index 3ef930147..afdabfd2e 100644 --- a/tests/test_GreedyParameterPointPreDefinedSampler.C +++ b/tests/test_GreedyCustomSampler.C @@ -16,7 +16,7 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../GreedyParameterPointPreDefinedSampler.h" +#include "algo/greedy/GreedyCustomSampler.h" #define _USE_MATH_DEFINES #include @@ -27,7 +27,7 @@ TEST(GoogleTestFramework, GoogleTestFrameworkFound) { SUCCEED(); } -TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointPreDefinedSamplerCentroid) +TEST(GreedyCustomSamplerSerialTest, Test_GreedyCustomSamplerCentroid) { // Get the rank of this process, and the number of processors. int mpi_init, d_rank, d_num_procs; @@ -40,7 +40,7 @@ TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointP MPI_Comm_size(MPI_COMM_WORLD, &d_num_procs); std::vector paramPoints = {1.0, 3.0, 6.0}; - CAROM::GreedyParameterPointPreDefinedSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 2, 3, "", "", true, 1, true); + CAROM::GreedyCustomSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 2, 3, "", "", true, 1, true); std::shared_ptr nextPointToSample = caromGreedySampler.getNextParameterPoint(); EXPECT_EQ(nextPointToSample.get()->item(0), 3.0); @@ -75,7 +75,7 @@ TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointP firstPoint = caromGreedySampler.getNextPointRequiringErrorIndicator(); } -TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointPreDefinedSamplerMultiDimensionalCentroid) +TEST(GreedyCustomSamplerSerialTest, Test_GreedyCustomSamplerMultiDimensionalCentroid) { // Get the rank of this process, and the number of processors. int mpi_init, d_rank, d_num_procs; @@ -100,7 +100,7 @@ TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointP item2.item(1) = 16.0; std::vector paramPoints = {item0, item1, item2}; - CAROM::GreedyParameterPointPreDefinedSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 2, 3, "", "", true, 1, true); + CAROM::GreedyCustomSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 2, 3, "", "", true, 1, true); std::shared_ptr nextPointToSample = caromGreedySampler.getNextParameterPoint(); EXPECT_EQ(nextPointToSample.get()->item(0), 3.0); @@ -141,7 +141,7 @@ TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointP firstPoint = caromGreedySampler.getNextPointRequiringErrorIndicator(); } -TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointSaveAndLoad) +TEST(GreedyCustomSamplerSerialTest, Test_GreedySaveAndLoad) { // Get the rank of this process, and the number of processors. int mpi_init, d_rank, d_num_procs; @@ -154,10 +154,10 @@ TEST(GreedyParameterPointPreDefinedSamplerSerialTest, Test_GreedyParameterPointS MPI_Comm_size(MPI_COMM_WORLD, &d_num_procs); std::vector paramPoints = {1.0, 2.0, 3.0, 99.0, 100.0, 101.0}; - CAROM::GreedyParameterPointPreDefinedSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 3, 4, "", "", false, 1, true); + CAROM::GreedyCustomSampler caromGreedySampler(paramPoints, false, 0.1, 1, 1, 3, 4, "", "", false, 1, true); caromGreedySampler.save("greedy_test"); - CAROM::GreedyParameterPointPreDefinedSampler caromGreedySamplerLoad("greedy_test"); + CAROM::GreedyCustomSampler caromGreedySamplerLoad("greedy_test"); caromGreedySamplerLoad.save("greedy_test_LOAD"); CAROM::Vector pointToFindNearestROM(1, false); diff --git a/tests/test_IncrementalSVD.C b/tests/test_IncrementalSVD.C index 5b6012f9c..faeb20c4c 100644 --- a/tests/test_IncrementalSVD.C +++ b/tests/test_IncrementalSVD.C @@ -16,7 +16,7 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../IncrementalSVD.h" +#include "linalg/svd/IncrementalSVD.h" /** * Simple smoke test to make sure Google Test is properly linked diff --git a/tests/test_Matrix.C b/tests/test_Matrix.C index 917b08268..b9e064eeb 100644 --- a/tests/test_Matrix.C +++ b/tests/test_Matrix.C @@ -16,7 +16,7 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../Matrix.h" +#include "linalg/Matrix.h" /** * Simple smoke test to make sure Google Test is properly linked diff --git a/tests/test_QDEIM.C b/tests/test_QDEIM.C index 6698db2de..9e4f95260 100644 --- a/tests/test_QDEIM.C +++ b/tests/test_QDEIM.C @@ -16,8 +16,8 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../QDEIM.h" -#include "../Matrix.h" +#include "hyperreduction/QDEIM.h" +#include "linalg/Matrix.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_RandomizedSVD.C b/tests/test_RandomizedSVD.C index e6a28d906..8fb34d0f8 100644 --- a/tests/test_RandomizedSVD.C +++ b/tests/test_RandomizedSVD.C @@ -18,7 +18,7 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../BasisGenerator.h" +#include "linalg/BasisGenerator.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_SVD.C b/tests/test_SVD.C index 233ad283b..35f164b5f 100644 --- a/tests/test_SVD.C +++ b/tests/test_SVD.C @@ -16,8 +16,8 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../Options.h" -#include "../SVD.h" +#include "linalg/Options.h" +#include "linalg/svd/SVD.h" /** * Simple smoke test to make sure Google Test is properly linked diff --git a/tests/test_StaticSVD.C b/tests/test_StaticSVD.C index 7bb653d1d..97a82b462 100644 --- a/tests/test_StaticSVD.C +++ b/tests/test_StaticSVD.C @@ -1,4 +1,14 @@ -#include "../BasisGenerator.h" +/****************************************************************************** + * + * Copyright (c) 2013-2021, 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) + * + *****************************************************************************/ + +#include "linalg/BasisGenerator.h" #include #include #include diff --git a/tests/test_Vector.C b/tests/test_Vector.C index ac1b99404..a4fdd33a9 100644 --- a/tests/test_Vector.C +++ b/tests/test_Vector.C @@ -16,7 +16,7 @@ #ifdef CAROM_HAS_GTEST #include #include -#include "../Vector.h" +#include "linalg/Vector.h" #define _USE_MATH_DEFINES #include diff --git a/tests/test_include.C b/tests/test_include.C new file mode 100644 index 000000000..bf9d298c0 --- /dev/null +++ b/tests/test_include.C @@ -0,0 +1,97 @@ +/****************************************************************************** + * + * Copyright (c) 2013-2021, 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) + * + *****************************************************************************/ + +// Description: Simple test of the incremental fast update algorithm and +// incremental sampler. + +#include "librom.h" + +#include "mpi.h" + +#include + +int +main( + int argc, + char* argv[]) +{ + // Initialize MPI and get the number of processors and this processor's + // rank. + MPI_Init(&argc, &argv); + int size; + MPI_Comm_size(MPI_COMM_WORLD, &size); + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + // Given the number of processors and the rank of this processor set the + // dimension of the problem. + int dim; + if (size == 1) { + dim = 6; + } + else if (size == 2) { + dim = 3; + } + else if (size == 3) { + dim = 2; + } + else if (size == 6) { + dim = 1; + } + else { + if (rank == 0) { + printf("Illegal number of procs.\n"); + printf("Allowed number of procs is 1, 2, 3, or 6.\n"); + } + return 1; + } + + // Construct the incremental basis generator to use the fast update + // incremental algorithm and the incremental sampler. + CAROM::Options svd_options = CAROM::Options(dim, 2).setMaxBasisDimension(2) + .setIncrementalSVD(1.0e-2, 1.0e-6, 1.0e-2, 0.11, true).setDebugMode(true); + + + CAROM::BasisGenerator inc_basis_generator( + svd_options, true + ); + + // Define the values for the first sample. + double vals0[6] = {1.0, 6.0, 3.0, 8.0, 17.0, 9.0}; + + // Define the values for the second sample. + double vals1[6] = {2.0, 7.0, 4.0, 9.0, 18.0, 10.0}; + + bool status = false; + + // Take the first sample. + if (inc_basis_generator.isNextSample(0.0)) { + status = inc_basis_generator.takeSample(&vals0[dim*rank], 0.0, 0.11); + if (status) { + inc_basis_generator.computeNextSampleTime(&vals0[dim*rank], + &vals0[dim*rank], + 0.0); + } + } + + // Take the second sample. + if (status && inc_basis_generator.isNextSample(0.11)) { + status = inc_basis_generator.takeSample(&vals1[dim*rank], 0.11, 0.11); + if (status) { + inc_basis_generator.computeNextSampleTime(&vals1[dim*rank], + &vals1[dim*rank], + 0.11); + } + } + + // Finalize MPI and return. + MPI_Finalize(); + return !status; +} diff --git a/tests/uneven_dist.C b/tests/uneven_dist.C index c41753f45..e2755c607 100644 --- a/tests/uneven_dist.C +++ b/tests/uneven_dist.C @@ -12,7 +12,7 @@ // sampler in which the complete system in unevenly distributed // across the processors. -#include "../BasisGenerator.h" +#include "linalg/BasisGenerator.h" #include "mpi.h" diff --git a/tests/weak_scaling.C b/tests/weak_scaling.C index eba649367..b275a0573 100644 --- a/tests/weak_scaling.C +++ b/tests/weak_scaling.C @@ -14,7 +14,7 @@ // same for all processor decompositions when // dim * number of processors is constant. -#include "../BasisGenerator.h" +#include "linalg/BasisGenerator.h" #include "mpi.h"