import nmesh ell = nmesh.ellipsoid([3, 2]) # create ellipsoid cone = nmesh.conic([-3, 0], 2, [3, 0], 0) # create cone inters = nmesh.intersect([ell, cone]) # create intersection of objects bbox = [[-5., -4.], [5., 4.]] mesh_ex = nmesh.mesh(objects=[inters], a0=0.4, bounding_box=bbox) nmesh.visual.plot2d_ps(mesh_ex, "intersection.ps")
""" ##### Creating the mesh ##### # For now, we use a very very simple mesh... rings = nmesh.union([nmesh.difference(nmesh.ellipsoid([3.0,3.0], transform=[("shift",[-2.5,0.0])]), [nmesh.ellipsoid([1.5,1.5], transform=[("shift",[-2.5,0.0])])]), nmesh.difference(nmesh.ellipsoid([3.0,3.0], transform=[("shift",[2.5,0.0])]), [nmesh.ellipsoid([1.5,1.5], transform=[("shift",[2.5,0.0])])])]) boxed_rings=nmesh.intersect([rings,nmesh.box([-8.0,-2.5],[8.0,2.5])]) N = 100 density = "density=1.;" the_mesh = nmesh.mesh(objects = [boxed_rings], cache_name="rings-mesh", a0=0.3, bounding_box=[[-10.0,-3.5],[10.0,3.5]], neigh_force_scale = 1., density = density, initial_settling_steps = 50, max_relaxation = 4, # callback=(my_function, N), # max_steps=677 max_steps=200
# Simulation parameters sigma0 = 1.0 print """ ** Example: meshing half ring and compute current density for contacts at either side. This is for possible collaboration with Uni Hamburg. ** """ ##### Creating the mesh ##### ring = nmesh.difference( nmesh.ellipsoid([4.0, 4.0]), [nmesh.ellipsoid([2.5, 2.5])]) halfring = nmesh.intersect([ring, nmesh.box([-4.0, -0.0], [4.0, 4.0])]) the_mesh = nmesh.mesh( objects=[halfring], cache_name="halfring", a0=0.2, bounding_box=[[-4.0, -4], [4.0, 4.0]], neigh_force_scale=1., initial_settling_steps=50, max_relaxation=4, max_steps=400) nfem.set_default_mesh(the_mesh) the_mesh.save("themesh.nmesh")
# external ring R = nmesh.ellipsoid( [outer_radius, outer_radius], transform=[("shift",[x*centres_distance, y*centres_distance])] ) #internal ring r = nmesh.ellipsoid( [inner_radius, inner_radius], transform=[("shift",[x*centres_distance, y*centres_distance])] ) # take the difference rings.append(nmesh.difference(R,[r])) # cut the rings at top and bottom union_rings = nmesh.union(rings) rings_array = nmesh.intersect([union_rings,rings_box]) # semiaxis of a rhombus on the diagonals of the array d = (centres_distance/2.) - Numeric.sqrt(outer_radius**2 - (centres_distance/2.)**2) # rhombi on the diagonals of the array for x in range(-3,4,2): for y in range(-3,4,2): centre_x = 0.5*x*centres_distance centre_y = 0.5*y*centres_distance # centre of the rhombus c = Numeric.array([centre_x,centre_y]) # 4 corners of the rhombus
# Simulation parameters sigma0=1.0 print """ ** Example: meshing half ring and compute current density for contacts at either side. This is for possible collaboration with Uni Hamburg. ** """ ##### Creating the mesh ##### ring = nmesh.difference(nmesh.ellipsoid([4.0,4.0]),[nmesh.ellipsoid([2.5,2.5])]) halfring=nmesh.intersect([ring,nmesh.box([-4.0,-0.0],[4.0,4.0])]) the_mesh = nmesh.mesh(objects = [halfring], cache_name="halfring", a0=0.2, bounding_box=[[-4.0,-4],[4.0,4.0]], neigh_force_scale = 1., initial_settling_steps = 50, max_relaxation = 4, max_steps=400 ) nfem.set_default_mesh(the_mesh) the_mesh.save("themesh.nmesh")
import nmesh ell = nmesh.ellipsoid([3,2]) # create ellipsoid cone = nmesh.conic([-3,0],2,[3,0],0) # create cone inters = nmesh.intersect([ell, cone]) # create intersection of objects bbox = [[-5.,-4.],[5.,4.]] mesh_ex = nmesh.mesh(objects = [inters], a0=0.4, bounding_box=bbox) nmesh.visual.plot2d_ps(mesh_ex,"intersection.ps")
# external ring R = nmesh.conic( [0.0,0.0,-thickness], outer_radius, [0.0,0.0,thickness], outer_radius, \ transform=[("shift",trasl)] ) #internal ring r = nmesh.conic( [0.0,0.0,-thickness], inner_radius, [0.0,0.0,thickness], inner_radius, \ transform=[("shift",trasl)], ) # take the difference ring = nmesh.difference(R,[r]) box = nmesh.box([-10,0,-thickness/2.],[10,10,thickness/2.]) system = nmesh.intersect([ring, box]) density = """density = 1.;""" N = 50 # create mesh of three objects and bounding box mesh_ex = nmesh.mesh(objects = [system], a0=rod, bounding_box=bbox, density = density, # with these values there is # a bit more pressure than with # the default values (as suggested