@ali_geo – it seems to work for me.
If I modify my code to remove the point-generation code (since you have your own point data file), and then use a coarser mesh size I get:
#!python
import numpy
import random
import pathlib
filename = pathlib.Path( "~/surface.csv" ).expanduser()
def main( mesh_size ):
set_performance_mode( True )
cubit.cmd( "reset" )
data = read_dat_file( filename )
create_surface( data )
surface_id = cubit.get_last_id( "surface" )
mesh_surface( surface_id, mesh_size )
set_performance_mode( False )
def read_dat_file( dat_filename ):
data = {}
x, y, z = [ [], [], [] ]
f = open( dat_filename, "r" )
fLines = f.readlines()
for fLine in fLines:
fLine = fLine.strip().split( "," )
row_id = int( fLine[0] )
if ( row_id in data.keys() ) == False:
data[row_id] = { "x": [], "y": [], "z": [] }
data[row_id]["x"].append( float( fLine[1] ) )
data[row_id]["y"].append( float( fLine[2] ) )
data[row_id]["z"].append( float( fLine[3] ) )
return data
def create_surface( data ):
row_ids = list( data.keys() )
curves_in_surface = []
for row_id in row_ids:
row_data = data[row_id]
x, y, z = [ row_data["x"], row_data["y"], row_data["z"] ]
vertices_in_curve = []
for i in range( 0, len( x ) ):
cubit.cmd( f"create vertex {x[i]} {y[i]} {z[i]}" )
vertices_in_curve.append( cubit.get_last_id( "vertex" ) )
cubit.cmd( f"create curve spline location vertex {cubit.get_id_string( vertices_in_curve )} delete" )
curves_in_surface.append( cubit.get_last_id( "curve" ) )
cubit.cmd( f"create surface skin curve {cubit.get_id_string( curves_in_surface )}" )
cubit.cmd( f"delete curve {cubit.get_id_string( curves_in_surface )}" )
def mesh_surface( surface_id, mesh_size ):
cubit.cmd( f"surface {surface_id} size {mesh_size}" )
cubit.cmd( f"surface {surface_id} scheme map" )
cubit.cmd( f"mesh surface {surface_id}" )
def set_performance_mode( status=True ):
if status == True:
cubit.cmd( "undo off" )
cubit.cmd( "info off" )
cubit.cmd( "echo off" )
cubit.cmd( "warning off" )
cubit.cmd( "journal off" )
cubit.cmd( "graphics off" )
elif status == False:
cubit.cmd( "undo on" )
cubit.cmd( "info on" )
cubit.cmd( "echo on" )
cubit.cmd( "warning on" )
cubit.cmd( "journal on" )
cubit.cmd( "graphics on" )
main( mesh_size=50)
