72 lines
1.5 KiB
Python
72 lines
1.5 KiB
Python
|
from dolfin import *
|
||
|
|
||
|
|
||
|
mesh_in = '/home/yeye/Desktop/leomesh.xml'
|
||
|
mesh_out = '/home/yeye/Desktop/aorta.h5'
|
||
|
mesh = Mesh(mesh_in)
|
||
|
|
||
|
hdf = HDF5File(mesh.mpi_comm(), mesh_out, 'w')
|
||
|
boundaries = MeshFunction('size_t', mesh,2)
|
||
|
|
||
|
marked = 1
|
||
|
testmesh = 0
|
||
|
|
||
|
hdf.write(mesh, '/mesh')
|
||
|
|
||
|
if marked==1:
|
||
|
|
||
|
class Inlet(SubDomain):
|
||
|
def inside(self, x, on_boundary):
|
||
|
return on_boundary and between(x[0],(0.1975,0.1989)) and between(x[2],(0.07,0.1))
|
||
|
|
||
|
class Outlet(SubDomain):
|
||
|
def inside(self, x, on_boundary):
|
||
|
return on_boundary and between(x[0],(0.1975,0.1989)) and between(x[2],(0,0.04))
|
||
|
|
||
|
class Walls(SubDomain):
|
||
|
def inside(self, x, on_boundary):
|
||
|
return on_boundary
|
||
|
|
||
|
|
||
|
outlet = Outlet()
|
||
|
inlet = Inlet()
|
||
|
walls = Walls()
|
||
|
|
||
|
boundaries.set_all(0)
|
||
|
walls.mark(boundaries,1)
|
||
|
outlet.mark(boundaries,3)
|
||
|
inlet.mark(boundaries,2)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
hdf.write(boundaries, '/boundaries')
|
||
|
hdf.close()
|
||
|
|
||
|
|
||
|
|
||
|
if testmesh:
|
||
|
print('Testing Mesh...')
|
||
|
meshname = mesh_out
|
||
|
pathtoB = '/home/yeye/Desktop/boundaries.xdmf'
|
||
|
mesh = Mesh()
|
||
|
hdf = HDF5File(mesh.mpi_comm(), meshname , 'r')
|
||
|
hdf.read(mesh, '/mesh', False)
|
||
|
boundaries = MeshFunction('size_t', mesh , mesh.topology().dim() - 1)
|
||
|
hdf.read(boundaries, '/boundaries')
|
||
|
# To save the boundaries information
|
||
|
XDMFFile(pathtoB).write(boundaries)
|
||
|
print('Boundary info printed in ' + pathtoB)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|