[cig-commits] commit: Remove vtk2csv and generate_pvd

Mercurial hg at geodynamics.org
Sat Nov 19 10:34:51 PST 2011


changeset:   407:edbd7dd99083
user:        Walter Landry <wlandry at caltech.edu>
date:        Sat Nov 19 10:33:47 2011 -0800
files:       tools/generate_pvd.cxx tools/vtk2csv.py
description:
Remove vtk2csv and generate_pvd


diff -r bc353ca03921 -r edbd7dd99083 tools/generate_pvd.cxx
--- a/tools/generate_pvd.cxx	Sat Nov 19 10:31:59 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/* A simple program to generate field and particle pvd files 
-
-   You will need Boost (www.boost.org) to compile this.  Almost any
-   version should do.  On Debian, you compile it with
-
-     g++ generate_pvd.cxx -o generate_pvd -lboost_filesystem -lboost_system
-
-   To generate a static binary, compile it with
-
-     g++ generate_pvd.cxx -o generate_pvd -lboost_system -lboost_filesystem -static
-
-   Usage: generate_pvd NAME TYPE START END STEP
-
-   NAME will, in general, be either 'fields' or
-   'picIntegrationPoints'.  If you create and output other swarms,
-   then use those names.
-
-   TYPE is either 's' for structured (e.g. fields) or 'u' for
-   unstructured (e.g. picIntegrationPoints'.
-
-   For example
-
-     generate_pvd fields s 0 100 10
-
-   will generate fields.pvd.  That file starts at t=0 and includes
-   every 10'th step up to and including 100.  Put the pvd file in the
-   same directory as your other output files.  Open it with Paraview,
-   and you should be able to use the movie controls (play, pause, step
-   forward/backward, jump to beginning/end) to examine the time
-   series.
-
-**  Copyright (C) 2009, 2010, California Institute of Technology
-
-**  This software is free software; you can redistribute it and/or
-**  modify it under the terms of the GNU General Public License as
-**  published by the Free Software Foundation; either version 2 of the
-**  License, or (at your option) any later version.
-**
-**  This library 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 library; if not, write to the Free Software
-**  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-**  02110-1301 USA
-*/
-
-
-#include <boost/filesystem.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <cstdlib>
-#include <iostream>
-
-namespace fs=boost::filesystem;
-using namespace std;
-
-
-int main(int argc, char *argv[])
-{
-  if(argc<5)
-    {
-      cerr << "Not enough arguments\n"
-           << "Usage: generate_pvd [name] [type] [start] [end] [step]\n";
-      exit(1);
-    }
-  string name(argv[1]);
-  string suffix(argv[2]);
-  if(suffix!="u" && suffix!="s")
-    {
-      cerr << "Wrong suffix: " << suffix << "\n"
-           << "Only 'u' and 's' allowed\n";
-      exit(1);
-    }
-
-  int start=atoi(argv[3]);
-  int end=atoi(argv[4]);
-  int step=1;
-  if(argc>5)
-    step=atoi(argv[5]);
-  
-  fs::ofstream pvd(name+".pvd");
-
-  pvd << "<?xml version=\"1.0\"?>\n"
-      << "<VTKFile type=\"Collection\" version=\"0.1\">\n"
-      << "  <Collection>\n";
-  for(int i=start; i<=end; i+=step)
-    {
-      pvd << "    <DataSet timestep=\"" << i
-          << "\" file=\"" << name << ".";
-      pvd.width(5);
-      pvd.fill('0');
-      pvd << i << ".pvt" << suffix << "\"/>\n";
-    }
-  pvd << "  </Collection>\n"
-      << "</VTKFile>\n";
-}
diff -r bc353ca03921 -r edbd7dd99083 tools/vtk2csv.py
--- a/tools/vtk2csv.py	Sat Nov 19 10:31:59 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-# vtk2csv
-# 
-# Reads in Gale pvts and/or pvtu data and combines it into a single
-# csv file that can be read by vts2matlab Requires pvpython (included
-# with paraview) to be installed.  Invoke it with something like
-#
-#   pvpython vtk2csv.py output/*.pvt[su]
-#
-# Tested with paraview 3.6.1
-#
-# It creates a csv file corresponding to each pvts and pvtu file.
-#
-# Written by Walter Landry with contributions from Bill Broadley and
-# Mark Fleharty
-#
-# Copyright (C) 2009 California Institute of Technology, University of
-# New Mexico, and the Regents of the University of California
-#
-#  This software is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License as
-#  published by the Free Software Foundation; either version 2 of the
-#  License, or (at your option) any later version.
-#
-#  This library 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 library; if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-#  02110-1301 USA
-
-def decode(vtk_file):
-    import xml.etree.ElementTree as ElementTree
-    root = ElementTree.parse(vtk_file)
-    iter = root.getiterator()
-
-    outfile=open(os.path.splitext(vtk_file)[0]+".csv","w")
-
-    fields={}
-    components={}
-    extents=""
-    for element in iter:
-        # Get the extents for use by external scripts
-        if(element.tag=="Piece"):
-            for name, value in element.items():
-                if(name=="Extent" or name=="NumberOfPoints"):
-                    extents=value
-        # Get the data for each individual variable
-        if(element.tag=="DataArray"):
-            field=""
-            comps=0
-            for name, value in element.items():
-                if (name == 'NumberOfComponents'):
-                    comps=int(value)
-                elif (name=='Name' and value!="offsets" and value!="types"):
-                    fields[value]=[]
-                    field=value
-            if field:
-                if comps:
-                    components[field]=comps
-                else:
-                    components[field]=1
-                if element.text:
-                    text = element.text
-                    text_list = text.split()
-                    aDict=dict()
-                    aDict.clear()	
-                    for i in range (0,len(text_list)):
-                        fields[field].append(text_list[i])
-
-    # Print everything out
-    if extents:
-        outfile.write("# %s\n" % extents)
-    outfile.write("# x, y, z, ")
-    for j in components:
-        if j!="Points":
-            if components==1:
-                outfile.write("%s, " % j)
-            else:
-                for k in range(0,components[j]):
-                    outfile.write("%s%d, " % (j,k))
-    outfile.write("\n")
-    for i in range(0,len(fields["Points"])/3):
-        for n in range(0,3):
-            outfile.write("%s, " % fields["Points"][i*3+n])
-        for j in fields:
-            if j!="Points":
-                for n in range(0,components[j]):
-                    outfile.write("%s, " % fields[j][i*components[j]+n])
-        outfile.write("\n")
-    # Remove the old vtk file
-    os.remove(vtk_file)
-
-
-# First open the parallel vtk xml file and write a serial xml file
-
-from paraview.servermanager import *
-Connect()
-
-for i in range(1,len(sys.argv)):
-   filename=sys.argv[i]
-   print filename
-
-   # Structured Grid
-   if os.path.splitext(filename)[1]=='.pvts':
-       vts_name=os.path.splitext(filename)[0] + ".vts"
-       reader = sources.XMLPStructuredGridReader(FileName=filename)
-       writer=writers.XMLStructuredGridWriter(Input=reader,
-                                              DataMode=0,
-                                              FileName=vts_name)
-       writer.UpdatePipeline()
-       decode(vts_name)
-       
-   # Unstructured Grid (particles)
-   elif os.path.splitext(filename)[1]=='.pvtu':
-       vtu_name=os.path.splitext(filename)[0] + ".vtu"
-       reader = sources.XMLPUnstructuredGridReader(FileName=filename)
-       writer=writers.XMLUnstructuredGridWriter(Input=reader,
-                                                DataMode=0,
-                                                FileName=vtu_name)
-       writer.UpdatePipeline()
-       decode(vtu_name)
-   else:
-       print "Skipping non-parallel VTK file:",filename
-
-



More information about the CIG-COMMITS mailing list