yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #02175
[Branch ~yade-dev/yade/trunk] Rev 1773: 1. Use colon as separator to all path parameters to scons (PATH, CPPPATH etc), to avoid shell esc...
------------------------------------------------------------
revno: 1773
committer: Václav Šmilauer <vaclav@falx>
branch nick: trunk
timestamp: Fri 2009-10-16 08:33:55 +0200
message:
1. Use colon as separator to all path parameters to scons (PATH, CPPPATH etc), to avoid shell escaping insaneness. NOT BACKWARDS COMPATIBLE if you call scons from scripts with multiple paths. Scons.profile-* files will work.
2. Add PATH parameter to scons, for things like pkg-config that we call during the configure stage (you can propagate whole path by saying scons PATH=$PATH)
3. Extend VTKRecorder to record interactions as well; add some cpm-related parameters.
4. avgStress is now Vector3r
5. Fix openGL-less builds (missing parenthesis in core/SConscript)
modified:
SConstruct
core/SConscript
pkg/dem/Engine/StandAloneEngine/VTKRecorder.cpp
pkg/dem/Engine/StandAloneEngine/VTKRecorder.hpp
pkg/dem/meta/ConcretePM.cpp
pkg/dem/meta/ConcretePM.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 'SConstruct'
--- SConstruct 2009-10-04 14:37:41 +0000
+++ SConstruct 2009-10-16 06:33:55 +0000
@@ -118,6 +118,8 @@
## compatibility hack again
if 'AddVariables' not in dir(opts): opts.AddVariables=opts.AddOptions
+def colonSplit(x): return x.split(':')
+
#
# The convention now is, that
# 1. CAPITALIZED options are
@@ -138,14 +140,15 @@
# OK, dummy prevents bug in scons: if one selects all, it says all in scons.config, but without quotes, which generates error.
ListVariable('features','Optional features that are turned on','python,log4cxx,opengl,gts,openmp',names=['opengl','python','log4cxx','cgal','openmp','gts','vtk']),
('jobs','Number of jobs to run at the same time (same as -j, but saved)',4,None,int),
- ('extraModules', 'Extra directories with their own SConscript files (must be in-tree) (whitespace separated)',None,None,Split),
+ #('extraModules', 'Extra directories with their own SConscript files (must be in-tree) (whitespace separated)',None,None,Split),
('buildPrefix','Where to create build-[version][variant] directory for intermediary files','..'),
EnumVariable('linkStrategy','How to link plugins together','per-class',['per-class','per-pkg[broken]','monolithic','static[broken]']),
('version','Yade version (if not specified, guess will be attempted)',None),
- ('CPPPATH', 'Additional paths for the C preprocessor (whitespace separated)',None,None,Split),
- ('LIBPATH','Additional paths for the linker (whitespace separated)',None,None,Split),
- ('QTDIR','Directories where to look for qt3',['/usr/share/qt3','/usr/lib/qt','/usr/lib/qt3','/usr/qt/3','/usr/lib/qt-3.3'],None,Split),
- ('VTKINCDIR','Directories where to look for VTK headers',['/usr/include/vtk','/usr/include/vtk-5.0'],None,Split),
+ ('CPPPATH', 'Additional paths for the C preprocessor (colon-separated)',None,None,colonSplit),
+ ('LIBPATH','Additional paths for the linker (colon-separated)',None,None,colonSplit),
+ ('QTDIR','Directories where to look for qt3',['/usr/share/qt3','/usr/lib/qt','/usr/lib/qt3','/usr/qt/3','/usr/lib/qt-3.3'],None,colonSplit),
+ ('PATH','Path (not imported automatically from the shell) (colon-separated)',None,None,colonSplit),
+ ('VTKINCDIR','Directories where to look for VTK headers',['/usr/include/vtk','/usr/include/vtk-5.0'],None,colonSplit),
('CXX','The c++ compiler','g++'),
('CXXFLAGS','Additional compiler flags for compilation (like -march=core2).',None,None,Split),
('march','Architecture to use with -march=... when optimizing','native',None,None),
@@ -166,6 +169,7 @@
propagatedEnvVars=['HOME','TERM','DISTCC_HOSTS','LD_PRELOAD','FAKEROOTKEY','LD_LIBRARY_PATH']
for v in propagatedEnvVars:
if os.environ.has_key(v): env.Append(ENV={v:os.environ[v]})
+if env.has_key('PATH'): env.Append(ENV={'PATH':env['PATH']})
# get number of jobs from DEB_BUILD_OPTIONS if defined
# see http://www.de.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options
=== modified file 'core/SConscript'
--- core/SConscript 2009-08-18 12:53:22 +0000
+++ core/SConscript 2009-10-16 06:33:55 +0000
@@ -35,7 +35,7 @@
'miniWm3',
'rt', # realtime lib, for clock_gettime
]+
- ['$QGLVIEWER_LIB','yade-opengl'] if 'YADE_OPENGL' in env['CPPDEFINES'] else [],
+ (['$QGLVIEWER_LIB','yade-opengl'] if 'YADE_OPENGL' in env['CPPDEFINES'] else []),
CPPDEFINES=env['CPPDEFINES']+[('YADE_VERSION','\\"'+env['realVersion']+'\\"'),]
)
])
=== modified file 'pkg/dem/Engine/StandAloneEngine/VTKRecorder.cpp'
--- pkg/dem/Engine/StandAloneEngine/VTKRecorder.cpp 2009-10-11 11:22:25 +0000
+++ pkg/dem/Engine/StandAloneEngine/VTKRecorder.cpp 2009-10-16 06:33:55 +0000
@@ -11,6 +11,7 @@
//#include<vtkXMLMultiBlockDataWriter.h>
//#include<vtkMultiBlockDataSet.h>
#include<vtkTriangle.h>
+#include<vtkLine.h>
#include<yade/core/MetaBody.hpp>
#include<yade/pkg-common/Sphere.hpp>
#include<yade/pkg-common/Facet.hpp>
@@ -26,6 +27,7 @@
/* we always want to save the first state as well */
initRun=true;
compress=false;
+ skipFacetIntr=true;
}
VTKRecorder::~VTKRecorder()
@@ -42,12 +44,17 @@
vector<bool> recActive(REC_SENTINEL,false);
FOREACH(string& rec, recorders){
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 LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: spheres, facets, colors, cpmDamage). Ignored.");
+ // else if(rec=="intr") recActive[REC_INTR]=true;
+ else LOG_ERROR("Unknown recorder named `"<<rec<<"' (supported are: spheres, velocity, facets, colors, cpm). Ignored.");
}
+ // cpm needs interactions
+ if(recActive[REC_CPM]) recActive[REC_INTR]=true;
+ // spheres
vtkSmartPointer<vtkPoints> spheresPos = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> spheresCells = vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkFloatArray> radii = vtkSmartPointer<vtkFloatArray>::New();
@@ -56,21 +63,56 @@
vtkSmartPointer<vtkFloatArray> spheresColors = vtkSmartPointer<vtkFloatArray>::New();
spheresColors->SetNumberOfComponents(3);
spheresColors->SetName("Colors");
-
+ vtkSmartPointer<vtkFloatArray> spheresVelocity = vtkSmartPointer<vtkFloatArray>::New();
+ spheresVelocity->SetNumberOfComponents(3);
+ spheresVelocity->SetName("velocity");
+
+ // facets
+ vtkSmartPointer<vtkPoints> facetsPos = vtkSmartPointer<vtkPoints>::New();
+ vtkSmartPointer<vtkCellArray> facetsCells = vtkSmartPointer<vtkCellArray>::New();
+ vtkSmartPointer<vtkFloatArray> facetsColors = vtkSmartPointer<vtkFloatArray>::New();
+ facetsColors->SetNumberOfComponents(3);
+ facetsColors->SetName("Colors");
+
+ // interactions
+ vtkSmartPointer<vtkPoints> intrBodyPos = vtkSmartPointer<vtkPoints>::New();
+ vtkSmartPointer<vtkCellArray> intrCells = vtkSmartPointer<vtkCellArray>::New();
+ vtkSmartPointer<vtkFloatArray> intrForceN = vtkSmartPointer<vtkFloatArray>::New();
+ intrForceN->SetNumberOfComponents(1);
+ intrForceN->SetName("forceN");
+
+ // extras for CPM
if(recActive[REC_CPM]) CpmStateUpdater::update(rootBody);
vtkSmartPointer<vtkFloatArray> cpmDamage = vtkSmartPointer<vtkFloatArray>::New();
cpmDamage->SetNumberOfComponents(1);
cpmDamage->SetName("cpmDamage");
vtkSmartPointer<vtkFloatArray> cpmStress = vtkSmartPointer<vtkFloatArray>::New();
- cpmStress->SetNumberOfComponents(1);
+ cpmStress->SetNumberOfComponents(3);
cpmStress->SetName("cpmStress");
- vtkSmartPointer<vtkPoints> facetsPos = vtkSmartPointer<vtkPoints>::New();
- vtkSmartPointer<vtkCellArray> facetsCells = vtkSmartPointer<vtkCellArray>::New();
- vtkSmartPointer<vtkFloatArray> facetsColors = vtkSmartPointer<vtkFloatArray>::New();
- facetsColors->SetNumberOfComponents(3);
- facetsColors->SetName("Colors");
-
+ if(recActive[REC_INTR]){
+ // save body positions, referenced by ids by vtkLine
+ FOREACH(const shared_ptr<Body>& b, *rootBody->bodies){
+ const Vector3r& pos=b->physicalParameters->se3.position;
+ intrBodyPos->InsertNextPoint(pos[0],pos[1],pos[2]);
+ }
+ FOREACH(const shared_ptr<Interaction>& I, *rootBody->interactions){
+ if(!I->isReal()) continue;
+ //const NormalShearInteraction* phys = YADE_CAST<NormalShearInteraction*>(i->interactionPhysics.get());
+ if(skipFacetIntr){
+ if(!(dynamic_cast<Sphere*>(Body::byId(I->getId1())->geometricalModel.get()))) continue;
+ if(!(dynamic_cast<Sphere*>(Body::byId(I->getId2())->geometricalModel.get()))) continue;
+ }
+ vtkSmartPointer<vtkLine> line = vtkSmartPointer<vtkLine>::New();
+ line->GetPointIds()->SetId(0,I->getId1());
+ line->GetPointIds()->SetId(1,I->getId2());
+ intrCells->InsertNextCell(line);
+ if(recActive[REC_CPM]){
+ const CpmPhys* phys = YADE_CAST<CpmPhys*>(I->interactionPhysics.get());
+ intrForceN->InsertNextValue(phys->Fn);
+ }
+ }
+ }
FOREACH(const shared_ptr<Body>& b, *rootBody->bodies){
if (recActive[REC_SPHERES])
@@ -89,9 +131,14 @@
float c[3] = {color[0],color[1],color[2]};
spheresColors->InsertNextTupleValue(c);
}
+ if(recActive[REC_VELOCITY]){
+ spheresVelocity->InsertNextTupleValue((float*)(&(YADE_CAST<ParticleParameters*>(b->physicalParameters.get()))->velocity));
+ }
if (recActive[REC_CPM]) {
cpmDamage->InsertNextValue(YADE_PTR_CAST<CpmMat>(b->physicalParameters)->normDmg);
- cpmStress->InsertNextValue(YADE_PTR_CAST<CpmMat>(b->physicalParameters)->avgStress);
+ const Vector3r& ss=YADE_PTR_CAST<CpmMat>(b->physicalParameters)->avgStress;
+ float s[3]={ss[0],ss[1],ss[2]};
+ cpmStress->InsertNextTupleValue(s);
}
continue;
}
@@ -133,6 +180,7 @@
spheresUg->SetCells(VTK_VERTEX, spheresCells);
spheresUg->GetPointData()->AddArray(radii);
if (recActive[REC_COLORS]) spheresUg->GetPointData()->AddArray(spheresColors);
+ if (recActive[REC_VELOCITY]) spheresUg->GetPointData()->AddArray(spheresVelocity);
if (recActive[REC_CPM]) {
spheresUg->GetPointData()->AddArray(cpmDamage);
spheresUg->GetPointData()->AddArray(cpmStress);
@@ -157,6 +205,19 @@
writer->SetInput(facetsUg);
writer->Write();
}
+ if (recActive[REC_INTR])
+ {
+ vtkSmartPointer<vtkUnstructuredGrid> intrUg = vtkSmartPointer<vtkUnstructuredGrid>::New();
+ intrUg->SetPoints(intrBodyPos);
+ intrUg->SetCells(VTK_LINE, intrCells);
+ if (recActive[REC_CPM]) intrUg->GetCellData()->AddArray(intrForceN);
+ vtkSmartPointer<vtkXMLUnstructuredGridWriter> writer = vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
+ if(compress) writer->SetCompressor(compressor);
+ string fn=fileName+"intrs."+lexical_cast<string>(rootBody->currentIteration)+".vtu";
+ writer->SetFileName(fn.c_str());
+ writer->SetInput(intrUg);
+ writer->Write();
+ }
//vtkSmartPointer<vtkMultiBlockDataSet> multiblockDataset = vtkSmartPointer<vtkMultiBlockDataSet>::New();
//multiblockDataset->SetBlock(0, spheresUg );
=== modified file 'pkg/dem/Engine/StandAloneEngine/VTKRecorder.hpp'
--- pkg/dem/Engine/StandAloneEngine/VTKRecorder.hpp 2009-10-11 11:22:25 +0000
+++ pkg/dem/Engine/StandAloneEngine/VTKRecorder.hpp 2009-10-16 06:33:55 +0000
@@ -4,11 +4,14 @@
class VTKRecorder: public PeriodicEngine {
public:
- enum {REC_SPHERES=0,REC_FACETS,REC_COLORS,REC_CPM,REC_SENTINEL};
+ enum {REC_SPHERES=0,REC_FACETS,REC_COLORS,REC_CPM,REC_INTR,REC_VELOCITY,REC_SENTINEL};
//! A stuff to record: spheres,facets,colors
vector<string> recorders;
string fileName;
+ //! turn on compression of the output XML files
bool compress;
+ //! skip interactions with facets
+ bool skipFacetIntr;
VTKRecorder();
~VTKRecorder();
void init(MetaBody*);
=== modified file 'pkg/dem/meta/ConcretePM.cpp'
--- pkg/dem/meta/ConcretePM.cpp 2009-10-11 11:22:25 +0000
+++ pkg/dem/meta/ConcretePM.cpp 2009-10-16 06:33:55 +0000
@@ -355,14 +355,15 @@
const body_id_t id1=I->getId1(), id2=I->getId2();
Dem3DofGeom* geom=YADE_CAST<Dem3DofGeom*>(I->interactionGeometry.get());
- Vector3r f[]={phys->normalForce,-phys->normalForce}; const Vector3r pos[]={geom->se31.position,geom->se32.position}; const body_id_t ids[]={id1,id2};
- Real stress=phys->normalForce.Length()/phys->crossSection;
- for(int i=0; i<2; i++){
- int sgn=(geom->contactPoint-pos[i]).Dot(f[i])>0?1:-1;
- bodyStats[ids[i]].avgStress+=sgn*stress;
- bodyStats[ids[i]].nLinks++;
+ Vector3r stress=(1./phys->crossSection)*phys->normalForce;
+ const Vector3r& p1(geom->se31.position); const Vector3r& cp(geom->contactPoint);
+ for(int i=0; i<3; i++){
+ stress[i]*=cp[i]>p1[i] ? 1. : -1.;
}
-
+ bodyStats[id1].avgStress+=stress;
+ bodyStats[id2].avgStress+=stress;
+ bodyStats[id1].nLinks++; bodyStats[id2].nLinks++;
+
if(!phys->isCohesive) continue;
bodyStats[id1].nCohLinks++; bodyStats[id1].dmgSum+=(1-phys->relResidualStrength); bodyStats[id1].epsPlSum+=phys->epsPlSum;
bodyStats[id2].nCohLinks++; bodyStats[id2].dmgSum+=(1-phys->relResidualStrength); bodyStats[id2].epsPlSum+=phys->epsPlSum;
=== modified file 'pkg/dem/meta/ConcretePM.hpp'
--- pkg/dem/meta/ConcretePM.hpp 2009-10-11 11:22:25 +0000
+++ pkg/dem/meta/ConcretePM.hpp 2009-10-16 06:33:55 +0000
@@ -70,8 +70,8 @@
//! sum of plastic strains normalized by number of contacts
Real normEpsPl;
//! averaged stress on the particle
- Real avgStress;
- CpmMat(): epsVolumetric(0.), numBrokenCohesive(0), numContacts(0), normDmg(0.), epsPlBroken(0.), normEpsPl(0.), avgStress(0.) {createIndex();};
+ Vector3r avgStress;
+ CpmMat(): epsVolumetric(0.), numBrokenCohesive(0), numContacts(0), normDmg(0.), epsPlBroken(0.), normEpsPl(0.), avgStress(Vector3r::ZERO) {createIndex();};
REGISTER_ATTRIBUTES(BodyMacroParameters, (epsVolumetric) (numBrokenCohesive) (numContacts) (normDmg) (epsPlBroken) (normEpsPl) (avgStress));
REGISTER_CLASS_AND_BASE(CpmMat,BodyMacroParameters);
REGISTER_CLASS_INDEX(CpmMat,BodyMacroParameters);
@@ -317,7 +317,7 @@
#endif
class CpmStateUpdater: public PeriodicEngine {
- struct BodyStats{ int nCohLinks; int nLinks; Real dmgSum, epsPlSum, avgStress; BodyStats(): nCohLinks(0), nLinks(0), dmgSum(0.), epsPlSum(0.), avgStress(0.) {} };
+ struct BodyStats{ int nCohLinks; int nLinks; Real dmgSum, epsPlSum; Vector3r avgStress; BodyStats(): nCohLinks(0), nLinks(0), dmgSum(0.), epsPlSum(0.), avgStress(Vector3r::ZERO) {} };
public:
//! maximum damage over all contacts
static Real maxOmega;