yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #03032
[Branch ~yade-dev/yade/trunk] Rev 1963: Rewrite KinematicLocalisationAnalyser::DefToFile for vtk format.
------------------------------------------------------------
revno: 1963
committer: Vincent Richefeu <richefeu@macbook-pro-de-vincent-richefeu.local>
branch nick: trunk
timestamp: Tue 2010-01-12 15:35:36 +0100
message:
Rewrite KinematicLocalisationAnalyser::DefToFile for vtk format.
modified:
lib/triangulation/KinematicLocalisationAnalyser.cpp
lib/triangulation/basicVTKwritter.cpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== modified file 'lib/triangulation/KinematicLocalisationAnalyser.cpp'
--- lib/triangulation/KinematicLocalisationAnalyser.cpp 2010-01-11 19:59:22 +0000
+++ lib/triangulation/KinematicLocalisationAnalyser.cpp 2010-01-12 14:35:36 +0000
@@ -190,6 +190,51 @@
bool KinematicLocalisationAnalyser::DefToFile(const char* output_file_name)
{
+ ComputeParticlesDeformation();
+ Tesselation& Tes = TS1->tesselation();
+ RTriangulation& Tri = Tes.Triangulation();
+ basicVTKwritter vtk((unsigned int)(Tri.number_of_vertices()), (unsigned int)(Tri.number_of_finite_cells()));
+ vtk.open(output_file_name, "test bidon"); // <- what a pretty comment!
+
+ vtk.begin_vertices();
+ RTriangulation::Finite_vertices_iterator V_it = Tri.finite_vertices_begin();
+ for (; V_it != Tri.finite_vertices_end(); ++V_it) vtk.file << V_it->point() << endl;
+ vtk.end_vertices();
+
+ vtk.begin_cells();
+ Finite_cells_iterator cell = Tri.finite_cells_begin();
+ for (; cell != Tri.finite_cells_end(); ++cell)
+ {
+ vtk.write_cell(
+ cell->vertex(0)->info().id(),
+ cell->vertex(1)->info().id(),
+ cell->vertex(2)->info().id(),
+ cell->vertex(3)->info().id()
+ );
+ }
+ vtk.end_cells();
+
+ vtk.begin_data("Strain_matrix", POINT_DATA, TENSORS, FLOAT);
+ V_it = finite_vertices_begin();
+ for (; V_it != Tri.finite_vertices_end(); ++V_it)
+ {
+ Tenseur_sym3 epsilon(ParticleDeformation[V_it->info().id()]);
+ vtk.file << ParticleDeformation[V_it->info().id()] << endl;
+ }
+ vtk.end_data();
+
+ vtk.begin_data("Strain_deviator", POINT_DATA, SCALARS, FLOAT);
+ V_it = finite_vertices_begin();
+ for (; V_it != Tri.finite_vertices_end(); ++V_it)
+ {
+ Tenseur_sym3 epsilon(ParticleDeformation[V_it->info().id()]);
+ vtk.write_data( (float) epsilon.Deviatoric().Norme() );
+ }
+ vtk.end_data();
+
+ return true;
+
+ /*
ofstream output_file(output_file_name);
if (!output_file.is_open()) {
cerr << "Error opening files";
@@ -215,10 +260,11 @@
for (RTriangulation::Finite_vertices_iterator V_it =
Tri.finite_vertices_begin(); V_it != Tri.finite_vertices_end(); V_it++) {
- Tenseur_sym3 epsilon(ParticleDeformation[V_it->info().id()]); // partie sym�trique
+ Tenseur_sym3 epsilon(ParticleDeformation[V_it->info().id()]); // partie symetrique
double dev = (double) epsilon.Deviatoric().Norme();
output_file<<V_it->info().id()<<endl<<ParticleDeformation[V_it->info().id()]<<dev<<endl;
- }
+ }
+ */
}
bool KinematicLocalisationAnalyser::DistribsToFile (const char* output_file_name)
=== modified file 'lib/triangulation/basicVTKwritter.cpp'
--- lib/triangulation/basicVTKwritter.cpp 2009-12-22 18:19:41 +0000
+++ lib/triangulation/basicVTKwritter.cpp 2010-01-12 14:35:36 +0000
@@ -2,22 +2,22 @@
using namespace std;
-void basicVTKwritter::open(const char * filename, const char * comment)
+bool basicVTKwritter::open(const char * filename, const char * comment)
{
file.open(filename,ios_base::out);
if (!file)
{
cerr << "Cannot open file [" << filename << "]" << endl;
- return;
+ return false;
}
// Header
- file << "# vtk DataFile Version 2.0" << endl;
+ file << "# vtk DataFile Version 3.0" << endl;
file << comment << endl;
file << "ASCII" << endl;
file << "DATASET UNSTRUCTURED_GRID" << endl;
file << endl;
-
+ return true;
}
void basicVTKwritter::begin_vertices()
Follow ups