Aug-01-2019, 08:53 AM
Hi
I took the opportunity to build a more realistic model, and to validate it using a professional tool; I got the same results (see pictures).
Unfortunately I don't know how to share the files on the forum, especially the original meshes (send me a PM); I just can share the python file
hope it helps a bit
Paul
I took the opportunity to build a more realistic model, and to validate it using a professional tool; I got the same results (see pictures).
Unfortunately I don't know how to share the files on the forum, especially the original meshes (send me a PM); I just can share the python file
hope it helps a bit
Paul
import numpy as np; import os, time; import h5py; PATH = str(os.getcwd()); FileNameHDF5 = 'Distance_min.h5'; t0 = time.time(); with h5py.File(PATH + '/' + FileNameHDF5, 'r') as h5: data = h5.get('Saddle/Saddle_nodes'); Floor = np.array(data); del data; data = h5.get('Sphere/Sphere_nodes'); Ball = np.array(data); del data; ## get the number of rows/nodes per part n1 = np.shape(Floor)[0]; # for the floor n2 = np.shape(Ball)[0]; # for the ball index1 = np.arange(0,n1, dtype = np.int); index2 = np.arange(0,n2, dtype = np.int); # ball: the vect 1 is n1 blocs of n2 rows # vect 1 = [0 0 0 ... 0 0 0 1 1 1 1 ... 1 1 1 and son on], # floor; vect 2 is the blox of n2 nodes (floor) repeated n1 times # vect 1 and vect 2 are vectors of indexes of floor and ball respectively j1 = np.ones(n2, dtype = np.int); # warning: indexes must be integer j2 = np.ones(n1, dtype = np.int); # warning: indexes must be integer vect1 = np.kron(index1,j1); # vect 1 returns the index of the Floor rows vect2 = np.kron(j2,index2); # vect 2 returns the same for the Ball rows NumberOfRows = np.shape(vect1)[0]; k = np.arange(0,NumberOfRows, dtype = np.int); # k allows to # distance_vector = np.sqrt( (Ball[vect2[k], 1] - Floor[vect1[k], 1])**2 + (Ball[vect2[k], 2] - Floor[vect1[k], 2])**2 + (Ball[vect2[k], 3] - Floor[vect1[k], 3])**2 ) minimum_distance = np.min(distance_vector); del n1; del n2; del j1; del j2; del vect1; del vect2; t1 = time.time(); print("The minimum distance has been found to {}".format(minimum_distance)) print("the {} calculations took {} second".format(NumberOfRows,t1-t0));