edge_rest_lengths = np.diff(origcoords) deform_lengths = edge_rest_lengths.copy() min_point = (abs(mesh.maxCoord[axis]) - abs(mesh.minCoord[axis])) / 2.0 el_reduction = 0.6 dx = mesh.maxCoord[axis] - min_point deform_lengths = ( deform_lengths - ((1.0 - el_reduction) * deform_lengths[0]) + abs((origcoords[1:] - min_point)) * ((0.5 * deform_lengths[0]) / dx) ) # print(edge_rest_lengths.shape, deform_lengths.shape) sp.deform_1d(deform_lengths, mesh, axis="x", norm="Min", constraints=[]) # In[22]: axis = 1 orgs = np.linspace(mesh.minCoord[axis], mesh.maxCoord[axis], mesh.elementRes[axis] + 1) value_to_constrain = 1.0 yconst = [(sp.find_closest(orgs, value_to_constrain), np.array([value_to_constrain, 0]))] # In[23]:
# In[432]: #X-Axis mesh.reset() axis = 0 origcoords = np.linspace(mesh.minCoord[axis], mesh.maxCoord[axis], mesh.elementRes[axis] + 1) edge_rest_lengths = np.diff(origcoords) deform_lengths = edge_rest_lengths.copy() third = edge_rest_lengths.shape[0]/3 deform_lengths[third:2*third] *= refineby ##The matix can go singular when this is exactly 1. #print(edge_rest_lengths.shape, deform_lengths.shape) sp.deform_1d(deform_lengths, mesh,axis = 'x',norm = 'Min', constraints = []) # In[433]: #Y-Axis axis = 1 origcoords = np.linspace(mesh.minCoord[axis], mesh.maxCoord[axis], mesh.elementRes[axis] + 1) edge_rest_lengths = np.diff(origcoords) third = edge_rest_lengths.shape[0]/3 deform_lengths = np.copy(edge_rest_lengths) deform_lengths deform_lengths[2*third:] *= refineby ##The matix can go singular when this is exactly 1. sp.deform_1d(deform_lengths, mesh, axis = 'y',norm = 'Min', constraints = [])
if refineMesh: mesh.reset() axis = 0 origcoords = np.linspace(mesh.minCoord[axis], mesh.maxCoord[axis], mesh.elementRes[axis] + 1) edge_rest_lengths = np.diff(origcoords) deform_lengths = edge_rest_lengths.copy() min_point = (abs(mesh.maxCoord[axis]) - abs(mesh.minCoord[axis]))/2. el_reduction = 0.6 dx = mesh.maxCoord[axis] - min_point deform_lengths = deform_lengths - ((1.-el_reduction) *deform_lengths[0]) + abs((origcoords[1:] - min_point))*((0.5*deform_lengths[0])/dx) #print(edge_rest_lengths.shape, deform_lengths.shape) sp.deform_1d(deform_lengths, mesh,axis = 'x',norm = 'Min', constraints = []) # In[22]: axis = 1 orgs = np.linspace(mesh.minCoord[axis], mesh.maxCoord[axis], mesh.elementRes[axis] + 1) value_to_constrain = 1. yconst = [(sp.find_closest(orgs, value_to_constrain), np.array([value_to_constrain,0]))] # In[23]: