Skip to content

Commit

Permalink
Rename warpmesh->UM2N
Browse files Browse the repository at this point in the history
  • Loading branch information
jwallwork23 committed Oct 24, 2024
1 parent 14be7f2 commit 8a76295
Show file tree
Hide file tree
Showing 122 changed files with 317 additions and 4,023 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Install and Test WarpMesh
name: Install and test UM2N

on:
push:
Expand All @@ -9,7 +9,7 @@ on:

jobs:
test-warpmesh:
name: Test WarpMesh
name: Test UM2N
runs-on: ubuntu-latest
container:
image: firedrakeproject/firedrake:latest
Expand Down Expand Up @@ -52,12 +52,12 @@ jobs:
. /home/firedrake/firedrake/bin/activate
python3 -m pip install 'git+https://github.com/facebookresearch/pytorch3d.git'
- name: Install WarpMesh
- name: Install UM2N
run: |
. /home/firedrake/firedrake/bin/activate
python3 -m pip install -e .
- name: Run WarpMesh test suite
- name: Run UM2N test suite
run: |
. /home/firedrake/firedrake/bin/activate
python3 -m pytest tests/test* -v
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Solving complex Partial Differential Equations (PDEs) accurately and efficiently

The latest test status:

[![UM2N](https://github.com/mesh-adaptation/UM2N/actions/workflows/test_warpmesh.yml/badge.svg)](https://github.com/mesh-adaptation/UM2N/actions/workflows/test_warpmesh.yml)
[![UM2N](https://github.com/mesh-adaptation/UM2N/actions/workflows/test_suite.yml/badge.svg)](https://github.com/mesh-adaptation/UM2N/actions/workflows/test_suite.yml)


## 🛠️ Installation
Expand All @@ -31,7 +31,7 @@ Just navigate to **project root** folder, open terminal and execute the
```
This will install [Firedrake](https://www.firedrakeproject.org/download.html)
and [Movement](https://github.com/mesh-adaptation/movement) under the `install`
folder, as well as the `WarpMesh` package. Note that the pytorch installed is a cpu version.
folder, as well as the `UM2N` package. Note that the pytorch installed is a cpu version.

- GPU (cuda) support

Expand Down Expand Up @@ -114,7 +114,7 @@ The number of samples in the dataset can be changed by modifying the variable

## 🚀 Train the model (This is outdated)

A training notebook is provided: `script/train_warpmesh.ipynb`. Further training
A training notebook is provided: `script/train_um2n.ipynb`. Further training
details can be found in the notebook.

Here is also a link to pre-trained models:
Expand All @@ -136,7 +136,7 @@ The documentation is generated by Sphinx. To build the documentation, under the
## 🧩 Project Layout

```
├── warpmesh (Implementation of the project)
├── UM2N (Implementation of the project)
│ ├── __init__.py
│ ├── generator (Dataset generator)
│ ├── processor (Data processor)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import movement as mv
import numpy as np # noqa

import warpmesh as wm # noqa

__all__ = ["BurgersSolver"]


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import firedrake as fd
import movement as mv

from warpmesh.generator.equation_solver import EquationSolver
from UM2N.generator.equation_solver import EquationSolver

os.environ["OMP_NUM_THREADS"] = "1"
__all__ = ["MeshGenerator"]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import firedrake as fd # noqa
import torch
import movement as mv # noqa
import warpmesh as wm # noqa
import UM2N
import numpy as np
import pandas as pd

Expand All @@ -20,7 +20,7 @@
import matplotlib.pyplot as plt # noqa

from tqdm import tqdm # noqa
from warpmesh.model.train_util import model_forward
from UM2N.model.train_util import model_forward


def get_log_og(log_path, idx):
Expand Down Expand Up @@ -826,7 +826,7 @@ def eval_problem(
# self.u_prev_adapt.project(self.u_cur)

# check mesh integrity - Only perform evaluation on non-tangling mesh # noqa
num_tangle = wm.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
num_tangle = UM2N.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
if isinstance(num_tangle, torch.Tensor):
num_tangle = num_tangle.item()
if num_tangle > 0: # has tangled elems:
Expand Down Expand Up @@ -859,7 +859,7 @@ def eval_problem(
self.mesh_new.coordinates.dat.data[:] = y

if ((step + 1) % self.save_interval == 0) or (step == 0):
fig, plot_data_dict = wm.plot_compare(
fig, plot_data_dict = UM2N.plot_compare(
self.mesh_fine,
self.mesh,
self.mesh_new,
Expand Down Expand Up @@ -943,16 +943,16 @@ def make_all_dirs(self, log_path, plot_path, plot_more_path, plot_data_path):
self.make_plot_data_dir(plot_data_path)

def make_log_dir(self, log_path):
wm.mkdir_if_not_exist(log_path)
UM2N.mkdir_if_not_exist(log_path)

def make_plot_dir(self, plot_path):
wm.mkdir_if_not_exist(plot_path)
UM2N.mkdir_if_not_exist(plot_path)

def make_plot_more_dir(self, plot_more_path):
wm.mkdir_if_not_exist(plot_more_path)
UM2N.mkdir_if_not_exist(plot_more_path)

def make_plot_data_dir(self, plot_data_path):
wm.mkdir_if_not_exist(plot_data_path)
UM2N.mkdir_if_not_exist(plot_data_path)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import firedrake as fd # noqa

import movement as mv # noqa
import warpmesh as wm # noqa
import numpy as np

import firedrake.function as ffunc
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions warpmesh/test/bench_burgers.py → UM2N/test/bench_burgers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import torch # noqa
from torch_geometric.loader import DataLoader

import warpmesh as wm # noqa
from warpmesh.model.train_util import generate_samples
import UM2N
from UM2N.model.train_util import generate_samples


def get_log_og(log_path, idx):
Expand Down Expand Up @@ -302,7 +302,7 @@ def eval_problem(self):
dur_ms = (end - start) * 1000

# check mesh integrity - Only perform evaluation on non-tangling mesh # noqa
num_tangle = wm.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
num_tangle = UM2N.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
if isinstance(num_tangle, torch.Tensor):
num_tangle = num_tangle.item()
if num_tangle > 0: # has tangled elems:
Expand Down Expand Up @@ -368,7 +368,7 @@ def eval_problem(self):
df.to_csv(os.path.join(self.log_path, f"log{self.idx}_{cur_step}.csv")) # noqa

# plot compare mesh
compare_plot = wm.plot_mesh_compare_benchmark(
compare_plot = UM2N.plot_mesh_compare_benchmark(
out.detach().cpu().numpy(),
sample.y.detach().cpu().numpy(),
sample.face.detach().cpu().numpy(),
Expand Down Expand Up @@ -485,13 +485,13 @@ def get_error(self):
return error_og, error_adapt

def make_log_dir(self):
wm.mkdir_if_not_exist(self.log_path)
UM2N.mkdir_if_not_exist(self.log_path)

def make_plot_dir(self):
wm.mkdir_if_not_exist(self.plot_path)
UM2N.mkdir_if_not_exist(self.plot_path)

def make_plot_more_dir(self):
wm.mkdir_if_not_exist(self.plot_more_path)
UM2N.mkdir_if_not_exist(self.plot_more_path)

def make_plot_data_dir(self):
wm.mkdir_if_not_exist(self.plot_data_path)
UM2N.mkdir_if_not_exist(self.plot_data_path)
File renamed without changes.
26 changes: 13 additions & 13 deletions warpmesh/test/bench_swirl.py → UM2N/test/bench_swirl.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import torch
from torch_geometric.loader import DataLoader

import warpmesh as wm
from warpmesh.model.train_util import model_forward
import UM2N
from UM2N.model.train_util import model_forward


def get_log_og(log_path, idx):
Expand Down Expand Up @@ -126,10 +126,10 @@ def __init__(
self.y_0 = kwargs.pop("y_0", 0.25)

# initital condition of u on coarse / fine mesh
u_init_exp = wm.get_u_0(
u_init_exp = UM2N.get_u_0(
self.x, self.y, self.r_0, self.x_0, self.y_0, self.sigma
) # noqa
u_init_exp_fine = wm.get_u_0(
u_init_exp_fine = UM2N.get_u_0(
self.x_fine, self.y_fine, self.r_0, self.x_0, self.y_0, self.sigma
) # noqa
self.u_init = fd.Function(self.scalar_space).interpolate(u_init_exp)
Expand Down Expand Up @@ -265,7 +265,7 @@ def solve_u(self, t):
Solve the PDE problem using RK (SSPRK) scheme on the coarse mesh
store the solution field to a varaible: self.u_cur
"""
c_exp = wm.get_c(self.x, self.y, t, alpha=self.alpha)
c_exp = UM2N.get_c(self.x, self.y, t, alpha=self.alpha)
c_temp = fd.Function(self.vector_space).interpolate(c_exp)
self.c.project(c_temp)

Expand All @@ -283,7 +283,7 @@ def solve_u_fine(self, t):
Solve the PDE problem using RK (SSPRK) scheme on the fine mesh
store the solution field to a varaible: self.u_cur_fine
"""
c_exp = wm.get_c(self.x_fine, self.y_fine, t, alpha=self.alpha)
c_exp = UM2N.get_c(self.x_fine, self.y_fine, t, alpha=self.alpha)
c_temp = fd.Function(self.vector_space_fine).interpolate(c_exp)
self.c_fine.project(c_temp)

Expand All @@ -303,16 +303,16 @@ def project_u_(self):
return

def make_log_dir(self):
wm.mkdir_if_not_exist(self.log_path)
UM2N.mkdir_if_not_exist(self.log_path)

def make_plot_dir(self):
wm.mkdir_if_not_exist(self.plot_path)
UM2N.mkdir_if_not_exist(self.plot_path)

def make_plot_more_dir(self):
wm.mkdir_if_not_exist(self.plot_more_path)
UM2N.mkdir_if_not_exist(self.plot_more_path)

def make_plot_data_dir(self):
wm.mkdir_if_not_exist(self.plot_data_path)
UM2N.mkdir_if_not_exist(self.plot_data_path)

def eval_problem(self, model_name="model"):
print("In eval problem")
Expand Down Expand Up @@ -484,7 +484,7 @@ def eval_problem(self, model_name="model"):
self.uh_model = fd.Function(function_space_model).project(self.u_cur) # noqa

# check mesh integrity - Only perform evaluation on non-tangling mesh # noqa
num_tangle = wm.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
num_tangle = UM2N.get_sample_tangle(out, sample.x[:, :2], sample.face) # noqa
if isinstance(num_tangle, torch.Tensor):
num_tangle = num_tangle.item()
if num_tangle > 0: # has tangled elems:
Expand All @@ -500,7 +500,7 @@ def eval_problem(self, model_name="model"):
# self.solve_u_fine(self.t)
u_fine = fd.Function(function_space_fine).project(self.u_cur_fine) # noqa

fig, plot_data_dict = wm.plot_compare(
fig, plot_data_dict = UM2N.plot_compare(
self.mesh_fine,
self.mesh_coarse,
self.mesh_new,
Expand Down Expand Up @@ -574,7 +574,7 @@ def eval_problem(self, model_name="model"):
df = pd.DataFrame(res, index=[0])
df.to_csv(os.path.join(self.log_path, f"log_{idx:04d}.csv"))
# plot compare mesh
plot_fig = wm.plot_mesh_compare_benchmark(
plot_fig = UM2N.plot_mesh_compare_benchmark(
out.detach().cpu().numpy(),
sample.y.detach().cpu().numpy(),
sample.face.detach().cpu().numpy(),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import firedrake as fd
import matplotlib.pyplot as plt # noqa

import warpmesh as wm
import UM2N

__all__ = ["compare_error"]

Expand Down Expand Up @@ -66,21 +66,21 @@ def func(x, y):
# construct the helmholtz equation
eq = None
if problem_type == "helmholtz":
eq = wm.HelmholtzEqGenerator(
eq = UM2N.HelmholtzEqGenerator(
params={
"u_exact_func": u_exact,
}
)
elif problem_type == "poisson":
eq = wm.PoissonEqGenerator(
eq = UM2N.PoissonEqGenerator(
params={
"u_exact_func": u_exact,
}
)

# solution on og mesh
og_res = eq.discretise(mesh)
og_solver = wm.EquationSolver(
og_solver = UM2N.EquationSolver(
params={
"function_space": og_res["function_space"],
"LHS": og_res["LHS"],
Expand All @@ -93,7 +93,7 @@ def func(x, y):
# solution on MA mesh
mesh_MA.coordinates.dat.data[:] = data_in.y.detach().cpu().numpy()
ma_res = eq.discretise(mesh_MA)
ma_solver = wm.EquationSolver(
ma_solver = UM2N.EquationSolver(
params={
"function_space": ma_res["function_space"],
"LHS": ma_res["LHS"],
Expand All @@ -107,7 +107,7 @@ def func(x, y):
uh_model = None
if num_tangle == 0:
model_res = eq.discretise(mesh_model)
model_solver = wm.EquationSolver(
model_solver = UM2N.EquationSolver(
params={
"function_space": model_res["function_space"],
"LHS": model_res["LHS"],
Expand All @@ -125,7 +125,7 @@ def func(x, y):
res_high_res = eq.discretise(high_res_mesh)
uh_exact = fd.interpolate(res_high_res["u_exact"], high_res_function_space)

fig, plot_data_dict = wm.plot_compare(
fig, plot_data_dict = UM2N.plot_compare(
mesh_fine,
mesh,
mesh_MA,
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 0 additions & 24 deletions docs/conf.py

This file was deleted.

4 changes: 0 additions & 4 deletions docs/html/.buildinfo

This file was deleted.

Binary file removed docs/html/.doctrees/environment.pickle
Binary file not shown.
Binary file removed docs/html/.doctrees/index.doctree
Binary file not shown.
Loading

0 comments on commit 8a76295

Please sign in to comment.