Esempio n. 1
0
def triangle_cp_cnstr(n_steps = 10, dx = -1.99):

    cp = CreasePattern(n_steps = n_steps)

    cp.nodes = [[ 0, 0, 0 ],
                [ 1, 0, 0 ],
                [ 1, 1, 0]]

    cp.crease_lines = [[ 0, 1 ],
                       [ 1, 2 ],
                       [ 2, 0 ]]
    
    cp.facets = [[0, 1, 2 ]]

    cp.grab_pts = [[[0.667,0.333,0],0],
                   [[0.1,0.05,0],0]]
    
    
    cp.cnstr_lhs = [
                    [(0, 0, 1.0)],
                    [(0, 1, 1.0)],
                    [(0, 2, 1.0)],
                    [(1, 1, 1.0)],
                    [(1, 2, 1.0)],
                    [(2, 2, 1.0)],
                    ]

    cp.cnstr_rhs = [0.0, 0.0, 0.0, 0.0, 0.0, dx]

    X = np.zeros((cp.n_dofs,), dtype = float)
    X[1] = 0.01

    print 'L ', cp.grab_pts_L
    print 'initial lengths\n', cp.c_lengths
    print 'initial vectors\n', cp.c_vectors

    print 'initial R\n', cp.get_R(X)
    print 'initial dR\n', cp.get_dR(X)

    X = cp.solve(X)

    print '========== results =============='
    print 'solution X\n', X
    print 'final positions\n', cp.get_new_nodes(X)
    print 'final vectors\n', cp.get_new_vectors(X)
    print 'final lengths\n', cp.get_new_lengths(X)

    return cp
Esempio n. 2
0
 # little example with all visual elements
 # ToDo: suface missing
 cp = CreasePattern()
 
 cp.nodes = [[0, 0, 0],
         [1, 0, 0],
         [1, 1, 0],
         [0, 1, 0],
         [0.2, 0.2, 0],
         [0.5, 0.5, 0.0]]
 cp.crease_lines = [[0, 1],
         [1, 2],
         [2, 3],
         [3, 0],
         [1, 3]]
 cp.facets = [[0, 1, 3],
         [1, 2, 3]]
 cp.grab_pts = [[4, 0]]
 cp.line_pts = [[5, 4]]
 cp.cnstr_lhs = [[(1, 2, 1.0)],
                 [(0, 0, 1.0)],
                 [(0, 1, 1.0)],
                 [(0, 2, 1.0)],
                 [(3, 0, 1.0)],
                 [(3, 2, 1.0)],
                 [(2, 2, 1.0)],
                 [(5, 0, 1.0)]]
 cp.cnstr_rhs = np.zeros((len(cp.cnstr_lhs),), dtype = float)                    
 cp.cnstr_rhs[0] = 0.5
 cp.n_steps = 10
 u_0 = np.zeros((cp.n_n * cp.n_d,), dtype = float)
 u_0[5] = 0.05