Skip to content

Commit

Permalink
Merge pull request #22 from LLNL/prom_dg_local_advection
Browse files Browse the repository at this point in the history
Add DG local advection prom example
  • Loading branch information
ckendrick authored Feb 15, 2024
2 parents 96e5835 + 7e39ee0 commit dda95c6
Show file tree
Hide file tree
Showing 7 changed files with 952 additions and 13 deletions.
30 changes: 17 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,34 @@ link_libraries(
add_subdirectory("extern/pybind11")

pybind11_add_module(_pylibROM
bindings/pylibROM/pylibROM.cpp
bindings/pylibROM/pylibROM.cpp

bindings/pylibROM/linalg/pyMatrix.cpp
bindings/pylibROM/linalg/pyVector.cpp
bindings/pylibROM/linalg/pyBasisGenerator.cpp
bindings/pylibROM/linalg/pyBasisReader.cpp
bindings/pylibROM/linalg/pyMatrix.cpp
bindings/pylibROM/linalg/pyVector.cpp
bindings/pylibROM/linalg/pyBasisGenerator.cpp
bindings/pylibROM/linalg/pyBasisReader.cpp
bindings/pylibROM/linalg/pyBasisWriter.cpp
bindings/pylibROM/linalg/pyOptions.cpp
bindings/pylibROM/linalg/pyNNLS.cpp
bindings/pylibROM/linalg/svd/pySVD.cpp
bindings/pylibROM/linalg/svd/pyStaticSVD.cpp
bindings/pylibROM/linalg/svd/pyIncrementalSVD.cpp
bindings/pylibROM/linalg/pyOptions.cpp
bindings/pylibROM/linalg/pyNNLS.cpp
bindings/pylibROM/linalg/svd/pySVD.cpp
bindings/pylibROM/linalg/svd/pyStaticSVD.cpp
bindings/pylibROM/linalg/svd/pyIncrementalSVD.cpp

bindings/pylibROM/algo/pyDMD.cpp
bindings/pylibROM/algo/pyDMD.cpp
bindings/pylibROM/algo/pyParametricDMD.cpp
bindings/pylibROM/algo/pyNonuniformDMD.cpp
bindings/pylibROM/algo/pyAdaptiveDMD.cpp
bindings/pylibROM/algo/pyAdaptiveDMD.cpp
bindings/pylibROM/algo/manifold_interp/pyInterpolator.cpp
bindings/pylibROM/algo/manifold_interp/pyMatrixInterpolator.cpp
bindings/pylibROM/algo/manifold_interp/pyVectorInterpolator.cpp

bindings/pylibROM/hyperreduction/pyDEIM.cpp
bindings/pylibROM/hyperreduction/pyGNAT.cpp
bindings/pylibROM/hyperreduction/pyQDEIM.cpp
bindings/pylibROM/hyperreduction/pyS_OPT.cpp
bindings/pylibROM/hyperreduction/pySTSampling.cpp
bindings/pylibROM/hyperreduction/pyUtilities.cpp

bindings/pylibROM/utils/mpi_utils.cpp
bindings/pylibROM/utils/pyDatabase.hpp
bindings/pylibROM/utils/pyDatabase.cpp
Expand Down
1 change: 1 addition & 0 deletions bindings/pylibROM/algo/manifold_interp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from _pylibROM.algo.manifold_interp import *
20 changes: 20 additions & 0 deletions bindings/pylibROM/algo/manifold_interp/pyInterpolator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "linalg/Matrix.h"
#include "linalg/Vector.h"
#include "algo/manifold_interp/Interpolator.h"

namespace py = pybind11;
using namespace CAROM;

void
init_Interpolator(pybind11::module_ &m)
{
m.def("obtainRBFToTrainingPoints", &obtainRBFToTrainingPoints);
m.def("rbfWeightedSum", &rbfWeightedSum);
m.def("obtainRBF", &obtainRBF);
m.def("convertClosestRBFToEpsilon", &convertClosestRBFToEpsilon);
m.def("obtainRotationMatrices", &obtainRotationMatrices);
}
27 changes: 27 additions & 0 deletions bindings/pylibROM/algo/manifold_interp/pyMatrixInterpolator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "linalg/Matrix.h"
#include "linalg/Vector.h"
#include "algo/manifold_interp/MatrixInterpolator.h"

namespace py = pybind11;
using namespace CAROM;

void
init_MatrixInterpolator(pybind11::module_ &m)
{
py::class_<MatrixInterpolator>(m, "MatrixInterpolator")
.def(py::init<std::vector<Vector *>, std::vector<Matrix *>, std::vector<Matrix *>, int, std::string, std::string, std::string, double>(),
py::arg("parameter_points"),
py::arg("rotation_matrices"),
py::arg("reduced_matrices"),
py::arg("ref_point"),
py::arg("matrix_type"),
py::arg("rbf") = "G",
py::arg("interp_method") = "LS",
py::arg("closest_rbf_val") = 0.9)
.def("interpolate", &MatrixInterpolator::interpolate, py::arg("point"), py::arg("orthogonalize") = false)
.def("__del__", [](MatrixInterpolator& self) { self.~MatrixInterpolator(); });
}
29 changes: 29 additions & 0 deletions bindings/pylibROM/algo/manifold_interp/pyVectorInterpolator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include "linalg/Matrix.h"
#include "linalg/Vector.h"
#include "algo/manifold_interp/VectorInterpolator.h"

namespace py = pybind11;
using namespace CAROM;

void
init_VectorInterpolator(pybind11::module_ &m)
{
py::class_<VectorInterpolator>(m, "VectorInterpolator")
.def(py::init<std::vector<Vector *>, std::vector<Matrix *>, std::vector<Vector *>, int, std::string, std::string, double>(),
py::arg("parameter_points"),
py::arg("rotation_matrices"),
py::arg("reduced_vectors"),
py::arg("ref_point"),
py::arg("rbf") = "G",
py::arg("interp_method") = "LS",
py::arg("closest_rbf_val") = 0.9)
.def("interpolate", &VectorInterpolator::interpolate)
.def("__del__", [](VectorInterpolator& self) { self.~VectorInterpolator(); });

m.def("obtainInterpolatedVector", &obtainInterpolatedVector);
m.def("solveLinearSystem", &solveLinearSystem);
}
10 changes: 10 additions & 0 deletions bindings/pylibROM/pylibROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ void init_ParametricDMD(pybind11::module_ &m);
void init_NonuniformDMD(pybind11::module_ &m);
void init_AdaptiveDMD(pybind11::module_ &m);

//algo/manifold_interp
void init_Interpolator(pybind11::module_ &);
void init_VectorInterpolator(pybind11::module_ &);
void init_MatrixInterpolator(pybind11::module_ &);

//hyperreduction
void init_DEIM(pybind11::module_ &m);
void init_GNAT(pybind11::module_ &m);
Expand Down Expand Up @@ -69,6 +74,11 @@ PYBIND11_MODULE(_pylibROM, m) {
init_AdaptiveDMD(algo);
init_NonuniformDMD(algo);

py::module manifold_interp = algo.def_submodule("manifold_interp");
init_Interpolator(manifold_interp);
init_VectorInterpolator(manifold_interp);
init_MatrixInterpolator(manifold_interp);

py::module hyperreduction = m.def_submodule("hyperreduction");
init_DEIM(hyperreduction);
init_GNAT(hyperreduction);
Expand Down
Loading

0 comments on commit dda95c6

Please sign in to comment.