yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #11368
[Branch ~yade-pkg/yade/git-trunk] Rev 3364: fix a few mistakes and make a real (not empty) test function
------------------------------------------------------------
revno: 3364
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
timestamp: Tue 2012-11-27 19:31:45 +0100
message:
fix a few mistakes and make a real (not empty) test function
modified:
pkg/dem/FlowEngine.hpp
pkg/dem/UnsaturatedEngine.cpp
pkg/dem/UnsaturatedEngine.hpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/FlowEngine.hpp'
--- pkg/dem/FlowEngine.hpp 2012-11-23 13:02:02 +0000
+++ pkg/dem/FlowEngine.hpp 2012-11-27 18:31:45 +0000
@@ -32,6 +32,7 @@
typedef FlowSolver::Finite_vertices_iterator Finite_vertices_iterator;
typedef FlowSolver::Finite_cells_iterator Finite_cells_iterator;
typedef FlowSolver::Cell_handle Cell_handle;
+ typedef FlowSolver::Vertex_handle Vertex_handle;
typedef RTriangulation::Finite_edges_iterator Finite_edges_iterator;
@@ -111,11 +112,12 @@
TPL int getCell(double posX, double posY, double posZ, Solver& flow){return flow->getCell(posX, posY, posZ);}
double MeasureAveragedPressure(double posY){return solver->MeasureAveragedPressure(posY);}
double MeasureTotalAveragedPressure(){return solver->MeasureTotalAveragedPressure();}
+ #ifdef EIGENSPARSE_LIB
TPL void exportMatrix(string filename,Solver& flow) {if (useSolver==3) flow->exportMatrix(filename.c_str());
else cerr<<"available for Cholmod solver (useSolver==3)"<<endl;}
TPL void exportTriplets(string filename,Solver& flow) {if (useSolver==3) flow->exportTriplets(filename.c_str());
else cerr<<"available for Cholmod solver (useSolver==3)"<<endl;}
-
+ #endif
void emulateAction(){
scene = Omega::instance().getScene().get();
action();}
@@ -135,9 +137,10 @@
Real _getCellFlux(unsigned int cond) {return getCellFlux(cond,solver);}
Real _getBoundaryFlux(unsigned int boundary) {return getBoundaryFlux(boundary,solver);}
int _getCell(Vector3r pos) {return getCell(pos[0],pos[1],pos[2],solver);}
+ #ifdef EIGENSPARSE_LIB
void _exportMatrix(string filename) {exportMatrix(filename,solver);}
void _exportTriplets(string filename) {exportTriplets(filename,solver);}
-
+ #endif
virtual ~FlowEngine();
virtual void action();
@@ -261,8 +264,10 @@
.def("updateBCs",&FlowEngine::_updateBCs,"tells the engine to update it's boundary conditions before running (especially useful when changing boundary pressure - should not be needed for point-wise imposed pressure)")
.def("emulateAction",&FlowEngine::emulateAction,"get scene and run action (may be used to manipulate engine outside the main loop).")
.def("getCell",&FlowEngine::_getCell,(python::arg("pos")),"get id of the cell containing (X,Y,Z).")
+ #ifdef EIGENSPARSE_LIB
.def("exportMatrix",&FlowEngine::_exportMatrix,(python::arg("filename")="matrix"),"Export system matrix to a file with all entries (even zeros will displayed).")
.def("exportTriplets",&FlowEngine::_exportTriplets,(python::arg("filename")="triplets"),"Export system matrix to a file with only non-zero entries.")
+ #endif
)
DECLARE_LOGGER;
};
@@ -354,8 +359,10 @@
void PressureProfile(double wallUpY, double wallDownY) {return solver->MeasurePressureProfile(wallUpY,wallDownY);}
int _getCell(Vector3r pos) {return getCell(pos[0],pos[1],pos[2],solver);}
+ #ifdef EIGENSPARSE_LIB
void _exportMatrix(string filename) {exportMatrix(filename,solver);}
void _exportTriplets(string filename) {exportTriplets(filename,solver);}
+ #endif
// void _setImposedPressure(unsigned int cond, Real p) {setImposedPressure(cond,p,solver);}
// void _clearImposedPressure() {clearImposedPressure(solver);}
@@ -392,8 +399,10 @@
.def("getCell",&PeriodicFlowEngine::_getCell,python::arg("pos"),"get id of the cell containing 'pos'.")
.def("getConstrictionsFull",&PeriodicFlowEngine::getConstrictionsFull,"Get the list of constrictions (inscribed circle) for all finite facets.")
+ #ifdef EIGENSPARSE_LIB
.def("exportMatrix",&PeriodicFlowEngine::_exportMatrix,(python::arg("filename")="matrix"),"Export system matrix to a file with all entries (even zeros will displayed).")
.def("exportTriplets",&PeriodicFlowEngine::_exportTriplets,(python::arg("filename")="triplets"),"Export system matrix to a file with only non-zero entries.")
+ #endif
)
DECLARE_LOGGER;
=== modified file 'pkg/dem/UnsaturatedEngine.cpp'
--- pkg/dem/UnsaturatedEngine.cpp 2012-11-27 12:18:19 +0000
+++ pkg/dem/UnsaturatedEngine.cpp 2012-11-27 18:31:45 +0000
@@ -36,13 +36,61 @@
void UnsaturatedEngine::testFunction()
{
+ cout<<"This is Chao's test program"<<endl;
+
+// UnsaturatedEngine inherits from Emanuele's flow engine, so it contains many things. However, we will ignore what's in it for the moment.
+// The only thing interesting for us is that UnsaturatedEngine contains an object "triangulation" from CGAL library.
+// Let us define an alias for this triangulation:
+
+ RTriangulation& triangulation = solver->T[solver->currentTes].Triangulation();
+
+ //Now, you can use "triangulation", with all the functions listed in CGAL documentation
+ //We can insert spheres (here I'm in fact stealing the code from Tesselation::insert() (see Tesselation.ipp)
+ unsigned int k=0;
+ Real x=0.5, y=0.5,z=0.5, rad=0.1;
+ Vertex_handle Vh;
+ Vh = triangulation.insert(CGALSphere(Point(x,y,z),pow(rad,2)));
+ //The vertex base includes integers, so we can assign indices to the vertex/spheres
+ Vh->info() = k;
+ k = k+1;
+
+ // Now, let's add more spheres to make it more fun...
+ Vh = triangulation.insert(CGALSphere(Point(0,0,0.2),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(0.9,0,0.2),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(0.9,0.8,0.2),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(1,0.9,0.8),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(1,0.1,0.8),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(0.2,0.0,0.8),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(0.2,0.9,0.8),pow(0.05,2)));
+ Vh->info() = k++;
+ Vh = triangulation.insert(CGALSphere(Point(0.2,0.8,0.),pow(0.05,2)));
+ Vh->info() = k++;
+ cout << "triangulation.number_of_vertices()" << triangulation.number_of_vertices() << endl;
+
+ //now we can start playing with pressure (=0 for dry pore, =1 for saturated pore)
+ //they all have 0 by default, we find one cell and set pressure to 1
+ Cell_handle cell = triangulation.locate(Point(0.3,0.3,0.3));
+ cell->info().p()=1;
+
+ solver->noCache = false;
+
+ /*
+ //This is how we could input spheres from the simulation into a triangulation, we will use it latter as fow now we only define a few spheres manually (below)
//here we define the pointer to Yade's scene
scene = Omega::instance().getScene().get();
-
//copy sphere positions in a buffer...
setPositionsBuffer(true);
//then create a triangulation and initialize pressure in the elements, everything will be contained in "solver"
Build_Triangulation(P_zero,solver);
+ */
+
+
}
@@ -382,6 +430,18 @@
return volume;
}
+template<class Solver>
+void UnsaturatedEngine::setImposedPressure ( unsigned int cond, Real p,Solver& flow )
+{
+ if ( cond>=flow->imposedP.size() ) LOG_ERROR ( "Setting p with cond higher than imposedP size." );
+ flow->imposedP[cond].second=p;
+ //force immediate update of boundary conditions
+ flow->pressureChanged=true;
+}
+
+template<class Solver>
+void UnsaturatedEngine::clearImposedPressure ( Solver& flow ) { flow->imposedP.clear(); flow->IPCells.clear();}
+
YADE_PLUGIN ( ( UnsaturatedEngine ) );
#endif //FLOW_ENGINE
=== modified file 'pkg/dem/UnsaturatedEngine.hpp'
--- pkg/dem/UnsaturatedEngine.hpp 2012-11-27 12:18:19 +0000
+++ pkg/dem/UnsaturatedEngine.hpp 2012-11-27 18:31:45 +0000
@@ -26,6 +26,9 @@
typedef FlowSolver::Finite_cells_iterator Finite_cells_iterator;
typedef FlowSolver::Cell_handle Cell_handle;
typedef RTriangulation::Finite_edges_iterator Finite_edges_iterator;
+ typedef RTriangulation::Vertex_handle Vertex_handle;
+ typedef RTriangulation::Point CGALSphere;
+ typedef CGALSphere::Point Point;