[cig-commits] commit: Now writes vtk
Mercurial
hg at geodynamics.org
Fri Feb 10 16:00:09 PST 2012
changeset: 11:d3cfe8600192
user: Walter Landry <wlandry at caltech.edu>
date: Mon Nov 28 14:10:42 2011 -0800
files: initial.cxx main.cxx write_vtk.hxx wscript
description:
Now writes vtk
diff -r d2666ac3ef8e -r d3cfe8600192 initial.cxx
--- a/initial.cxx Mon Nov 28 12:07:54 2011 -0800
+++ b/initial.cxx Mon Nov 28 14:10:42 2011 -0800
@@ -1,6 +1,7 @@
#include <complex>
#include "Model.hxx"
#include "constants.hxx"
+#include "write_vtk.hxx"
void initial(const Model &model, double zx[N+1][N], double zy[N][N+1],
double log_etax[N+1][N], double log_etay[N][N+1],
@@ -151,4 +152,7 @@ void initial(const Model &model, double
}
}
}
+ write_vtk("p_initial",N,N,p);
+ write_vtk("zx_initial",N+1,N,zx);
+ write_vtk("zy_initial",N,N,zy);
}
diff -r d2666ac3ef8e -r d3cfe8600192 main.cxx
--- a/main.cxx Mon Nov 28 12:07:54 2011 -0800
+++ b/main.cxx Mon Nov 28 14:10:42 2011 -0800
@@ -32,6 +32,7 @@ int main()
initial(model,zx,zy,log_etax,log_etay,p,fx,fy);
+ return 0;
for(int iteration=0;iteration<max_iterations;++iteration)
{
/* Compute the boundary jumps */
diff -r d2666ac3ef8e -r d3cfe8600192 write_vtk.hxx
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/write_vtk.hxx Mon Nov 28 14:10:42 2011 -0800
@@ -0,0 +1,34 @@
+#include "boost/filesystem.hpp"
+#include "boost/filesystem/fstream.hpp"
+#include <fstream>
+
+template<int NY>
+void write_vtk(const std::string &name, int NX, int N, const double data[][NY])
+{
+ boost::filesystem::create_directory("output");
+ boost::filesystem::ofstream initial("output/"+name+".vtk");
+
+ initial << "# vtk DataFile Version 2.0\n"
+ << name << "\n"
+ << "ASCII\n"
+ << "DATASET STRUCTURED_POINTS\n"
+ << "DIMENSIONS "
+ << NX << " "
+ << NY << " "
+ << "1\n"
+ << "ORIGIN 0 0 0\n"
+ << "SPACING "
+ << (1.0/N) << " "
+ << (1.0/N) << " "
+ << (1.0/N) << "\n"
+ << "POINT_DATA "
+ << NX*NY << "\n"
+ << "SCALARS " << name << " double 1\n"
+ << "LOOKUP_TABLE default\n";
+
+ for(int j=0;j<NY;++j)
+ for(int i=0;i<NX;++i)
+ {
+ initial << data[i][j] << "\n";
+ }
+}
diff -r d2666ac3ef8e -r d3cfe8600192 wscript
--- a/wscript Mon Nov 28 12:07:54 2011 -0800
+++ b/wscript Mon Nov 28 14:10:42 2011 -0800
@@ -15,4 +15,5 @@ def build(bld):
target = 'Gamr_disc',
# cxxflags = ['-std=c++0x','-g','-D_GLIBCXX_DEBUG'],
cxxflags = ['-std=c++0x','-O3'],
+ lib = ['boost_filesystem', 'boost_system'],
)
More information about the CIG-COMMITS
mailing list