####################################################################################
#
# STEPS - STochastic Engine for Pathway Simulation
# Copyright (C) 2007-2023 Okinawa Institute of Science and Technology, Japan.
# Copyright (C) 2003-2006 University of Antwerp, Belgium.
#
# See the file AUTHORS for details.
# This file is part of STEPS.
#
# STEPS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# STEPS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#################################################################################
###
[docs]def tetmesh2metis(mesh, ofile):
"""
Convert STEPS Tetmesh data to metis connectivity data.
Parameters:
* mesh STEPS Tetmesh object
* ofile Output file name.
Return:
None
"""
with open(ofile, 'w') as out:
ntets = mesh.ntets
out.write("%i\n" % (ntets))
for t in range(ntets):
#tet_vol = mesh.getTetVol(t)
#out.write('%e ' % (tet_vol))
tet_vertices = mesh.getTet(t)
for v in tet_vertices:
out.write("%i " % (v + 1))
out.write("\n")
[docs]def readPartition(partition_file):
"""
Load partition information from Metis .epart file.
Parameters:
* partition_file .epart file generated by Metis.
Return:
partition list for parallel TetOpsplit solver
"""
partition = []
with open(partition_file, 'r') as parts:
for line in parts:
partition.append(int(line))
return partition