yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #04370
[Branch ~yade-dev/yade/trunk] Rev 2220: VTKRecorder changes:
------------------------------------------------------------
revno: 2220
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-05-13 21:09:48 +0200
message:
VTKRecorder changes:
1. clumpIds recorder changed to clumpId
2. materialID recorder changed to materialId
3. ids recorder changed to id
4. Syntax cleaning
5. Default parameter 'all' is added
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-13 15:36:03 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp 2010-05-13 19:09:48 +0000
@@ -22,20 +22,29 @@
YADE_REQUIRE_FEATURE(VTK)
CREATE_LOGGER(VTKRecorder);
-void VTKRecorder::action()
-{
+void VTKRecorder::action(){
vector<bool> recActive(REC_SENTINEL,false);
FOREACH(string& rec, recorders){
- if(rec=="spheres") recActive[REC_SPHERES]=true;
+ if(rec=="all"){
+ recActive[REC_SPHERES]=true;
+ recActive[REC_VELOCITY]=true;
+ recActive[REC_FACETS]=true;
+ recActive[REC_COLORS]=true;
+ recActive[REC_INTR]=true;
+ recActive[REC_ID]=true;
+ recActive[REC_CLUMPID]=true;
+ recActive[REC_MATERIALID]=true;
+ }
+ else if(rec=="spheres") recActive[REC_SPHERES]=true;
else if(rec=="velocity") recActive[REC_VELOCITY]=true;
else if(rec=="facets") recActive[REC_FACETS]=true;
else if(rec=="colors") recActive[REC_COLORS]=true;
else if(rec=="cpm") recActive[REC_CPM]=true;
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.");
+ else if((rec=="ids") || (rec=="id")) recActive[REC_ID]=true;
+ else if((rec=="clumpids") || (rec=="clumpId")) recActive[REC_CLUMPID]=true;
+ else if(rec=="materialId") recActive[REC_MATERIALID]=true;
+ else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: all, spheres, velocity, facets, colors, cpm, intr, id, clumpId, materialId). Ignored.");
}
// cpm needs interactions
if(recActive[REC_CPM]) recActive[REC_INTR]=true;
@@ -46,12 +55,12 @@
vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();
radii->SetNumberOfComponents(1);
radii->SetName("radii");
- vtkSmartPointer<vtkFloatArray> spheresIds = vtkSmartPointer<vtkFloatArray>::New();
- spheresIds->SetNumberOfComponents(1);
- spheresIds->SetName("IDS");
- vtkSmartPointer<vtkFloatArray> clumpIds = vtkSmartPointer<vtkFloatArray>::New();
- clumpIds->SetNumberOfComponents(1);
- clumpIds->SetName("clumpIDS");
+ vtkSmartPointer<vtkFloatArray> spheresId = vtkSmartPointer<vtkFloatArray>::New();
+ spheresId->SetNumberOfComponents(1);
+ spheresId->SetName("id");
+ vtkSmartPointer<vtkFloatArray> clumpId = vtkSmartPointer<vtkFloatArray>::New();
+ clumpId->SetNumberOfComponents(1);
+ clumpId->SetName("clumpId");
vtkSmartPointer<vtkFloatArray> spheresColors = vtkSmartPointer<vtkFloatArray>::New();
spheresColors->SetNumberOfComponents(3);
spheresColors->SetName("colors");
@@ -61,11 +70,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");
+ vtkSmartPointer<vtkFloatArray> materialId = vtkSmartPointer<vtkFloatArray>::New();
+ materialId->SetNumberOfComponents(1);
+ materialId->SetName("materialId");
-
// facets
vtkSmartPointer<vtkPoints> facetsPos = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> facetsCells = vtkSmartPointer<vtkCellArray>::New();
@@ -84,7 +92,7 @@
intrAbsForceT->SetName("absForceT");
// extras for CPM
- if(recActive[REC_CPM]) { CpmStateUpdater csu; csu.update(scene); }
+ if(recActive[REC_CPM]){ CpmStateUpdater csu; csu.update(scene); }
vtkSmartPointer<vtkFloatArray> cpmDamage = vtkSmartPointer<vtkFloatArray>::New();
cpmDamage->SetNumberOfComponents(1);
cpmDamage->SetName("cpmDamage");
@@ -131,22 +139,18 @@
FOREACH(const shared_ptr<Body>& b, *scene->bodies){
if (!b) continue;
-
- if (recActive[REC_SPHERES])
- {
+ if (recActive[REC_SPHERES]){
const Sphere* sphere = dynamic_cast<Sphere*>(b->shape.get());
- if (sphere)
- {
+ if (sphere){
if(skipNondynamic && !b->isDynamic) continue;
vtkIdType pid[1];
const Vector3r& pos = b->state->pos;
pid[0] = spheresPos->InsertNextPoint(pos[0], pos[1], pos[2]);
spheresCells->InsertNextCell(1,pid);
radii->InsertNextValue(sphere->radius);
- if (recActive[REC_IDS]) spheresIds->InsertNextValue(b->getId());
- if (recActive[REC_CLUMPIDS]) clumpIds->InsertNextValue(b->clumpId);
- if (recActive[REC_COLORS])
- {
+ if (recActive[REC_ID]) spheresId->InsertNextValue(b->getId());
+ if (recActive[REC_CLUMPID]) clumpId->InsertNextValue(b->clumpId);
+ if (recActive[REC_COLORS]){
const Vector3r& color = sphere->color;
float c[3] = {color[0],color[1],color[2]};
spheresColors->InsertNextTupleValue(c);
@@ -155,15 +159,12 @@
const Vector3r& vel = b->state->vel;
float v[3] = { vel[0],vel[1],vel[2] };
spheresVelocity->InsertNextTupleValue(v);
-
+
const Vector3r& angVel = b->state->angVel;
float av[3] = { angVel[0],angVel[1],angVel[2] };
sphAngVel->InsertNextTupleValue(av);
-
- //spheresVelocity->InsertNextTupleValue((float*)(&b->state->vel));
- //sphAngVel->InsertNextTupleValue((float*)(&b->state->angVel));
}
- if (recActive[REC_CPM]) {
+ if (recActive[REC_CPM]){
cpmDamage->InsertNextValue(YADE_PTR_CAST<CpmState>(b->state)->normDmg);
const Vector3r& ss=YADE_PTR_CAST<CpmState>(b->state)->sigma;
const Vector3r& tt=YADE_PTR_CAST<CpmState>(b->state)->tau;
@@ -173,33 +174,30 @@
cpmSigmaM->InsertNextValue((ss[0]+ss[1]+ss[2])/3.);
cpmTau->InsertNextTupleValue(t);
}
- if (recActive[REC_MATERIALID]) materialID->InsertNextValue(b->material->id);
+ if (recActive[REC_MATERIALID]) materialId->InsertNextValue(b->material->id);
continue;
}
}
- if (recActive[REC_FACETS])
- {
+ if (recActive[REC_FACETS]){
const Facet* facet = dynamic_cast<Facet*>(b->shape.get());
- if (facet)
- {
+ if (facet){
const Se3r& O = b->state->se3;
const vector<Vector3r>& localPos = facet->vertices;
Matrix3r facetAxisT=O.orientation.toRotationMatrix();
vtkSmartPointer<vtkTriangle> tri = vtkSmartPointer<vtkTriangle>::New();
vtkIdType nbPoints=facetsPos->GetNumberOfPoints();
- for (int i=0;i<3;++i) {
+ for (int i=0;i<3;++i){
Vector3r globalPos = O.position + facetAxisT * localPos[i];
facetsPos->InsertNextPoint(globalPos[0], globalPos[1], globalPos[2]);
tri->GetPointIds()->SetId(i,nbPoints+i);
}
facetsCells->InsertNextCell(tri);
- if (recActive[REC_COLORS])
- {
+ if (recActive[REC_COLORS]){
const Vector3r& color = facet->color;
float c[3] = {color[0],color[1],color[2]};
facetsColors->InsertNextTupleValue(c);
}
- if (recActive[REC_MATERIALID]) materialID->InsertNextValue(b->material->id);
+ if (recActive[REC_MATERIALID]) materialId->InsertNextValue(b->material->id);
continue;
}
}
@@ -208,41 +206,39 @@
vtkSmartPointer<vtkDataCompressor> compressor;
if(compress) compressor=vtkSmartPointer<vtkZLibDataCompressor>::New();
- if (recActive[REC_SPHERES])
- {
+ if (recActive[REC_SPHERES]){
vtkSmartPointer<vtkUnstructuredGrid> spheresUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
spheresUg->SetPoints(spheresPos);
spheresUg->SetCells(VTK_VERTEX, spheresCells);
spheresUg->GetPointData()->AddArray(radii);
- if (recActive[REC_IDS]) spheresUg->GetPointData()->AddArray(spheresIds);
- if (recActive[REC_CLUMPIDS]) spheresUg->GetPointData()->AddArray(clumpIds);
+ if (recActive[REC_ID]) spheresUg->GetPointData()->AddArray(spheresId);
+ if (recActive[REC_CLUMPID]) spheresUg->GetPointData()->AddArray(clumpId);
if (recActive[REC_COLORS]) spheresUg->GetPointData()->AddArray(spheresColors);
- if (recActive[REC_VELOCITY]) {
+ if (recActive[REC_VELOCITY]){
spheresUg->GetPointData()->AddArray(spheresVelocity);
spheresUg->GetPointData()->AddArray(sphAngVel);
}
- if (recActive[REC_CPM]) {
+ if (recActive[REC_CPM]){
spheresUg->GetPointData()->AddArray(cpmDamage);
spheresUg->GetPointData()->AddArray(cpmSigma);
spheresUg->GetPointData()->AddArray(cpmSigmaM);
spheresUg->GetPointData()->AddArray(cpmTau);
}
- if (recActive[REC_MATERIALID]) spheresUg->GetPointData()->AddArray(materialID);
+ 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";
writer->SetFileName(fn.c_str());
writer->SetInput(spheresUg);
- writer->Write();
+ writer->Write();
}
- if (recActive[REC_FACETS])
- {
+ if (recActive[REC_FACETS]){
vtkSmartPointer<vtkUnstructuredGrid> facetsUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
facetsUg->SetPoints(facetsPos);
facetsUg->SetCells(VTK_TRIANGLE, facetsCells);
if (recActive[REC_COLORS]) facetsUg->GetCellData()->AddArray(facetsColors);
- if (recActive[REC_MATERIALID]) facetsUg->GetPointData()->AddArray(materialID);
+ 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";
@@ -250,8 +246,7 @@
writer->SetInput(facetsUg);
writer->Write();
}
- if (recActive[REC_INTR])
- {
+ if (recActive[REC_INTR]){
vtkSmartPointer<vtkUnstructuredGrid> intrUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
intrUg->SetPoints(intrBodyPos);
intrUg->SetCells(VTK_LINE, intrCells);
@@ -264,7 +259,7 @@
string fn=fileName+"intrs."+lexical_cast<string>(scene->currentIteration)+".vtu";
writer->SetFileName(fn.c_str());
writer->SetInput(intrUg);
- writer->Write();
+ writer->Write();
}
//vtkSmartPointer<vtkMultiBlockDataSet> multiblockDataset = vtkSmartPointer<vtkMultiBlockDataSet>::New();
=== modified file 'pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-13 15:36:03 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-13 19:09:48 +0000
@@ -4,15 +4,17 @@
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,REC_MATERIALID};
+ enum {REC_SPHERES=0,REC_FACETS,REC_COLORS,REC_CPM,REC_INTR,REC_VELOCITY,REC_ID,REC_CLUMPID,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``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;
+ ((vector<string>,recorders,,"List of active recorders (as strings). Accepted recorders are:\n\n``all``\n\tSaves all possible parameters, except of specific. Default value.\n``spheres``\n\tSaves positions and radii (``radii``) of :yref:`spherical<Sphere>` particles.\n``id``\n\tSaves id's (field ``id``) of spheres; active only if ``spheres`` is active.\n``clumpId``\n\tSaves id's of clumps to which each sphere belongs (field ``clumpId``); 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;
+ if (recorders.empty()) {recorders.push_back("all");} //Default value
);
DECLARE_LOGGER;
};