-1

Coordinates of the hexagon [Hexagon](https://i.sstatic.net/tww83.png)

Now I want to add coordinates between these coordinates such that these 8 coordinates 27 coordinates as shownenter image description here an find the new coordinates too

I tried to make a code but not working much well xi = [-1.0, 0.0, 1.0] ele_arr is the coordinates given

cord1 = np.zeros([(N+1)*(N+1)*(NPZ+1),4],dtype = 'float64')

cord1[0,:] = ele_arr[-1,:]
cord1[N,:] = ele_arr[-2,:]
cord1[N*(N+1),:] = ele_arr[3,:]
cord1[((N+1)*(N+1))-1,:] = ele_arr[2,:]
cord1[-1,:] = ele_arr[0,:]
cord1[-1-(N),:] = ele_arr[1,:]
cord1[-1-(N*(N+1)),:] = ele_arr[-4,:]
cord1[-((N+1)*(N+1)),:] = ele_arr[-3,:]


for i in range(1,NPZ):
    gap = (N+1) * (N+1)
    cord1[i*gap,1:4] = np.array([cord1[0,1] + ((cord1[-((N+1)*(N+1)),1] - cord1[0,1]) * ((xi[i] - xi[0])/2)),
                                 cord1[0,2] + ((cord1[-((N+1)*(N+1)),2] - cord1[0,2]) * ((xi[i] - xi[0])/2)),
                                 cord1[0,3] + ((cord1[-((N+1)*(N+1)),3] - cord1[0,3]) * ((xi[i] - xi[0])/2))])

    cord1[i*gap + N,1:4] = np.array([cord1[N,1] + ((cord1[-1-(N*(N+1)),1] - cord1[N,1]) * ((xi[i] - xi[0])/2)),
                                     cord1[N,2] + ((cord1[-1-(N*(N+1)),2] - cord1[N,2]) * ((xi[i] - xi[0])/2)),
                                     cord1[N,3] + ((cord1[-1-(N*(N+1)),3] - cord1[N,3]) * ((xi[i] - xi[0])/2))])

    cord1[i*gap + N + (N+1)*N,1:4] = np.array([cord1[((N+1)*(N+1))-1,1] + ((cord1[-1,1] - cord1[((N+1)*(N+1))-1,1]) * ((xi[i] - xi[0])/2)),
                                           cord1[((N+1)*(N+1))-1,2] +  ((cord1[-1,2] - cord1[((N+1)*(N+1))-1,2]) * ((xi[i] - xi[0])/2)),
                                           cord1[((N+1)*(N+1))-1,3] + ((cord1[-1,3] - cord1[((N+1)*(N+1))-1,3]) * ((xi[i] - xi[0])/2))])

    cord1[i*gap + (N+1)*N,1:4] = np.array([ cord1[N*(N+1),1] + ((cord1[-1-N,1] - cord1[N*(N+1),1]) * ((xi[i] - xi[0])/2)),
                                               cord1[N*(N+1),2] + ((cord1[-1-N,2] - cord1[N*(N+1),2]) * ((xi[i] - xi[0])/2)),
                                               cord1[N*(N+1),3] + ((cord1[-1-N,3] - cord1[N*(N+1),3]) * ((xi[i] - xi[0])/2))])


for i in range(NPZ+1):
    for j in range(1,N):
        cord1[i*(N+1)*(N+1)+j,1:4] = [cord1[i*(N+1)*(N+1),1] + ((cord1[i*(N+1)*(N+1)+N,1] - cord1[i*(N+1)*(N+1),1]) * (((xi[j] - xi[0])/2))),
                                    cord1[i*(N+1)*(N+1),2] + ((cord1[i*(N+1)*(N+1)+N,2] - cord1[i*(N+1)*(N+1),2]) * (((xi[j] - xi[0])/2))),
                                    cord1[i*(N+1)*(N+1),3] + ((cord1[i*(N+1)*(N+1)+N,3] - cord1[i*(N+1)*(N+1),3]) * (((xi[j] - xi[0])/2)))]

        cord1[i*(N+1)*(N+1)+(N*(N+1))+j,1:4] = [cord1[i*(N+1)*(N+1)+(N*(N+1)),1] + ((cord1[i*(N+1)*(N+1)+(N*(N+1))+N,1] - cord1[i*(N+1)*(N+1)+(N*(N+1)),1]) * (((xi[j] - xi[0])/2))),
                                                cord1[i*(N+1)*(N+1)+(N*(N+1)),2] + ((cord1[i*(N+1)*(N+1)+(N*(N+1))+N,2] - cord1[i*(N+1)*(N+1)+(N*(N+1)),2]) * (((xi[j] - xi[0])/2))),
                                                cord1[i*(N+1)*(N+1)+(N*(N+1)),3] + ((cord1[i*(N+1)*(N+1)+(N*(N+1))+N,3] - cord1[i*(N+1)*(N+1)+(N*(N+1)),3]) * (((xi[j] - xi[0])/2)))]

for i in range(NPZ+1):
    for j in range(N+1):
        for k in range(1,N):
            cord1[(i*gap)+(k*(N+1))+j,1:4] = [cord1[(i*gap)+j,1] + ((cord1[(i*gap)+j+(N*(N+1)),1] - cord1[(i*gap)+j,1]) * (((xi[k] - xi[0])/2))),
                                              cord1[(i*gap)+j,2] + ((cord1[(i*gap)+j+(N*(N+1)),2] - cord1[(i*gap)+j,2]) * (((xi[k] - xi[0])/2))),
                                              cord1[(i*gap)+j,3] + ((cord1[(i*gap)+j+(N*(N+1)),3] - cord1[(i*gap)+j,3]) * (((xi[k] - xi[0])/2)))]
2
  • "I want to add coordinates between these coordinates such that these 8 coordinates 27 coordinates": what ??
    – user1196549
    Commented Nov 18, 2022 at 8:04
  • i want to add extra internal node at particular distances such that these 8 outer corner nodes remains the same. but extra internal nodes are created to make 27 nodes when 1 nodes in between is added at every edge and face. As shown in hyperlink above under "enter image description here" Commented Nov 18, 2022 at 14:38

1 Answer 1

0

Hard code it: let a, b, c, d, e, f, g, h be the eight points. Then add the averages of

(a, b), (b, c), (c, d), (d, a), (d, e), (e, f), (g, h), (h, d), (a, d), (b, e), (c, f), (d, h), (a, b, c, d), (a, d, b, e), (e, f, g, h), (b, e, c, f), (c, f, d, h), (d, h, a, d), (a, b, c, d, e, f, g).

2
  • can't use average as many times it is not even avg. Sometimes xi value is [-1.0, -0.447213595499957, 0.447213595499957, 1.0] In this case total nodes would be, (length of xi)^3 Commented Nov 18, 2022 at 14:38
  • @SAURABHAGARWAL; then your question is unintelligible.
    – user1196549
    Commented Nov 18, 2022 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.