I am able to generate meshes with svmtk, but I am not understanding how I can define boundary surface tags? I.e. if I have a mesh with subdomains, how do I set the boundary tag to 1 for subdomain A that boarders subdomain B, and then set boundary tag to 2 for subdomain A that boarders subdomain C? I would preferably be able to do this within svmtk or must I use other tools?
This is the code I am using. Thanks for the help!
# %%
import SVMTK as svmtk
import meshio
# %%
def create_mesh(stl_files, output, resolution=16):
# Load the surfaces into SVM-Tk and combine in list
surfaces = []
for stl_file in stl_files:
surfaces.append(svmtk.Surface(stl_file))
# Create a map for the subdomains with tags
# Bitstring order: [body, bone, lung, tumor]
# 0 = outside surface, 1 = inside surface
# Order matters: tumor patterns come FIRST to override other tissues
smap = svmtk.SubdomainMap()
# Tag 4: Tumor tissue (overrides all other tissues where present)
smap.add("1111", 4) # Inside body, bone, lung, and tumor
smap.add("1101", 4) # Inside body, bone, and tumor (outside lung)
smap.add("1011", 4) # Inside body, lung, and tumor (outside bone)
smap.add("1001", 4) # Inside body and tumor (outside bone and lung)
# Tag 2: Bone tissue (inside body and bone, outside tumor)
smap.add("1100", 2)
smap.add("1110", 2) # Inside body, bone, lung, outside tumor
smap.add("0100", 2) # Outside body, lung, tumor
# Tag 3: Lung tissue (inside body and lung, outside tumor)
smap.add("1010", 3)
smap.add("0010", 3) # Outside body, bone, tumor
# Tag 1: Body tissue (inside body, outside bone, lung, tumor)
smap.add("1000", 1)
# Create a tagged domain from the list of surfaces
# and the map
domain = svmtk.Domain(surfaces, smap)
# Create and save the volume mesh
domain.create_mesh(resolution)
domain.save(output)
mesh = meshio.read(output) # or "input.msh" for Gmsh
output_xdmf = output.replace(".mesh", ".xdmf")
meshio.write(output_xdmf, mesh)
if __name__ == "__main__":
stl_files = ["body.remesh.smooth.stl","bone.remesh.smooth.stl",
"lung.remesh.smooth.stl","tumor.remesh.smooth.stl"]
stl_files = ["./stl_files/" + stl_file for stl_file in stl_files]
create_mesh(stl_files, "./stl_files/combined_final.mesh", resolution=16)

