def __init__(self, ref_el, degree): if degree < 1: raise Exception("Trimmed serendipity face elements only valid for k >= 1") flat_el = flatten_reference_cube(ref_el) dim = flat_el.get_spatial_dimension() if dim != 2: raise Exception("Trimmed serendipity face elements only valid for dimensions 2") 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]) EL = e_lambda_1_2d_part_one(degree, dx, dy, x_mid, y_mid) if degree >= 2: FL = trimmed_f_lambda_2d(degree, dx, dy, x_mid, y_mid) else: FL = () Sminus_list = EL + FL Sminus_list = [[-a[1], a[0]] for a in Sminus_list] self.basis = {(0, 0): Array(Sminus_list)} super(TrimmedSerendipityFace, self).__init__(ref_el=ref_el, degree=degree, mapping="contravariant piola")
def __init__(self, ref_el, degree): flat_el = flatten_reference_cube(ref_el) poly_set = ONPolynomialSet(hypercube_simplex_map[flat_el], degree) dual = DPCDualSet(ref_el, flat_el, degree) formdegree = flat_el.get_spatial_dimension() # n-form super().__init__(poly_set=poly_set, dual=dual, order=degree, ref_el=ref_el, formdegree=formdegree)
def __init__(self, ref_el): flat_el = flatten_reference_cube(ref_el) poly_set = polynomial_set.ONPolynomialSet( hypercube_simplex_map[flat_el], 0) dual = P0Dual(ref_el) degree = 0 formdegree = ref_el.get_spatial_dimension() # n-form super(DPC0, self).__init__(poly_set=poly_set, dual=dual, order=degree, ref_el=ref_el, formdegree=formdegree)
def __init__(self, ref_el, degree): if degree < 1: raise Exception("Trimmed Serendipity_k edge elements only valid for k >= 1") flat_el = flatten_reference_cube(ref_el) dim = flat_el.get_spatial_dimension() if dim != 2: if dim != 3: raise Exception("Trimmed Serendipity_k edge elements only valid for dimensions 2 and 3") 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 if dim == 2: EL = e_lambda_1_2d_part_one(degree, dx, dy, x_mid, y_mid) else: EL = e_lambda_1_3d_trimmed(degree, dx, dy, dz, x_mid, y_mid, z_mid) if degree >= 2: if dim == 2: FL = trimmed_f_lambda_2d(degree, dx, dy, x_mid, y_mid) else: FL = f_lambda_1_3d_trimmed(degree, dx, dy, dz, x_mid, y_mid, z_mid) else: FL = () if dim == 3: if degree >= 4: IL = I_lambda_1_3d(degree, dx, dy, dz, x_mid, y_mid, z_mid) + I_lambda_1_tilde_3d(degree, dx, dy, dz, x_mid, y_mid, z_mid) else: IL = () Sminus_list = EL + FL if dim == 3: Sminus_list = Sminus_list + IL if dim == 2: self.basis = {(0, 0): Array(Sminus_list)} else: self.basis = {(0, 0, 0): Array(Sminus_list)} super(TrimmedSerendipityEdge, self).__init__(ref_el=ref_el, degree=degree, mapping="covariant piola")
def __init__(self, ref_el, degree): if degree < 1: raise Exception("Trimmed serendipity face elements only valid for k >= 1") flat_el = flatten_reference_cube(ref_el) dim = flat_el.get_spatial_dimension() if dim != 2: if dim != 3: raise Exception("Trimmed serendipity face elements only valid for dimensions 2 and 3") 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 if dim == 3: FL = f_lambda_2_3d(degree, dx, dy, dz, x_mid, y_mid, z_mid) if (degree > 1): IL = I_lambda_2_3d(degree, dx, dy, dz, x_mid, y_mid, z_mid) else: IL = () Sminus_list = FL + IL self.basis = {(0, 0, 0): Array(Sminus_list)} super(TrimmedSerendipityDiv, self).__init__(ref_el=ref_el, degree=degree, mapping="contravariant piola") else: # Put all 2 dimensional stuff here. if degree < 1: raise Exception("Trimmed serendipity face elements only valid for k >= 1") EL = e_lambda_1_2d_part_one(degree, dx, dy, x_mid, y_mid) if degree >= 2: FL = trimmed_f_lambda_2d(degree, dx, dy, x_mid, y_mid) else: FL = () Sminus_list = EL + FL Sminus_list = [[-a[1], a[0]] for a in Sminus_list] self.basis = {(0, 0): Array(Sminus_list)} super(TrimmedSerendipityDiv, self).__init__(ref_el=ref_el, degree=degree, mapping="contravariant piola")
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
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