Commit de269c6a authored by Jonathan Lambrechts's avatar Jonathan Lambrechts

fix vtk output

parent 4d2a7402
......@@ -45,6 +45,16 @@ class ScontactInterface :
self._p.write(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
def write_vtk(self, odir, i, t) :
outputname = "%s/part-%05i.vtp" % (odir, i)
self._p.writeVtk(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
def write_boundary_vtk(self, odir, i, t) :
outputname = "%s/boundary-%05i.vtp" % (odir, i)
self._p.writeBoundaryVtk(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
class MeshLoader(object) :
......
......@@ -42,5 +42,15 @@ class ScontactInterface :
self._p.write(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
def write_vtk(self, odir, i, t) :
outputname = "%s/part-%05i.vtp" % (odir, i)
self._p.writeVtk(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
def write_boundary_vtk(self, odir, i, t) :
outputname = "%s/boundary-%05i.vtp" % (odir, i)
self._p.writeBoundaryVtu(outputname + "_tmp")
shutil.move(outputname + "_tmp", outputname)
......@@ -765,7 +765,7 @@ void particleProblemWrite(const ParticleProblem *p, const char *filename) {
fclose(output);
}
void particleProblemWriteVtu(ParticleProblem *p, const char *filename) {
void particleProblemWriteVtk(ParticleProblem *p, const char *filename) {
FILE *f = fopen(filename, "w");
fprintf(f, "<VTKFile type=\"PolyData\">\n");
fprintf(f, "<PolyData>\n");
......@@ -795,14 +795,13 @@ void particleProblemWriteVtu(ParticleProblem *p, const char *filename) {
#endif
}
fprintf(f, "\n</DataArray>\n</Points>\n");
//fprintf(f, "<Cells>\n<DataArray type=\"Int32\" Name=\"connectivity\" />\n<DataArray type=\"Int32\" Name=\"offsets\" />\n<DataArray type=\"UInt8\" Name=\"types\" />\n</Cells>\n");
//fprintf(f, "</Piece>\n");
fprintf(f, "</Piece>\n");
fprintf(f, "</PolyData>\n");
fprintf(f, "</VTKFile>\n");
fclose(f);
}
void particleProblemWriteBoundaryVtu(ParticleProblem *p, const char *filename) {
void particleProblemWriteBoundaryVtk(ParticleProblem *p, const char *filename) {
FILE *f = fopen(filename, "w");
fprintf(f, "<VTKFile type=\"PolyData\">\n");
fprintf(f, "<PolyData>\n");
......
......@@ -27,8 +27,8 @@ double *particleProblemPosition(ParticleProblem *p);
double *particleProblemExternalForces(ParticleProblem *p);
unsigned long int particleProblemNParticle(ParticleProblem *p);
void particleProblemUseJacobi(ParticleProblem *p, int jacobi, double relax);
void particleProblemWriteVtu(ParticleProblem *p, const char *filename);
void particleProblemWriteBoundaryVtu(ParticleProblem *p, const char *filename);
void particleProblemWriteVtk(ParticleProblem *p, const char *filename);
void particleProblemWriteBoundaryVtk(ParticleProblem *p, const char *filename);
double *particleProblemRadius(ParticleProblem *p);
int *particleProblemDiskTag(ParticleProblem *p);
int *particleProblemSegmentTag(ParticleProblem *p);
......
......@@ -142,8 +142,8 @@ struct ParticleProblem{};
PyObject *position() {return coordVector2PyArray(particleProblemPosition($self->_this), particleProblemNParticle($self->_this), DIMENSION);}
PyObject *externalForces() {return coordVector2PyArray(particleProblemExternalForces($self->_this), particleProblemNParticle($self->_this), DIMENSION);}
void useJacobi(int jacobi, double relax = 0.5) {particleProblemUseJacobi($self->_this, jacobi, relax);}
void writeVtu(const char *filename) {particleProblemWriteVtu($self->_this, filename);}
void writeBoundaryVtu(const char *filename) {particleProblemWriteBoundaryVtu($self->_this, filename);}
void writeVtk(const char *filename) {particleProblemWriteVtk($self->_this, filename);}
void writeBoundaryVtk(const char *filename) {particleProblemWriteBoundaryVtk($self->_this, filename);}
};
PyObject *particleToMesh(PyObject *position, PyObject *elements);
......@@ -60,9 +60,9 @@ mv.velocity = -1/tEnd
p.setBoundaryVelocity("Pile", [0, mv.velocity])
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
p.write(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t)
fluid.write_position(outputdir, ii, t)
p.write_vtk(outputdir, ii, t)
p.write_boundary_vtk(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t, "vtk")
tic = time.clock()
......@@ -74,7 +74,7 @@ while t < tEnd :
mv.position += dt * mv.velocity
t += dt
ii += 1
p.write(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t)
fluid.write_position(outputdir, ii, t)
p.write_vtk(outputdir, ii, t)
p.write_boundary_vtk(outputdir, ii, t)
fluid.write_solution(outputdir, ii, t, "vtk")
print("%i : %.2g/%.2g" % (ii, t, tEnd))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment