Hi all , I wrote a python script for converting a tet mesh into a Dolphin XML mesh.
Posting it here just in case it is handy for anyone #FENICS
[code]all_nodes_list = cubit.parse_cubit_list(“node”," in volume all ")
print(‘all_nodes’,all_nodes)
file_contents =
file_contents.append(’<dolfin nsmap="’+"{‘dolfin’: ‘https://fenicsproject.org/’}"+’">\n’)
file_contents.append(’\n’)
nodal_coordinates_list =
for node_id in all_nodes_list:
nodal_coordinates_list.append(cubit.get_nodal_coordinates(node_id))
sorted_nodes_list = sorted(all_nodes_list)
print(‘sorted_nodes_list’,sorted_nodes_list)
sorted_nodal_coordinates_list = [x for _,x in sorted(zip(all_nodes_list,nodal_coordinates_list))]
file_contents.append(’ \n’)
for node_id , nodal_coordinates in zip(sorted_nodes_list, sorted_nodal_coordinates_list):
file_contents.append(’ \n’ )
file_contents.append(’ \n’)
all_tets_list = cubit.parse_cubit_list(“tet”," in volume all ")
print(‘all_tets_list’,all_tets_list)
print(len(all_tets_list))
file_contents.append(’ \n’)
nodes_in_tet_list = cubit.parse_cubit_list(“node”," in tet 1 ")
print(‘nodes_in_tet_list’,nodes_in_tet_list)
for tet_id in all_tets_list:
nodes_in_tet = cubit.parse_cubit_list(“node”," in tet “+str(tet_id)+” ")
file_contents.append(’ \n’)
file_contents.append(’’)
f = open(‘mesh_in_dolphin_xml_shimwell_method.xml’, ‘w’)
for line in file_contents:
f.write(line)
f.close()[/code]