yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #04434
[Branch ~yade-dev/yade/trunk] Rev 2233: VtkRecorder changes:
------------------------------------------------------------
revno: 2233
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-05-17 17:08:57 +0200
message:
VtkRecorder changes:
1. Velocities of particles are now exported as Vector3 and Length component separately.
2. Added 'force' parameter for facets and spheres (sorry, not good tested yet)
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-14 18:35:45 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.cpp 2010-05-17 15:08:57 +0000
@@ -34,6 +34,7 @@
recActive[REC_ID]=true;
recActive[REC_CLUMPID]=true;
recActive[REC_MATERIALID]=true;
+ recActive[REC_FORCE]=true;
}
else if(rec=="spheres") recActive[REC_SPHERES]=true;
else if(rec=="velocity") recActive[REC_VELOCITY]=true;
@@ -44,7 +45,8 @@
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, color, cpm, intr, id, clumpId, materialId). Ignored.");
+ else if(rec=="force") recActive[REC_FORCE]=true;
+ else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: all, spheres, velocity, facets, color, force, cpm, intr, id, clumpId, materialId). Ignored.");
}
// cpm needs interactions
if(recActive[REC_CPM]) recActive[REC_INTR]=true;
@@ -52,24 +54,47 @@
// spheres
vtkSmartPointer<vtkPoints> spheresPos = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> spheresCells = vtkSmartPointer<vtkCellArray>::New();
+
vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();
radii->SetNumberOfComponents(1);
radii->SetName("radii");
+
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("color");
- vtkSmartPointer<vtkFloatArray> spheresVelocity = vtkSmartPointer<vtkFloatArray>::New();
- spheresVelocity->SetNumberOfComponents(3);
- spheresVelocity->SetName("velocity");
- vtkSmartPointer<vtkFloatArray> sphAngVel = vtkSmartPointer<vtkFloatArray>::New();
- sphAngVel->SetNumberOfComponents(3);
- sphAngVel->SetName("angVel");
+
+ vtkSmartPointer<vtkFloatArray> spheresLinVelVec = vtkSmartPointer<vtkFloatArray>::New();
+ spheresLinVelVec->SetNumberOfComponents(3);
+ spheresLinVelVec->SetName("linVelVec"); //Linear velocity in Vector3 form
+
+ vtkSmartPointer<vtkFloatArray> spheresLinVelLen = vtkSmartPointer<vtkFloatArray>::New();
+ spheresLinVelLen->SetNumberOfComponents(1);
+ spheresLinVelLen->SetName("linVelLen"); //Length (magnitude) of linear velocity
+
+ vtkSmartPointer<vtkFloatArray> spheresAngVelVec = vtkSmartPointer<vtkFloatArray>::New();
+ spheresAngVelVec->SetNumberOfComponents(3);
+ spheresAngVelVec->SetName("angVelVec"); //Angular velocity in Vector3 form
+
+ vtkSmartPointer<vtkFloatArray> spheresAngVelLen = vtkSmartPointer<vtkFloatArray>::New();
+ spheresAngVelLen->SetNumberOfComponents(1);
+ spheresAngVelLen->SetName("angVelLen"); //Length (magnitude) of angular velocity
+
+ vtkSmartPointer<vtkFloatArray> spheresForceVec = vtkSmartPointer<vtkFloatArray>::New();
+ spheresForceVec->SetNumberOfComponents(3);
+ spheresForceVec->SetName("forceVec");
+
+ vtkSmartPointer<vtkFloatArray> spheresForceLen = vtkSmartPointer<vtkFloatArray>::New();
+ spheresForceLen->SetNumberOfComponents(1);
+ spheresForceLen->SetName("forceLen");
+
vtkSmartPointer<vtkFloatArray> spheresMaterialId = vtkSmartPointer<vtkFloatArray>::New();
spheresMaterialId->SetNumberOfComponents(1);
spheresMaterialId->SetName("materialId");
@@ -81,6 +106,16 @@
vtkSmartPointer<vtkFloatArray> facetsColors = vtkSmartPointer<vtkFloatArray>::New();
facetsColors->SetNumberOfComponents(3);
facetsColors->SetName("color");
+
+ vtkSmartPointer<vtkFloatArray> facetsForceVec = vtkSmartPointer<vtkFloatArray>::New();
+ facetsForceVec->SetNumberOfComponents(3);
+ facetsForceVec->SetName("forceVec");
+
+ vtkSmartPointer<vtkFloatArray> facetsForceLen = vtkSmartPointer<vtkFloatArray>::New();
+ facetsForceLen->SetNumberOfComponents(1);
+ facetsForceLen->SetName("forceLen");
+
+
vtkSmartPointer<vtkFloatArray> facetsMaterialId = vtkSmartPointer<vtkFloatArray>::New();
facetsMaterialId->SetNumberOfComponents(1);
facetsMaterialId->SetName("materialId");
@@ -164,12 +199,21 @@
if(recActive[REC_VELOCITY]){
const Vector3r& vel = b->state->vel;
float v[3] = { vel[0],vel[1],vel[2] };
- spheresVelocity->InsertNextTupleValue(v);
+ spheresLinVelVec->InsertNextTupleValue(v);
+ spheresLinVelLen->InsertNextValue(vel.norm());
const Vector3r& angVel = b->state->angVel;
float av[3] = { angVel[0],angVel[1],angVel[2] };
- sphAngVel->InsertNextTupleValue(av);
- }
+ spheresAngVelVec->InsertNextTupleValue(av);
+ spheresAngVelLen->InsertNextValue(angVel.norm());
+ }
+ if(recActive[REC_FORCE]){
+ const Vector3r& force = scene->forces.getForce(b->getId());
+ float f[3] = { force[0],force[1],force[2] };
+ spheresForceVec->InsertNextTupleValue(f);
+ spheresForceLen->InsertNextValue(force.norm());
+ }
+
if (recActive[REC_CPM]){
cpmDamage->InsertNextValue(YADE_PTR_CAST<CpmState>(b->state)->normDmg);
const Vector3r& ss=YADE_PTR_CAST<CpmState>(b->state)->sigma;
@@ -203,6 +247,12 @@
float c[3] = {color[0],color[1],color[2]};
facetsColors->InsertNextTupleValue(c);
}
+ if(recActive[REC_FORCE]){
+ const Vector3r& force = scene->forces.getForce(b->getId());
+ float f[3] = { force[0],force[1],force[2] };
+ facetsForceVec->InsertNextTupleValue(f);
+ facetsForceLen->InsertNextValue(force.norm());
+ }
if (recActive[REC_MATERIALID]) facetsMaterialId->InsertNextValue(b->material->id);
continue;
}
@@ -222,8 +272,14 @@
if (recActive[REC_CLUMPID]) spheresUg->GetPointData()->AddArray(clumpId);
if (recActive[REC_COLORS]) spheresUg->GetPointData()->AddArray(spheresColors);
if (recActive[REC_VELOCITY]){
- spheresUg->GetPointData()->AddArray(spheresVelocity);
- spheresUg->GetPointData()->AddArray(sphAngVel);
+ spheresUg->GetPointData()->AddArray(spheresLinVelVec);
+ spheresUg->GetPointData()->AddArray(spheresAngVelVec);
+ spheresUg->GetPointData()->AddArray(spheresLinVelLen);
+ spheresUg->GetPointData()->AddArray(spheresAngVelLen);
+ }
+ if (recActive[REC_FORCE]){
+ spheresUg->GetPointData()->AddArray(spheresForceVec);
+ spheresUg->GetPointData()->AddArray(spheresForceLen);
}
if (recActive[REC_CPM]){
spheresUg->GetPointData()->AddArray(cpmDamage);
@@ -245,6 +301,10 @@
facetsUg->SetPoints(facetsPos);
facetsUg->SetCells(VTK_TRIANGLE, facetsCells);
if (recActive[REC_COLORS]) facetsUg->GetCellData()->AddArray(facetsColors);
+ if (recActive[REC_FORCE]){
+ facetsUg->GetCellData()->AddArray(facetsForceVec);
+ facetsUg->GetCellData()->AddArray(facetsForceLen);
+ }
if (recActive[REC_MATERIALID]) facetsUg->GetCellData()->AddArray(facetsMaterialId);
vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
if(compress) writer->SetCompressor(compressor);
=== modified file 'pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp'
--- pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-14 18:35:45 +0000
+++ pkg/dem/Engine/GlobalEngine/VTKRecorder.hpp 2010-05-17 15:08:57 +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_ID,REC_CLUMPID,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,REC_FORCE};
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``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 ``color``); 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 ``color``); 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 as Vector3 and length(fields ``linVelVec``, ``linVelLen`` and ``angVelVec``, ``angVelLen`` respectively``); only effective with ``spheres``.\n``facets``\n\tSave :yref:`facets<Facet>` positions (vertices).\n``force``\n\tSaves forces of :yref:`spheres<Sphere>` and of :yref:`facets<Facet>` as Vector3 and length; only active if ``spheres`` or ``facets`` is activated.\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"))
((int,mask,0,"If mask defined, only bodies with corresponding groupMask will be exported. If 0 - all bodies will be exported.")),
/*ctor*/
initRun=true;
Follow ups