Esempio n. 1
0
    def __init__(self, element):

        nodes = element.dual.nodes
        dim = element.ref_el.get_spatial_dimension()

        if dim == 2:
            ref_el = UFCQuadrilateral()
        elif dim == 3:
            ref_el = UFCHexahedron()
        else:
            raise ValueError("Illegal element dimension %s" % dim)

        entity_ids = element.dual.entity_ids

        flat_entity_ids = flatten_entities(entity_ids)
        dual = DualSet(nodes, ref_el, flat_entity_ids)
        super(FlattenedDimensions, self).__init__(ref_el, dual,
                                                  element.get_order(),
                                                  element.get_formdegree(),
                                                  element._mapping)
        self.element = element

        # Construct unflattening map for passing correct values to tabulate()
        self.unflattening_map = compute_unflattening_map(
            self.element.ref_el.get_topology())
Esempio n. 2
0
    def __init__(self, element):

        nodes = element.dual.nodes
        dim = element.ref_el.get_spatial_dimension()

        if dim == 2:
            ref_el = UFCQuadrilateral()
        elif dim == 3:
            ref_el = UFCHexahedron()
        else:
            raise ValueError("Illegal element dimension %s" % dim)

        entity_ids = element.dual.entity_ids

        flat_entity_ids = flatten_entities(entity_ids)
        dual = DualSet(nodes, ref_el, flat_entity_ids)
        super(FlattenedDimensions, self).__init__(ref_el, dual, element.get_order(), element.get_formdegree(), element._mapping)
        self.element = element

        # Construct unflattening map for passing correct values to tabulate()
        self.unflattening_map = compute_unflattening_map(self.element.ref_el.get_topology())
Esempio n. 3
0
    def __init__(self, ref_el, degree):

        flat_el = flatten_reference_cube(ref_el)
        dim = flat_el.get_spatial_dimension()
        flat_topology = flat_el.get_topology()

        verts = flat_el.get_vertices()

        dx = ((verts[-1][0] - x)/(verts[-1][0] - verts[0][0]), (x - verts[0][0])/(verts[-1][0] - verts[0][0]))
        dy = ((verts[-1][1] - y)/(verts[-1][1] - verts[0][1]), (y - verts[0][1])/(verts[-1][1] - verts[0][1]))
        x_mid = 2*x-(verts[-1][0] + verts[0][0])
        y_mid = 2*y-(verts[-1][1] + verts[0][1])
        try:
            dz = ((verts[-1][2] - z)/(verts[-1][2] - verts[0][2]), (z - verts[0][2])/(verts[-1][2] - verts[0][2]))
            z_mid = 2*z-(verts[-1][2] + verts[0][2])
        except IndexError:
            dz = None
            z_mid = None

        VL = v_lambda_0(dim, dx, dy, dz)
        EL = []
        FL = []
        IL = []
        s_list = []
        entity_ids = {}
        cur = 0

        for top_dim, entities in flat_topology.items():
            entity_ids[top_dim] = {}
            for entity in entities:
                entity_ids[top_dim][entity] = []

        for j in sorted(flat_topology[0]):
            entity_ids[0][j] = [cur]
            cur = cur + 1

        EL += e_lambda_0(degree, dim, dx, dy, dz, x_mid, y_mid, z_mid)

        for j in sorted(flat_topology[1]):
            entity_ids[1][j] = list(range(cur, cur + degree - 1))
            cur = cur + degree - 1

        FL += f_lambda_0(degree, dim, dx, dy, dz, x_mid, y_mid, z_mid)

        for j in sorted(flat_topology[2]):
            entity_ids[2][j] = list(range(cur, cur + tr(degree)))
            cur = cur + tr(degree)

        if dim == 3:
            IL += i_lambda_0(degree, dx, dy, dz, x_mid, y_mid, z_mid)

            entity_ids[3] = {}
            entity_ids[3][0] = list(range(cur, cur + len(IL)))
            cur = cur + len(IL)

        s_list = VL + EL + FL + IL
        assert len(s_list) == cur
        formdegree = 0

        super(Serendipity, self).__init__(ref_el=ref_el, dual=None, order=degree, formdegree=formdegree)

        self.basis = {(0,)*dim: Array(s_list)}

        topology = ref_el.get_topology()
        unflattening_map = compute_unflattening_map(topology)
        unflattened_entity_ids = {}
        unflattened_entity_closure_ids = {}

        entity_closure_ids = make_entity_closure_ids(flat_el, entity_ids)

        for dim, entities in sorted(topology.items()):
            unflattened_entity_ids[dim] = {}
            unflattened_entity_closure_ids[dim] = {}
        for dim, entities in sorted(flat_topology.items()):
            for entity in entities:
                unflat_dim, unflat_entity = unflattening_map[(dim, entity)]
                unflattened_entity_ids[unflat_dim][unflat_entity] = entity_ids[dim][entity]
                unflattened_entity_closure_ids[unflat_dim][unflat_entity] = entity_closure_ids[dim][entity]
        self.entity_ids = unflattened_entity_ids
        self.entity_closure_ids = unflattened_entity_closure_ids
        self._degree = degree
        self.flat_el = flat_el
Esempio n. 4
0
 def __init__(self, element):
     super(FlattenedDimensions, self).__init__()
     self.product = element
     self._unflatten = compute_unflattening_map(element.cell.get_topology())
Esempio n. 5
0
File: cube.py Progetto: FInAT/FInAT
 def __init__(self, element):
     super(FlattenedDimensions, self).__init__()
     self.product = element
     self._unflatten = compute_unflattening_map(element.cell.get_topology())
Esempio n. 6
0
    def __init__(self, ref_el, degree, mapping):
        if degree < 1:
            raise Exception(
                "Trimmed serendipity elements only valid for k >= 1")

        flat_el = flatten_reference_cube(ref_el)
        dim = flat_el.get_spatial_dimension()
        self.fdim = dim
        if dim != 3:
            if dim != 2:
                raise Exception(
                    "Trimmed serendipity elements only valid for dimensions 2 and 3"
                )

        flat_topology = flat_el.get_topology()
        entity_ids = {}
        cur = 0

        for top_dim, entities in flat_topology.items():
            entity_ids[top_dim] = {}
            for entity in entities:
                entity_ids[top_dim][entity] = []

        # 3-d case.
        if dim == 3:
            entity_ids[3] = {}
            for l in sorted(flat_topology[1]):
                entity_ids[1][l] = list(range(cur, cur + degree))
                cur = cur + degree
            if (degree > 1):
                face_ids = degree
                for k in range(2, degree):
                    face_ids += 2 * (k - 1)
                for j in sorted(flat_topology[2]):
                    entity_ids[2][j] = list(range(cur, cur + face_ids))
                    cur += face_ids
            interior_ids = 0
            for k in range(4, degree):
                interior_ids = interior_ids + 3 * choose_ijk_total(k - 4)
            if (degree > 3):
                if (degree == 4):
                    interior_tilde_ids = 3
                elif (degree == 5):
                    interior_tilde_ids = 8
                elif (degree == 6):
                    interior_tilde_ids = 6 + 3 * (degree - 3)
                else:
                    interior_tilde_ids = 6 + 3 * (degree - 4)
            else:
                interior_tilde_ids = 0

            entity_ids[3][0] = list(
                range(cur, cur + interior_ids + interior_tilde_ids))
            cur = cur + interior_ids + interior_tilde_ids
        else:
            for j in sorted(flat_topology[1]):
                entity_ids[1][j] = list(range(cur, cur + degree))
                cur = cur + degree

            if (degree >= 2):
                entity_ids[2][0] = list(
                    range(cur,
                          cur + 2 * triangular_number(degree - 2) + degree))

            cur += 2 * triangular_number(degree - 2) + degree
        formdegree = 1

        entity_closure_ids = make_entity_closure_ids(flat_el, entity_ids)

        super(TrimmedSerendipity, self).__init__(ref_el=ref_el,
                                                 dual=None,
                                                 order=degree,
                                                 formdegree=formdegree,
                                                 mapping=mapping)

        topology = ref_el.get_topology()
        unflattening_map = compute_unflattening_map(topology)
        unflattened_entity_ids = {}
        unflattened_entity_closure_ids = {}

        for dim, entities in sorted(topology.items()):
            unflattened_entity_ids[dim] = {}
            unflattened_entity_closure_ids[dim] = {}
        for dim, entities in sorted(flat_topology.items()):
            for entity in entities:
                unflat_dim, unflat_entity = unflattening_map[(dim, entity)]
                unflattened_entity_ids[unflat_dim][unflat_entity] = entity_ids[
                    dim][entity]
                unflattened_entity_closure_ids[unflat_dim][
                    unflat_entity] = entity_closure_ids[dim][entity]
        self.entity_ids = unflattened_entity_ids
        self.entity_closure_ids = unflattened_entity_closure_ids
        self._degree = degree
        self.flat_el = flat_el