Skip to content
Snippets Groups Projects
Commit c50ce18f authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Allow overriding variable class in make_sym_vector

parent 2b3b9d25
No related branches found
No related tags found
No related merge requests found
......@@ -1571,17 +1571,21 @@ def make_common_subexpression(field, prefix=None, scope=None):
return CommonSubexpression(field, prefix, scope)
def make_sym_vector(name, components):
def make_sym_vector(name, components, var_class=None):
"""Return an object array of *components* subscripted
:class:`Variable` instances.
:class:`Variable` (or subclass) instances.
:param components: The number of components in the vector.
:arg components: The number of components in the vector.
:arg var_class: The :class:`Variable` subclass to use for instantiating
the scalar variables.
"""
if isinstance(components, int):
components = list(range(components))
if var_class is None:
var_class = Variable
from pytools.obj_array import join_fields
vfld = Variable(name)
vfld = var_class(name)
return join_fields(*[vfld.index(i) for i in components])
......
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