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

generate tuples for quadrilateral elements #17

Open
mghadam opened this issue Mar 5, 2016 · 1 comment
Open

generate tuples for quadrilateral elements #17

mghadam opened this issue Mar 5, 2016 · 1 comment

Comments

@mghadam
Copy link

mghadam commented Mar 5, 2016

Hello,

I'm trying to work on adding support for quadrilateral elements
(Quadrangle, Quadrangle8, Quadrangle9)

How can I generate appropriate tuples with generate_nonnegative_integer_tuples_summing_to_at_most tool?

I have added

def generate_quadrangle_vertex_tuples(order):
    yield (0, 0)
    yield (order, 0)
    yield (order,order)
    yield (0, order)


def generate_quadrangle_edge_tuples(order):
    for i in range(1, order):
        yield (i, 0)
    for i in range(1, order):
        yield (order, i)
    for i in range(1, order):
        yield (i, order)
    for i in range(1, order):
        yield (0, i)


def generate_quadrangle_volume_tuples(order):
    for i in range(1, order):
        for j in range(1, order):
            yield (j, i)

and

class GmshIncompleteQuadrilateralElement(GmshElementBase):
    dimensions = 2

    def __init__(self, order):
        self.order = order

    @memoize_method
    def gmsh_node_tuples(self):
        result = []
        for tup in generate_quadrangle_vertex_tuples(self.order):
            result.append(tup)
        for tup in generate_quadrangle_edge_tuples(self.order):
            result.append(tup)
        return result


class GmshQuadrilateralElement(GmshElementBase):
    dimensions = 2

    @memoize_method
    def gmsh_node_tuples(self):
        result = []
        for tup in generate_quadrangle_vertex_tuples(self.order):
            result.append(tup)
        for tup in generate_quadrangle_edge_tuples(self.order):
            result.append(tup)
        for tup in generate_quadrangle_volume_tuples(self.order):
            result.append(tup)
        return result

which generate:

el = GmshQuadrilateralElement(1)
el.gmsh_node_tuples()

[(0, 0), (1, 0), (1, 1), (0, 1)]

el = GmshQuadrilateralElement(2)
el.gmsh_node_tuples()

[(0, 0), (2, 0), (2, 2), (0, 2), (1, 0), (2, 1), (1, 2), (0, 1), (1, 1)]

el = GmshIncompleteQuadrilateralElement(2)
el.gmsh_node_tuples()

[(0, 0), (2, 0), (2, 2), (0, 2), (1, 0), (2, 1), (1, 2), (0, 1)]

but the node numbering is not compatible (sum of integers > self.order | self.dimension) with tuples returned by lexicographic_node_tuples.

Thanks

@inducer
Copy link
Owner

inducer commented Mar 6, 2016

For quadrilaterals I think you want generate_nonnegative_integer_tuples_below:

https://github.com/inducer/pytools/blob/8c1ffcd02513bbe1d19ce804aae69cdb743439f7/pytools/__init__.py#L1090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants