yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #08203
[Branch ~yade-dev/yade/trunk] Rev 2992: - fixed undefined variable when Triaxial engine is not present
------------------------------------------------------------
revno: 2992
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2012-01-13 20:19:18 +0100
message:
- fixed undefined variable when Triaxial engine is not present
modified:
pkg/dem/MicroMacroAnalyser.cpp
pkg/dem/TesselationWrapper.cpp
pkg/dem/TesselationWrapper.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/MicroMacroAnalyser.cpp'
--- pkg/dem/MicroMacroAnalyser.cpp 2012-01-13 11:24:44 +0000
+++ pkg/dem/MicroMacroAnalyser.cpp 2012-01-13 19:19:18 +0000
@@ -129,7 +129,7 @@
Real rad = s->radius;
TS.grains[Idg].sphere = CGT::Sphere(CGT::Point(pos[0],pos[1],pos[2]),rad);
-// TS.grains[Idg].translation = trans;
+ // TS.grains[Idg].translation = trans;
AngleAxisr aa((*bi)->state->ori);
Vector3r rotVec=aa.axis()*aa.angle();
TS.grains[Idg].rotation = CGT::Vecteur(rotVec[0],rotVec[1],rotVec[2]);
@@ -218,7 +218,7 @@
TS.prof = triaxialCompressionEngine->depth;//find_parameter("prof=", Statefile);
TS.porom = 0/*analyser->ComputeMacroPorosity() crasher?*/;//find_parameter("porom=", Statefile);
TS.ratio_f = triaxialCompressionEngine-> ComputeUnbalancedForce(scene); //find_parameter("ratio_f=", Statefile);
- }
+ } else TS.wszzh=TS.wsxxd=TS.wsyyfa=TS.eps3=TS.eps1=TS.eps2=TS.haut=TS.larg=TS.prof=TS.porom=TS.ratio_f=0;
if (filename!=NULL) TS.to_file(filename);
return TS;
}
=== modified file 'pkg/dem/TesselationWrapper.cpp'
--- pkg/dem/TesselationWrapper.cpp 2012-01-13 11:24:44 +0000
+++ pkg/dem/TesselationWrapper.cpp 2012-01-13 19:19:18 +0000
@@ -13,7 +13,8 @@
#include<yade/extra/boost_python_len.hpp>
#include<yade/pkg/dem/Shop.hpp>
#include"TesselationWrapper.hpp"
-#include <yade/lib/triangulation/Timer.h>
+#include<yade/lib/triangulation/Timer.h>
+#include<yade/pkg/dem/SpherePack.hpp>
YADE_PLUGIN((TesselationWrapper));
CREATE_LOGGER(TesselationWrapper);
@@ -296,10 +297,45 @@
TS.to_file(filename.c_str(),bz2);
}
-void TesselationWrapper::defToVtkWithInput (string inputFile1, string inputFile2, string outputFile, bool bz2){
+void TesselationWrapper::defToVtkFromStates (string inputFile1, string inputFile2, string outputFile, bool bz2){
mma.analyser->DefToFile(inputFile1.c_str(),inputFile2.c_str(),outputFile.c_str(),bz2);
}
+void createSphere(shared_ptr<Body>& body, Vector3r position, Real radius, bool big, bool dynamic )
+{
+ body = shared_ptr<Body>(new Body); body->groupMask=2;
+ shared_ptr<Sphere> iSphere(new Sphere);
+ body->state->blockedDOFs=State::DOF_NONE;
+ body->state->pos=position;
+ iSphere->radius = radius;
+ body->shape = iSphere;
+}
+
+void TesselationWrapper::defToVtkFromPositions (string inputFile1, string inputFile2, string outputFile, bool bz2){
+ SpherePack sp1, sp2;
+ sp1.fromFile(inputFile1);
+ sp2.fromFile(inputFile2);
+ size_t imax=sp1.pack.size();
+ if (imax!=sp2.pack.size()) LOG_ERROR("The files have different numbers of spheres");
+ shared_ptr<Body> body;
+ for(size_t i=0; i<imax; i++){
+ const SpherePack::Sph& sp(sp1.pack[i]);
+ LOG_DEBUG("sphere (" << sp.c << " " << sp.r << ")");
+ createSphere(body,sp.c,sp.r,false,true);
+ scene->bodies->insert(body);
+ }
+ mma.setState(1);
+ scene->bodies->clear();
+ for(size_t i=0; i<imax; i++){
+ const SpherePack::Sph& sp(sp2.pack[i]);
+ LOG_DEBUG("sphere (" << sp.c << " " << sp.r << ")");
+ createSphere(body,sp.c,sp.r,false,true);
+ scene->bodies->insert(body);
+ }
+ mma.setState(2);
+ mma.analyser->DefToFile(outputFile.c_str());
+}
+
void TesselationWrapper::defToVtk (string outputFile){
mma.analyser->DefToFile(outputFile.c_str());
}
=== modified file 'pkg/dem/TesselationWrapper.hpp'
--- pkg/dem/TesselationWrapper.hpp 2012-01-13 11:24:44 +0000
+++ pkg/dem/TesselationWrapper.hpp 2012-01-13 19:19:18 +0000
@@ -85,7 +85,8 @@
void loadState (string fileName, bool stateNumber=0, bool bz2=false);
void saveState (string fileName, bool stateNumber=0, bool bz2=false);
/// read two state files and write per-particle deformation to a vtk file. The second variant uses existing states.
- void defToVtkWithInput (string inputFile1, string inputFile2, string outputFile="def.vtk", bool bz2=false);
+ void defToVtkFromStates (string inputFile1, string inputFile2, string outputFile="def.vtk", bool bz2=false);
+ void defToVtkFromPositions (string inputFile1, string inputFile2, string outputFile="def.vtk", bool bz2=false);
void defToVtk (string outputFile="def.vtk");
/// return python array containing voronoi volumes, per-particle porosity, and optionaly per-particle deformation, if states 0 and 1 have been assigned
@@ -111,12 +112,13 @@
mma.analyser->SetConsecutive(false);
,/*py*/
.def("triangulate",&TesselationWrapper::insertSceneSpheres,(python::arg("reset")=true),"triangulate spheres of the packing")
- .def("setState",&TesselationWrapper::setState,(python::arg("state")=0),"Make the current state the initial (0) or final (1) configuration for the definition of displacement increments, use only state=0 if you just want to get only volmumes and porosity.")
+ .def("setState",&TesselationWrapper::setState,(python::arg("state")=0),"Make the current state of the simulation the initial (0) or final (1) configuration for the definition of displacement increments, use only state=0 if you just want to get volmumes and porosity.")
.def("loadState",&TesselationWrapper::loadState,(python::arg("stateNumber")=0),"Load a file with positions to define state 0 or 1.")
.def("saveState",&TesselationWrapper::saveState,(python::arg("outputFile")="state",python::arg("bz2")=true),"Save a file with positions, can be later reloaded in order to define state 0 or 1.")
.def("volume",&TesselationWrapper::Volume,(python::arg("id")=0),"Returns the volume of Voronoi's cell of a sphere.")
.def("defToVtk",&TesselationWrapper::defToVtk,(python::arg("outputFile")="def.vtk"),"Write local deformations in vtk format from states 0 and 1.")
- .def("defToVtkWithInput",&TesselationWrapper::defToVtkWithInput,(python::arg("input1")="state1",python::arg("input2")="state2",python::arg("outputFile")="def.vtk",python::arg("bz2")=false),"Write local deformations in vtk format from position input files.")
+ .def("defToVtkFromStates",&TesselationWrapper::defToVtkFromStates,(python::arg("input1")="state1",python::arg("input2")="state2",python::arg("outputFile")="def.vtk",python::arg("bz2")=false),"Write local deformations in vtk format from state files (since the file format is very special, consider using defToVtkFromPositions instead).")
+ .def("defToVtkFromPositions",&TesselationWrapper::defToVtkFromPositions,(python::arg("input1")="pos1",python::arg("input2")="pos2",python::arg("outputFile")="def.vtk",python::arg("bz2")=false),"Write local deformations in vtk format from state files (since the file format is very special, consider using defToVtkFromPositions instead).")
.def("computeVolumes",&TesselationWrapper::ComputeVolumes,"Compute volumes of all Voronoi's cells.")
.def("getVolPoroDef",&TesselationWrapper::getVolPoroDef,(python::arg("deformation")=false),"Return a table with per-sphere computed quantities. Include deformations on the increment defined by states 0 and 1 if deformation=True (make sure to define states 0 and 1 consistently).")
);