def create_cp_factory():
    # begin
    from oricreate.api import CreasePatternState, CustomCPFactory

    x = np.array([[0, 0, 0],
                  [1, 0, 0],
                  [1, 1, 0],
                  [2, 1, 0]
                  ], dtype='float_')

    L = np.array([[0, 1], [1, 2], [2, 0],
                  [1, 3], [2, 3]],
                 dtype='int_')

    F = np.array([[0, 1, 2],
                  [1, 3, 2],
                  ], dtype='int_')

    cp = CreasePatternState(X=x,
                            L=L,
                            F=F
                            )

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory
def create_hu():
    cp = CreasePatternState(X=[
        [0, 0.5, 0],
        [1, 0, 0],
        [1, 1, 0],
        [2, 0.5, 0],
    ],
                            L=[[0, 1], [1, 2], [2, 0], [1, 3], [2, 3]],
                            F=[[0, 1, 2], [1, 3, 2]])

    cp_factory = CustomCPFactory(formed_object=cp)

    # begin
    from oricreate.fu import FuTargetPsiValue
    # Link the crease factory it with the constraint client
    fu_target_psi_value = \
        FuTargetPsiValue(forming_task=cp_factory,
                         psi_value=(1, lambda t: -0.5 * t)
                         )
    cp = cp_factory.formed_object
    print(cp.iL)
    print(cp.iL_psi)
    print('fu:', fu_target_psi_value.get_f(1.0))
    print('f_du:\n', fu_target_psi_value.get_f_du(1.0))
    # end
    return fu_target_psi_value
def create_cp_factory():
    cp = CreasePatternState(X=[[0, 0, z_e], [1, 0, 0], [1, 1, 0], [2, 1, z_e]],
                            L=[[0, 1], [1, 2], [2, 0], [1, 3], [3, 2]],
                            F=[[0, 1, 2], [1, 3, 2]])

    cp_factory = CustomCPFactory(formed_object=cp)
    return cp_factory
def create_hu():
    cp = CreasePatternState(X=[
        [0, 0.5, -0.5],
        [1, 0, 0],
        [1, 1, 0],
        [2, 0.5, -0.5],
    ],
                            L=[[0, 1], [1, 2], [2, 0], [1, 3], [2, 3]],
                            F=[[0, 1, 2], [1, 3, 2]])

    cp_factory = CustomCPFactory(formed_object=cp)

    # begin
    from oricreate.hu import HuPsiConstraints
    # Link the crease factory it with the constraint client
    hu_psi_constraints = \
        HuPsiConstraints(forming_task=cp_factory,
                         psi_constraints=[(1, False), ]
                         )
    cp = cp_factory.formed_object
    print(cp.iL)
    print(cp.iL_psi)
    print('gu:', hu_psi_constraints.get_H(1.0))
    print('g_du:\n', hu_psi_constraints.get_H_du(1.0))
    # end
    return hu_psi_constraints
def create_gu():
    cp = CreasePatternState(X=[[0, 0.5, -0.5],
                               [1, 0, 0],
                               [1, 1, 0],
                               [2, 0.5, -0.5],
                               ],
                            L=[[0, 1], [1, 2], [2, 0], [1, 3],
                               [2, 3]],
                            F=[[0, 1, 2], [1, 3, 2]]
                            )

    cp_factory = CustomCPFactory(formed_object=cp)

    # begin
    from oricreate.gu import GuPsiConstraints
    # Link the crease factory it with the constraint client
    gu_dof_constraints = \
        GuPsiConstraints(forming_task=cp_factory,
                         psi_constraints=[([(0, 1.0)], 0),
                                          ])
    cp = cp_factory.formed_object
    print(cp.iL)
    print(cp.iL_psi)
    print('gu:', gu_dof_constraints.get_G(1.0))
    print('g_du:\n', gu_dof_constraints.get_G_du(1.0))
    # end
    return gu_dof_constraints
Exemple #6
0
def create_cp_factory():
    # begin
    from oricreate.api import CreasePatternState, CustomCPFactory

    x = np.array([
        [-1, 0, 0],
        [0, 0, 0],
        [1, 1, 0],
        [2, 0, 0],
        [1, -1, 0],
        [-1, 1, 0],
        [-1, -1, 0],
        [2, 1, 0],
        [2, -1, 0],
    ],
                 dtype='float_')

    L = np.array(
        [
            [0, 1],
            [1, 2],
            [2, 0],
            [1, 3],
            [1, 7],
            [1, 4],
            [3, 4],
            #[1, 5],
            [6, 1],
            [0, 5],
            [2, 5],
            [0, 6],
            [4, 6],
            [3, 7],
            [2, 7],
            [3, 8],
            [4, 8]
        ],
        dtype='int_')

    F = np.array([
        [0, 1, 2],
        [1, 7, 2],
        [1, 4, 3],
        [1, 4, 6],
        [0, 2, 5],
        [0, 1, 6],
        [3, 1, 7],
        [3, 4, 8],
    ],
                 dtype='int_')

    cp = CreasePatternState(X=x, L=L, F=F)

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory
def create_cp_factory():
    # begin
    from oricreate.api import CreasePatternState, CustomCPFactory

    cp = CreasePatternState(X=[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0],
                               [0.5, 0.5, 0]],
                            L=[[0, 1], [1, 2], [2, 3], [3, 0], [0, 4], [1, 4],
                               [2, 4], [3, 4]],
                            F=[[0, 1, 4], [1, 2, 4], [4, 3, 2], [4, 3, 0]])

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory
Exemple #8
0
def create_cp_factory(R, H):
    # begin
    from oricreate.api import CreasePatternState, CustomCPFactory

    h2 = H / 2.0
    c60 = math.cos(math.pi / 3.0) * R
    s60 = math.sin(math.pi / 3.0) * R

    x = np.array([
        [R, 0, h2],
        [c60, s60, 0],
        [-c60, s60, h2],
        [-R, 0, 0],
        [-c60, -s60, h2],
        [c60, -s60, 0],
        [R, 0, -h2],
        [-c60, s60, -h2],
        [-c60, -s60, -h2],
        [0.0 * math.cos(math.pi / 3), -0.0 * math.sin(math.pi / 3), 0],
        [0.0 * math.cos(math.pi / 3), 0.0 * math.sin(math.pi / 3), 0],
        [-0.0, 0, 0],
    ],
                 dtype='float_')

    L = np.array(
        [[0, 6], [2, 7], [4, 8], [0, 5], [0, 9], [0, 10], [0, 1], [6, 5],
         [6, 9], [6, 10], [6, 1], [2, 1], [2, 10], [2, 11], [2, 3], [7, 1],
         [7, 10], [7, 11], [7, 3], [4, 3], [4, 11], [4, 9], [4, 5], [8, 3],
         [8, 11], [8, 9], [8, 5], [5, 9], [1, 10], [3, 11]],
        dtype='int_')

    F = np.array(
        [[0, 6, 1], [0, 1, 10], [0, 10, 6], [6, 1, 10], [2, 10, 1], [2, 1, 7],
         [2, 7, 10], [7, 10, 1], [2, 3, 11], [2, 11, 7], [2, 7, 3], [7, 3, 11],
         [4, 11, 3], [4, 3, 8], [4, 8, 11], [8, 11, 3], [4, 5, 9], [4, 9, 8],
         [4, 8, 5], [8, 5, 9], [0, 9, 5], [0, 5, 6], [0, 6, 9], [6, 9, 5]],
        dtype='int_')

    cp = CreasePatternState(X=x, L=L, F=F)

    #     cp.u[(9, 10, 11), 2] = -0.01
    #     cp.u[(5, 1, 3), 2] = 0.01
    #     cp.u[0, 0] = -0.01
    #     cp.u[3, 0] = -0.005
    #     cp.u[3, 1] = -0.005
    #     cp.u[5, 0] = 0.005
    #     cp.u[5, 1] = 0.005

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory
Exemple #9
0
def create_sim_step():
    from oricreate.api import CreasePatternState, CustomCPFactory

    cp = CreasePatternState(X=[
        [0, 0, 0],
        [1, 0, 0],
        [0.5, 0.5, 0],
    ],
                            L=[
                                [0, 1],
                                [1, 2],
                                [2, 0],
                            ],
                            F=[[0, 1, 2]])

    cp_factory = CustomCPFactory(formed_object=cp)

    # begin
    from oricreate.fu import FuTargetFaces, FuTF
    from oricreate.gu import GuConstantLength
    from oricreate.api import r_, s_, t_
    # Link the pattern factory with the goal function client.
    do_something = FormingTask(previous_task=cp_factory)
    # configure the forming task so that it uses
    # the rigid folding kinematics optimization framework RFKOF
    target_face = FuTF([r_, s_, t_], [0, 1, 2])
    fu_target_faces = FuTargetFaces(tf_lst=[target_face])

    # Link the crease factory it with the constraint client
    gu_constant_length = GuConstantLength()

    sim_config = SimulationConfig(fu=fu_target_faces,
                                  gu={'cl': gu_constant_length},
                                  acc=1e-6)
    sim_step = SimulationStep(forming_task=do_something, config=sim_config)
    sim_step.t = 0.4
    print('goal function for t = 0.4:', sim_step.get_f())
    sim_step.t = 0.8
    print('goal function for t = 0.8:', sim_step.get_f())
    print('goal function derivatives')
    print(sim_step.get_f_du())
    print('constraints')
    print(sim_step.get_G())
    print('constraint derivatives')
    print(sim_step.get_G_du())
    sim_step._solve_fmin()
    print('target position:\n', sim_step.cp_state.x)
    # end
    return sim_step
def create_cp_factory():
    cp = CreasePatternState(X=[
        [0, 0, 0],
        [1, 0, 0],
        [.5, .5, 0],
    ],
                            L=[
                                [0, 1],
                                [1, 2],
                                [2, 0],
                            ],
                            F=[
                                [0, 2, 1],
                            ])

    cp_factory = CustomCPFactory(formed_object=cp)
    return cp_factory
 def _get_upper_plate(self):
     f = self.factory_task
     N_h = f.N_h
     x_1 = self.fold_angle_cntl.x_1
     x_corners = x_1[N_h[(1, 1, -2, -2), (0, -1, 0, -1)]]
     x_corners[:, 2] += 0.008 + 0.4
     ft = CustomCPFactory(
         formed_object=CreasePatternState(
             X=x_corners,
             L=[[0, 1],
                [1, 2],
                [2, 0],
                [1, 2],
                 [2, 3],
                 [3, 1]],
             F=[[0, 1, 2],
                [1, 2, 3]]))
     return ft
def create_cp_factory():
    # begin
    import numpy as np
    from oricreate.api import CreasePatternState, CustomCPFactory

    x = np.array([
        [0, 0, 0],
        [1, 0, 0],
        [2, 0, 0],
        [0, 1, 0],
        [1, 1, 0],
        [2, 1, 0],
    ],
                 dtype='float_')

    L = np.array([[0, 1], [1, 2], [3, 4], [4, 5], [0, 3], [1, 4], [2, 5]],
                 dtype='int_')

    F = np.array([
        [0, 1, 4, 3],
        [1, 2, 5, 4],
    ], dtype='int_')

    x_mid = (x[F[:, 1]] + x[F[:, 3]]) / 2.0
    x_mid[:, 2] -= 1.0
    n_F = len(F)
    n_x = len(x)
    x_mid_i = np.arange(n_x, n_x + n_F)

    L_mid = np.array([[F[:, 0], x_mid_i[:]], [F[:, 1], x_mid_i[:]],
                      [F[:, 2], x_mid_i[:]], [F[:, 3], x_mid_i[:]]])
    L_mid = np.vstack([L_mid[0].T, L_mid[1].T, L_mid[2].T, L_mid[3].T])

    x_derived = np.vstack([x, x_mid])
    L_derived = np.vstack([L, F[:, (1, 3)], L_mid])
    F_derived = np.vstack([F[:, (0, 1, 2)], F[:, (0, 2, 3)]])

    cp = CreasePatternState(X=x_derived, L=L_derived, F=F_derived)

    cp.u[5, 2] = 0.01

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory
def create_cp_factory02(n=4):
    x, y = np.mgrid[0:n + 1, 0:2]
    z = np.zeros_like(x)
    X = np.c_[x.flatten(), y.flatten(), z.flatten()]
    N = np.arange((n) * 2).reshape(2, n)
    L1 = np.c_[N[0], N[1]]
    L2 = np.c_[N[0, :-1], N[0, 1:]]
    L3 = np.c_[N[1, :-1], N[1, 1:]]
    L4 = np.c_[N[0, :-1], N[1, 1:]]
    L = np.vstack([L1, L2, L3, L4])
    F1 = np.c_[N[0, :-1], N[1, 1:], N[1, :-1]]
    F2 = np.c_[N[0, :-1], N[0, :-1], N[1, 1:]]
    F = np.vstack([F1, F2])
    cp = CreasePatternState(X=X,
                            L=L,
                            F=F
                            )

    cp_factory = CustomCPFactory(formed_object=cp)
    return cp_factory
Exemple #14
0
 def _get_factory_task(self):
     h = 2.0
     v = 4.0
     X_base = [
         [0, 0, 0],
         [-h, 0, 0],
         [-h / 2.0, -v, 0],
         [h / 2.0, -v, 0],
         [h / 2.0, 0, 0],
         [h / 2.0, v, 0],
         [-h / 2.0, v, 0],
     ]
     X_add_left = [[-2 * h, 0, 0], [-3. / 2. * h, -v, 0],
                   [-3. / 2. * h, v, 0], [-5. / 2. * h, -v, 0],
                   [-5. / 2. * h, v, 0], [-5. / 2. * h, 0, 0]]
     L_base = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2],
               [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]
     L_add_left = [
         [1, 7],
         [1, 8],
         [1, 9],
         [7, 8],
         [7, 9],
         [2, 8],
         [6, 9],
         [7, 10],
         [7, 11],
         [8, 10],
         [9, 11],
         [7, 12],
         [10, 12],
         [11, 12],
     ]
     F_base = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6],
               [0, 6, 1]]
     F_add_left = [[1, 7, 8], [1, 7, 9], [1, 8, 2], [1, 9, 6], [7, 8, 10],
                   [7, 9, 11], [7, 12, 10], [7, 12, 11]]
     cp = CreasePatternState(X=X_base + X_add_left,
                             L=L_base + L_add_left,
                             F=F_base + F_add_left)
     return CustomCPFactory(formed_object=cp)
Exemple #15
0
    def _get_factory_task(self):

        l_length = self.L_green
        X = np.array([
            [0, 0],
            [l_length / 2.0, 0],
            [l_length, 0],
            [0, l_length / 2.0],
            [0, l_length],
            [-l_length / 2.0, 0],
            [-l_length, 0],
            [0, -l_length / 2.0],
            [0, -l_length],
            [l_length / 2, l_length / 2],
            [-l_length / 2, l_length / 2],
            [-l_length / 2, -l_length / 2],
            [l_length / 2, -l_length / 2],
        ],
                     dtype=np.float_)
        X = np.c_[X[:, 0], X[:, 1], X[:, 0] * 0]
        L = [[0, 1], [1, 2], [0, 3], [3, 4], [0, 5], [5, 6], [0, 7], [7, 8],
             [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2],
             [1, 9], [9, 3], [3, 10], [10, 5], [5, 11], [11, 7], [7, 12],
             [12, 1]]
        L = np.array(L, dtype=np.int_)

        F = [
            [0, 1, 3],
            [0, 3, 5],
            [0, 5, 7],
            [0, 7, 1],
            [1, 9, 3],
            [3, 10, 5],
            [5, 11, 7],
            [7, 12, 1],
            [2, 9, 1],
        ]

        F = np.array(F, dtype=np.int_)
        cp = CreasePatternState(X=X, L=L, F=F)
        return CustomCPFactory(formed_object=cp)
def create_sim_step():
    from oricreate.api import CreasePatternState, CustomCPFactory

    cp = CreasePatternState(X=[[0, 0, 0],
                               [1, 0, 0],
                               [0.5, 1, 0],
                               [1.5, 1, 0],
                               [2.0, 0.0, 0]
                               ],
                            L=[[0, 1],
                               [1, 2],
                               [2, 0],
                               [1, 3],
                               [2, 3],
                               [3, 4],
                               ],
                            F=[[0, 1, 2],
                               [1, 2, 3],
                               [1, 3, 4]]
                            )

    cp_factory = CustomCPFactory(formed_object=cp)

    # begin
    from oricreate.fu import FuTF
    from oricreate.api import r_, s_, t_
    target_face = FuTF([r_, s_, - 0.5 * (r_ - 1) * (r_ - 1) * t_ + 1.0],
                       [0, 1, 2, 3, 4])
    # fix all nodes in x and y direction - let the z direction free
    dof_constraints = \
        [([(i, 0, 1.0)], 0.0) for i in range(0, 5)] +\
        [([(i, 1, 1.0)], 0.0) for i in range(0, 5)]
    sim_step = MapToSurface(previous_task=cp_factory,
                            target_faces=[target_face],
                            dof_constraints=dof_constraints
                            )
    print('initial position\n', cp_factory.formed_object.x)
    print('target position:\n', sim_step.x_1)
    # end
    return sim_step
    def _get_interlock_plate(self):
        f = self.factory_task
        N_h, N_i = f.N_h, f.N_i
        x_1 = self.fold_angle_cntl.x_1

        N_h_F = N_h[::3, :]
        N_i_F = N_i[1::3, :]

        F_lower = np.array(
            [N_i_F, N_h_F[:-1, :-1], N_h_F[1:, :-1]], dtype=np.float_)
        F_upper = np.array(
            [N_i_F, N_h_F[:-1, 1:], N_h_F[1:, 1:]], dtype=np.float_)
        F_I = np.vstack([F_lower.reshape(3, -1).T,
                         F_upper.reshape(3, -1).T])
        L_F_I = F_I[:, [[0, 1], [1, 2], [2, 0]]]
        L_I = np.unique(L_F_I.reshape(-1, 2), axis=1)
        ft = CustomCPFactory(
            formed_object=CreasePatternState(
                X=x_1,
                L=L_I,
                F=F_I))
        return ft
 def _get_factory_task(self):
     h_long = 2.0
     h_short = 0.9
     v = 4.0
     X_base = [[0, 0, 0],
               [-h_short, 0, 0],
               [-h_long / 2.0, -v, 0],
               [h_long / 2.0, -v, 0],
               [h_short, 0, 0],
               [h_long / 2.0, v, 0],
               [-h_long / 2.0, v, 0],
               ]
     X_add_left = [
         [-h_long - h_short, 0, 0],
         [-h_short - h_long / 2.0, -v, 0],
         [-h_short - h_long / 2.0, v, 0],
         [-2 * h_short - h_long / 2.0, -v, 0],
         [-2 * h_short - h_long / 2.0, v, 0],
         [-2.0 * h_short - h_long, 0, 0],
         [-2 * h_short - 3. / 2. * h_long, -v, 0],
         [-2 * h_short - 3. / 2. * h_long, v, 0],
     ]
     L_base = [[0, 1],
               [0, 2],
               [0, 3],
               [0, 4],
               [0, 5],
               [0, 6],
               [1, 2],
               [2, 3],
               [3, 4],
               [4, 5],
               [5, 6],
               [6, 1]
               ]
     L_add_left = [[1, 7],
                   [1, 8],
                   [1, 9],
                   [7, 8],
                   [7, 9],
                   [2, 8],
                   [6, 9],
                   [7, 10],
                   [7, 11],
                   [8, 10],
                   [9, 11],
                   [10, 12],
                   [11, 12],
                   [7, 12],
                   [12, 13],
                   [12, 14],
                   [10, 13],
                   [11, 14]
                   ]
     F_base = [[0, 1, 2],
               [0, 2, 3],
               [0, 3, 4],
               [0, 4, 5],
               [0, 5, 6],
               [0, 6, 1]
               ]
     F_add_left = [[1, 7, 8],
                   [1, 7, 9],
                   [1, 8, 2],
                   [1, 9, 6],
                   [7, 8, 10],
                   [7, 9, 11],
                   [7, 12, 10],
                   [7, 12, 11],
                   [12, 13, 10],
                   [12, 14, 11]
                   ]
     cp = CreasePatternState(X=X_base + X_add_left,
                             L=L_base + L_add_left,
                             F=F_base + F_add_left)
     return CustomCPFactory(formed_object=cp)
def create_cp_factory(n=4, b=1):
    '''
    define quantity of facets
    number of facets=2n-1
    n = 4
    '''

    # create coordinates

    # number of coordinates
    num_coord = 2 * n + 1

    # create array
    X = np.zeros((num_coord, 3))

    X[n + 1:2 * n + 1, 1] = b

    i = 1

    while i <= n:
        X[i, 0] = i
        X[n + i, 0] = i
        i = i + 1

    print('X', X)

    # create lines

    # number of lines
    num_lines = 4 * n - 1

    # create array
    L = np.zeros((num_lines, 2))

    i = 0

    while i <= n - 1:
        j = 3 * i
        L[j, 0] = i
        L[j, 1] = i + 1
        i = i + 1

    i = 0

    while i + 1 <= n:
        j = 3 * i + 1
        L[j, 0] = i + 1
        L[j, 1] = i + n + 1
        i = i + 1

    i = 0

    while i + 2 <= n + 1:
        j = 3 * i + 2
        L[j, 0] = i + 1 + n
        L[j, 1] = i
        i = i + 1

    i = 0

    while i <= n - 2:
        j = i + n + 1
        L[3 * n + i, 0] = j
        k = i + n + 2
        L[3 * n + i, 1] = k
        i = i + 1

    print('L', L)

    # create facets

    # number of facets
    num_facet = 2 * n - 1

    # create array
    F = np.zeros((num_facet, 3))

    i = 0

    while i <= n - 1:
        F[i, 0] = i
        F[i, 1] = i + 1
        F[i, 2] = i + n + 1
        i = i + 1

    i = 1

    while i <= n - 1:
        F[n + i - 1, 0] = i
        F[n + i - 1, 1] = i + n + 1
        F[n + i - 1, 2] = i + n
        i = i + 1

    print('F', F)

    cp = CreasePatternState(X=X,
                            L=L,
                            F=F
                            )

    cp_factory = CustomCPFactory(formed_object=cp)
    return cp_factory
            G_du[l, j, :] += 2 * v_0 - 2 * u_i + 2 * u_j

        # reshape the 3D matrix to a 2D matrix
        # with rows for crease lines and columns representing
        # the derivatives with respect to the node displacements
        # in 3d.
        #
        G_du = G_du.reshape(cp.n_L, cp.n_N * cp.n_D)
        return G_du


if __name__ == '__main__':

    from oricreate.api import CreasePatternState, CustomCPFactory

    cp = CreasePatternState(X=[[-4, -5, -3],
                               [0, 0.0, 0],
                               [1.0, 0.1, 0],
                               ],
                            L=[[0, 1], [1, 2], [2, 0]],
                            )

    forming_task = CustomCPFactory(formed_object=cp)
    constant_length = GuConstantLength(forming_task)

    U = np.zeros_like(cp.X)
    U[2] += 1.0

    print([constant_length.get_G(U, 0)])
    print([constant_length.get_G_du(U, 0)])
    def _get_factory_task(self):

        X = np.array(
            [[0, 0], [3, 0], [-0.5, 1.936491673103709],
             [-3.5, 1.936491673103709], [-1.90625, -0.6051536478449089],
             [-1.7421875, -3.600664204677208], [0.1640625, -2.995510556832299],
             [-4, 3.872983346207417], [-1, 3.872983346207417],
             [1.625, 5.325352101035199], [-7, 3.872983346207417],
             [-6.5, 1.936491673103709], [-3.6484375, -4.205817852522117],
             [-3.8125, -1.210307295689817], [-1.578125, -6.596174761509507],
             [0.328125, -5.991021113664598], [-3.5, 5.809475019311126],
             [-5.40625, 6.414628667156034], [-1.4140625, -9.591685318341806],
             [0.4921875, -8.986531670496896],
             [-1.906250000000001, 8.351120340259744],
             [-4.906250000000001, 8.351120340259742]],
            dtype=np.float_)
        X = np.c_[X[:, 0], X[:, 1], X[:, 0] * 0]
        L = [
            [1, 2],  # ***
            [2, 3],
            [1, 3],
            [1, 4],  # ***
            [3, 4],
            [1, 5],  # ***
            [4, 5],
            [1, 6],  # ***
            [5, 6],
            [1, 7],
            [6, 7],
            [4, 8],
            [3, 8],
            [8, 9],
            [3, 9],
            [9, 10],
            [3, 10],
            [4, 11],
            [8, 11],
            [4, 12],
            [11, 12],
            [6, 13],
            [5, 13],
            [13, 14],
            [5, 14],
            [7, 15],
            [6, 15],
            [7, 16],
            [15, 16],
            [11, 17],
            [8, 17],
            [11, 18],
            [17, 18],
            [16, 19],
            [15, 19],
            [16, 20],
            [19, 20],
            [18, 21],
            [17, 21],
            [18, 22],
            [21, 22],
        ]
        L = np.array(L, dtype=np.int_) - 1

        F = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [2, 9, 8],
             [2, 8, 7], [2, 7, 3], [3, 7, 10], [3, 10, 11], [16, 10, 7],
             [16, 17, 10], [16, 20, 17], [17, 20, 21], [14, 6, 5], [14, 15, 6],
             [14, 18, 15], [15, 18, 19], [4, 13, 12], [4, 12, 5]]

        F = np.array(F, dtype=np.int_)
        cp = CreasePatternState(X=X, L=L, F=F)
        return CustomCPFactory(formed_object=cp)
Exemple #22
0
if __name__ == '__main__':
    from oricreate.api import \
        CreasePattern, CustomCPFactory, MapToSurface

    from oricreate.fu import \
        FuNodeDist

    import numpy as np

    cp = CreasePattern(X=[[0, 0, 0], [0.5, 0, 0], [10.0, 0, 0]],
                       L=[[0, 1], [1, 2], [2, 0]])
    cpf = CustomCPFactory(formed_object=cp)
    init = MapToSurface(previous_task=cpf)
    oc = FuNodeDist(forming_task=init, L=[[0, 1], [1, 2]])

    u = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]], dtype='f')
    print('f', oc.get_f(u))
    print('f_du', oc.get_f_du(u))
Exemple #23
0
 def _ftt_default(self):
     return FTT(root=CustomCPFactory())
Exemple #24
0
def create_cp_factory():
    # begin
    from oricreate.api import CreasePatternState, CustomCPFactory

    x = np.array([[0, 0, 0],
                  [2, 0, 0],
                  [3, 0, 0],
                  [4, 0, 0],
                  [0, 1, 0],
                  [2, 1, 0],
                  [0, 2, 0],
                  [1, 2, 0],
                  [3, 2, 0],
                  [4, 2, 0],
                  [2, 3, 0],
                  [4, 3, 0],
                  [0, 4, 0],
                  [1, 4, 0],
                  [2, 4, 0],
                  [4, 4, 0],
                  ], dtype='float_')

    L = np.array([[0, 1], [1, 2], [2, 3],
                  [4, 5],
                  [6, 7],
                  [8, 9],
                  [10, 11],
                  [12, 13], [13, 14],  [14, 15],
                  [4, 6],
                  [0, 4],
                  [6, 12],
                  [7, 13],
                  [1, 5],  [10, 14],
                  [2, 8],
                  [3, 9],
                  [9, 11],  [11, 15],
                  [7, 5],
                  [5, 8],
                  [8, 10], [10, 7]
                  ],
                 dtype='int_')

    F = np.array([[0, 1, 5, 4],
                  [1, 2, 8, 5],
                  [3, 9, 8, 2],
                  [9, 11, 10, 8],
                  [15, 14, 10, 11],
                  [14, 13, 7, 10],
                  [12, 6, 7, 13],
                  [6, 4, 5, 7],
                  [7, 5, 8, 10]
                  ], dtype='int_')

    L_range = np.arange(len(L))

    x_mid = (x[F[:, 1]] + x[F[:, 3]]) / 2.0
    x_mid[:, 2] -= 0.5
    n_F = len(F)
    n_x = len(x)
    x_mid_i = np.arange(n_x, n_x + n_F)

    L_mid = np.array([[F[:, 0], x_mid_i[:]],
                      [F[:, 1], x_mid_i[:]],
                      [F[:, 2], x_mid_i[:]],
                      [F[:, 3], x_mid_i[:]]])
    L_mid = np.vstack([L_mid[0].T, L_mid[1].T, L_mid[2].T, L_mid[3].T])

    x_derived = np.vstack([x, x_mid])
    L_derived = np.vstack([L, F[:-1, (1, 3)], L_mid])
    F_derived = np.vstack([F[:, (0, 1, 3)], F[:, (1, 2, 3)]])

    cp = CreasePatternState(X=x_derived,
                            L=L_derived,
                            F=F_derived
                            )

    print(cp.viz3d)
    cp.viz3d['cp'].L_selection = L_range

    cp.u[(2, 3, 8, 9), 2] = 0.01
    cp.u[(6, 7, 12, 13), 2] = -0.005
    cp.u[(10, 11, 14, 15), 2] = 0.005
    print('n_N', cp.n_N)
    print('n_L', cp.n_L)
    print('n_free', cp.n_dofs - cp.n_L)

    cp_factory = CustomCPFactory(formed_object=cp)
    # end
    return cp_factory, L_range
 def _get_factory_task(self):
     dx = self.L_blue
     dy = self.L_blue * np.sin(np.pi / 3)
     x1 = np.linspace(0, 4 * dx, 5)
     x2 = np.linspace(0, 5 * dx, 6)
     row0 = np.c_[dx + x1, np.zeros_like(x1), np.zeros_like(x1)]
     row1 = np.c_[-dx / 2 + x2, dy + np.zeros_like(x2), np.zeros_like(x2)]
     row2 = np.c_[x2, 2 * dy + np.zeros_like(x2), np.zeros_like(x2)]
     row3 = np.c_[-dx / 2 + x1, 3 * dy +
                  np.zeros_like(x1), np.zeros_like(x1)]
     X = np.vstack([row0, row1, row2, row3])
     L = [[0, 6],  # 0
          [2, 8],  # 1 ***
          [3, 9],
          [4, 10],
          [0, 7],
          [1, 8],  # 5
          [2, 9],
          [3, 10],  # 7 ***
          [1, 2],
          [3, 4],
          [6, 11],  # 10 ***
          [7, 12],  # 11 ***
          [8, 13],  # 12 ***
          [9, 14],  # 13 ***
          [10, 15],  # 14 ***
          [5, 11],  # 15
          [6, 12],  # 16 ***
          [7, 13],  # 17 ***
          [8, 14],  # 18 ***
          [9, 15],  # 19 ***
          [10, 16],  # 20
          [5, 6],
          [6, 7],  # 22 ***
          [7, 8],
          [8, 9],  # 24 ***
          [9, 10],  # 25 ***
          [11, 18],  # 26 ***
          [12, 19],
          [13, 20],
          [14, 21],
          [11, 17],  # 30
          [12, 18],  # 31
          [13, 19],  # 32 ***
          [15, 21],
          [11, 12],  # 34 ***
          [12, 13],  # 35 ***
          [13, 14],  # 36
          [14, 15],  # 37 ***
          [15, 16],  # 38
          [17, 18],
          [19, 20]  # 40
          ]
     F = [[0, 7, 6],
          [1, 2, 8],
          [2, 9, 8],
          [3, 10, 9],
          [3, 4, 10],
          [5, 6, 11],
          [6, 12, 11],
          [6, 7, 12],
          [7, 13, 12],
          [7, 8, 13],
          [8, 14, 13],
          [8, 9, 14],
          [9, 15, 14],
          [9, 10, 15],
          [10, 16, 15],
          [11, 18, 17],
          [11, 12, 18],
          [12, 13, 19],
          [13, 20, 19],
          [14, 15, 21]
          ]
     cp = CreasePatternState(X=X,
                             L=L,
                             F=F)
     return CustomCPFactory(formed_object=cp)
Exemple #26
0
        # imshow.module_manager.scalar_lut_manager.load_lut_from_list(lut)
        # print 'yyy'
        return image


if __name__ == '__main__':

    from oricreate.api import CreasePatternState, CustomCPFactory, FTV
    from oricreate.crease_pattern import \
        CreasePatternBasesViz3D

    cp = CreasePatternState(X=[[0, 0, 0], [2, 0, 0], [0, 1, 0]],
                            L=[[0, 1], [1, 2], [2, 0]],
                            F=[[0, 1, 2], ])

    cp_factory = CustomCPFactory(formed_object=cp)

    eftlogo_bases = CreasePatternBasesViz3D(
        label='EFT bases', vis3d=cp)

    efttitle_viz3d = FacetsWithImageViz3D(label='EFT title',
                                          F_ref=[0],
                                          N_ref=[0],
                                          F_covered=[[0, 0]],
                                          atimes=[0.0],
                                          im_files=['eft_01.png'],
                                          im_widths=[2],
                                          im_offsets=[[0, 0, 0.001]],
                                          vis3d=cp)

    print('x_refs', efttitle_viz3d.x_refs)