← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2219: `materialID` property is added to VTKRecorder

 

------------------------------------------------------------
revno: 2219
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-05-13 17:36:03 +0200
message:
  `materialID` property is added to VTKRecorder
modified:
  pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp
  pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp


--
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 'pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp	2010-05-04 13:56:05 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp	2010-05-13 15:36:03 +0000
@@ -34,6 +34,7 @@
 		else if(rec=="intr") recActive[REC_INTR]=true;
 		else if(rec=="ids") recActive[REC_IDS]=true;
 		else if(rec=="clumpids") recActive[REC_CLUMPIDS]=true;
+		else if(rec=="materialID") recActive[REC_MATERIALID]=true;
 		else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: spheres, velocity, facets, colors, cpm, intr, ids, clumpids). Ignored.");
 	}
 	// cpm needs interactions
@@ -60,6 +61,10 @@
 	vtkSmartPointer<vtkFloatArray> sphAngVel = vtkSmartPointer<vtkFloatArray>::New();
 	sphAngVel->SetNumberOfComponents(3);
 	sphAngVel->SetName("angVel");
+	vtkSmartPointer<vtkFloatArray> materialID = vtkSmartPointer<vtkFloatArray>::New();
+	materialID->SetNumberOfComponents(1);
+	materialID->SetName("materialID");
+	
 
 	// facets
 	vtkSmartPointer<vtkPoints> facetsPos = vtkSmartPointer<vtkPoints>::New();
@@ -168,6 +173,7 @@
 					cpmSigmaM->InsertNextValue((ss[0]+ss[1]+ss[2])/3.);
 					cpmTau->InsertNextTupleValue(t);
 				}
+				if (recActive[REC_MATERIALID]) materialID->InsertNextValue(b->material->id);
 				continue;
 			}
 		}
@@ -193,6 +199,7 @@
 					float c[3] = {color[0],color[1],color[2]};
 					facetsColors->InsertNextTupleValue(c);
 				}
+				if (recActive[REC_MATERIALID]) materialID->InsertNextValue(b->material->id);
 				continue;
 			}
 		}
@@ -220,6 +227,8 @@
 			spheresUg->GetPointData()->AddArray(cpmSigmaM);
 			spheresUg->GetPointData()->AddArray(cpmTau);
 		}
+		if (recActive[REC_MATERIALID]) spheresUg->GetPointData()->AddArray(materialID);
+		
 		vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
 		if(compress) writer->SetCompressor(compressor);
 		string fn=fileName+"spheres."+lexical_cast<string>(scene->currentIteration)+".vtu";
@@ -233,6 +242,7 @@
 		facetsUg->SetPoints(facetsPos);
 		facetsUg->SetCells(VTK_TRIANGLE, facetsCells);
 		if (recActive[REC_COLORS]) facetsUg->GetCellData()->AddArray(facetsColors);
+		if (recActive[REC_MATERIALID]) facetsUg->GetPointData()->AddArray(materialID);
 		vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
 		if(compress) writer->SetCompressor(compressor);
 		string fn=fileName+"facets."+lexical_cast<string>(scene->currentIteration)+".vtu";

=== modified file 'pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp	2010-04-26 13:58:23 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp	2010-05-13 15:36:03 +0000
@@ -4,14 +4,14 @@
 
 class VTKRecorder: public PeriodicEngine {
 	public:
-		enum {REC_SPHERES=0,REC_FACETS,REC_COLORS,REC_CPM,REC_INTR,REC_VELOCITY,REC_IDS,REC_CLUMPIDS,REC_SENTINEL};
+		enum {REC_SPHERES=0,REC_FACETS,REC_COLORS,REC_CPM,REC_INTR,REC_VELOCITY,REC_IDS,REC_CLUMPIDS,REC_SENTINEL,REC_MATERIALID};
 		virtual void action();
 	YADE_CLASS_BASE_DOC_ATTRS_CTOR(VTKRecorder,PeriodicEngine,"Engine recording snapshots of simulation into series of *.vtu files, readable by VTK-based postprocessing programs such as Paraview. Both bodies (spheres and facets) and interactions can be recorded, with various vector/scalar quantities that are defined on them.\n\n:yref:`PeriodicEngine.initRun` is initialized to ``True`` automatically.",
 		((bool,compress,false,"Compress output XML files [experimental]."))
 		((bool,skipFacetIntr,true,"Skip interactions with facets, when saving interactions"))
 		((bool,skipNondynamic,false,"Skip non-dynamic spheres (but not facets)."))
 		((string,fileName,"","Base file name; it will be appended with {spheres,intrs,facets}-243100.vtu depending on active recorders and step number (243100 in this case). It can contain slashes, but the directory must exist already."))
-		((vector<string>,recorders,,"List of active recorders (as strings). Accepted recorders are:\n\n``spheres``\n\tSaves positions and radii (``radii``) of :yref:`spherical<Sphere>` particles.\n``ids``\n\tSaves id's (field ``IDS``) of spheres; active only if ``spheres`` is active.\n``clumpids``\n\tSaves id's of clumps to which each sphere belongs (field ``clumpIDS``); active only if ``spheres`` is active.\n``colors``\n\tSaves colors of :yref:`spheres<Sphere>` and of :yref:`facets<Facet>` (field ``colors`` spheres and ``Colors`` for facets); only active if ``spheres`` or ``facets`` is activated.\n``velocity``\n\tSaves linear and angular velocities of spherical particles (fields ``velocity`` and ``angVel`` respectively``); only effective with ``spheres``.\n``facets``\n\tSave :yref:`facets<Facet>` positions (vertices).\n``cpm``\n\tSaves data pertaining to the :yref:`concrete model<Law2_Dem3DofGeom_CpmPhys_Cpm>`: ``cpmDamage`` (normalized residual strength averaged on particle), ``cpmSigma`` (stress on particle, normal components), ``cpmTau`` (shear components of stress on particle), ``cpmSigmaM`` (mean stress around particle); ``intr`` is activated automatically by ``cpm``.\n``intr``\n\tWhen ``cpm`` is used, it saves magnitude of normal (``forceN``) and shear (``absForceT``) forces.\n\n\tWithout ``cpm``, saves [TODO]\n\n")),
+		((vector<string>,recorders,,"List of active recorders (as strings). Accepted recorders are:\n\n``spheres``\n\tSaves positions and radii (``radii``) of :yref:`spherical<Sphere>` particles.\n``ids``\n\tSaves id's (field ``IDS``) of spheres; active only if ``spheres`` is active.\n``clumpids``\n\tSaves id's of clumps to which each sphere belongs (field ``clumpIDS``); active only if ``spheres`` is active.\n``colors``\n\tSaves colors of :yref:`spheres<Sphere>` and of :yref:`facets<Facet>` (field ``colors`` spheres and ``Colors`` for facets); only active if ``spheres`` or ``facets`` is activated.\n``materialID``\n\tSaves materialID of :yref:`spheres<Sphere>` and of :yref:`facets<Facet>`; only active if ``spheres`` or ``facets`` is activated.\n``velocity``\n\tSaves linear and angular velocities of spherical particles (fields ``velocity`` and ``angVel`` respectively``); only effective with ``spheres``.\n``facets``\n\tSave :yref:`facets<Facet>` positions (vertices).\n``cpm``\n\tSaves data pertaining to the :yref:`concrete model<Law2_Dem3DofGeom_CpmPhys_Cpm>`: ``cpmDamage`` (normalized residual strength averaged on particle), ``cpmSigma`` (stress on particle, normal components), ``cpmTau`` (shear components of stress on particle), ``cpmSigmaM`` (mean stress around particle); ``intr`` is activated automatically by ``cpm``.\n``intr``\n\tWhen ``cpm`` is used, it saves magnitude of normal (``forceN``) and shear (``absForceT``) forces.\n\n\tWithout ``cpm``, saves [TODO]\n\n")),
 		/*ctor*/ initRun=true;
 	);
 	DECLARE_LOGGER;


Follow ups