Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshmode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiaoyu Wei
meshmode
Commits
5d6dd963
Commit
5d6dd963
authored
4 years ago
by
Alexandru Fikl
Browse files
Options
Downloads
Patches
Plain Diff
add a test with a split mesh with multiple groups
parent
5f3d14e4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_meshmode.py
+80
-0
80 additions, 0 deletions
test/test_meshmode.py
with
80 additions
and
0 deletions
test/test_meshmode.py
+
80
−
0
View file @
5d6dd963
...
...
@@ -1272,6 +1272,86 @@ def test_is_affine_group_check(mesh_name):
assert
all
(
grp
.
is_affine
for
grp
in
mesh
.
groups
)
==
is_affine
def
split_mesh
(
mesh
,
axis
,
cutoff
):
groups
=
[]
for
grp
in
mesh
.
groups
:
mask
=
np
.
any
(
mesh
.
vertices
[
axis
,
grp
.
vertex_indices
]
<
cutoff
,
axis
=
1
)
groups
.
append
(
grp
.
copy
(
vertex_indices
=
grp
.
vertex_indices
[
mask
,
:].
copy
(),
nodes
=
grp
.
nodes
[:,
mask
,
:].
copy
())
)
groups
.
append
(
grp
.
copy
(
vertex_indices
=
grp
.
vertex_indices
[
~
mask
,
:].
copy
(),
nodes
=
grp
.
nodes
[:,
~
mask
,
:].
copy
())
)
from
meshmode.mesh
import
Mesh
return
Mesh
(
vertices
=
mesh
.
vertices
,
groups
=
groups
,
is_conforming
=
mesh
.
is_conforming
)
@pytest.mark.parametrize
(
"
ambient_dim
"
,
[
1
,
2
,
3
])
def
test_mesh_multiple_groups
(
ctx_factory
,
ambient_dim
,
visualize
=
False
):
ctx
=
ctx_factory
()
queue
=
cl
.
CommandQueue
(
ctx
)
order
=
4
from
meshmode.mesh.generation
import
generate_regular_rect_mesh
mesh
=
generate_regular_rect_mesh
(
a
=
(
-
0.5
,)
*
ambient_dim
,
b
=
(
0.5
,)
*
ambient_dim
,
n
=
(
8
,)
*
ambient_dim
,
order
=
order
)
mesh
=
split_mesh
(
mesh
,
axis
=
0
,
cutoff
=
0.0
)
assert
mesh
.
facial_adjacency_groups
assert
mesh
.
nodal_adjacency
from
meshmode.discretization
import
Discretization
from
meshmode.discretization.poly_element
import
\
PolynomialWarpAndBlendGroupFactory
as
GroupFactory
discr
=
Discretization
(
ctx
,
mesh
,
GroupFactory
(
order
))
if
visualize
:
group_id
=
discr
.
empty
(
queue
,
dtype
=
np
.
int
)
for
igrp
,
grp
in
enumerate
(
discr
.
groups
):
group_id_view
=
grp
.
view
(
group_id
)
group_id_view
.
fill
(
igrp
)
from
meshmode.discretization.visualization
import
make_visualizer
vis
=
make_visualizer
(
queue
,
discr
,
vis_order
=
order
)
vis
.
write_vtk_file
(
"
test_mesh_multiple_groups.vtu
"
,
[
(
"
group_id
"
,
group_id
)
],
overwrite
=
True
)
# check face restrictions
from
meshmode.discretization.connection
import
(
make_face_restriction
,
make_face_to_all_faces_embedding
,
make_opposite_face_connection
,
check_connection
)
for
boundary_tag
in
[
BTAG_ALL
,
FACE_RESTR_INTERIOR
,
FACE_RESTR_ALL
]:
conn
=
make_face_restriction
(
discr
,
GroupFactory
(
order
),
boundary_tag
=
boundary_tag
,
per_face_groups
=
False
)
check_connection
(
conn
)
bdry_f
=
conn
.
to_discr
.
empty
(
queue
)
bdry_f
.
fill
(
1.0
)
if
boundary_tag
==
FACE_RESTR_INTERIOR
:
opposite
=
make_opposite_face_connection
(
conn
)
check_connection
(
opposite
)
op_bdry_f
=
opposite
(
queue
,
bdry_f
)
assert
abs
(
cl
.
array
.
sum
(
bdry_f
-
op_bdry_f
).
get
(
queue
))
<
1.0e-14
if
boundary_tag
==
FACE_RESTR_ALL
:
embedding
=
make_face_to_all_faces_embedding
(
conn
,
conn
.
to_discr
)
check_connection
(
embedding
)
if
__name__
==
"
__main__
"
:
import
sys
if
len
(
sys
.
argv
)
>
1
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment