def write(filename, mesh, write_binary=False):
assert not write_binary<EOL>if mesh.points.shape[<NUM_LIT:1>] == <NUM_LIT:2>:<EOL><INDENT>logging.warning(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL>mesh.points = numpy.column_stack(<EOL>[mesh.points[:, <NUM_LIT:0>], mesh.points[:, <NUM_LIT:1>], numpy.zeros(mesh.points.shape[<NUM_LIT:0>])]<EOL>)<EOL><DEDENT>cells = mesh.cells.copy()<EOL>if "<STR_LIT>" in cells:<EOL><INDENT>cells["<STR_LIT>"] = cells["<STR_LIT>"][<EOL>:, [<NUM_LIT:0>, <NUM_LIT:1>, <NUM_LIT:2>, <NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:5>, <NUM_LIT:6>, <NUM_LIT:7>, <NUM_LIT:8>, <NUM_LIT:11>, <NUM_LIT:10>, <NUM_LIT:9>, <NUM_LIT:16>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:12>, <NUM_LIT:15>, <NUM_LIT>, <NUM_LIT>]<EOL>]<EOL><DEDENT>if "<STR_LIT>" in cells:<EOL><INDENT>cells["<STR_LIT>"] = cells["<STR_LIT>"][<EOL>:,<EOL>[<EOL><NUM_LIT:0>,<EOL><NUM_LIT:1>,<EOL><NUM_LIT:2>,<EOL><NUM_LIT:3>,<EOL><NUM_LIT:4>,<EOL><NUM_LIT:5>,<EOL><NUM_LIT:6>,<EOL><NUM_LIT:7>,<EOL><NUM_LIT:8>,<EOL><NUM_LIT:11>,<EOL><NUM_LIT:10>,<EOL><NUM_LIT:9>,<EOL><NUM_LIT:16>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT:12>,<EOL><NUM_LIT:15>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL><NUM_LIT:20>,<EOL><NUM_LIT>,<EOL><NUM_LIT>,<EOL>],<EOL>]<EOL><DEDENT>with open(filename, "<STR_LIT:wb>") as fh:<EOL><INDENT>fh.write(("<STR_LIT>").encode("<STR_LIT:utf-8>"))<EOL>fh.write(("<STR_LIT>").encode("<STR_LIT:utf-8>"))<EOL>fh.write(("<STR_LIT>").encode("<STR_LIT:utf-8>"))<EOL>fh.write(("<STR_LIT>").encode("<STR_LIT:utf-8>"))<EOL>fh.write(("<STR_LIT>").encode("<STR_LIT:utf-8>"))<EOL>tag_data = {}<EOL>other_data = {}<EOL>for cell_type, a in mesh.cell_data.items():<EOL><INDENT>tag_data[cell_type] = {}<EOL>other_data[cell_type] = {}<EOL>for key, data in a.items():<EOL><INDENT>if key in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>tag_data[cell_type][key] = data.astype(numpy.int32)<EOL><DEDENT>else:<EOL><INDENT>other_data[cell_type][key] = data<EOL><DEDENT><DEDENT><DEDENT>dimension = <NUM_LIT:2><EOL>for cell_type in cells.keys():<EOL><INDENT>name_elem = _meshio_to_mdpa_type[cell_type]<EOL>if local_dimension_types[name_elem] == <NUM_LIT:3>:<EOL><INDENT>dimension = <NUM_LIT:3><EOL>break<EOL><DEDENT><DEDENT>_write_nodes(fh, mesh.points, write_binary)<EOL>_write_elements_and_conditions(fh, cells, tag_data, write_binary, dimension)<EOL>for name, dat in mesh.point_data.items():<EOL><INDENT>_write_data(fh, "<STR_LIT>", name, dat, write_binary)<EOL><DEDENT>cell_data_raw = raw_from_cell_data(other_data)<EOL>for (<EOL>name,<EOL>dat,<EOL>) in (<EOL>cell_data_raw.items()<EOL>):  <EOL><INDENT>_write_data(fh, "<STR_LIT>", name, dat, write_binary)<EOL><DEDENT><DEDENT>return<EOL>
Writes mdpa files, cf.
    <https://github.com/KratosMultiphysics/Kratos/wiki/Input-data>.