本文整理汇总了Python中meshpy.tet.MeshInfo.set_facets方法的典型用法代码示例。如果您正苦于以下问题:Python MeshInfo.set_facets方法的具体用法?Python MeshInfo.set_facets怎么用?Python MeshInfo.set_facets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meshpy.tet.MeshInfo
的用法示例。
在下文中一共展示了MeshInfo.set_facets方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_tetgen
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def test_tetgen():
from meshpy.tet import MeshInfo, build
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0),
(2, 0, 0),
(2, 2, 0),
(0, 2, 0),
(0, 0, 12),
(2, 0, 12),
(2, 2, 12),
(0, 2, 12),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
build(mesh_info)
示例2: main
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def main():
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0),
(2, 0, 0),
(2, 2, 0),
(0, 2, 0),
(0, 0, 12),
(2, 0, 12),
(2, 2, 12),
(0, 2, 12),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
mesh_info.save_nodes("bar")
mesh_info.save_poly("bar")
mesh = build(mesh_info)
mesh.save_nodes("barout")
mesh.save_elements("barout")
mesh.save_faces("barout")
mesh.write_vtk("test.vtk")
示例3: generateCubeMesh
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def generateCubeMesh():
mesh_info = MeshInfo()
mesh_info.set_points([
(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0),
(0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1),
])
mesh_info.set_facets([
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4, 5, 1],
[1, 5, 6, 2],
[2, 6, 7, 3],
[3, 7, 4, 0],
])
mesh = build(mesh_info)
cellList = []
vertexList = []
mupifMesh = Mesh.UnstructuredMesh()
print("Mesh Points:")
for i, p in enumerate(mesh.points):
print(i, p)
vertexList.extend([Vertex.Vertex(i, i, p)])
print("Point numbers in tetrahedra:")
for i, t in enumerate(mesh.elements):
print(i, t)
cellList.extend([Cell.Tetrahedron_3d_lin(mupifMesh, i, i, t)])
mupifMesh.setup(vertexList, cellList)
return(mupifMesh)
示例4: create_beam
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def create_beam(vol):
# build using MeshPy
from meshpy.tet import MeshInfo,build
mesh_info = MeshInfo()
mesh_info.set_points([
(0,0,0),
(0,1,0),
(0,1,1),
(0,0,1),
(5,0,0),
(5,1,0),
(5,1,1),
(5,0,1),
])
mesh_info.set_facets([
[0,1,2,3],
[4,5,6,7],
[0,1,5,4],
[1,2,6,5],
[0,3,7,4],
[3,2,6,7],
])
mesh = build(mesh_info,max_volume=vol)
return fmsh.MeshPyTet(mesh)
示例5: generate_Preview
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def generate_Preview():
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
config = bpy.context.scene.CONFIG_MeshPy
vertList = []
faceList = []
meshPoints = []
meshFacets = []
split_faceList = []
split_vertList = []
ob = bpy.context.active_object
obname = ob.name
#compute mesh
compute_vertices(ob, meshPoints)
compute_polygones(ob, meshFacets)
if config.make_subdivision == False:
arg = "Y"
else:
arg = ""
mesh_info = MeshInfo()
mesh_info.set_points(meshPoints)
mesh_info.set_facets(meshFacets)
print(meshPoints)
print(meshFacets)
#args = ("pq" + str(config.ratio_quality) + "a" + str(config.ratio_maxsize) + str(arg))
'''
示例6: brep2lar
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def brep2lar(larBrep):
V,FV = larBrep
mesh_info = MeshInfo()
mesh_info.set_points(V)
mesh_info.set_facets(FV)
mesh = build(mesh_info)
W = [v for h,v in enumerate(mesh.points)]
CW = [tet for k,tet in enumerate(mesh.elements)]
FW = sorted(set(AA(tuple)(CAT(AA(faces)(CW)))))
EW = sorted(set(AA(tuple)(CAT(AA(edges)(FW)))))
return W,CW,FW,EW
示例7: save_mesh
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def save_mesh(filepath,
mesh,
boundary_condition,
use_graphics,
fem_dimensions,
mass_density,
poisson_ratio,
young_modulus,
meshpy
):
"""Write mesh data out to ply file
If graphics are checked to be exported, it will prep any UVs and normals it can and prepare
a full list of faces FEM3D meshes have their mesh run through MeshPy which is a Python
interface for TetGen
"""
file = open(filepath, "w", encoding="utf8", newline="\n")
fwrite = file.write
verts = []
faces = []
elements = []
uvcoords = {}
normals = {}
has_uv = bool(mesh.uv_textures) and mesh.uv_textures.active
if has_uv and use_graphics:
mesh.calc_tessface()
uv_data = mesh.tessface_uv_textures.active.data
for i, polygon in enumerate(mesh.polygons):
uv = uv_data[i].uv1, uv_data[i].uv2, uv_data[i].uv3, uv_data[i].uv4
for j, vert in enumerate(polygon.vertices):
uvcoord = uv[j][0], uv[j][1]
normal = mesh.vertices[vert].normal[:]
vertcoord = mesh.vertices[vert].co[:]
if vertcoord not in uvcoords:
uvcoords[vertcoord] = uvcoord
if vertcoord not in normals:
normals[vertcoord] = normal
if fem_dimensions == '3':
from meshpy.tet import MeshInfo, build, Options
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
bpy.context.scene.update()
# get list of verts and faces direct from mesh
mesh_verts = []
for vert in mesh.vertices:
mesh_verts.append(vert.co[:])
mesh_faces = []
for face in mesh.polygons:
mesh_faces.append(face.vertices[:])
args = meshpy
mesh_info = MeshInfo()
mesh_info.set_points(mesh_verts)
mesh_info.set_facets(mesh_faces)
tets = build(mesh_info, Options(args),
verbose=True,
attributes=False,
volume_constraints=False,
max_volume=None,
diagnose=False,
insert_points=None)
# Ply prep by creating updated vert list and face list using tets.points and tets.elements
for point in tets.points:
verts.append((point[0], point[1], point[2]))
for tet in tets.elements:
elements.append((tet[0], tet[1], tet[2], tet[3]))
for face in tets.faces:
faces.append((face[2], face[1], face[0]))
else:
for vert in mesh.vertices:
verts.append((vert.co[0], vert.co[1], vert.co[2]))
for face in mesh.polygons:
if len(face.vertices) == 3:
faces.append((face.vertices[0], face.vertices[1], face.vertices[2]))
else:
faces.append((face.vertices[0], face.vertices[1], face.vertices[2]))
faces.append((face.vertices[0], face.vertices[2], face.vertices[3]))
fwrite("ply\n")
fwrite("format ascii 1.0\n")
fwrite("comment Created by OpenSurgSim FEM exporter for Blender\n")
fwrite("comment MeshPy options '%s'\n" % meshpy)
fwrite("element vertex %d\n" % len(verts))
fwrite("property double x\n"
"property double y\n"
"property double z\n")
if use_graphics:
#.........这里部分代码省略.........
示例8: make_box_mesh
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def make_box_mesh(a=(0, 0, 0), b=(1, 1, 1),
max_volume=None, periodicity=None,
boundary_tagger=(lambda fvi, el, fn, all_v: []),
return_meshpy_mesh=False):
"""Return a mesh for a brick from the origin to `dimensions`.
*max_volume* specifies the maximum volume for each tetrahedron.
*periodicity* is either None, or a triple of bools, indicating
whether periodic BCs are to be applied along that axis.
See :func:`make_conformal_mesh` for the meaning of *boundary_tagger*.
A few stock boundary tags are provided for easy application
of boundary conditions, namely plus_[xyz] and minus_[xyz] tag
the appropriate faces of the brick.
"""
def count(iterable):
result = 0
for i in iterable:
result += 1
return result
from meshpy.tet import MeshInfo, build
from meshpy.geometry import make_box
points, facets, _, facet_markers = make_box(a, b)
mesh_info = MeshInfo()
mesh_info.set_points(points)
mesh_info.set_facets(facets, facet_markers)
if periodicity is None:
periodicity = (False, False, False)
axes = ["x", "y", "z"]
per_count = count(p for p in periodicity if p)
marker_to_tag = {}
mesh_periodicity = []
periodic_tags = set()
if per_count:
mesh_info.pbc_groups.resize(per_count)
pbc_group_number = 0
for axis, axis_per in enumerate(periodicity):
minus_marker = 1+2*axis
plus_marker = 2+2*axis
minus_tag = "minus_"+axes[axis]
plus_tag = "plus_"+axes[axis]
marker_to_tag[minus_marker] = minus_tag
marker_to_tag[plus_marker] = plus_tag
if axis_per:
pbcg = mesh_info.pbc_groups[pbc_group_number]
pbc_group_number += 1
pbcg.facet_marker_1 = minus_marker
pbcg.facet_marker_2 = plus_marker
translation = [0, 0, 0]
translation[axis] = b[axis]-a[axis]
pbcg.set_transform(translation=translation)
mesh_periodicity.append((minus_tag, plus_tag))
periodic_tags.add(minus_tag)
periodic_tags.add(plus_tag)
else:
mesh_periodicity.append(None)
generated_mesh = build(mesh_info, max_volume=max_volume)
fvi2fm = generated_mesh.face_vertex_indices_to_face_marker
def wrapped_boundary_tagger(fvi, el, fn, all_v):
face_tag = marker_to_tag[fvi2fm[frozenset(fvi)]]
if face_tag in periodic_tags:
return [face_tag]
else:
return [face_tag] + boundary_tagger(fvi, el, fn, all_v)
from hedge.mesh import make_conformal_mesh_ext
from hedge.mesh.element import Tetrahedron
vertices = numpy.asarray(generated_mesh.points, dtype=float, order="C")
result = make_conformal_mesh_ext(
vertices,
[Tetrahedron(i, el_idx, vertices)
for i, el_idx in enumerate(generated_mesh.elements)],
wrapped_boundary_tagger,
periodicity=mesh_periodicity)
if return_meshpy_mesh:
return result, generated_mesh
else:
return result
示例9: ProcessGlobalAction
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
#.........这里部分代码省略.........
if ElementPoints[2] != ElementPoints[3]:
for point in [ElementPoints[0],ElementPoints[2],ElementPoints[3]]:
if not point in MeshPointsIndex:
MeshPointsIndex[point] = PointIndex
MeshPoints.append(False)
MeshPoints[PointIndex] = NumberedPoints['points'][point]['point']
PointIndex += 1
MeshFacet.append(MeshPointsIndex[point])
MeshFacets.append(MeshFacet)
else:
for point in ElementPoints:
if not point in MeshPointsIndex:
MeshPointsIndex[point] = PointIndex
MeshPoints.append(False)
MeshPoints[PointIndex] = NumberedPoints['points'][point]['point']
PointIndex += 1
if not MeshPointsIndex[point] in MeshFacet:
MeshFacet.append(MeshPointsIndex[point])
else:
print "Mesh error or 3-point 3DFACE."
MeshFacets.append(MeshFacet)
MeshFacet = []
for point in list(set(AdditionalPoints)):
if not point in MeshPointsIndex: #See whether the point is already indexed by its native number
MeshPointsIndex[point] = PointIndex
MeshPoints.append(False)
MeshPoints[PointIndex] = NumberedPoints['points'][point]['point']
PointIndex += 1
saveobject(MeshFacets, r'MeshFacets')
saveobject(MeshPoints, r'MeshPoints')
mesh_info.set_facets(MeshFacets)
mesh_info.set_points(MeshPoints)
#insertaddpoints
#points = np.array([list(x) for x in MeshPoints])
#qhull = scipy.spatial.Delaunay(points)
#mesh_info.Options(switches='pq')
#mesh_info.set_points([
# (0,0,0), (12,0,0), (12,12,0), (0,12,0),
# (0,0,12), (12,0,12), (12,12,12), (0,12,12),
# ])
#mesh_info.set_facets([
# [0,1,2,3],
# [4,5,6,7],
# [0,4,5,1],
# [1,5,6,2],
# [2,6,7,3],
# [3,7,4,0],
# ])
#opts = Options(switches='pq')
#opts.maxvolume = 0.0001
#opts.parse_switches()
mesh_info.regions.resize(1)
mesh_info.regions[0] = [
MeshPoints[0][0], MeshPoints[0][1], MeshPoints[0][2], # point in volume -> first box
0, # region tag (user-defined number)
Parameters['maxvolume'], # max tet volume in region
]
mesh = build(mesh_info, options=Options(switches="pqT", epsilon=Parameters['tolerance']), volume_constraints=True)
print "Created mesh with {} points, {} faces and {} elements.".format(len(mesh.points), len(mesh.faces), len(mesh.elements))
#mesh = build(mesh_info, options=Options(switches="pTi", epsilon=Parameters['tolerance'], insertaddpoints=True), volume_constraints=True, insert_points=additional_points)
示例10: array
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
# mesh_info.set_facets([
# [0,1,2],
# [0,1,3],
# [1,2,3],
# [3,2,0]
# ])
#Cubic entire cubic voronoi cell....
a = 0.5; b = -0.5
mesh_info.set_points([
(b,b,b), (b,b,a), (b,a,a),(b,a,b),(a,b,b), (a,b,a), (a,a,a),(a,a,b)
])
mesh_info.set_facets([
[0,1,2,3],
[0,1,5,4],
[0,4,7,3],
[6,2,1,5],
[6,2,3,7],
[6,7,4,5]])
addpoints = [(0.0,0.0,0.0), (0.375,0.375,0.375)]
# addpoints = [array([0.0,0.0,0.0]), array(0.375,0.375,0.375)]
opts = Options("VO9pa0.04") # Overriding 'pq'
mesh = build(mesh_info,options=opts, insert_points = addpoints)
# mesh = build(mesh_info,max_volume = 0.1)
vols = []
tets = []
points = []
print "Mesh Points:"
示例11: MeshInfo
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
from meshpy.tet import MeshInfo, build
mesh_info = MeshInfo()
mesh_info.set_points([
(0,0,0), (2,0,0), (2,2,0), (0,2,0),
(0,0,12), (2,0,12), (2,2,12), (0,2,12),
])
mesh_info.set_facets([
[0,1,2,3],
[4,5,6,7],
[0,4,5,1],
[1,5,6,2],
[2,6,7,3],
[3,7,4,0],
])
mesh = build(mesh_info)
print "Mesh Points:"
for i, p in enumerate(mesh.points):
print i, p
print "Point numbers in tetrahedra:"
for i, t in enumerate(mesh.elements):
print i, t
mesh.write_vtk("test.vtk")
示例12: add_to_all_vertex_indices
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
# vertex indices for a box missing the -z face
box_without_minus_z = [
[4,5,6,7],
[0,4,5,1],
[1,5,6,2],
[2,6,7,3],
[3,7,4,0],
]
def add_to_all_vertex_indices(facets, increment):
return [[pt+increment for pt in facet] for facet in facets]
mesh_info.set_facets(
[[0,1,2,3]] # base
+box_without_minus_z # first box
+add_to_all_vertex_indices(box_without_minus_z, 4) # second box
)
# set the volume properties -- this is where the tet size constraints are
mesh_info.regions.resize(2)
mesh_info.regions[0] = [0,0,2, # point in volume -> first box
0, # region tag (user-defined number)
1e-1, # max tet volume in region
]
mesh_info.regions[1] = [0,0,7, # point in volume -> second box
0, # region tag (user-defined number, arbitrary)
1e-2, # max tet volume in region
]
mesh = build(mesh_info, volume_constraints=True)
示例13: coarse_gen
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def coarse_gen(cd,bdim,bmin,file_name):
# INPUT: voxel cube side length (fl), box dimensions (fl), box minimum values (fl), name of file to create for mesh output (str)
# This function generates a coarse mesh given info from NEURON sections.
# Returns this mesh as a STEPS tuple, of which entry 0 is a steps.geom.Tetmesh object,
# also saves STEPS format files for the Tetmesh to current directory under given file name (xml & ASCII file formats).
## CALCULATE BOX INFO ##
box_w = bdim[0]
box_l = bdim[1]
box_h = bdim[2]
min_x = bmin[0]
min_y = bmin[1]
min_z = bmin[2]
cl = cd
if not (box_w % cl == box_l % cl == box_h % cl == 0):
print 'ERRROR: voxel cube side length not a common factor of all box dimensions'
sys.exit()
wpoints = 1+(box_w)/cl
lpoints = 1+(box_l)/cl
hpoints = 1+(box_h)/cl
print "cube side length: ", cl
print "box w,l,h: ", box_w,box_l,box_h
print "w,l,h # points: ", wpoints,lpoints,hpoints
cpoints = []
hfacets = []
vfacets = []
## GENERATE POINTS AND FACETS ##
for hp in range(int(hpoints)):
for lp in range(int(lpoints)):
for wp in range(int(wpoints)):
cpoints.append((min_x+wp*cl,min_y+lp*cl,min_z+hp*cl))
pindex = (hp*lpoints*wpoints)+(lp*wpoints)+wp
# horizontal facets
if (wp < int(wpoints)-1 and lp < int(lpoints)-1):
hfacets.append([int(pindex), int(pindex+1), int(pindex+1+wpoints), int(pindex+wpoints)])
# vertical facets
if (hp > 0):
if (wp > 0):
vfacets.append([int(pindex),int(pindex-1),int(pindex-1-lpoints*wpoints),int(pindex-lpoints*wpoints)])
if (lp > 0):
vfacets.append([int(pindex),int(pindex-wpoints),int(pindex-wpoints-lpoints*wpoints),int(pindex-lpoints*wpoints)])
all_facets = hfacets+vfacets
## PASS MESH TO STEPS ##
mesh_info = MeshInfo()
mesh_info.set_points(cpoints)
mesh_info.set_facets(all_facets)
m = build(mesh_info)
# write mesh proxies
nodeproxy = smeshio.ElementProxy('node',3)
for i, p in enumerate(m.points):
nodeproxy.insert(i,p)
tetproxy = smeshio.ElementProxy('tet',4)
newtet = [0,0,0,0]
for i, t in enumerate(m.elements):
newtet[0] = nodeproxy.getSTEPSID(int(t[0]))
newtet[1] = nodeproxy.getSTEPSID(int(t[1]))
newtet[2] = nodeproxy.getSTEPSID(int(t[2]))
newtet[3] = nodeproxy.getSTEPSID(int(t[3]))
tetproxy.insert(i, newtet)
# build mesh from proxies and save in STEPS format (xml & ASCII)
nodedata = nodeproxy.getAllData()
tetdata = tetproxy.getAllData()
newmesh = steps.geom.Tetmesh(nodedata, tetdata)
smeshio.saveMesh(file_name,newmesh)
# Load mesh into STEPS
steps_mesh = smeshio.loadMesh(file_name)
print "STEPS loaded Tetmesh successfully."
print "# Vertices: ", steps_mesh[0].countVertices()
print "# Tets: ", steps_mesh[0].countTets()
print "# Faces/Tris: ", steps_mesh[0].countTris()
return steps_mesh
示例14: generate_TetMesh
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
def generate_TetMesh():
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
bpy.context.scene.update()
print("Scene Updated!")
config = bpy.context.scene.CONFIG_MeshPy
tetIndex = 0
vertList = []
faceList = []
meshPoints = []
meshFacets = []
split_faceList = []
split_vertList = []
ob = bpy.context.active_object
obname = ob.name
#convert all faces to triangles for testing
### that did not help with the crash problem:(
'''
for vert in ob.data.vertices:
vert.select = True
bpy.ops.object.mode_set(mode = 'EDIT', toggle = False)
bpy.ops.mesh.quads_convert_to_tris()
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = False)
'''
#compute mesh
compute_vertices(ob, meshPoints)
compute_faces(ob, meshFacets)
if config.make_subdivision == False:
arg = "Y"
else:
arg = ""
mesh_info = MeshInfo()
mesh_info.set_points(meshPoints)
mesh_info.set_facets(meshFacets)
debugArg = ""
args = (debugArg + "pq" + str(config.ratio_quality) + "a" + str(config.ratio_maxsize) + str(arg))
#args = ("o2" + str(arg))
tetmesh = build(mesh_info, Options(args),
verbose = True,
attributes = False,
volume_constraints = False,
max_volume = None,
diagnose = False,
insert_points = None)
compute_mesh(tetmesh, vertList, faceList)
##all this should only be executed when preview is disabled
if config.make_split == True:
##add counter to iterate to iterate the loop through all tetras
#print(len(tetmesh.elements))
while tetIndex < len(tetmesh.elements):
compute_mesh_split(tetmesh, split_faceList, split_vertList, vertList)
#print("split_faceList ", tetIndex, ": ", split_faceList[tetIndex])
#print("split_vertList ", tetIndex, ": ", split_vertList[tetIndex])
#put this in a separate loop maybe bring some speed up
#create mesh
tetname = obname + "Tet"
tet = create_mesh(tetname, split_vertList[tetIndex], split_faceList[tetIndex])
#run configs
enable_game(config, tet)
enable_physics(config, tet, tetname)
#bpy.ops.group.create(name='test')
world_correction(config, ob, tet)
tetIndex = tetIndex + 1
else:
#create mesh
tetname = obname + "Tet"
tetMesh = create_mesh(tetname, vertList, faceList)
#run configs
enable_game(config, tetMesh)
enable_physics(config, tetMesh, tetname)
world_correction(config, ob, tetMesh)
示例15: add_to_all_vertex_indices
# 需要导入模块: from meshpy.tet import MeshInfo [as 别名]
# 或者: from meshpy.tet.MeshInfo import set_facets [as 别名]
[3,7,4,0],
]
def add_to_all_vertex_indices(facets, increment):
return [[pt+increment for pt in facet] for facet in facets]
facets = [[0,1,2,3]] + box_without_minus_z # first box
facets += add_to_all_vertex_indices(box_without_minus_z, 4)# second box
facets += add_to_all_vertex_indices(box_without_minus_z, 8)# third box
facet_mrks = []
for f in facets:
facet_mrks.append(-(int(f == max(facets)))) # Finding the surface boundary facet and labeling negative
mesh_info.set_facets(facets,
facet_mrks # Surface boundary conditions
)
# figuring out what each of the volume constraints should be
# the edge length here is divided by four to make sure there are at least 3 nodes per layer
vc = lambda x: (x/4)**3/6
# set the volume properties -- this is where the tet size constraints are
mesh_info.regions.resize(3)
mesh_info.regions[0] = [0,0,1-delta_con/2,# point in volume -> first box
10, # region tag (user-defined number)
vc(delta_con), # max tet volume in region
]
mesh_info.regions[1] = [0,0,((1-delta_con)-delta_base/2), # point in volume -> second box