Skip to content

Commit

Permalink
nnls criterion option
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer2368 committed Jul 10, 2024
1 parent 28d1552 commit 5a060eb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 86 deletions.
79 changes: 0 additions & 79 deletions dependencies/FindMETIS.cmake

This file was deleted.

6 changes: 2 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WORKDIR $LIB_DIR
RUN sudo git clone https://github.com/scivision/mumps.git
WORKDIR ./mumps
RUN sudo git checkout v5.6.2.1
RUN sudo wget -O cmake/FindMETIS.cmake https://github.com/LLNL/scaleupROM/raw/install/dependencies/FindMETIS.cmake
RUN sudo wget -O cmake/FindMETIS.cmake "https://raw.githubusercontent.com/LLNL/scaleupROM/main/install-helper/mumps/FindMETIS.cmake"
# RUN sudo sed -i 's/if(parallel IN_LIST METIS_FIND_COMPONENTS)/if("parallel" IN_LIST METIS_FIND_COMPONENTS)/g' cmake/FindMETIS.cmake

# RUN sudo sed -i 's/option(CMAKE_TLS_VERIFY "Verify TLS certificates" ON)/option(CMAKE_TLS_VERIFY "Verify TLS certificates" OFF)/g' options.cmake
Expand Down Expand Up @@ -52,9 +52,7 @@ ENV YAML_DIR=$LIB_DIR/yaml-cpp
# install libROM for scaleupROM
WORKDIR $LIB_DIR
RUN sudo git clone https://github.com/LLNL/libROM.git
WORKDIR ./libROM
RUN sudo git pull && sudo git checkout mpi-io
WORKDIR ./build
WORKDIR ./libROM/build
# libROM is using the MFEM without MUMPS right now.
RUN sudo cmake .. -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DUSE_MFEM=OFF -DMFEM_USE_GSLIB=${MFEM_USE_GSLIB}
RUN sudo make -j 16
Expand Down
4 changes: 4 additions & 0 deletions include/rom_interfaceform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "rom_handler.hpp"
#include "hdf5_utils.hpp"
#include "hyperreduction_integ.hpp"
#include "linalg/NNLS.h"

namespace mfem
{
Expand Down Expand Up @@ -55,6 +56,9 @@ class ROMInterfaceForm : public InterfaceForm
/// @brief Flag for precomputing necessary coefficients for fast computation.
bool precompute = false;

/// @brief Energy norm criterion for NNLS.
CAROM::NNLS_termination nnls_criterion = CAROM::NNLS_termination::L2;

public:
ROMInterfaceForm(Array<Mesh *> &meshes_, Array<FiniteElementSpace *> &fes_,
Array<FiniteElementSpace *> &comp_fes_, TopologyHandler *topol_);
Expand Down
3 changes: 3 additions & 0 deletions include/rom_nonlinearform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class ROMNonlinearForm : public NonlinearForm
/// @brief Flag for precomputing necessary coefficients for fast computation.
bool precompute = false;

/// @brief Energy norm criterion for NNLS.
CAROM::NNLS_termination nnls_criterion = CAROM::NNLS_termination::L2;

/*
Flag for being reference ROMNonlinearForm.
If not reference, all EQPElement arrays are view arrays, not owning them.
Expand Down
10 changes: 8 additions & 2 deletions src/rom_interfaceform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "rom_interfaceform.hpp"
#include "etc.hpp"
#include "utils/mpi_utils.h" // this is from libROM/utils.
#include "linalg/NNLS.h"

using namespace std;

Expand All @@ -27,6 +26,12 @@ ROMInterfaceForm::ROMInterfaceForm(

// block_offsets should be updated according to the number of basis vectors.
block_offsets = -1;

std::string nnls_str = config.GetOption<std::string>("model_reduction/eqp/criterion", "l2");
if (nnls_str == "l2") nnls_criterion = CAROM::NNLS_termination::L2;
else if (nnls_str == "linf") nnls_criterion = CAROM::NNLS_termination::LINF;
else
mfem_error("ROMNonlinearForm: unknown NNLS criterion!\n");
}

ROMInterfaceForm::~ROMInterfaceForm()
Expand Down Expand Up @@ -546,7 +551,8 @@ void ROMInterfaceForm::TrainEQPForIntegrator(
CAROM::Vector eqpSol(Gt.numRows(), true);
int nnz = 0;
{
CAROM::NNLSSolver nnls(nnls_tol, 0, maxNNLSnnz, 2);
CAROM::NNLSSolver nnls(nnls_tol, 0, maxNNLSnnz, 2, 1.0e-4, 1.0e-14,
100000, 100000, nnls_criterion);

CAROM::Vector rhs_ub(rhs_Gw);
CAROM::Vector rhs_lb(rhs_Gw);
Expand Down
9 changes: 8 additions & 1 deletion src/rom_nonlinearform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ ROMNonlinearForm::ROMNonlinearForm(const int num_basis, FiniteElementSpace *f, c
{
height = width = num_basis;

std::string nnls_str = config.GetOption<std::string>("model_reduction/eqp/criterion", "l2");
if (nnls_str == "l2") nnls_criterion = CAROM::NNLS_termination::L2;
else if (nnls_str == "linf") nnls_criterion = CAROM::NNLS_termination::LINF;
else
mfem_error("ROMNonlinearForm: unknown NNLS criterion!\n");

for (int k = 0; k < Nt; k++) jac_timers[k] = new StopWatch;
}

Expand Down Expand Up @@ -769,7 +775,8 @@ void ROMNonlinearForm::TrainEQPForIntegrator(
CAROM::Vector eqpSol(Gt.numRows(), true);
int nnz = 0;
{
CAROM::NNLSSolver nnls(nnls_tol, 0, maxNNLSnnz, 2);
CAROM::NNLSSolver nnls(nnls_tol, 0, maxNNLSnnz, 2, 1.0e-4, 1.0e-14,
100000, 100000, nnls_criterion);

CAROM::Vector rhs_ub(rhs_Gw);
CAROM::Vector rhs_lb(rhs_Gw);
Expand Down

0 comments on commit 5a060eb

Please sign in to comment.