/[escript]/trunk/finley/src/Mesh_saveVTK.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_saveVTK.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 120 by jgs, Mon Feb 28 07:06:33 2005 UTC revision 121 by jgs, Fri May 6 04:26:16 2005 UTC
# Line 348  void Finley_Mesh_saveVTK(const char * fi Line 348  void Finley_Mesh_saveVTK(const char * fi
348          "type=\"Int32\" "          "type=\"Int32\" "
349          "format=\"ascii\">\n");          "format=\"ascii\">\n");
350      int NN = elements->ReferenceElement->Type->numNodes;      int NN = elements->ReferenceElement->Type->numNodes;
351        int counter = 0;
352      for (i = 0; i < numCells; i++) {      for (i = 0; i < numCells; i++) {
353        fprintf(fileHandle_p, "%d ",        fprintf(fileHandle_p, "%d ",
354            mesh_p->Elements->Nodes[INDEX2(0, i, NN)]);            mesh_p->Elements->Nodes[INDEX2(0, i, NN)]);
355          counter++; /* counter for the number of connectivity points written */
356          /* if the counter gets too big (i.e. the line gets too long),
357           * then add a newline and reset */
358          if (counter > 19) {
359          fprintf(fileHandle_p, "\n");
360          counter = 0;
361          }
362        for (j = 1; j < numVTKNodesPerElement; j++) {        for (j = 1; j < numVTKNodesPerElement; j++) {
363      fprintf(fileHandle_p,"%d ", mesh_p->Elements->Nodes[INDEX2(j, i, NN)]);      fprintf(fileHandle_p,"%d ", mesh_p->Elements->Nodes[INDEX2(j, i, NN)]);
364        counter++;
365        /* if the counter gets too big (i.e. the line gets too long),
366         * then add a newline and reset */
367        if (counter > 19) {
368            fprintf(fileHandle_p, "\n");
369            counter = 0;
370        }
371        }        }
372      }      }
373      fprintf(fileHandle_p, "\n");      fprintf(fileHandle_p, "\n");
# Line 363  void Finley_Mesh_saveVTK(const char * fi Line 378  void Finley_Mesh_saveVTK(const char * fi
378          "Name=\"offsets\" "          "Name=\"offsets\" "
379          "type=\"Int32\" "          "type=\"Int32\" "
380          "format=\"ascii\">\n");          "format=\"ascii\">\n");
381        counter = 0;  /* counter for the number of offsets written to file */
382      for (i=numVTKNodesPerElement; i<=numCells*numVTKNodesPerElement; i+=numVTKNodesPerElement) {      for (i=numVTKNodesPerElement; i<=numCells*numVTKNodesPerElement; i+=numVTKNodesPerElement) {
383        fprintf(fileHandle_p, "%d ", i);        fprintf(fileHandle_p, "%d ", i);
384          counter++;
385          /* if the counter gets too big (i.e. the line gets too long),
386           * then add a newline and reset */
387          if (counter > 19) {
388          counter = 0;
389          fprintf(fileHandle_p, "\n");
390          }
391      }      }
392      fprintf(fileHandle_p, "\n");      fprintf(fileHandle_p, "\n");
393      fprintf(fileHandle_p, "</DataArray>\n");      fprintf(fileHandle_p, "</DataArray>\n");
394    
395      /* write out the DataArray element for the types */      /* write out the DataArray element for the types */
396        counter = 0; /* counter for the number of types written to file */
397      fprintf(fileHandle_p, "<DataArray "      fprintf(fileHandle_p, "<DataArray "
398          "Name=\"types\" "          "Name=\"types\" "
399          "type=\"UInt8\" "          "type=\"UInt8\" "
400          "format=\"ascii\">\n");          "format=\"ascii\">\n");
401      for (i=0; i<numCells; i++) {      for (i=0; i<numCells; i++) {
402        fprintf(fileHandle_p, "%d ", cellType);        fprintf(fileHandle_p, "%d ", cellType);
403          counter++;
404          /* if the counter gets too big (i.e. the line gets too long),
405           * then add a newline and reset */
406          if (counter > 30) {
407          counter = 0;
408          fprintf(fileHandle_p, "\n");
409          }
410      }      }
411      fprintf(fileHandle_p, "\n");      fprintf(fileHandle_p, "\n");
412      fprintf(fileHandle_p, "</DataArray>\n");      fprintf(fileHandle_p, "</DataArray>\n");
# Line 502  void Finley_Mesh_saveVTK(const char * fi Line 533  void Finley_Mesh_saveVTK(const char * fi
533            "type=\"Float32\" "            "type=\"Float32\" "
534            "NumberOfComponents=\"%d\" "            "NumberOfComponents=\"%d\" "
535            "format=\"ascii\">\n",            "format=\"ascii\">\n",
536            dataNameStr, nComp);            dataNameStr, nCompReqd);
537        for (i=0; i<mesh_p->Nodes->numNodes; i++) {        for (i=0; i<mesh_p->Nodes->numNodes; i++) {
538      switch (nodetype) {      switch (nodetype) {
539      case(FINLEY_DEGREES_OF_FREEDOM):      case(FINLEY_DEGREES_OF_FREEDOM):
# Line 583  void Finley_Mesh_saveVTK(const char * fi Line 614  void Finley_Mesh_saveVTK(const char * fi
614    fclose(fileHandle_p);    fclose(fileHandle_p);
615    return;    return;
616  }  }
617    
618    /*
619     * $Log$
620     * Revision 1.4  2005/05/06 04:26:15  jgs
621     * Merge of development branch back to main trunk on 2005-05-06
622     *
623     * Revision 1.1.2.6  2005/05/06 01:17:19  cochrane
624     * Fixed incorrect reporting of number of components in PointData arrays for
625     * vector data.
626     *
627     * Revision 1.1.2.5  2005/05/05 05:38:44  cochrane
628     * Improved formatting of VTK file output.
629     *
630     * Revision 1.1.2.4  2005/02/22 10:03:54  cochrane
631     * Implementation of writing of vtk xml files from finley.  This function will
632     * require more testing, but on the cases that I have tried (and with the help
633     * of Lutz and mayavi), it looks like it's producing the correct output.  Testing
634     * with more realistic data would be good.  I'm at least confident enough to
635     * commit my changes.
636     *
637     * Revision 1.1.2.3  2005/02/17 05:53:26  gross
638     * some bug in saveDX fixed: in fact the bug was in
639     * DataC/getDataPointShape
640     *
641     * Revision 1.1.2.2  2005/02/10 01:34:22  cochrane
642     * Quick fix to make sure that saveVTK compiles so that finley is still buildable.  Apologies to those this has affected.
643     *
644     * Revision 1.1.2.1  2005/02/09 06:53:15  cochrane
645     * Initial import to repository.  This is the file to implement saving finley/escript meshes out to vtk formatted files.  It is basically just a hack of the opendx equivalent, with a lot of the opendx stuff still in the file, so it doesn't actually work just yet, but it probably needs to be added to the cvs.
646     *
647     * Revision 1.1.1.1  2004/10/26 06:53:57  jgs
648     * initial import of project esys2
649     *
650     * Revision 1.1  2004/07/27 08:27:11  gross
651     * Finley: saveDX added: now it is possible to write data on boundary and contact elements
652     *
653     */

Legend:
Removed from v.120  
changed lines
  Added in v.121

  ViewVC Help
Powered by ViewVC 1.1.26