4
4
// Modified by Garth N. Wells 2005
6
6
// First added: 2003-05-06
7
// Last changed: 2006-02-13
7
// Last changed: 2006-11-14
9
9
#include <dolfin/dolfin_log.h>
10
10
#include <dolfin/Vector.h>
35
35
FILE *fp = fopen(filename.c_str(), "a");
37
// Get array (assumes uniprocessor case)
41
38
fprintf(fp, "%s = [", x.name().c_str());
42
39
for (unsigned int i = 0; i < x.size(); i++)
43
fprintf(fp, " %.15g", xx[i]);
41
// FIXME: This is a slow way to access PETSc vectors. Need a fast way
42
// which is consistent for different vector types.
44
fprintf(fp, " %.15g", temp);
44
46
fprintf(fp, " ];\n");
83
82
if ( counter == 0 )
84
83
fprintf(fp,"points = [");
86
fprintf(fp,"points{%d} = [", counter + 1);
87
for (VertexIterator n(mesh); !n.end(); ++n) {
91
if ( mesh.type() == Mesh::triangles ) {
93
fprintf(fp,"%.15f %.15f]';\n", p.x, p.y);
85
fprintf(fp,"points{%u} = [", counter + 1);
86
for (VertexIterator v(mesh); !v.end();)
91
if ( mesh.type().cellType() == CellType::triangle )
94
fprintf(fp,"%.15f %.15f]';\n", p.x(), p.y());
95
fprintf(fp,"%.15f %.15f\n", p.x, p.y );
96
fprintf(fp,"%.15f %.15f\n", p.x(), p.y() );
99
fprintf(fp,"%.15f %.15f %.15f]';\n", p.x, p.y, p.z);
100
fprintf(fp,"%.15f %.15f %.15f]';\n", p.x(), p.y(), p.z());
101
fprintf(fp,"%.15f %.15f %.15f\n", p.x, p.y, p.z);
102
fprintf(fp,"%.15f %.15f %.15f\n", p.x(), p.y(), p.z());
105
105
fprintf(fp,"\n");
108
108
if ( counter == 0 )
109
109
fprintf(fp,"cells = [");
111
fprintf(fp,"cells{%d} = [", counter + 1);
112
for (CellIterator c(mesh); !c.end(); ++c)
111
fprintf(fp,"cells{%u} = [", counter + 1);
112
for (CellIterator c(mesh); !c.end();)
114
for (VertexIterator n(c); !n.end(); ++n)
115
fprintf(fp, "%d ", n->id() + 1);
114
for (VertexIterator v(c); !v.end(); ++v)
115
fprintf(fp, "%u ", (v->index()) + 1 );
118
119
fprintf(fp, "]';\n");
120
121
fprintf(fp, "\n");
126
127
if ( counter == 0 )
127
128
fprintf(fp,"edges = [1;2;0;0;0;0;0];\n\n");
129
fprintf(fp,"edges{%d} = [1;2;0;0;0;0;0];\n\n", counter + 1);
130
fprintf(fp,"edges{%u} = [1;2;0;0;0;0;0];\n\n", counter + 1);
167
168
fprintf(fp, "%s = [", u.name().c_str());
168
169
for (unsigned int i = 0; i < u.vectordim(); i++)
170
for (VertexIterator n(u.mesh()); !n.end(); ++n)
171
fprintf(fp, " %.15f", u(*n, i));
171
for (VertexIterator v(u.mesh()); !v.end(); ++v)
172
fprintf(fp, " %.15f", u(*v, i));
172
173
fprintf(fp, ";");
174
175
fprintf(fp, " ]';\n\n");
178
fprintf(fp, "%s{%d} = [", u.name().c_str(), counter1 + 1);
179
fprintf(fp, "%s{%u} = [", u.name().c_str(), counter1 + 1);
179
180
for (unsigned int i = 0; i < u.vectordim(); i++)
181
for (VertexIterator n(u.mesh()); !n.end(); ++n)
182
fprintf(fp, " %.15f", u(*n, i));
182
for (VertexIterator v(u.mesh()); !v.end(); ++v)
183
fprintf(fp, " %.15f", u(*v, i));
183
184
fprintf(fp, ";");
185
186
fprintf(fp, " ]';\n\n");