← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1958: - Add a function KLA::DefToFile() writing the triangulation and deformations to a file

 

------------------------------------------------------------
revno: 1958
committer: Bruno Chareyre <bchareyre@r1arduina>
branch nick: trunk
timestamp: Mon 2010-01-11 18:18:22 +0100
message:
  - Add a function KLA::DefToFile() writing the triangulation and deformations to a file
  - Use it in MMAnalyser. 
modified:
  lib/triangulation/KinematicLocalisationAnalyser.cpp
  lib/triangulation/KinematicLocalisationAnalyser.hpp
  pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.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	2009-12-13 19:58:33 +0000
+++ lib/triangulation/KinematicLocalisationAnalyser.cpp	2010-01-11 17:18:22 +0000
@@ -13,14 +13,14 @@
 #include "Tesselation.h"
 #include "KinematicLocalisationAnalyser.hpp"
 #include "TriaxialState.h"
-
-
+
+
 #include <iostream>
 #include <fstream>
 #include <sstream>
 //#include <utility>
-
-namespace CGT {
+
+namespace CGT {
 
 int n_debug = 0;
 //cerr << "n_debug=" << n_debug++ << endl;   /// DEBUG LINE  ///
@@ -165,8 +165,40 @@
 	return filteredList;
 }
 
-
-bool KinematicLocalisationAnalyser::ToFile (const char* output_file_name)
+bool KinematicLocalisationAnalyser::DefToFile(const char* output_file_name)
+{
+	ofstream output_file(output_file_name);
+	if (!output_file.is_open()) {
+		cerr << "Error opening files";
+		return false;
+	}
+	ComputeParticlesDeformation();
+
+	Tesselation& Tes = TS1->tesselation();
+	RTriangulation& Tri = Tes.Triangulation();
+
+	output_file << Tri.number_of_vertices();
+	for (RTriangulation::Finite_vertices_iterator  V_it =
+				Tri.finite_vertices_begin(); V_it !=  Tri.finite_vertices_end(); V_it++)
+		output_file<<V_it->info().id()<<" "<<V_it->point()<<endl;
+	
+	output_file << Tri.number_of_finite_cells();
+	Finite_cells_iterator cell = Tri.finite_cells_begin();
+	Finite_cells_iterator cell0 = Tri.finite_cells_end();
+	for (; cell != cell0; cell++) {
+		for (unsigned int index=0; index<4; index++) output_file << cell->vertex(index)->info().id()<<" " ;
+		output_file<<endl;
+	}
+
+	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
+		double dev = (double) epsilon.Deviatoric().Norme();
+		output_file<<V_it->info().id()<<" "<<ParticleDeformation[V_it->info().id()]<<endl<<dev<<endl;
+	}
+}
+
+bool KinematicLocalisationAnalyser::DistribsToFile (const char* output_file_name)
 {
 	ofstream output_file (output_file_name);
 	if (!output_file.is_open())	{
@@ -1041,4 +1073,4 @@
 
 
 
-} // namespace CGT
+} // namespace CGT

=== modified file 'lib/triangulation/KinematicLocalisationAnalyser.hpp'
--- lib/triangulation/KinematicLocalisationAnalyser.hpp	2009-12-22 23:52:51 +0000
+++ lib/triangulation/KinematicLocalisationAnalyser.hpp	2010-01-11 17:18:22 +0000
@@ -36,16 +36,11 @@
 
 class KinematicLocalisationAnalyser
 {
-
-
-
 	public:
-
 		typedef vector< pair<Real,Real> > RGrid1D;
 		typedef vector<vector <Real> >  RGrid2D;
 		typedef vector<vector<vector<Real> > > RGrid3D;
 
-
 		KinematicLocalisationAnalyser();
 		KinematicLocalisationAnalyser ( const char* state_file1 );
 		KinematicLocalisationAnalyser ( const char* state_file1, const char* state_file0, bool consecutive_files = true );
@@ -59,7 +54,9 @@
 		void SetNO_ZERO_ID (bool);
 		void SwitchStates ( void );
 
-		bool ToFile ( const char* output_file_name );
+		bool DistribsToFile (const char* output_file_name);
+		///Write the averaged deformation on each grain in a file (vertices and cells lists included in the file), no need to call ComputeParticlesDeformation()
+		bool DefToFile (const char* output_file_name = "deformations");
 		ofstream& ContactDistributionToFile ( ofstream& output_file );
 		ofstream& AllNeighborDistributionToFile ( ofstream& output_file );
 		ofstream& StrictNeighborDistributionToFile ( ofstream& output_file );

=== modified file 'pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp'
--- pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp	2010-01-11 16:12:57 +0000
+++ pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp	2010-01-11 17:18:22 +0000
@@ -48,6 +48,9 @@
 	else if (Omega::instance().getCurrentIteration() % interval == 0) {
 		setState(ncb, 2, true, true);
 		analyser->ComputeParticlesDeformation();
+		for (int i=0; i<analyser->ParticleDeformation.size();i++) cerr<< analyser->ParticleDeformation[i]<<endl;
+		analyser->DefToFile();
+		
 		CGT::Tenseur_sym3 epsg(analyser->grad_u_total);
 		ofile << Omega::instance().getCurrentIteration() << analyser->Delta_epsilon(1,1)<<" "<<analyser->Delta_epsilon(2,2)<<" "<<analyser->Delta_epsilon(3,3)<<" "<<epsg(1,1)<<" "<<epsg(2,2)<< " "<<epsg(3,3)<<" "<<epsg(1,2)<<" "<<epsg(1,3)<<" "<<epsg(2,3)<<endl;
 		analyser->SwitchStates();