Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PROM DG advection #18

Merged
merged 34 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fde5ebf
Initialize
siuwuncheung Sep 21, 2023
ba8d5bc
example work in progress.
dreamer2368 Sep 14, 2023
d4be459
initial translation. not tested yet.
dreamer2368 Sep 18, 2023
c3c1384
some minor fix. still needs debugging.
dreamer2368 Sep 19, 2023
f4ff23b
mfem binding fixes with PyMFEM interface.
dreamer2368 Sep 20, 2023
4ec3034
GNAT example demonstrated.
dreamer2368 Sep 20, 2023
63d4a11
libROM with hypre 2.28.0.
dreamer2368 Sep 20, 2023
d92abac
updated comments.
dreamer2368 Sep 20, 2023
d2d8014
example command and results update.
dreamer2368 Sep 22, 2023
68d359f
updated libROM branch.
dreamer2368 Sep 28, 2023
93bbebb
Merge branch 'main' into prom_dg_advection
siuwuncheung Sep 28, 2023
d2c1ee1
Rename
siuwuncheung Sep 28, 2023
37f50fe
Add options
siuwuncheung Sep 28, 2023
9d0b010
Introduce frequency parameter
siuwuncheung Sep 28, 2023
ab4d0cb
Add ROM settings
siuwuncheung Sep 28, 2023
8c0c305
Minor changes
siuwuncheung Sep 29, 2023
13fe722
Change ODE Solver type
siuwuncheung Sep 29, 2023
f470fff
Implement FOM implicit solve
siuwuncheung Sep 29, 2023
75bbb82
Add ROM implementation
siuwuncheung Sep 29, 2023
96b598e
Adding timing
siuwuncheung Sep 29, 2023
516a927
Minor changes
siuwuncheung Oct 2, 2023
4087acb
Remove redundant variable
siuwuncheung Oct 2, 2023
573a735
Add rdim/ef options in Basis Reader
siuwuncheung Oct 3, 2023
212f823
Comment on seg fault
siuwuncheung Oct 3, 2023
8b4a043
Merge branch 'nl_prom_example' into prom_dg_advection
siuwuncheung Oct 3, 2023
6fc84d8
Place initial takeSample
siuwuncheung Oct 3, 2023
c46a7d9
Update extern
siuwuncheung Oct 3, 2023
3723f8b
some minor fix.
dreamer2368 Oct 3, 2023
8604571
Change add
siuwuncheung Oct 3, 2023
96887b5
Assign zeros
siuwuncheung Oct 3, 2023
eb011bd
Fix final calculations
siuwuncheung Oct 11, 2023
f817621
Debugging
siuwuncheung Oct 12, 2023
e06047e
Add some comments
siuwuncheung Oct 12, 2023
d85a461
Add example results
siuwuncheung Oct 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
branch = stable
[submodule "extern/libROM"]
path = extern/libROM
url = https://github.com/LLNL/libROM.git
branch = mfem_fix
url = https://github.com/LLNL/libROM.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ pybind11_add_module(_pylibROM
bindings/pylibROM/mfem/pySampleMesh.cpp

bindings/pylibROM/python_utils/cpp_utils.hpp
bindings/pylibROM/python_utils/cpp_utils.cpp
)
message("building pylibROM...")

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ For parallel version, a manual installation is required:
```
git clone https://github.com/mfem/PyMFEM.git
cd PyMFEM
python3 setup.py install --with-parallel
python3 setup.py install --with-parallel --with-gslib
```
On LC quartz, use `--user` flag:
```
python3 setup.py install --with-parallel --user
python3 setup.py install --with-parallel --with-gslib --user
```
Make sure [`swig`](https://pypi.org/project/swig) is installed first. Also, the binary file must be located in `PATH` environment variable.

Expand Down
62 changes: 46 additions & 16 deletions bindings/pylibROM/linalg/pyBasisReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,51 @@ void init_BasisReader(pybind11::module_ &m) {
py::arg("base_file_name"),
py::arg("file_format") = Database::formats::HDF5
)
.def("isNewBasis",(bool (BasisReader::*)(double)) &BasisReader::isNewBasis)
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double)) &BasisReader::getSpatialBasis)
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getSpatialBasis)
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getSpatialBasis)
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,double)) &BasisReader::getSpatialBasis)
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double)) &BasisReader::getTemporalBasis)
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getTemporalBasis)
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getTemporalBasis)
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,double)) &BasisReader::getTemporalBasis)
.def("getSingularValues",(Vector* (BasisReader::*)(double)) &BasisReader::getSingularValues)
.def("getSingularValues",(Vector* (BasisReader::*)(double,double)) &BasisReader::getSingularValues)
.def("getDim", (int (BasisReader::*)(const std::string,double)) &BasisReader::getDim)
.def("getNumSamples", (int (BasisReader::*)(const std::string,double)) &BasisReader::getNumSamples)
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double)) &BasisReader::getSnapshotMatrix)
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getSnapshotMatrix)
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getSnapshotMatrix)
.def("isNewBasis",(bool (BasisReader::*)(double)) &BasisReader::isNewBasis,
py::arg("time"))
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double)) &BasisReader::getSpatialBasis,
py::arg("time"))
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getSpatialBasis,
py::arg("time"),
py::arg("n"))
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getSpatialBasis,
py::arg("time"),
py::arg("start_col"),
py::arg("end_col"))
.def("getSpatialBasis",(Matrix* (BasisReader::*)(double,double)) &BasisReader::getSpatialBasis,
py::arg("time"),
py::arg("ef").noconvert())
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double)) &BasisReader::getTemporalBasis,
py::arg("time"))
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getTemporalBasis,
py::arg("time"),
py::arg("n"))
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getTemporalBasis,
py::arg("time"),
py::arg("start_col"),
py::arg("end_col"))
.def("getTemporalBasis",(Matrix* (BasisReader::*)(double,double)) &BasisReader::getTemporalBasis,
py::arg("time"),
py::arg("ef").noconvert())
.def("getSingularValues",(Vector* (BasisReader::*)(double)) &BasisReader::getSingularValues,
py::arg("time"))
.def("getSingularValues",(Vector* (BasisReader::*)(double,double)) &BasisReader::getSingularValues,
py::arg("time"),
py::arg("ef"))
.def("getDim", (int (BasisReader::*)(const std::string,double)) &BasisReader::getDim,
py::arg("kind"),
py::arg("time"))
.def("getNumSamples", (int (BasisReader::*)(const std::string,double)) &BasisReader::getNumSamples,
py::arg("kind"),
py::arg("time"))
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double)) &BasisReader::getSnapshotMatrix,
py::arg("time"))
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double,int)) &BasisReader::getSnapshotMatrix,
py::arg("time"),
py::arg("n"))
.def("getSnapshotMatrix",(Matrix* (BasisReader::*)(double,int,int)) &BasisReader::getSnapshotMatrix,
py::arg("time"),
py::arg("start_col"),
py::arg("end_col"))
.def("__del__", [](BasisReader& self) { self.~BasisReader(); }); // Destructor
}
9 changes: 6 additions & 3 deletions bindings/pylibROM/mfem/pySampleMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,24 @@ void init_mfem_SampleMesh(pybind11::module_ &m) {
ParFiniteElementSpace *spfes_target = self.GetSampleFESpace(space);

// deep copy of the spfes_target.
void *spfes_address = extractSwigPtrAddress(spfespace);
void *spfes_address = extractSwigPtr<void>(spfespace);
ParFiniteElementSpace *spfes = new (spfes_address) ParFiniteElementSpace(*spfes_target);
})

.def("GetSampleMesh", [](CAROM::SampleMeshManager& self, py::object &sppmesh){
ParMesh *sppmesh_target = self.GetSampleMesh();

// deep copy of the spfes_target.
void *sppmesh_address = extractSwigPtrAddress(sppmesh);
void *sppmesh_address = extractSwigPtr<void>(sppmesh);
ParMesh *sample_pmesh = new (sppmesh_address) ParMesh(*sppmesh_target);
})

.def("GetNumVarSamples", &CAROM::SampleMeshManager::GetNumVarSamples)

.def("GetSampledValues", &CAROM::SampleMeshManager::GetSampledValues)
.def("GetSampledValues", [](CAROM::SampleMeshManager &self, const std::string variable, py::object &v, CAROM::Vector &s){
Vector *v_ptr = extractSwigPtr<Vector>(v);
self.GetSampledValues(variable, *v_ptr, s);
})

.def("GetSampleElements", &CAROM::SampleMeshManager::GetSampleElements)

Expand Down
11 changes: 0 additions & 11 deletions bindings/pylibROM/python_utils/cpp_utils.cpp

This file was deleted.

3 changes: 0 additions & 3 deletions bindings/pylibROM/python_utils/cpp_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ get1DArrayFromPtr(T *ptr, const int nelem, bool free_when_done=false)
get1DArrayBufferHandle(ptr, free_when_done));
}

void *
extractSwigPtrAddress(const py::handle &swig_target);

template<typename T>
T*
extractSwigPtr(const py::handle &swig_target)
Expand Down
2 changes: 1 addition & 1 deletion docker/librom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN sudo git clone https://github.com/LLNL/libROM.git
WORKDIR ./libROM
RUN sudo git pull
# pylibROM is currently based on a specific commit of the libROM.
RUN sudo git checkout mfem_fix
RUN sudo git checkout 0809d7d09dc24f0963c38fc8c0a2649948142ba0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this change was actually part of #17, but should this be changed to be the head of the main branch of libROM? This commit SHA seems to be outdated since a few PRs have been merged in libROM. Maybe this should be changed in a separate PR to make sure the two repos stay in sync.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we are using a static commit for libROM to keep pylibROM stable and avoid any unpredicted breakdowns due to the actively changing C++ libROM. From time to time I saw Kevin change the SHA, after some necessary changes were made in C++ libROM. @dreamer2368 , may I ask if it is accurate?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. We'd like to update SHA occasionally, but at the same time specify SHA explicitly which can be information for debugging. I think mfem_fix branch is now merged to main branch of the libROM, so it's okay to update this SHA now.

WORKDIR ./build
RUN sudo cmake .. -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DUSE_MFEM=${USE_MFEM} -DMFEM_USE_GSLIB=${MFEM_USE_GSLIB}
# RUN sudo cmake .. -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DUSE_MFEM=OFF
Expand Down
143 changes: 143 additions & 0 deletions examples/data/beam-hex-nurbs.mesh
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
MFEM NURBS mesh v1.0

#
# MFEM Geometry Types (see mesh/geom.hpp):
#
# SEGMENT = 1
# SQUARE = 3
# CUBE = 5
#

dimension
3

elements
2
1 5 0 1 4 5 6 7 10 11
2 5 1 2 3 4 7 8 9 10

boundary
10
3 3 5 4 1 0
3 3 0 1 7 6
3 3 4 5 11 10
1 3 5 0 6 11
3 3 6 7 10 11
3 3 4 3 2 1
3 3 1 2 8 7
2 3 2 3 9 8
3 3 3 4 10 9
3 3 7 8 9 10

edges
20
0 0 1
0 5 4
0 6 7
0 11 10
1 1 2
1 4 3
1 7 8
1 10 9
2 0 5
2 1 4
2 2 3
2 6 11
2 7 10
2 8 9
3 0 6
3 1 7
3 2 8
3 3 9
3 4 10
3 5 11

vertices
12

knotvectors
4
1 5 0 0 1 2 3 4 4
1 5 0 0 1 2 3 4 4
1 2 0 0 1 1
1 2 0 0 1 1

weights
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

FiniteElementSpace
FiniteElementCollection: NURBS1
VDim: 3
Ordering: 1

0 0 0
4 0 0
8 0 0
8 1 0
4 1 0
0 1 0
0 0 1
4 0 1
8 0 1
8 1 1
4 1 1
0 1 1
1 0 0
2 0 0
3 0 0
3 1 0
2 1 0
1 1 0
1 0 1
2 0 1
3 0 1
3 1 1
2 1 1
1 1 1
5 0 0
6 0 0
7 0 0
7 1 0
6 1 0
5 1 0
5 0 1
6 0 1
7 0 1
7 1 1
6 1 1
5 1 1
Loading