Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
7dc2d82
refactor tensor products a bit
alexfikl Oct 24, 2020
7594971
implement face_vertex_indices for tensor products
alexfikl Oct 31, 2020
0164616
fix doc header
alexfikl Oct 31, 2020
fa414db
remove inappropriate uses of issubclass
alexfikl Oct 31, 2020
554214b
Implement tensor product face restrictions (with voodoo element basis…
inducer Nov 2, 2020
956da03
Merge pull request #1 from inducer/tp-face-restriction
alexfikl Nov 3, 2020
8dac59e
improve docs
alexfikl Nov 3, 2020
fa01334
underscore 1d tensor product methods
alexfikl Nov 3, 2020
07f315d
expand more tests to tensor products
alexfikl Nov 3, 2020
4dcb4c1
make ascii cube slightly larger
alexfikl Nov 3, 2020
13decc1
Merge branch 'master' into tensor-product-additions
alexfikl Nov 4, 2020
6bc483d
update comment
alexfikl Nov 5, 2020
02a3a48
use mesh order for resampling matrix
alexfikl Nov 6, 2020
673dd00
fix quad weights for tensor products
alexfikl Nov 6, 2020
a82685f
add back removed mesh (huh)
alexfikl Nov 6, 2020
06711ac
rework tensor product inheritance a bit
alexfikl Nov 6, 2020
3356de6
add gmsh quad test
alexfikl Nov 7, 2020
165b844
move vertex shuffle to separate function
alexfikl Nov 8, 2020
468a625
generate high-order gmsh quad mesh in test
alexfikl Nov 9, 2020
53e819e
use more elements in gmsh quad test
alexfikl Nov 9, 2020
1563970
fix typo in element group
alexfikl Nov 9, 2020
d6467f4
use mass matrix is quadrature weights are not provided
alexfikl Nov 13, 2020
72b2e51
use same order for the mesh and discr
alexfikl Nov 13, 2020
2efede8
Merge branch 'master' into tensor-product-additions
alexfikl Nov 13, 2020
90ffb1e
point back at gmsh_interop master
alexfikl Nov 13, 2020
73bea32
memoize tensor product weights
alexfikl Nov 13, 2020
5f27b78
fix typo in tensor product mass matrix
alexfikl Nov 18, 2020
24eae18
Merge branch 'master' into tensor-product-additions
alexfikl Nov 18, 2020
34c7e79
Merge branch 'master' into tensor-product-additions
inducer Nov 18, 2020
6ad559b
Explain the tensor product face restriction FIXME
inducer Nov 19, 2020
df303cb
Merge branch 'master' into tensor-product-additions
alexfikl Nov 22, 2020
e65545b
Merge branch 'master' into tensor-product-additions
alexfikl Nov 25, 2020
82be9e8
Make use of some shapes, spaces facilities from modepy in meshmode.mesh
inducer Dec 1, 2020
61d0b06
Merge pull request #2 from inducer/modern-modepy
alexfikl Dec 1, 2020
d79952d
add more shape checks to MeshElementGroup
alexfikl Dec 2, 2020
dae30bb
expand test_sanity_single_element for tensor products
alexfikl Dec 2, 2020
8cd7a38
use modepy unit nodes in gmsh reader
alexfikl Dec 2, 2020
5a06cbf
point requirements.txt to modepy branch
alexfikl Dec 2, 2020
bb5080e
update simple-dg example
alexfikl Dec 2, 2020
5912ccb
allow missing nodes for firedrake
alexfikl Dec 2, 2020
7d0d861
implement get_copy_kwargs
alexfikl Dec 2, 2020
d53887d
initialize MeshElementGroup fully on unpickling
alexfikl Dec 2, 2020
6fa04a8
update basis_for_space calls
alexfikl Dec 2, 2020
0520f71
rename biunit_vertices_for_space after modepy
alexfikl Dec 2, 2020
d775213
use more modern modepy in poly_element
alexfikl Dec 2, 2020
760d92b
update modern modepy in face restriction
alexfikl Dec 2, 2020
4ea8c45
fix MeshElementGroup subclass pickling
alexfikl Dec 3, 2020
63f2341
use modern modepy in visualization
alexfikl Dec 3, 2020
0f37a6a
use modern modepy in make_group_from_vertices
alexfikl Dec 3, 2020
4465d55
update MeshElementGroup docs
alexfikl Dec 3, 2020
f99d6eb
use new tensor_product_nodes in poly_element
alexfikl Dec 3, 2020
bef4afb
fix shadowing
alexfikl Dec 3, 2020
a3293b4
Merge branch 'master' into tensor-product-additions
inducer Dec 10, 2020
ec213e6
Point modepy back to master in req.txt
inducer Dec 11, 2020
821b326
Merge branch 'master' into tensor-product-additions
inducer Dec 20, 2020
79fcade
handle all cases in if condition
alexfikl Dec 21, 2020
adbc990
use stricter orthogonality check in tensor products
alexfikl Dec 21, 2020
e401f61
add comment for tensor product is_orthogonal check
alexfikl Dec 21, 2020
d9fbabb
take full unit_nodes in tensor product element groups
alexfikl Dec 21, 2020
f2b33e3
rename some variables
alexfikl Dec 21, 2020
0c10f6b
Tweak is_orthogonal_basis comment
inducer Dec 23, 2020
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
11 changes: 6 additions & 5 deletions examples/simple-dg.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,13 @@ def get_local_face_mass_matrix(self, afgrp, volgrp, dtype):
afgrp.nunit_dofs),
dtype=dtype)

from modepy.tools import UNIT_VERTICES
import modepy as mp
for iface, fvi in enumerate(
volgrp.mesh_el_group.face_vertex_indices()):
face_vertices = UNIT_VERTICES[volgrp.dim][np.array(fvi)].T
matrix[:, iface, :] = mp.nodal_face_mass_matrix(
shape = mp.Simplex(volgrp.dim)
unit_vertices = mp.unit_vertices_for_shape(shape).T

for face in mp.faces_for_shape(shape):
face_vertices = unit_vertices[np.array(face.volume_vertex_indices)].T
matrix[:, face.face_index, :] = mp.nodal_face_mass_matrix(
volgrp.basis(), volgrp.unit_nodes, afgrp.unit_nodes,
volgrp.order,
face_vertices)
Expand Down
8 changes: 4 additions & 4 deletions meshmode/discretization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def nelements(self):

@property
def nunit_dofs(self):
"""The number of (for now: nodal) degrees of freedom ("DOFs") associated with a
single element.
"""The number of (for now: nodal) degrees of freedom ("DOFs")
associated with a single element.
"""
return self.unit_nodes.shape[-1]

@property
def ndofs(self):
"""The total number of (for now: nodal) degrees of freedom ("DOFs") associated with
the element group.
"""The total number of (for now: nodal) degrees of freedom ("DOFs")
associated with the element group.
"""
return self.nunit_dofs * self.nelements

Expand Down
80 changes: 30 additions & 50 deletions meshmode/discretization/connection/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def _build_boundary_connection(actx, vol_discr, bdry_discr, connection_data,
bdry_grp = bdry_discr.groups[ibdry_grp]
data = connection_data[igrp, face_id]

bdry_unit_nodes_01 = (bdry_grp.unit_nodes + 1)*0.5
result_unit_nodes = (np.dot(data.A, bdry_unit_nodes_01).T + data.b).T
result_unit_nodes = data.face.map_to_volume(bdry_grp.unit_nodes)

batches.append(
InterpolationBatch(
Expand Down Expand Up @@ -140,9 +139,9 @@ def _get_face_vertices(mesh, boundary_tag):

# }}}
else:
# For FRESTR_INTERIOR_FACES, this is likely every vertex in the book.
# For FACE_RESTR_INTERIOR, this is likely every vertex in the book.
# Don't ever bother trying to cut the list down.
# For FRESTR_ALL_FACES, it literally is every single vertex.
# For FACE_RESTR_ALL, it literally is every single vertex.

return np.arange(mesh.nvertices, dtype=np.intp)

Expand Down Expand Up @@ -208,7 +207,7 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

# }}}

from meshmode.mesh import Mesh, SimplexElementGroup
from meshmode.mesh import Mesh, _ModepyElementGroup
bdry_mesh_groups = []
connection_data = {}

Expand All @@ -220,9 +219,10 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

mgrp = grp.mesh_el_group

if not isinstance(mgrp, SimplexElementGroup):
if not isinstance(mgrp, _ModepyElementGroup):
raise NotImplementedError("can only take boundary of "
"SimplexElementGroup-based meshes")
"meshes based on SimplexElementGroup and "
"TensorProductElementGroup")

# {{{ pull together per-group face lists

Expand Down Expand Up @@ -257,44 +257,42 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

# }}}

grp_face_vertex_indices = mgrp.face_vertex_indices()
grp_vertex_unit_coordinates = mgrp.vertex_unit_coordinates()

batch_base = 0

# group by face_id
# group by face_index

for face_id in range(mgrp.nfaces):
batch_boundary_el_numbers_in_grp = np.array(
[
ibface_el
for ibface_el, ibface_face in group_boundary_faces
if ibface_face == face_id],
dtype=np.intp)
for face in mgrp._modepy_faces:
batch_boundary_el_numbers_in_grp = np.array([
ibface_el
for ibface_el, ibface_face in group_boundary_faces
if ibface_face == face.face_index
], dtype=np.intp)

# {{{ preallocate arrays for mesh group

nbatch_elements = len(batch_boundary_el_numbers_in_grp)

if per_face_groups or face_id == 0:
if per_face_groups or face.face_index == 0:
if per_face_groups:
ngroup_bdry_elements = nbatch_elements
else:
ngroup_bdry_elements = len(group_boundary_faces)

# make up some not-terrible nodes for the boundary Mesh
space = mp.space_for_shape(face, mgrp.order)
bdry_unit_nodes = mp.edge_clustered_nodes_for_space(space, face)

vol_basis = mp.basis_for_space(
mgrp._modepy_space, mgrp._modepy_shape).functions

vertex_indices = np.empty(
(ngroup_bdry_elements, mgrp.dim+1-1),
(ngroup_bdry_elements, face.nvertices),
mgrp.vertex_indices.dtype)

bdry_unit_nodes = mp.warp_and_blend_nodes(mgrp.dim-1, mgrp.order)
bdry_unit_nodes_01 = (bdry_unit_nodes + 1)*0.5

vol_basis = mp.simplex_onb(mgrp.dim, mgrp.order)
nbdry_unit_nodes = bdry_unit_nodes_01.shape[-1]
nbdry_unit_nodes = bdry_unit_nodes.shape[-1]
nodes = np.empty(
(discr.ambient_dim, ngroup_bdry_elements, nbdry_unit_nodes),
dtype=np.float64)

# }}}

new_el_numbers = batch_base + np.arange(nbatch_elements)
Expand All @@ -303,24 +301,7 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

# {{{ no per-element axes in these computations

# Find boundary vertex indices
loc_face_vertices = list(grp_face_vertex_indices[face_id])

# Find unit nodes for boundary element
face_vertex_unit_coordinates = \
grp_vertex_unit_coordinates[loc_face_vertices]

# Find A, b such that A [e_1 e_2] + b = [r_1 r_2]
# (Notation assumes that the volume is 3D and the face is 2D.
# Code does not.)

b = face_vertex_unit_coordinates[0]
A = ( # noqa
face_vertex_unit_coordinates[1:]
- face_vertex_unit_coordinates[0]).T

face_unit_nodes = (np.dot(A, bdry_unit_nodes_01).T + b).T

face_unit_nodes = face.map_to_volume(bdry_unit_nodes)
resampling_mat = mp.resampling_matrix(
vol_basis,
face_unit_nodes, mgrp.unit_nodes)
Expand All @@ -331,7 +312,7 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

# Find vertex_indices
glob_face_vertices = mgrp.vertex_indices[
batch_boundary_el_numbers_in_grp][:, loc_face_vertices]
batch_boundary_el_numbers_in_grp][:, face.volume_vertex_indices]
vertex_indices[new_el_numbers] = \
vol_to_bdry_vertices[glob_face_vertices]

Expand All @@ -343,17 +324,16 @@ def make_face_restriction(actx, discr, group_factory, boundary_tag,

# }}}

connection_data[igrp, face_id] = _ConnectionBatchData(
connection_data[igrp, face.face_index] = _ConnectionBatchData(
group_source_element_indices=batch_boundary_el_numbers_in_grp,
group_target_element_indices=new_el_numbers,
A=A,
b=b,
face=face,
)

is_last_face = face_id + 1 == mgrp.nfaces
is_last_face = face.face_index + 1 == mgrp.nfaces

if per_face_groups or is_last_face:
bdry_mesh_group = SimplexElementGroup(
bdry_mesh_group = type(mgrp)(
mgrp.order, vertex_indices, nodes,
unit_nodes=bdry_unit_nodes)
bdry_mesh_groups.append(bdry_mesh_group)
Expand Down
Loading