yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #04371
[Branch ~yade-dev/yade/trunk] Rev 2221: subscribedBodies parameter is added to VTKRecorder
------------------------------------------------------------
revno: 2221
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-05-13 21:49:44 +0200
message:
subscribedBodies parameter is added to VTKRecorder
added:
pkg/dem/Engine/GlobalEngine/VTKRecorder.inc
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 19:09:48 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp 2010-05-13 19:49:44 +0000
@@ -137,72 +137,18 @@
}
}
- FOREACH(const shared_ptr<Body>& b, *scene->bodies){
- if (!b) continue;
- if (recActive[REC_SPHERES]){
- const Sphere* sphere = dynamic_cast<Sphere*>(b->shape.get());
- 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_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);
- }
- if(recActive[REC_VELOCITY]){
- 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);
- }
- 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;
- float s[3]={ss[0],ss[1],ss[2]};
- float t[3]={tt[0],tt[1],tt[2]};
- cpmSigma->InsertNextTupleValue(s);
- cpmSigmaM->InsertNextValue((ss[0]+ss[1]+ss[2])/3.);
- cpmTau->InsertNextTupleValue(t);
- }
- if (recActive[REC_MATERIALID]) materialId->InsertNextValue(b->material->id);
- continue;
- }
+ if (subscribedBodies.empty()) {
+ FOREACH(const shared_ptr<Body>& b, *scene->bodies){
+ #include"VTKRecorder.inc"
}
- if (recActive[REC_FACETS]){
- const Facet* facet = dynamic_cast<Facet*>(b->shape.get());
- 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){
- 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]){
- 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);
- continue;
- }
+ } else {
+ FOREACH(body_id_t id,subscribedBodies){
+ assert(id<(body_id_t)scene->bodies->size());
+ Body* b=Body::byId(id,scene).get();
+ #include"VTKRecorder.inc"
}
}
-
+
vtkSmartPointer<vtkDataCompressor> compressor;
if(compress) compressor=vtkSmartPointer<vtkZLibDataCompressor>::New();
=== modified file 'pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-13 19:09:48 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-13 19:49:44 +0000
@@ -11,7 +11,8 @@
((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``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")),
+ ((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"))
+ ((std::vector<int>,subscribedBodies,,"List of bodies, which will be exported. If empty - all bodies will be exported.")),
/*ctor*/
initRun=true;
if (recorders.empty()) {recorders.push_back("all");} //Default value
=== added file 'pkg/dem/Engine/GlobalEngine/VTKRecorder.inc'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.inc 1970-01-01 00:00:00 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.inc 2010-05-13 19:49:44 +0000
@@ -0,0 +1,64 @@
+
+ if (!b) continue;
+ if (recActive[REC_SPHERES]){
+ const Sphere* sphere = dynamic_cast<Sphere*>(b->shape.get());
+ 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_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);
+ }
+ if(recActive[REC_VELOCITY]){
+ 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);
+ }
+ 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;
+ float s[3]={ss[0],ss[1],ss[2]};
+ float t[3]={tt[0],tt[1],tt[2]};
+ cpmSigma->InsertNextTupleValue(s);
+ cpmSigmaM->InsertNextValue((ss[0]+ss[1]+ss[2])/3.);
+ cpmTau->InsertNextTupleValue(t);
+ }
+ if (recActive[REC_MATERIALID]) materialId->InsertNextValue(b->material->id);
+ continue;
+ }
+ }
+ if (recActive[REC_FACETS]){
+ const Facet* facet = dynamic_cast<Facet*>(b->shape.get());
+ 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){
+ 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]){
+ 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);
+ continue;
+ }
+ }
Follow ups