-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bindings for AdaptiveDMD and NonuniformDMD. * added ci test for DMD class. * parallel test for DMD. * fix on parallel dmd test. * initial commit * initial commit * dg_euler.py in progress... * finished dg_euler testing example * minor changes and added mesh file * fom timer corrected * minor corrections to dg_euler.py * corrections to dg_euler.py and pyAdaptiveDMD.cpp --------- Co-authored-by: Kevin Chung <[email protected]> Co-authored-by: Henry Yu <[email protected]> Co-authored-by: Henry Yu <[email protected]> Co-authored-by: Henry Yu <[email protected]>
- Loading branch information
1 parent
4a8b2bc
commit 72c8cdf
Showing
11 changed files
with
1,192 additions
and
302 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
#include "algo/AdaptiveDMD.h" | ||
#include "linalg/Vector.h" | ||
#include "linalg/Matrix.h" | ||
|
||
namespace py = pybind11; | ||
using namespace CAROM; | ||
|
||
void init_AdaptiveDMD(pybind11::module_ &m){ | ||
|
||
py::class_<AdaptiveDMD, DMD>(m, "AdaptiveDMD") | ||
.def(py::init<int, double, std::string, std::string, double, bool, Vector*>(), | ||
py::arg("dim"), | ||
py::arg("desired_dt") = -1.0, | ||
py::arg("rbf") = "G", | ||
py::arg("interp_method") = "LS", | ||
py::arg("closest_rbf_val") = 0.9, | ||
py::arg("alt_output_basis") = false, | ||
py::arg("state_offset") = nullptr) | ||
.def("train", (void (AdaptiveDMD::*)(double, const Matrix*, double)) &AdaptiveDMD::train, | ||
py::arg("energy_fraction").noconvert(), | ||
py::arg("W0") = nullptr, | ||
py::arg("linearity_tol") = 0.0) | ||
.def("train", (void (AdaptiveDMD::*)(int, const Matrix*, double)) &AdaptiveDMD::train, | ||
py::arg("k").noconvert(), | ||
py::arg("W0") = nullptr, | ||
py::arg("linearity_tol") = 0.0) | ||
.def("getTrueDt", &AdaptiveDMD::getTrueDt) | ||
.def("getInterpolatedSnapshots", &AdaptiveDMD::getInterpolatedSnapshots); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Created by barrow9 on 6/4/23. | ||
// | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/numpy.h> | ||
#include <pybind11/operators.h> | ||
#include <pybind11/stl.h> | ||
#include "librom.h" | ||
#include "python_utils/cpp_utils.hpp" | ||
|
||
namespace py = pybind11; | ||
using namespace CAROM; | ||
|
||
void init_NonuniformDMD(pybind11::module_ &m) { | ||
|
||
py::class_<NonuniformDMD, DMD>(m, "NonuniformDMD") | ||
|
||
//constructor, default. | ||
.def(py::init<std::string>()) //constructor a | ||
|
||
.def(py::init([](int dim, | ||
bool alt_output_basis, | ||
Vector* state_offset, | ||
Vector* derivative_offset) { | ||
return new NonuniformDMD(dim, alt_output_basis, state_offset, derivative_offset); | ||
}), | ||
py::arg("dim"), | ||
py::arg("alt_output_basis") = false, | ||
py::arg("state_offset") = nullptr, | ||
py::arg("derivative_offset") = nullptr) | ||
|
||
//TODO: needed explicitly? | ||
.def("__del__", [](NonuniformDMD& self) { self.~NonuniformDMD(); }) // Destructor | ||
|
||
.def("setOffset", &NonuniformDMD::setOffset, py::arg("offset_vector"), py::arg("order")) | ||
|
||
.def("load", &NonuniformDMD::load, py::arg("base_file_name")) | ||
.def("save", &NonuniformDMD::save, py::arg("base_file_name")); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
MFEM mesh v1.0 | ||
|
||
# | ||
# MFEM Geometry Types (see mesh/geom.hpp): | ||
# | ||
# POINT = 0 | ||
# SEGMENT = 1 | ||
# TRIANGLE = 2 | ||
# SQUARE = 3 | ||
# TETRAHEDRON = 4 | ||
# CUBE = 5 | ||
# | ||
|
||
dimension | ||
2 | ||
|
||
# format: <attribute> <geometry type> <vertex 0> <vertex 1> ... | ||
elements | ||
9 | ||
1 3 0 1 4 3 | ||
2 3 1 2 5 4 | ||
3 3 2 0 3 5 | ||
4 3 3 4 7 6 | ||
5 3 4 5 8 7 | ||
6 3 5 3 6 8 | ||
7 3 6 7 1 0 | ||
8 3 7 8 2 1 | ||
9 3 8 6 0 2 | ||
|
||
boundary | ||
0 | ||
|
||
vertices | ||
9 | ||
|
||
nodes | ||
FiniteElementSpace | ||
FiniteElementCollection: L2_T1_2D_P1 | ||
VDim: 2 | ||
Ordering: 1 | ||
|
||
-1 -1 | ||
-0.333333333 -1 | ||
-1 -0.333333333 | ||
-0.333333333 -0.333333333 | ||
|
||
-0.333333333 -1 | ||
+0.333333333 -1 | ||
-0.333333333 -0.333333333 | ||
+0.333333333 -0.333333333 | ||
|
||
+0.333333333 -1 | ||
+1 -1 | ||
+0.333333333 -0.333333333 | ||
+1 -0.333333333 | ||
|
||
-1 -0.333333333 | ||
-0.333333333 -0.333333333 | ||
-1 +0.333333333 | ||
-0.333333333 +0.333333333 | ||
|
||
-0.333333333 -0.333333333 | ||
+0.333333333 -0.333333333 | ||
-0.333333333 +0.333333333 | ||
+0.333333333 +0.333333333 | ||
|
||
+0.333333333 -0.333333333 | ||
+1 -0.333333333 | ||
+0.333333333 +0.333333333 | ||
+1 +0.333333333 | ||
|
||
-1 +0.333333333 | ||
-0.333333333 +0.333333333 | ||
-1 +1 | ||
-0.333333333 +1 | ||
|
||
-0.333333333 +0.333333333 | ||
+0.333333333 +0.333333333 | ||
-0.333333333 +1 | ||
+0.333333333 +1 | ||
|
||
+0.333333333 +0.333333333 | ||
+1 +0.333333333 | ||
+0.333333333 +1 | ||
+1 +1 |
Oops, something went wrong.