Esempio n. 1
0
def MatrixS3D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Se = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    x_0 = Coefficients[6]
    r_c = Coefficients[4]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            for k in range(len(x_ip)):
                N = E.N(x_ip[i], x_ip[j], x_ip[k])
                N_T = N.transpose()
                B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], x_ip[k], Coords)
                B_T = B.transpose()
                x_coord = np.array([Coords[:, 0]]) @ N_T
                y_coord = np.array([Coords[:, 1]]) @ N_T
                z_coord = np.array([Coords[:, 2]]) @ N_T
                sigma = Coefficients[3](x_coord, y_coord, z_coord, r_c, x_0)
                Se += -N_T * (
                    sigma) * N * Jdet * weights[i] * weights[j] * weights[k]
                if Upwinded == True:
                    delta = CalcDelta3D(Coefficients,
                                        [x_coord, y_coord, z_coord], n)
                    Se += -delta * np.dot(
                        B_T, n.transpose()
                    ) * sigma * N * Jdet * weights[i] * weights[j] * weights[k]
    return Se
Esempio n. 2
0
def Dif_basic_F(S, Coords):
    E = Element("Q4")
    N = E.N()
    G_map = E.G_map()
    F = np.zeros((len(Coords), 1))
    #print(F)
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    W_ip = [1, 1]
    for i in range(len(x_ip)):

        N_l = N(x_ip[i], x_ip[i])  #N local
        N_T = np.transpose(N_l)
        B, Jdet = G_map(x_ip[i], x_ip[i], Coords)
        #print("N_T is ",N_T)
        S_val = S(x_ip[i], x_ip[i])
        #print(S_val)
        F = F + N_T * S_val * Jdet * W_ip[i] * W_ip[i]
        #print(F)
    #reference file
    file = open('../outputs/f_elemental.txt', 'w')
    for i in range(4):
        if i != 0:
            file.write('\n')
        file.write(str(F[i]))
        file.write(" ")
    file.close()
    return F
Esempio n. 3
0
def VectorF3D(Coords, n, Coefficients, sourceFunc, El_type, Upwinded):
    E = Element(El_type)
    weights = [1, 1]
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    f_ele = np.zeros((len(Coords), 1))
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            for k in range(len(x_ip)):
                N = E.N(x_ip[i], x_ip[j], x_ip[k])
                N_T = N.transpose()
                B, Jdet = E.G(x_ip[i], x_ip[j], x_ip[k], Coords)
                B_T = B.transpose()
                x_coord = np.array([Coords[:, 0]]) @ N_T
                y_coord = np.array([Coords[:, 1]]) @ N_T
                z_coord = np.array([Coords[:, 2]]) @ N_T
                source = SourceTerm3D([x_coord, y_coord, z_coord],
                                      Coefficients, sourceFunc)
                f_ele += N_T * source * Jdet * weights[i] * weights[
                    j] * weights[k]
                if Upwinded == True:
                    delta = CalcDelta3D(Coefficients,
                                        [x_coord, y_coord, z_coord], n)
                    f_ele += delta * np.dot(B_T, n.transpose(
                    )) * source * Jdet * weights[i] * weights[j] * weights[k]
    return f_ele
Esempio n. 4
0
def Dif_basic_K(Coords, k=1):  #let k be an optional arguement
    num_nodes = 4  # number of nodes
    E = Element("Q4")

    # K  = np.zeros((num_nodes,num_nodes))
    # Now to step through K_mat and integrate each element
    Ke = np.zeros((len(Coords), len(Coords)))

    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]

    W_ip = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):  # now ready to integrate
            G_m = E.G_map()
            B, Jdet = G_m(x_ip[i], x_ip[j], Coords)
            B_T = np.transpose(B)
            Ke = Ke + B_T.dot(B) * k * Jdet * W_ip[i] * W_ip[j]
            #print(Ke)
            #Ke = Ke + ((np.transpose(B)) * k * B * Jdet * W_ip[i] * W_ip[j])
            #Ke = Ke + (np.dot(np.transpose(B_val), k*B_val) * abs(J_d_val)*w_ip[i]*w_ip[j])

    #file = open('../outputs/K_elemental.txt', 'w')
    #for i in range(4):
    #    if i != 0:
    #        file.write('\n')
    #    for j in range(4):
    #        file.write(str(K[i, j]))
    #        file.write(" ")
    #file.close()
    return Ke
 def refresh(self):
     Element.refresh(self)
     if self.element:
         self.element.refresh()
         for dirty_rect in self.element.dirty_list:
             self.dirty_list.append(dirty_rect)
         self.element.dirty_list = []
     return
Esempio n. 6
0
    def __init__(self, context):
        super().__init__(context)

        self.add_to_cart_button = Element(By.NAME, 'add_cart', context)

        self.pdp_title = Element(
            By.XPATH, '//h3[contains(@class, "pdp__title")]/parent::div',
            context)
Esempio n. 7
0
 def update(self):
     if self.element:
         self.element.update()
         self.rect = self.element.rect
         for dirty_rect in self.element.dirty_list:
             self.dirty_list.append(dirty_rect)
         self.element.dirty_list = []
     Element.update(self)
     return
Esempio n. 8
0
 def __init__(self, _id, infos, vertex, matrix):
     Element.__init__(self,
                      _id=_id,
                      infos=infos,
                      vertex=vertex,
                      matrix=matrix)
     self.typeid = infos['typeid']
     self.radius = ENTITY_RADIUS[self.typeid]
     self.level = None
Esempio n. 9
0
 def __init__(self, element=None, grid_position=None, \
              grid_camera=None, **kwargs):
     Element.__init__(self, **kwargs)
     self.element = element
     if element:
         self.rect = element.rect
     self.grid_position = grid_position
     self.grid_camera = grid_camera
     return
Esempio n. 10
0
def Dif_basic_K(el_type,
                Coords,
                k=1,
                P_type='scalar'):  #let k be an optional arguement
    El = Element(el_type)
    if el_type == 'Q4':
        num_nodes = 4  # number of nodes
    elif el_type == 'Q8':
        num_nodes = 8
    else:
        print('Please enter a valid element type')
    K = np.zeros((num_nodes, num_nodes))
    G = El.G()  # snag B-matrix for element
    if (P_type == 'scalar'
        ):  # calculates B function based on scalar or vector problem!
        B = G
    elif (P_type == 'vector'):
        B = np.zeros((3, 8))
        for i in range(2 * num_nodes):
            B[0, 2 * i] = G[0, i]
            B[1, 2 * i - 1] = G[1, i]
            B[2, 2 * i] = G[0, i]
            B[2, 2 * i - 1] = G[1, i]
    else:
        print('Please enter valid problem type')
    #calculate jacobian determinant  -- take another look at this!!!!!

    J = lambda x, y: np.dot(G(x, y), Coords)
    J_d = lambda x, y: np.linalg.det(J(x, y))

    # K_mat = lambda x, y: np.dot(np.transpose(B(x,y)), k*B(x,y))*abs(Jd_m(x,y)) # Create K_matrix based on definition in scalar problem - heat
    #K_mat = lambda x, y: np.dot(K_mat1(x,y), J(x,y)) ##if mapped element, compute jacobian and tack on
    #print(K_mat(0,0)[0,0])
    # Now to step through K_mat and integrate each element
    Ke = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    w_ip = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):  # now ready to integrate
            B_val = G(x_ip[i], x_ip[j])
            J_d_val = J_d(x_ip[i], x_ip[j])
            #print(B_val)
            #print(J_d_val)
            Ke = Ke + (np.dot(np.transpose(B_val), k * B_val) * abs(J_d_val) *
                       w_ip[i] * w_ip[j])
    print(Ke)

    file = open('../outputs/K_elemental.txt', 'w')
    for i in range(4):
        if i != 0:
            file.write('\n')
        for j in range(4):
            file.write(str(K[i, j]))
            file.write(" ")
    file.close()
    return Ke
Esempio n. 11
0
class CatalogPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.product_title = Element(By.XPATH, '//a[contains(text(), "{}")]',
                                     context)

    def find_product_and_open_pdp(self, product_name):
        self.product_title.set_parameters(product_name)
        self.product_title.click()
Esempio n. 12
0
 def update(self):
     def names_are_synchronized():
         return self.image_name == self.old_image_name
     def sizes_are_synchronize():
         return self.old_rect is not None and self.rect.size == self.old_rect.size
     if not (names_are_synchronized() and sizes_are_synchronize()) and self.image_name != "":
         self.image = load_image(self.image_name, size=self.rect.size)
         self.refresh()
     self.old_image_name = self.image_name
     Element.update(self)
     return
Esempio n. 13
0
 def __init__(self, click_rect=None, is_clicked=False,
              click_duration=DEFAULT_BUTTON_CLICK_DURATION,
              **kwargs):
     Element.__init__(self, **kwargs)
     self.click_rect = click_rect
     self.is_clicked = is_clicked
     self.old_is_clicked = None
     if not self.click_rect:
         self.click_rect = self.rect
     self.click_duration = click_duration
     self.click_time_end = None
     return
Esempio n. 14
0
 def update(self):
     Element.update(self)
     if not self.click_rect:
         self.click_rect = self.rect
     if self.is_mouse_clicking():
         self.click()
     if self.is_clicked and self.click_time_end and \
     current_time_in_ms() > self.click_time_end:
         self.unclick()
     if self.old_is_clicked is None or self.is_clicked != self.old_is_clicked:
         self.old_is_clicked = self.is_clicked
         self.refresh()
     return
Esempio n. 15
0
def calcStressStrainElemental(d, A, NodalCoord, Connectivity):
    #calculate strains in center of element!
    E = Element("Q4")
    stress = np.zeros((3, len(Connectivity)))
    strain = np.zeros((3, len(Connectivity)))
    for e in range(0, len(Connectivity)):
        Coord_mat_el = getElementCoordinates(e, NodalCoord, Connectivity)
        Elemental_disp = getElementDisplacements(e, d, A)
        gradN, detJ = E.G_map(0, 0, Coord_mat_el)
        B = get_B_plane_stress(gradN)
        strain[:, e] = np.dot(B, Elemental_disp)[:, 0]
        stress[:, e] = strain[:, e]
    return strain, stress
Esempio n. 16
0
def ES_K(Coords):
    num_nodes = 4  # number of nodes
    E = Element("Q4")

    # Now to step through K_mat and integrate each element
    Ke = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    print(len(Coords))
    W_ip = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):  # now ready to integrate
            G_m = E.G_map()
            B, Jdet = G_m(x_ip[i], x_ip[j], Coords)
Esempio n. 17
0
def getInternalForces(Coord_mat_el,sigma):
    E = Element("Q4")
    weights = [1, 1]
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    fint_pre = np.zeros((1,8))
    count = 0
    for i in range(len(xIP)):
        for j in range(len(xIP)):
            gradN, detJ = E.G_map(xIP[i], xIP[j], Coord_mat_el)
            B = get_B_plane_stress(gradN)
            fint_pre += np.dot(np.transpose(B),sigma[:,count]) * detJ * weights[i] * weights[j]
            count += 1

    return np.transpose(fint_pre)
Esempio n. 18
0
 def update(self):
     if self.element or self.old_element:
         if (not self.old_element) or (not self.element) or \
         (self.element != self.old_element):
             self.refresh()
         if self.element:
             self.element.update()
             self.rect = self.element.rect
             for dirty_rect in self.element.dirty_list:
                 self.dirty_list.append(dirty_rect)
             self.element.dirty_list = []
         self.old_element = self.element
     Element.update(self)
     return
Esempio n. 19
0
def F_GRAV(trac):
    f_grav = np.zeros((8, 1))
    E = Element("Q4")

    weights = [1, 1]
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    for k in range(len(xIP)):
        s = xIP[k]
        N = E.N(s, s)
        J_s = np.matrix(detJsideQ4(s, s))
        n_mat = np.matrix(N.transpose())
        trac_mat = np.matrix(trac)
        f_grav += n_mat * trac_mat * J_s[0, k] * weights[k]
    return f_grav
Esempio n. 20
0
 def update(self):
     if self.old_bold != self.bold or self.old_italic != self.italic or \
        self.old_font_size != self.font_size or self.old_font_type != self.font_type:
         self.reset_font()
     elif self.old_text is None or self.old_text != self.text or \
          self.old_font_colour != self.font_colour:
         self.refresh()
     self.old_text = self.text
     self.old_bold = self.bold
     self.old_italic = self.italic
     self.old_font_colour = self.font_colour
     self.old_font_size = self.font_size
     self.old_font_type = self.font_type
     Element.update(self)
     return
Esempio n. 21
0
 def __init__(self, driver):
     self.top_item = ElementsList(driver, 'a.nav-menu-item__level-1')
     self.sub_item = ElementsList(driver,
                                  '.navigation-nav__subMenuOverLink')
     self.head_title_item = Element(driver, '.navigation-nav__HeadTitle')
     self.tabs = ElementsList(
         driver,
         '[data-component="SBIS3.CONTROLS.TabButtons"] .controls-TabButton')
     self.controls = ElementsList(driver,
                                  '[data-component^="SBIS3.CONTROLS"]')
     self.input_controls = ElementsList(
         driver, '[data-component^="SBIS3.CONTROLS"] input')
     self.error_txt = Element(driver, '.ws-smp-header')
     self.error_2_txt = Element(driver, '.controls-SubmitPopup__message')
     self.error_3_txt = Element(driver, '.error-page')
Esempio n. 22
0
 def elements(self):
     """ Return the list of valid elementsfor the current report suite """
     if self.account.cache:
         data = self.request_cached('Report', 'GetElements')
     else:
         data = self.request('Report', 'GetElements')
     return Element.list('elements', data, self, 'name', 'id')
Esempio n. 23
0
def Dif_basic_K(Coords, k=1):  #let k be an optional arguement
    E = Element("Q4")

    Ke = np.zeros((len(Coords), len(Coords)))

    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]

    W_ip = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):  # now ready to integrate
            G_m = E.G_map()
            B, Jdet = G_m(x_ip[i], x_ip[j], Coords)
            B_T = np.transpose(B)
            Ke = Ke + B_T.dot(B) * k * Jdet * W_ip[i] * W_ip[j]

    return Ke
Esempio n. 24
0
def getMassMatrix(C):
    E = Element("Q4")
    weights = [1, 1]
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    Me = np.zeros((8, 8))
    me(xIP, C, Me, E)
    return Me
Esempio n. 25
0
 def elements(self):
     """ Return the list of valid elementsfor the current report suite """
     if self.account.cache:
         data = self.request_cached('Report', 'GetElements')
     else:
         data = self.request('Report', 'GetElements')
     return Element.list('elements', data, self, 'name', 'id')
Esempio n. 26
0
def getStiffnessmatrix(C, D, thickness, el_epsilon, pt):
    E = Element("Q4")
    weights = [1, 1]
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    Ke = np.zeros((8, 8))
    ke(xIP, C, D, el_epsilon, pt, weights, thickness, E, Ke)
    return Ke
Esempio n. 27
0
    def mouseRelease(self, actor, event):
        if self.itemDragging:
            element = Element(type(self.pendingActor))

            # Copy pendingActor's properties to the element
            element.loadProperties(self.pendingActor)

            self.model.addElement(element, self.elements.keys()[self.elements.values().index(self.parentActor)])
            # Override and set the currently created actor as the proxy
            self.elements[element] = self.pendingActor
        elif self.selectionBox:
            # Process selection
            selectionBox = self.selectionBox
            self.selectionBox.fadeOut(lambda x: 
                                      self.overlayLayer.remove_child(selectionBox))
        self.resetDrag()
Esempio n. 28
0
def getStrainElement(Coord_mat_el, d):
    E = Element("Q4")
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    epsilon = np.zeros((3, 4))
    count = 0
    for i in range(len(xIP)):
        for j in range(len(xIP)):
            gradN, detJ = E.G_map(xIP[i], xIP[j], Coord_mat_el)
            B = get_B_plane_stress(gradN)
            val = np.dot(B, d)
            for k in range(3):
                epsilon[k, count] = val[k]

            count += 1

    return epsilon
Esempio n. 29
0
def getdkdumatrix(C, D_prime, thickness, el_sigma):
    E = Element("Q4")
    weights = [1, 1]
    xIP = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    Ke = np.zeros((8, 8))
    ke_prime(xIP, C, D_prime, el_sigma, weights, thickness, E, Ke)

    return Ke
Esempio n. 30
0
 def __init__(self, font_type="Monospace", font_colour=BLACK, text="", \
              font_size = 20, bold=False, italic=False, **kwargs):
     Element.__init__(self, **kwargs)
     self.font_type = font_type
     self.old_font_type = font_type
     self.font_colour = font_colour
     self.old_font_colour = font_colour
     self.text = text
     self.old_text = None
     self.bold = bold
     self.old_bold = bold
     self.italic = italic
     self.old_italic = italic
     self.font_size = font_size
     self.old_font_size = font_size
     self.font = load_system_font(font_type, self.font_size, bold, italic)
     return
Esempio n. 31
0
def MatrixT(Coords, Coefficients, Upwinded):
    E = Element('S2')
    Ke = np.zeros((2, 2))
    #x_ip = [-np.sqrt(3)/3,np.sqrt(3)/3]
    #weights = [1,1]
    x_ip = [0]
    weights = [2]
    h = (Coords[1][0] - Coords[0][0])
    Jdet = h / 2
    a = Coefficients[0]
    for i in range(len(x_ip)):
        N = E.N(x_ip[i])
        N_T = N.transpose()
        B = E.G(x_ip[i], Coords)
        B_T = B.transpose()
        Ke += a * N_T * B * Jdet * weights[i] + (
            h / 2) * a * B_T * B * Jdet * weights[i]
    return Ke
Esempio n. 32
0
def Dif_basic_F(el_type, S, Coords, P_type='scalar'):
    El = Element('Q4')
    if el_type == 'Q4':
        num_nodes = 4
    elif el_type == 'Q8':
        num_nodes = 8
    else:
        print('Please enter a valid element type')
    G = El.G()  # snag B-matrix for element
    if (P_type == 'scalar'
        ):  # calculates B function based on scalar or vector problem!
        B = G
    elif (P_type == 'vector'):
        B = np.zeros((3, 8))
        for i in range(2 * num_nodes):
            B[0, 2 * i] = G[0, i]
            B[1, 2 * i - 1] = G[1, i]
            B[2, 2 * i] = G[0, i]
            B[2, 2 * i - 1] = G[1, i]
    else:
        print('Please enter valid problem type')
    F = np.zeros(len(Coords))
    N = El.N()  # snag B-matrix for element
    J = lambda x, y: np.dot(G(x, y), Coords)
    J_d = lambda x, y: np.linalg.det(J(x, y))

    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    w_ip = [1, 1]
    for i in range(len(x_ip)):
        N_val = N(x_ip[i], x_ip[i])
        J_d_val = J_d(x_ip[i], x_ip[i])
        S_val = S(x_ip[i], x_ip[i])
        F = F + np.dot(np.transpose(N_val), S_val * J_d_val * w_ip[i])

    #reference file
    file = open('../outputs/f_elemental.txt', 'w')
    for i in range(4):
        if i != 0:
            file.write('\n')
        file.write(str(F[0, i]))
        file.write(" ")
    file.close()
    return F
Esempio n. 33
0
def MatrixT2D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Te = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            N = E.N(x_ip[i], x_ip[j], 0)
            N_T = N.transpose()
            B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], 0, Coords)
            B_T = B.transpose()
            Te += N_T * np.dot(n, B) * Jdet * weights[i] * weights[j]
            if Upwinded == True:
                x_coord = np.array([Coords[:, 0]]) @ N.transpose()
                y_coord = np.array([Coords[:, 1]]) @ N.transpose()
                delta = CalcDelta2D(Coefficients, [x_coord, y_coord], n)
                Te += delta * np.dot(B_T, n.transpose()) * np.dot(
                    n, B) * Jdet * weights[i] * weights[j]
    return Te
Esempio n. 34
0
class ProductPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.add_to_cart_button = Element(By.NAME, 'add_cart', context)

        self.pdp_title = Element(
            By.XPATH, '//h3[contains(@class, "pdp__title")]/parent::div',
            context)

    def add_product_to_cart(self):
        self.add_to_cart_button.click()

    def check_if_pdp_title_contains_text(self, text):
        self.pdp_title.is_element_visible()
        title = self.pdp_title.text()

        if text not in title:
            raise Exception(
                f'PDP title: {title} does not contain text: {text}')
Esempio n. 35
0
def VectorF(Coords, Coefficients, sourceFunc, Upwinded):
    E = Element("S2")
    #x_ip = [-np.sqrt(3)/3,np.sqrt(3)/3]
    #weights = [1,1]
    x_ip = [0]
    weights = [2]
    f_ele = np.zeros((2, 1))
    h = (Coords[1][0] - Coords[0][0])
    Jdet = h / 2
    a = Coefficients[0]
    for i in range(len(x_ip)):
        N = E.N(x_ip[i])
        N_T = N.transpose()
        B = E.G(x_ip[i], Coords)
        B_T = B.transpose()
        x_coord = np.dot(np.array([Coords[:, 0]]), N.transpose())
        source = SourceTerm(Coords, Coefficients, sourceFunc)
        f_ele += N_T * source * Jdet * weights[
            i]  #+ (h/2)* a * B_T *source * Jdet * weights[i]
    return f_ele
Esempio n. 36
0
    def __init__(self, context):
        self.context = context

        # MENU OPTIONS
        self.login_button = Element(
            By.XPATH, '//div[contains(@class, "header-menu__logged-out")]',
            context)

        self.cart_icon = Element(
            By.XPATH, '//div[contains(@class,"js-cart-menu-container")]',
            context)

        self.go_to_checkout_button = Element(
            By.XPATH, '//a[contains(text(),"Go to Checkout")]', context)

        self.cookie_button = Element(By.XPATH,
                                     '//input[@value="Agree and Proceed"]',
                                     context)

        self.country_modal_accept_button = Element(
            By.XPATH, '//a[contains(text(),"I understand")]', context)
Esempio n. 37
0
def MatrixK2D(Coords, n, Coefficients, el_type, Upwinded):
    E = Element(el_type)
    Ke = np.zeros((len(Coords), len(Coords)))
    x_ip = [-np.sqrt(3) / 3, np.sqrt(3) / 3]
    weights = [1, 1]
    for i in range(len(x_ip)):
        for j in range(len(x_ip)):
            N = E.N(x_ip[i], x_ip[j], 0)
            N_T = N.transpose()
            B, Jdet, G, J_inv = E.G_ext(x_ip[i], x_ip[j], 0, Coords)
            B_T = B.transpose()
            x_coord = np.array([Coords[:, 0]]) @ N_T
            y_coord = np.array([Coords[:, 1]]) @ N_T
            kappa_and_sigma = (Coefficients[0](x_coord, y_coord) +
                               Coefficients[3](x_coord, y_coord))
            Ke += N_T * (kappa_and_sigma) * N * Jdet * weights[i] * weights[j]
            if Upwinded == True:
                delta = CalcDelta2D(Coefficients, [x_coord, y_coord], n)
                Ke += delta * np.dot(B_T, n.transpose(
                )) * kappa_and_sigma * N * Jdet * weights[i] * weights[j]
    return Ke
Esempio n. 38
0
class BasePage:
    URL = ""

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

        # MENU OPTIONS
        self.login_button = Element(
            By.XPATH, '//div[contains(@class, "header-menu__logged-out")]',
            context)

        self.cart_icon = Element(
            By.XPATH, '//div[contains(@class,"js-cart-menu-container")]',
            context)

        self.go_to_checkout_button = Element(
            By.XPATH, '//a[contains(text(),"Go to Checkout")]', context)

        self.cookie_button = Element(By.XPATH,
                                     '//input[@value="Agree and Proceed"]',
                                     context)

        self.country_modal_accept_button = Element(
            By.XPATH, '//a[contains(text(),"I understand")]', context)

    def open(self):
        self.context.browser.get(self.context.base_e2e_url + self.URL)

    def click_login_button(self):
        self.login_button.click()

    def accept_cookie(self):
        self.cookie_button.click()

    def accept_country_modal(self):
        self.country_modal_accept_button.click()

    def go_to_checkout(self):
        self.cart_icon.mouse_hoover()
        self.go_to_checkout_button.click()
Esempio n. 39
0
class CartPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.delete_product_icon = Element(By.ID, 'id_form-0-DELETE', context)

        self.confirm_deleting_product_button = Element(
            By.XPATH, '//button[contains(text(), "Confirm")]', context)
        self.cart_content = Element(By.XPATH,
                                    '//div[@class="checkout__main-content"]',
                                    context)

        self.empty_cart_message = Element(
            By.XPATH,
            '//p[contains(@class, "checkout-container__headline-empty")]',
            context)

        self.empty_cart_message_text = 'Your cart is empty'

    def click_delete_product_icon(self):
        self.delete_product_icon.click()

    def remove_products_from_cart(self):
        self.click_delete_product_icon()
        self.confirm_deleting_product_button.click()

    def check_if_cart_is_not_empty(self):
        self.cart_content.is_element_visible()
        assert_that(self.cart_content.is_element_visible(), equal_to(True),
                    'Cart is empty!')

    def check_empty_cart_message(self):
        self.empty_cart_message.is_element_visible()
        message = self.empty_cart_message.text()
        assert_that(
            message, equal_to(self.empty_cart_message_text),
            f'Message text {message} is not equal to expected text: {self.empty_cart_message_text}'
        )
Esempio n. 40
0
    def __init__(self, context):
        super().__init__(context)

        self.delete_product_icon = Element(By.ID, 'id_form-0-DELETE', context)

        self.confirm_deleting_product_button = Element(
            By.XPATH, '//button[contains(text(), "Confirm")]', context)
        self.cart_content = Element(By.XPATH,
                                    '//div[@class="checkout__main-content"]',
                                    context)

        self.empty_cart_message = Element(
            By.XPATH,
            '//p[contains(@class, "checkout-container__headline-empty")]',
            context)

        self.empty_cart_message_text = 'Your cart is empty'
Esempio n. 41
0
    def __init__(self, context):
        super().__init__(context)

        self.email_field = Element(
            By.NAME, 'username', context
        )

        self.password_field = Element(
            By.NAME, 'password', context
        )

        self.next_button = Element(
            By.ID, 'idp-discovery-submit', context
        )

        self.login_button = Element(
            By.ID, 'okta-signin-submit', context
        )
Esempio n. 42
0
 def update(self):
     Element.update(self)
     self.started = self.is_started()
     self.finished = self.is_finished()
     return
Esempio n. 43
0
 def draw(self, screen):
     Element.draw(self, screen)
     location = (self.rect.x, self.rect.y)
     self.font.render_to(screen, location, self.text, self.font_colour)
     return
Esempio n. 44
0
 def elements(self):
     data = self.request('ReportSuite', 'GetAvailableElements')[0]['available_elements']
     return Element.list('elements', data, self, 'display_name', 'element_name')
Esempio n. 45
0
 def __init__(self, points=[], colour=BLACK, **kwargs):
     Element.__init__(self, **kwargs)
     self.points = points
     self.colour = colour
     return
Esempio n. 46
0
 def _render(self):
     self.element = Element(self.haml, self.attr_wrapper)
     self.django_variable = self.element.django_variable
     self.before = self._render_before(self.element)
     self.after = self._render_after(self.element)
     self._render_children()
Esempio n. 47
0
class ElementNode(HamlNode):
    '''Node which represents a HTML tag'''
    def __init__(self, haml):
        HamlNode.__init__(self, haml)
        self.django_variable = False

    def _render(self):
        self.element = Element(self.haml, self.attr_wrapper)
        self.django_variable = self.element.django_variable
        self.before = self._render_before(self.element)
        self.after = self._render_after(self.element)
        self._render_children()

    def _render_before(self, element):
        '''Render opening tag and inline content'''
        start = ["%s<%s" % (self.spaces, element.tag)]
        if element.id:
            start.append(" id=%s" % self.element.attr_wrap(self.replace_inline_variables(element.id)))
        if element.classes:
            start.append(" class=%s" % self.element.attr_wrap(self.replace_inline_variables(element.classes)))
        if element.attributes:
            start.append(' ' + self.replace_inline_variables(element.attributes))

        content = self._render_inline_content(self.element.inline_content)

        if element.nuke_inner_whitespace and content:
            content = content.strip()

        if element.self_close and not content:
            start.append(" />")
        elif content:
            start.append(">%s" % (content))
        elif self.children:
            start.append(">%s" % (self.render_newlines()))
        else:
            start.append(">")
        return ''.join(start)

    def _render_after(self, element):
        '''Render closing tag'''
        if element.inline_content:
            return "</%s>%s" % (element.tag, self.render_newlines())
        elif element.self_close:
            return self.render_newlines()
        elif self.children:
            return "%s</%s>\n" % (self.spaces, element.tag)
        else:
            return "</%s>\n" % (element.tag)

    def _post_render(self):
        # Inner whitespace removal
        if self.element.nuke_inner_whitespace:
            self.before = self.before.rstrip()
            self.after = self.after.lstrip()

            if self.children:
                node = self
                # If node renders nothing, do removal on its first child instead
                if node.children[0].empty_node == True:
                    node = node.children[0]
                if node.children:
                    node.children[0].before = node.children[0].before.lstrip()

                node = self
                if node.children[-1].empty_node == True:
                    node = node.children[-1]
                if node.children:
                    node.children[-1].after = node.children[-1].after.rstrip()

        # Outer whitespace removal
        if self.element.nuke_outer_whitespace:
            left_sibling = self.left_sibling()
            if left_sibling:
                # If node has left sibling, strip whitespace after left sibling
                left_sibling.after = left_sibling.after.rstrip()
                left_sibling.newlines = 0
            else:
                # If not, whitespace comes from it's parent node,
                # so strip whitespace before the node
                self.parent.before = self.parent.before.rstrip()
                self.parent.newlines = 0

            self.before = self.before.lstrip()
            self.after = self.after.rstrip()

            right_sibling = self.right_sibling()
            if right_sibling:
                right_sibling.before = right_sibling.before.lstrip()
            else:
                self.parent.after = self.parent.after.lstrip()
                self.parent.newlines = 0

        super(ElementNode, self)._post_render()

    def _render_inline_content(self, inline_content):
        if inline_content == None or len(inline_content) == 0:
            return None

        if self.django_variable:
            content = "{{ " + inline_content.strip() + " }}"
            return content
        else:
            return self.replace_inline_variables(inline_content)
Esempio n. 48
0
 def __init__(self, image_name="", **kwargs):
     Element.__init__(self, **kwargs)
     self.image_name = image_name
     self.old_image_name = None
     self.image = None
     return
Esempio n. 49
0
 def __init__(self, **kwargs):
     Element.__init__(self, **kwargs)
     self.started = False
     self.finished = False
     return
Esempio n. 50
0
 def __init__(self, element=None, **kwargs):
     Element.__init__(self, **kwargs)
     self.element = element
     self.old_element = None
     return
Esempio n. 51
0
 def elements(self):
     """ Return the list of valid elementsfor the current report suite """
     data = self.request('Report', 'GetElements')
     return Element.list('elements', data, self, 'name', 'id')
Esempio n. 52
0
 def draw(self, screen):
     Element.draw(self, screen)
     if self.element:
         self.element.draw(screen)
     return
Esempio n. 53
0
 def __init__(self, datas=None):
     super(List, self).__init__()
     UserList.__init__(self)
     Element.__init__(self)
     self.data = isinstance(datas, list) and datas or []
     self._text = None
Esempio n. 54
0
 def __init__(self, colour=BLACK, thickness=0, **kwargs):
     Element.__init__(self, **kwargs)
     self.colour = colour
     self.thickness = thickness
     return