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

Drop index from mesh element group constructor #395

Merged
merged 2 commits into from
Mar 4, 2024
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
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
name: Flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
-
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
# matches compat target in setup.py
python-version: '3.8'
Expand All @@ -27,7 +27,7 @@ jobs:
name: Pylint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Main Script"
run: |
echo "- scipy" >> .test-conda-env-py3.yml
Expand All @@ -39,7 +39,7 @@ jobs:
name: Mypy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Main Script"
run: |
curl -L -O https://tiker.net/ci-support-v0
Expand All @@ -52,7 +52,7 @@ jobs:
name: Pytest Conda Py3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Main Script"
run: |
sudo apt update && sudo apt install octave
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
name: Examples Conda Py3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Main Script"
run: |
export MPLBACKEND=Agg
Expand All @@ -141,7 +141,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
-
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -176,13 +176,16 @@ jobs:
name: Tests for downstream project ${{ matrix.downstream_project }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "Main Script"
env:
DOWNSTREAM_PROJECT: ${{ matrix.downstream_project }}
run: |
curl -L -O https://tiker.net/ci-support-v0
. ./ci-support-v0
if [[ "$DOWNSTREAM_PROJECT" == "grudge" && "$GITHUB_HEAD_REF" == "group-constr-drop-index" ]]; then
DOWNSTREAM_PROJECT=https://github.com/inducer/grudge.git@grad-test-overint
fi
test_downstream "$DOWNSTREAM_PROJECT"

# vim: sw=4
8 changes: 1 addition & 7 deletions meshmode/discretization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,7 @@ def __init__(self,
raise TypeError("'actx' must be an ArrayContext")

self.mesh = mesh
groups = []
for igrp, mg in enumerate(mesh.groups):
# TODO: setting index is deprecated
ng = group_factory(mg, index=igrp)
groups.append(ng)

self.groups = groups
self.groups = [group_factory(mg) for mg in mesh.groups]

self.real_dtype = np.dtype(real_dtype)
self.complex_dtype = np.dtype({
Expand Down
17 changes: 14 additions & 3 deletions test/test_meshmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
PytestPyOpenCLArrayContextFactory,
])

from meshmode.mesh import SimplexElementGroup, TensorProductElementGroup
from meshmode.mesh import (
MeshElementGroup, SimplexElementGroup, TensorProductElementGroup)
from meshmode.discretization.poly_element import (
InterpolatoryQuadratureSimplexGroupFactory,
default_simplex_group_factory,
Expand Down Expand Up @@ -914,6 +915,7 @@ def test_mesh_multiple_groups(actx_factory, ambient_dim, visualize=False):
mesh.vertices[0, mesh.groups[0].vertex_indices] < 0.0,
axis=1).astype(np.int64)
mesh = split_mesh_groups(mesh, element_flags)
assert isinstance(mesh, Mesh)

assert len(mesh.groups) == 2 # pylint: disable=no-member
assert mesh.facial_adjacency_groups
Expand All @@ -932,10 +934,19 @@ def test_mesh_multiple_groups(actx_factory, ambient_dim, visualize=False):

from meshmode.discretization import Discretization

def grp_factory(mesh_el_group, index):
def grp_factory(mesh_el_group: MeshElementGroup):
index = None

for i, meg in enumerate(mesh.groups): # pylint: disable=no-member
if meg is mesh_el_group:
index = i

if mesh_el_group.dim == mesh.ambient_dim:
assert index is not None

return default_simplex_group_factory(
base_dim=ambient_dim, order=order + 2 if index == 0 else order
)(mesh_el_group, index)
)(mesh_el_group)

discr = Discretization(actx, mesh, grp_factory)

Expand Down
Loading