Hello, everyone!<br>I've been using msh ASCII format, but now I need to output hundreds of $ElementData into a msh file, so ASCII file can be really big.<br>I tried to write the data in binary format, but can't work it out. Gmsh read my sample binary data file with one $ElementData, but ate lots of ram and showed wrong.<br>
I don't know where is the problem. If anyone can help me, please answer. <br>Thank you!<br><br>My part of code written in C to output $ElementData:<br><br><div> FILE* file = fopen("outfile.msh","wb");</div>
<div> fprintf(file, "$MeshFormat\n");</div><div> fprintf(file, "2.2 1 8\n");</div><div> int one = 1;</div><div> fwrite(&one, sizeof(int), 1, file);</div><div> fprintf(file, "\n");</div>
<div> fprintf(file, "$EndMeshFormat\n");</div><div> fprintf(file, "$ElementData\n");</div><div> fprintf(file, "1");</div><div> fprintf(file, "\"tag\"\n");</div>
<div> fprintf(file, "1\n0.0\n3\n0\n1\n%i\n",NElem);</div><div> for (int i=0; i<NElem; i++) {</div><div> int one = i + 1;</div><div> fwrite(&one, sizeof(int), 1, file);</div><div> fprintf(file, " ");</div>
<div> double two = EDA[i];</div><div> fwrite(&two, sizeof(double), 1, file);</div><div> fprintf(file, "\n");</div><div> }</div><div> fprintf(file, "$EndElementData");</div><div>
<br></div><div><br></div>-- <br>Cai Yuanwu ²ÌÔ°Îä<br>Dept. of Engineering Mechanics,<br>Dalian University of Technology,<br>Dalian 116024, China<br>