Skip to content
Snippets Groups Projects
Commit e9f6da0d authored by Thomas Gibson's avatar Thomas Gibson
Browse files

Fix improper classification of modal dofs; adopt QTAG_MODAL

parent 9474e507
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ THE SOFTWARE. ...@@ -22,7 +22,7 @@ THE SOFTWARE.
from pytools import memoize_method from pytools import memoize_method
from grudge.dof_desc import \ from grudge.dof_desc import \
QTAG_NONE, DTAG_MODAL, DTAG_BOUNDARY, DOFDesc, as_dofdesc QTAG_NONE, QTAG_MODAL, DTAG_BOUNDARY, DOFDesc, as_dofdesc
import numpy as np # noqa: F401 import numpy as np # noqa: F401
from meshmode.array_context import ArrayContext from meshmode.array_context import ArrayContext
from meshmode.discretization.connection import \ from meshmode.discretization.connection import \
...@@ -83,6 +83,12 @@ class DiscretizationCollection: ...@@ -83,6 +83,12 @@ class DiscretizationCollection:
quad_tag_to_group_factory[QTAG_NONE] = \ quad_tag_to_group_factory[QTAG_NONE] = \
PolynomialWarpAndBlendGroupFactory(order=order) PolynomialWarpAndBlendGroupFactory(order=order)
# Modal discr should always comes from the base discretization
quad_tag_to_group_factory[QTAG_MODAL] = \
_generate_modal_group_factory(
quad_tag_to_group_factory[QTAG_NONE]
)
self.quad_tag_to_group_factory = quad_tag_to_group_factory self.quad_tag_to_group_factory = quad_tag_to_group_factory
from meshmode.discretization import Discretization from meshmode.discretization import Discretization
...@@ -90,14 +96,6 @@ class DiscretizationCollection: ...@@ -90,14 +96,6 @@ class DiscretizationCollection:
self._volume_discr = Discretization(array_context, mesh, self._volume_discr = Discretization(array_context, mesh,
self.group_factory_for_quadrature_tag(QTAG_NONE)) self.group_factory_for_quadrature_tag(QTAG_NONE))
# Modal discr should always comes from the base discretization
self._modal_discr = Discretization(
array_context, mesh,
_generate_modal_group_factory(
self.group_factory_for_quadrature_tag(QTAG_NONE)
)
)
# {{{ management of discretization-scoped common subexpressions # {{{ management of discretization-scoped common subexpressions
from pytools import UniqueNameGenerator from pytools import UniqueNameGenerator
...@@ -173,14 +171,14 @@ class DiscretizationCollection: ...@@ -173,14 +171,14 @@ class DiscretizationCollection:
qtag = dd.quadrature_tag qtag = dd.quadrature_tag
if qtag is QTAG_MODAL:
return self._modal_discr(dd)
if dd.is_volume(): if dd.is_volume():
if qtag is not QTAG_NONE: if qtag is not QTAG_NONE:
return self._quad_volume_discr(qtag) return self._quad_volume_discr(qtag)
return self._volume_discr return self._volume_discr
if dd.is_modal():
return self._modal_discr
if qtag is not QTAG_NONE: if qtag is not QTAG_NONE:
no_quad_discr = self.discr_from_dd(DOFDesc(dd.domain_tag)) no_quad_discr = self.discr_from_dd(DOFDesc(dd.domain_tag))
...@@ -207,10 +205,23 @@ class DiscretizationCollection: ...@@ -207,10 +205,23 @@ class DiscretizationCollection:
to_dd = as_dofdesc(to_dd) to_dd = as_dofdesc(to_dd)
to_qtag = to_dd.quadrature_tag to_qtag = to_dd.quadrature_tag
from_qtag = from_dd.quadrature_tag
# {{{ mapping between modal and nodal representations
if (from_qtag is QTAG_MODAL and to_qtag is not QTAG_MODAL):
return self._modal_to_nodal_connection(to_dd)
if (to_qtag is QTAG_MODAL and from_qtag is not QTAG_MODAL):
return self._nodal_to_modal_connection(from_dd)
# }}}
assert (to_qtag is not QTAG_MODAL and from_qtag is not QTAG_MODAL)
if ( if (
not from_dd.is_volume() not from_dd.is_volume()
and from_dd.quadrature_tag == to_dd.quadrature_tag and from_qtag == to_qtag
and to_dd.domain_tag is FACE_RESTR_ALL): and to_dd.domain_tag is FACE_RESTR_ALL):
faces_conn = self.connection_from_dds( faces_conn = self.connection_from_dds(
DOFDesc("vol"), DOFDesc("vol"),
...@@ -226,10 +237,9 @@ class DiscretizationCollection: ...@@ -226,10 +237,9 @@ class DiscretizationCollection:
# {{{ simplify domain + qtag change into chained # {{{ simplify domain + qtag change into chained
if ( if (from_dd.domain_tag != to_dd.domain_tag
from_dd.domain_tag != to_dd.domain_tag and from_qtag is QTAG_NONE
and from_dd.quadrature_tag is QTAG_NONE and to_qtag is not QTAG_NONE):
and to_dd.quadrature_tag is not QTAG_NONE):
from meshmode.discretization.connection import \ from meshmode.discretization.connection import \
ChainedDiscretizationConnection ChainedDiscretizationConnection
...@@ -251,10 +261,10 @@ class DiscretizationCollection: ...@@ -251,10 +261,10 @@ class DiscretizationCollection:
# {{{ generic to-quad # {{{ generic to-quad
if ( if (from_dd.domain_tag == to_dd.domain_tag
from_dd.domain_tag == to_dd.domain_tag and from_qtag is QTAG_NONE
and from_dd.quadrature_tag is QTAG_NONE and to_qtag is not QTAG_NONE):
and to_dd.quadrature_tag is not QTAG_NONE):
from meshmode.discretization.connection.same_mesh import \ from meshmode.discretization.connection.same_mesh import \
make_same_mesh_connection make_same_mesh_connection
...@@ -265,21 +275,7 @@ class DiscretizationCollection: ...@@ -265,21 +275,7 @@ class DiscretizationCollection:
# }}} # }}}
# {{{ mapping between modal and nodal representations if from_qtag is not QTAG_NONE:
if (from_dd.domain_tag is DTAG_MODAL
and to_dd.is_volume()):
return self._modal_to_nodal_connection(to_qtag)
if (to_dd.domain_tag is DTAG_MODAL
and from_dd.is_volume()):
return self._nodal_to_modal_connection(from_dd.quadrature_tag)
# }}}
if from_dd.quadrature_tag is not QTAG_NONE:
raise ValueError("cannot interpolate *from* a " raise ValueError("cannot interpolate *from* a "
"(non-interpolatory) quadrature grid") "(non-interpolatory) quadrature grid")
...@@ -291,12 +287,12 @@ class DiscretizationCollection: ...@@ -291,12 +287,12 @@ class DiscretizationCollection:
if to_dd.domain_tag is FACE_RESTR_INTERIOR: if to_dd.domain_tag is FACE_RESTR_INTERIOR:
return self._interior_faces_connection() return self._interior_faces_connection()
elif to_dd.is_boundary_or_partition_interface(): elif to_dd.is_boundary_or_partition_interface():
assert from_dd.quadrature_tag is QTAG_NONE assert from_qtag is QTAG_NONE
return self._boundary_connection(to_dd.domain_tag.tag) return self._boundary_connection(to_dd.domain_tag.tag)
elif to_dd.is_volume(): elif to_dd.is_volume():
from meshmode.discretization.connection import \ from meshmode.discretization.connection import \
make_same_mesh_connection make_same_mesh_connection
to_discr = self._quad_volume_discr(to_dd.quadrature_tag) to_discr = self._quad_volume_discr(to_qtag)
from_discr = self._volume_discr from_discr = self._volume_discr
return make_same_mesh_connection(self._setup_actx, to_discr, return make_same_mesh_connection(self._setup_actx, to_discr,
from_discr) from_discr)
...@@ -327,45 +323,43 @@ class DiscretizationCollection: ...@@ -327,45 +323,43 @@ class DiscretizationCollection:
# {{{ modal to nodal connections # {{{ modal to nodal connections
@memoize_method @memoize_method
def _modal_to_nodal_connection(self, quadrature_tag): def _modal_discr(self, domain_tag):
from meshmode.discretization import Discretization
discr_base = self.discr_from_dd(DOFDesc(domain_tag, QTAG_NONE))
return Discretization(
self._setup_actx, discr_base.mesh,
self.group_factory_for_quadrature_tag(QTAG_MODAL)
)
@memoize_method
def _modal_to_nodal_connection(self, to_dd):
""" """
:arg quadrature_tag: a quadrature tag corresponding :arg to_dd: a :class:`grudge.dof_desc.DOFDesc`
to the "from_discr", which is assumed to be describing the dofs corresponding to the
either the base discretization or a quadrature *to_discr*
grid.
""" """
from meshmode.discretization.connection import \ from meshmode.discretization.connection import \
ModalToNodalDiscretizationConnection ModalToNodalDiscretizationConnection
if quadrature_tag is not QTAG_NONE:
to_discr = self._quad_volume_discr(quadrature_tag)
else:
to_discr = self._volume_discr
return ModalToNodalDiscretizationConnection( return ModalToNodalDiscretizationConnection(
from_discr=self._modal_discr, from_discr=self._modal_discr(to_dd.domain_tag),
to_discr=to_discr to_discr=self.discr_from_dd(to_dd)
) )
@memoize_method @memoize_method
def _nodal_to_modal_connection(self, quadrature_tag): def _nodal_to_modal_connection(self, from_dd):
""" """
:arg quadrature_tag: a quadrature tag corresponding :arg from_dd: a :class:`grudge.dof_desc.DOFDesc`
to the "to_discr", which is assumed to be describing the dofs corresponding to the
either the base discretization or a quadrature *from_discr*
grid.
""" """
from meshmode.discretization.connection import \ from meshmode.discretization.connection import \
NodalToModalDiscretizationConnection NodalToModalDiscretizationConnection
if quadrature_tag is not QTAG_NONE:
from_discr = self._quad_volume_discr(quadrature_tag)
else:
from_discr = self._volume_discr
return NodalToModalDiscretizationConnection( return NodalToModalDiscretizationConnection(
from_discr=from_discr, from_discr=self.discr_from_dd(from_dd),
to_discr=self._modal_discr to_discr=self._modal_discr(from_dd.domain_tag)
) )
# }}} # }}}
......
...@@ -34,9 +34,9 @@ from meshmode.mesh import \ ...@@ -34,9 +34,9 @@ from meshmode.mesh import \
__doc__ = """ __doc__ = """
.. autoclass:: DTAG_SCALAR .. autoclass:: DTAG_SCALAR
.. autoclass:: DTAG_VOLUME_ALL .. autoclass:: DTAG_VOLUME_ALL
.. autoclass:: DTAG_MODAL
.. autoclass:: DTAG_BOUNDARY .. autoclass:: DTAG_BOUNDARY
.. autoclass:: QTAG_NONE .. autoclass:: QTAG_NONE
.. autoclass:: QTAG_MODAL
.. autoclass:: DOFDesc .. autoclass:: DOFDesc
.. autofunction:: as_dofdesc .. autofunction:: as_dofdesc
...@@ -60,13 +60,6 @@ class DTAG_VOLUME_ALL: # noqa: N801 ...@@ -60,13 +60,6 @@ class DTAG_VOLUME_ALL: # noqa: N801
""" """
class DTAG_MODAL: # noqa: N801
"""
A tag denoting modal (rather than nodal)
degrees of freedom on cell volumes.
"""
class DTAG_BOUNDARY: # noqa: N801 class DTAG_BOUNDARY: # noqa: N801
"""A tag describing the meaning of degrees of freedom """A tag describing the meaning of degrees of freedom
on element boundaries which are adjacent to elements on element boundaries which are adjacent to elements
...@@ -111,6 +104,16 @@ class QTAG_NONE: # noqa: N801 ...@@ -111,6 +104,16 @@ class QTAG_NONE: # noqa: N801
""" """
class QTAG_MODAL: # noqa: N801
"""A quadrature tag indicating the use of a
basic discretization grid with modal degrees of
freedom. This tag is used to distinguish the
modal discretization (`QTAG_MODAL`) from
the base (nodal) discretization (e.g. `QTAG_NONE`)
or discretizations on quadrature grids.
"""
class DOFDesc: class DOFDesc:
"""Describes the meaning of degrees of freedom. """Describes the meaning of degrees of freedom.
...@@ -122,7 +125,6 @@ class DOFDesc: ...@@ -122,7 +125,6 @@ class DOFDesc:
.. automethod:: is_scalar .. automethod:: is_scalar
.. automethod:: is_discretized .. automethod:: is_discretized
.. automethod:: is_volume .. automethod:: is_volume
.. automethod:: is_modal
.. automethod:: is_boundary_or_partition_interface .. automethod:: is_boundary_or_partition_interface
.. automethod:: is_trace .. automethod:: is_trace
...@@ -142,8 +144,6 @@ class DOFDesc: ...@@ -142,8 +144,6 @@ class DOFDesc:
:class:`DTAG_SCALAR` (or the string ``"scalar"``), :class:`DTAG_SCALAR` (or the string ``"scalar"``),
:class:`DTAG_VOLUME_ALL` (or the string ``"vol"``) :class:`DTAG_VOLUME_ALL` (or the string ``"vol"``)
for the default volume discretization, for the default volume discretization,
:class:`DTAG_MODAL` (or the string ``"modal"``),
for denoting modal coefficients,
:data:`~meshmode.discretization.connection.FACE_RESTR_ALL` :data:`~meshmode.discretization.connection.FACE_RESTR_ALL`
(or the string ``"all_faces"``), or (or the string ``"all_faces"``), or
:data:`~meshmode.discretization.connection.FACE_RESTR_INTERIOR` :data:`~meshmode.discretization.connection.FACE_RESTR_INTERIOR`
...@@ -167,8 +167,6 @@ class DOFDesc: ...@@ -167,8 +167,6 @@ class DOFDesc:
domain_tag = DTAG_SCALAR domain_tag = DTAG_SCALAR
elif domain_tag in [DTAG_VOLUME_ALL, "vol"]: elif domain_tag in [DTAG_VOLUME_ALL, "vol"]:
domain_tag = DTAG_VOLUME_ALL domain_tag = DTAG_VOLUME_ALL
elif domain_tag in [DTAG_MODAL, "modal"]:
domain_tag = DTAG_MODAL
elif domain_tag in [FACE_RESTR_ALL, "all_faces"]: elif domain_tag in [FACE_RESTR_ALL, "all_faces"]:
domain_tag = FACE_RESTR_ALL domain_tag = FACE_RESTR_ALL
elif domain_tag in [FACE_RESTR_INTERIOR, "int_faces"]: elif domain_tag in [FACE_RESTR_INTERIOR, "int_faces"]:
...@@ -200,9 +198,6 @@ class DOFDesc: ...@@ -200,9 +198,6 @@ class DOFDesc:
def is_volume(self): def is_volume(self):
return self.domain_tag is DTAG_VOLUME_ALL return self.domain_tag is DTAG_VOLUME_ALL
def is_modal(self):
return self.domain_tag is DTAG_MODAL
def is_boundary_or_partition_interface(self): def is_boundary_or_partition_interface(self):
return isinstance(self.domain_tag, DTAG_BOUNDARY) return isinstance(self.domain_tag, DTAG_BOUNDARY)
...@@ -253,7 +248,7 @@ DD_SCALAR = DOFDesc(DTAG_SCALAR, None) ...@@ -253,7 +248,7 @@ DD_SCALAR = DOFDesc(DTAG_SCALAR, None)
DD_VOLUME = DOFDesc(DTAG_VOLUME_ALL, None) DD_VOLUME = DOFDesc(DTAG_VOLUME_ALL, None)
DD_MODAL = DOFDesc(DTAG_MODAL, None) DD_MODAL = DOFDesc(DTAG_VOLUME_ALL, QTAG_MODAL)
def as_dofdesc(dd): def as_dofdesc(dd):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment