def write_inp(mesh, path = None, maxwidth = <NUM_LIT>, sections = "<STR_LIT>"):
def set_to_inp(sets, keyword):<EOL><INDENT>ss = "<STR_LIT>"<EOL>for sk in sets.keys():<EOL><INDENT>labels = sets[sk].loc[sets[sk]].index.values<EOL>labels = list(labels)<EOL>labels.sort()<EOL>if len(labels)!= <NUM_LIT:0>:<EOL><INDENT>ss += "<STR_LIT>".format(keyword, sk)<EOL>ss += argiope.utils.list_to_string(labels) + "<STR_LIT:\n>"<EOL><DEDENT><DEDENT>return ss.strip()           <EOL><DEDENT>mesh = mesh.copy()<EOL>nodes_output = (mesh.nodes.coords.to_csv(header = False).split())<EOL>nodes_output = ("<STR_LIT:\n>".join(["<STR_LIT:U+0020>" + s.replace("<STR_LIT:U+002C>", "<STR_LIT:U+002CU+0020>") for s in nodes_output]))<EOL>if "<STR_LIT>" in mesh.nodes.columns.levels[<NUM_LIT:0>]: <EOL><INDENT>nsets = set_to_inp(mesh.nodes.sets, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>nsets = "<STR_LIT>"<EOL><DEDENT>surf_output = []<EOL>if "<STR_LIT>" in mesh.elements.keys():<EOL><INDENT>sk = mesh.elements.surfaces.keys()<EOL>for sindex in  np.unique(sk.labels[<NUM_LIT:0>]):<EOL><INDENT>slabel = sk.levels[<NUM_LIT:0>][sindex]<EOL>surface = mesh.elements.surfaces[slabel]<EOL>if surface.values.sum() != <NUM_LIT:0>:<EOL><INDENT>mesh.surface_to_element_sets(slabel)<EOL>surf_output.append( "<STR_LIT>".format(slabel))<EOL>for findex in surface.keys():<EOL><INDENT>if surface[findex].sum() != <NUM_LIT:0>:<EOL><INDENT>surf_output.append("<STR_LIT>".format(slabel, <EOL>findex[<NUM_LIT:1>:])) <EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>surf_output.append("<STR_LIT>")<EOL><DEDENT>elements_output = "<STR_LIT>"<EOL>for etype, group in mesh.elements.groupby((("<STR_LIT:type>", "<STR_LIT>", "<STR_LIT>"),)):<EOL><INDENT>els = group.conn.replace(<NUM_LIT:0>, np.nan).to_csv(header = False, <EOL>float_format='<STR_LIT>').split()<EOL>elements_output += "<STR_LIT>".format(etype)<EOL>elements_output += ("<STR_LIT:\n>".join(["<STR_LIT:U+0020>" + s.strip().strip("<STR_LIT:U+002C>").<EOL>replace("<STR_LIT:U+002C>", "<STR_LIT:U+002CU+0020>") for s in els]))<EOL>elements_output += "<STR_LIT:\n>"<EOL><DEDENT>elements_output = elements_output.strip() <EOL>el_sets = {} <EOL>section_output = "<STR_LIT>"<EOL>for material, group in mesh.elements.groupby("<STR_LIT>"):<EOL><INDENT>slabel = "<STR_LIT>".format(material)<EOL>section_output += "<STR_LIT>".format(<EOL>material,<EOL>argiope.utils.list_to_string(group.index.values))<EOL>if sections == "<STR_LIT>":<EOL><INDENT>section_output += "<STR_LIT>".format(<EOL>material)<EOL><DEDENT><DEDENT>if "<STR_LIT>" in mesh.elements.columns.levels[<NUM_LIT:0>]: <EOL><INDENT>esets = set_to_inp(mesh.elements.sets.swaplevel(<NUM_LIT:1>,<NUM_LIT:0>, axis = <NUM_LIT:1>)["<STR_LIT>"],"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>esets = "<STR_LIT>"<EOL><DEDENT>
Exports the mesh to the INP format.