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

Nonlinear elasticity projection rom example #17

Merged
merged 9 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
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